1 /* 2 * Copyright (c) 2020 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 OHOS_ABILITY_TEST_HELPER_H 17 #define OHOS_ABILITY_TEST_HELPER_H 18 19 #include <ability_state.h> 20 #include <iproxy_client.h> 21 #include <list> 22 #include <memory> 23 #include <string> 24 #include <want.h> 25 #include "ipc_skeleton.h" 26 namespace OHOS { 27 struct SliceRecord { 28 std::string name; 29 State state; 30 }; 31 32 class AbilityTestHelper { 33 public: 34 AbilityTestHelper() = delete; 35 ~AbilityTestHelper() = delete; 36 static void Initialize(); 37 static void UnInitialize(); 38 39 static void InstallCallback(const uint8_t resultCode, const void *resultMessage); 40 static void UninstallCallback(const uint8_t resultCode, const void *resultMessage); 41 static int32_t AbilityCallback(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); 42 static bool TestInstall(const std::string &hap); 43 static bool TestUnInstall(const std::string &bundleName); 44 static bool TestStartAbility(const Want &want); 45 static bool TestTerminateApp(const std::string &bundleName); 46 static State GetAbilityState(const ElementName &elementName); 47 static std::list<std::shared_ptr<SliceRecord>> GetSliceStack(const ElementName &elementName); 48 49 private: 50 static IClientProxy *GetAbilityInnerFeature(); 51 static void TestDumpAbility(const ElementName &elementName); 52 static void SemWait(); 53 static void SemPost(); 54 55 static SvcIdentity identity_; 56 static IClientProxy *proxy_; 57 static IpcObjectStub objectStub_; 58 }; 59 } 60 61 #endif // OHOS_ABILITY_TEST_HELPER_H