1 /* 2 * Copyright (c) 2024 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_RUNTIME_CJ_TEST_RUNNER_H 17 #define OHOS_ABILITY_RUNTIME_CJ_TEST_RUNNER_H 18 19 #include "bundle_info.h" 20 #include "cj_runtime.h" 21 #include "test_runner.h" 22 23 namespace OHOS { 24 namespace RunnerRuntime { 25 using namespace AppExecFwk; 26 using namespace AbilityRuntime; 27 28 class CJTestRunnerObject; 29 30 class CJTestRunner : public TestRunner { 31 public: 32 /** 33 * Creates a TestRunner instance with the input parameter passed. 34 * 35 * @param runtime Indicates the ability runtime. 36 * @param args Indicates the AbilityDelegatorArgs object. 37 * @param bundleInfo Indicates the bundle info. 38 * @return the TestRunner object if TestRunner object is created successfully; returns null otherwise. 39 */ 40 static std::unique_ptr<TestRunner> Create(const std::unique_ptr<Runtime> &runtime, 41 const std::shared_ptr<AbilityDelegatorArgs> &args, const AppExecFwk::BundleInfo &bundleInfo); 42 43 /** 44 * Default deconstructor used to deconstruct. 45 */ 46 ~CJTestRunner() override; 47 48 /** 49 * Prepares the testing environment for running test code. 50 */ 51 void Prepare() override; 52 53 /** 54 * Runs all test code. 55 */ 56 void Run() override; 57 58 bool Initialize() override; 59 60 private: 61 CJTestRunner(CJRuntime &cjRuntime, 62 const std::shared_ptr<AbilityDelegatorArgs> &args, const AppExecFwk::BundleInfo &bundleInfo); 63 64 void ReportFinished(const std::string &msg); 65 void ReportStatus(const std::string &msg); 66 67 CJRuntime &cjRuntime_; 68 std::shared_ptr<CJTestRunnerObject> cjTestRunnerObj_; 69 }; 70 } // namespace RunnerRuntime 71 } // namespace OHOS 72 #endif // OHOS_ABILITY_RUNTIME_CJ_TEST_RUNNER_H