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 #include "component_test/test_config.h" 17 18 #include <functional> 19 #include <string> 20 21 #include "component_test/component_test_manager_impl.h" 22 23 #include "base/json/json_util.h" 24 #include "base/log/log.h" 25 26 namespace OHOS::Ace::ComponentTest { 27 ParseComponentTestConfig(const std::string JsonText)28void ParseComponentTestConfig(const std::string JsonText) 29 { 30 auto json = JsonUtil::ParseJsonString(JsonText); 31 auto testConfig = &ComponentTestManagerImpl::Get()->testConfig; 32 testConfig->page_ = json->GetString("page"); 33 if (testConfig->page_ == "") { 34 LOGE("Error parsing componentTest parameter: \"page\""); 35 return; 36 } 37 testConfig->out_ = json->GetString("out"); 38 if (testConfig->out_ == "") { 39 LOGE("Error parsing componentTest parameter: \"out\""); 40 return; 41 } 42 testConfig->enableComponentTest_ = true; 43 } 44 GetPage() const45std::string TestConfig::GetPage() const 46 { 47 return page_; 48 } 49 GetOut() const50std::string TestConfig::GetOut() const 51 { 52 return out_; 53 } 54 IsComponentTestEnabled() const55bool TestConfig::IsComponentTestEnabled() const 56 { 57 return enableComponentTest_; 58 } 59 } // namespace OHOS::Ace::ComponentTest 60