1 /* 2 * Copyright (c) 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 #ifndef MOCK_OHOS_ABILITY_RUNTIME_MOCK_IABILITY_MONITOR_H 17 #define MOCK_OHOS_ABILITY_RUNTIME_MOCK_IABILITY_MONITOR_H 18 19 #include "gmock/gmock.h" 20 21 #include "iability_monitor.h" 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 class MockIabilityMonitor : public IAbilityMonitor { 26 public: 27 28 explicit MockIabilityMonitor(const std::string& abilityName); 29 virtual ~MockIabilityMonitor() = default; 30 31 virtual bool Match(const std::shared_ptr<ADelegatorAbilityProperty>& ability, bool isNotify = false); 32 waitForAbility()33 std::shared_ptr<ADelegatorAbilityProperty> waitForAbility() 34 { 35 return std::make_shared<ADelegatorAbilityProperty>(); 36 }; waitForAbility(const int64_t timeoutMs)37 std::shared_ptr<ADelegatorAbilityProperty> waitForAbility(const int64_t timeoutMs) 38 { 39 return std::make_shared<ADelegatorAbilityProperty>(); 40 }; 41 42 void OnAbilityStart(const std::weak_ptr<NativeReference>& abilityObj) override; 43 void OnAbilityForeground(const std::weak_ptr<NativeReference>& abilityObj) override; 44 void OnAbilityBackground(const std::weak_ptr<NativeReference>& abilityObj) override; 45 void OnAbilityStop(const std::weak_ptr<NativeReference>& abilityObj) override; 46 47 void OnWindowStageCreate(const std::weak_ptr<NativeReference>& abilityObj) override; 48 void OnWindowStageRestore(const std::weak_ptr<NativeReference>& abilityObj) override; 49 void OnWindowStageDestroy(const std::weak_ptr<NativeReference>& abilityObj) override; 50 51 bool start_; 52 bool foreground_; 53 bool background_; 54 bool stop_; 55 bool windowStageCreate_; 56 bool windowStageRestore_; 57 bool windowStageDestroy_; 58 }; 59 } // namespace AppExecFwk 60 } // namespace OHOS 61 62 #endif // MOCK_OHOS_ABILITY_RUNTIME_MOCK_IABILITY_MONITOR_H 63