• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MOCK_FOUNDATION_AAAFWK_INTERFACES_INNERKITS_ABILITY_CONNECT_CALLBACK_STUB_H
17 #define MOCK_FOUNDATION_AAAFWK_INTERFACES_INNERKITS_ABILITY_CONNECT_CALLBACK_STUB_H
18 
19 #include "ability_connect_callback_stub.h"
20 #include "gmock/gmock.h"
21 #include "semaphore_ex.h"
22 
23 namespace OHOS {
24 namespace AAFwk {
25 class MockAbilityConnectCallbackStub : public AbilityConnectionStub {
26 public:
27     MOCK_METHOD3(OnAbilityConnectDone,
28         void(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode));
29     MOCK_METHOD2(OnAbilityDisconnectDone, void(const AppExecFwk::ElementName &element, int resultCode));
30 
Wait()31     void Wait()
32     {
33         sem_.Wait();
34     }
35 
Post()36     int Post()
37     {
38         sem_.Post();
39         return 0;
40     }
41 
PostVoid()42     void PostVoid()
43     {
44         sem_.Post();
45     }
46 
47 private:
48     Semaphore sem_;
49 };
50 }  // namespace AAFwk
51 }  // namespace OHOS
52 
53 #endif  // MOCK_FOUNDATION_AAAFWK_INTERFACES_INNERKITS_ABILITY_CONNECT_CALLBACK_STUB_H