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 FOUNDATION_AAFWK_SERVICES_TEST_MOCK_SYSTEM_ABILITY_H 17 #define FOUNDATION_AAFWK_SERVICES_TEST_MOCK_SYSTEM_ABILITY_H 18 19 #include "hilog/log.h" 20 #include "iremote_object.h" 21 namespace OHOS { 22 #define REGISTER_SYSTEM_ABILITY_BY_ID(a, b, c) 23 #define REGISTER_SYSTEM_ABILITY(abilityClassName, abilityId, runOnCreate) 24 #define DECLEAR_SYSTEM_ABILITY(className) 25 static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD001100, "MockSystemAbility"}; 26 27 class SystemAbility { 28 public: MakeAndRegisterAbility(SystemAbility *)29 static bool MakeAndRegisterAbility(SystemAbility *) 30 { 31 return true; 32 } 33 34 protected: OnStart()35 virtual void OnStart() 36 { 37 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStart called"); 38 } 39 OnStop()40 virtual void OnStop() 41 { 42 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStop called"); 43 } 44 Publish(sptr<IRemoteObject> systemAbility)45 bool Publish(sptr<IRemoteObject> systemAbility) 46 { 47 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Publish called"); 48 systemAbility.ForceSetRefPtr(nullptr); 49 return true; 50 } 51 52 explicit SystemAbility(bool runOnCreate = false) 53 { 54 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility default Creator called %d", runOnCreate); 55 } 56 57 SystemAbility(const int32_t serviceId, bool runOnCreate = false) 58 { 59 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Creator called %d", runOnCreate); 60 } 61 ~SystemAbility()62 virtual ~SystemAbility() 63 { 64 HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Destructor called"); 65 } 66 }; 67 } // namespace OHOS 68 #endif // FOUNDATION_AAFWK_SERVICES_TEST_MOCK_SYSTEM_ABILITY_H 69