• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 #include "mock_ability_manager_client.h"
17 #include <gtest/gtest.h>
18 #define private public
19 #define protected public
20 #include "ability_manager_client.h"
21 #undef private
22 #undef protected
23 
24 namespace OHOS {
25 namespace AAFwk {
26 std::shared_ptr<AbilityManagerClient> mockInstance_ = nullptr;
27 std::mutex mockMutex_;
28 
GetInstance()29 std::shared_ptr<AbilityManagerClient> AbilityManagerClient::GetInstance()
30 {
31     if (mockInstance_ == nullptr) {
32         std::lock_guard<std::mutex> lock_l(mockMutex_);
33         if (mockInstance_ == nullptr) {
34             mockInstance_ = std::make_shared<AbilityManagerClient>();
35         }
36     }
37     return mockInstance_;
38 }
39 
AbilityManagerClient()40 AbilityManagerClient::AbilityManagerClient()
41 {
42     // log
43 }
44 
~AbilityManagerClient()45 AbilityManagerClient::~AbilityManagerClient()
46 {}
47 
AttachAbilityThread(sptr<IAbilityScheduler> scheduler,sptr<IRemoteObject> token)48 ErrCode AbilityManagerClient::AttachAbilityThread(
49     sptr<IAbilityScheduler> scheduler, sptr<IRemoteObject> token)
50 {
51     GTEST_LOG_(INFO) << "Mock AbilityManagerClient::AttachAbilityThread called";
52     return -1;
53 }
54 
AbilityTransitionDone(sptr<IRemoteObject> token,int state,const PacMap & saveData)55 ErrCode AbilityManagerClient::AbilityTransitionDone(sptr<IRemoteObject> token, int state, const PacMap& saveData)
56 {
57     return -1;
58 }
59 
ScheduleConnectAbilityDone(sptr<IRemoteObject> token,sptr<IRemoteObject> remoteObject)60 ErrCode AbilityManagerClient::ScheduleConnectAbilityDone(
61     sptr<IRemoteObject> token, sptr<IRemoteObject> remoteObject)
62 {
63     return -1;
64 }
65 
ScheduleDisconnectAbilityDone(sptr<IRemoteObject> token)66 ErrCode AbilityManagerClient::ScheduleDisconnectAbilityDone(sptr<IRemoteObject> token)
67 {
68     return -1;
69 }
70 
ScheduleCommandAbilityDone(sptr<IRemoteObject> token)71 ErrCode AbilityManagerClient::ScheduleCommandAbilityDone(sptr<IRemoteObject> token)
72 {
73     return -1;
74 }
75 
ScheduleCommandAbilityWindowDone(sptr<IRemoteObject> token,sptr<SessionInfo> sessionInfo,WindowCommand winCmd,AbilityCommand abilityCmd)76 ErrCode AbilityManagerClient::ScheduleCommandAbilityWindowDone(
77     sptr<IRemoteObject> token,
78     sptr<SessionInfo> sessionInfo,
79     WindowCommand winCmd,
80     AbilityCommand abilityCmd)
81 {
82     return -1;
83 }
84 
StartAbility(const Want & want,int requestCode,int32_t userId)85 ErrCode AbilityManagerClient::StartAbility(const Want& want, int requestCode, int32_t userId)
86 {
87     return -1;
88 }
89 
TerminateAbility(sptr<IRemoteObject> token,int resultCode,const Want * resultWant)90 ErrCode AbilityManagerClient::TerminateAbility(sptr<IRemoteObject> token, int resultCode, const Want* resultWant)
91 {
92     return -1;
93 }
94 
ConnectAbility(const Want & want,sptr<IAbilityConnection> connect,int32_t userId)95 ErrCode AbilityManagerClient::ConnectAbility(const Want &want, sptr<IAbilityConnection> connect, int32_t userId)
96 {
97     return -1;
98 }
99 
ConnectAbility(const Want & want,sptr<IAbilityConnection> connect,sptr<IRemoteObject> callerToken,int32_t userId)100 ErrCode AbilityManagerClient::ConnectAbility(
101     const Want& want, sptr<IAbilityConnection> connect, sptr<IRemoteObject> callerToken, int32_t userId)
102 {
103     return -1;
104 }
105 
DisconnectAbility(sptr<IAbilityConnection> connect)106 ErrCode AbilityManagerClient::DisconnectAbility(sptr<IAbilityConnection> connect)
107 {
108     return -1;
109 }
110 
AcquireDataAbility(const Uri & uri,bool tryBind,sptr<IRemoteObject> callerToken)111 sptr<IAbilityScheduler> AbilityManagerClient::AcquireDataAbility(
112     const Uri& uri, bool tryBind, sptr<IRemoteObject> callerToken)
113 {
114     GTEST_LOG_(INFO) << "Mock AcquireDataAbility called";
115     sptr<IAbilityScheduler> dataScheduler = new (std::nothrow) OHOS::AppExecFwk::MockAbilityThread();
116     return dataScheduler;
117 }
118 
ReleaseDataAbility(sptr<IAbilityScheduler> dataAbilityScheduler,sptr<IRemoteObject> callerToken)119 ErrCode AbilityManagerClient::ReleaseDataAbility(
120     sptr<IAbilityScheduler> dataAbilityScheduler, sptr<IRemoteObject> callerToken)
121 {
122     GTEST_LOG_(INFO) << "Mock ReleaseDataAbility called";
123     return ERR_OK;
124 }
125 
DumpState(const std::string & args,std::vector<std::string> & state)126 ErrCode AbilityManagerClient::DumpState(const std::string& args, std::vector<std::string>& state)
127 {
128     return -1;
129 }
130 
Connect()131 ErrCode AbilityManagerClient::Connect()
132 {
133     return -1;
134 }
135 
StopServiceAbility(const Want & want,sptr<IRemoteObject> token)136 ErrCode AbilityManagerClient::StopServiceAbility(const Want& want, sptr<IRemoteObject> token)
137 {
138     return -1;
139 }
140 
SetAbilityController(sptr<AppExecFwk::IAbilityController> abilityController,bool imAStabilityTest)141 ErrCode AbilityManagerClient::SetAbilityController(sptr<AppExecFwk::IAbilityController> abilityController,
142     bool imAStabilityTest)
143 {
144     return -1;
145 }
146 }  // namespace AAFwk
147 }  // namespace OHOS
148