1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2020 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19__all__ = [ 20 "SchedulerType", 21 "ToolCommandType", 22 "ConfigFileConst" 23] 24 25 26class SchedulerType(object): 27 """ 28 SchedulerType enumeration 29 """ 30 # default scheduler 31 SCHEDULER = "Scheduler" 32 COMBINATION = "Combination" 33 34 @property 35 def default_type(self): 36 return SchedulerType.SCHEDULER 37 38 @property 39 def combination_type(self): 40 return SchedulerType.COMBINATION 41 42 43class ToolCommandType(object): 44 TOOLCMD_KEY_HELP = "help" 45 TOOLCMD_KEY_SHOW = "show" 46 TOOLCMD_KEY_RUN = "run" 47 TOOLCMD_KEY_QUIT = "quit" 48 TOOLCMD_KEY_LIST = "list" 49 TOOLCMD_KEY_GEN = "gen" 50 51 @property 52 def run_command(self): 53 return ToolCommandType.TOOLCMD_KEY_RUN 54 55 @property 56 def help_command(self): 57 return ToolCommandType.TOOLCMD_KEY_HELP 58 59 60class ConfigFileConst(object): 61 FRAMECONFIG_FILEPATH = "framework_config.xml" 62 BUILDCONFIG_FILEPATH = "build_config.xml" 63 USERCONFIG_FILEPATH = "user_config.xml" 64 FILTERCONFIG_FILEPATH = "filter_config.xml" 65 RESOURCECONFIG_FILEPATH = "harmony_test.xml" 66 CASE_RESOURCE_FILEPATH = "ohos_test.xml" 67 SCENECONFIG_FILEPATH = "scene_config.xml" 68 FUZZCONFIG_FILEPATH = "fuzz_config.xml" 69 70 @property 71 def framework_config_file(self): 72 return ConfigFileConst.FRAMECONFIG_FILEPATH 73 74 @property 75 def user_config_file(self): 76 return ConfigFileConst.USERCONFIG_FILEPATH 77 78 79class JsTestConst(object): 80 BUILD_GN_FILE_TEMPLATE = """\ 81# Copyright (C) 2021 Huawei Device Co., Ltd. 82# Licensed under the Apache License, Version 2.0 (the "License"); 83# you may not use this file except in compliance with the License. 84# You may obtain a copy of the License at 85# 86# http://www.apache.org/licenses/LICENSE-2.0 87# 88# Unless required by applicable law or agreed to in writing, software 89# distributed under the License is distributed on an "AS IS" BASIS, 90# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 91# See the License for the specific language governing permissions and 92# limitations under the License. 93 94import("//build/test.gni") 95 96module_output_path = "%(output_path)s" 97 98ohos_js_unittest("%(suite_name)s") { 99 module_out_path = module_output_path 100 hap_profile = "./src/main/config.json" 101 deps = [ 102 ":%(suite_name)s_js_assets", 103 ":%(suite_name)s_resources", 104 ] 105 106 certificate_profile = "//test/developertest/signature/openharmony_sx.p7b" 107 hap_name = "%(suite_name)s" 108} 109ohos_js_assets("%(suite_name)s_js_assets") { 110 source_dir = "./src/main/js/default" 111} 112ohos_resources("%(suite_name)s_resources") { 113 sources = [ "./src/main/resources" ] 114 hap_profile = "./src/main/config.json" 115} 116 117group("unittest") { 118 testonly = true 119 deps = [ ":%(suite_name)s" ] 120} 121""" 122 123 @property 124 def build_gn_template(self): 125 return JsTestConst.BUILD_GN_FILE_TEMPLATE 126