• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (c) 2022 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    TOOLCMD_KEY_VERSION = "version"
51
52    @property
53    def run_command(self):
54        return ToolCommandType.TOOLCMD_KEY_RUN
55
56    @property
57    def help_command(self):
58        return ToolCommandType.TOOLCMD_KEY_HELP
59
60
61class ConfigFileConst(object):
62    FRAMECONFIG_FILEPATH = "framework_config.xml"
63    BUILDCONFIG_FILEPATH = "build_config.xml"
64    USERCONFIG_FILEPATH = "user_config.xml"
65    FILTERCONFIG_FILEPATH = "filter_config.xml"
66    RESOURCECONFIG_FILEPATH = "harmony_test.xml"
67    CASE_RESOURCE_FILEPATH = "ohos_test.xml"
68    SCENECONFIG_FILEPATH = "scene_config.xml"
69    FUZZCONFIG_FILEPATH = "fuzz_config.xml"
70
71    @property
72    def framework_config_file(self):
73        return ConfigFileConst.FRAMECONFIG_FILEPATH
74
75    @property
76    def user_config_file(self):
77        return ConfigFileConst.USERCONFIG_FILEPATH
78
79
80class JsTestConst(object):
81    BUILD_GN_FILE_TEMPLATE = """\
82# Copyright (C) 2021 Huawei Device Co., Ltd.
83# Licensed under the Apache License, Version 2.0 (the "License");
84# you may not use this file except in compliance with the License.
85# You may obtain a copy of the License at
86#
87#     http://www.apache.org/licenses/LICENSE-2.0
88#
89# Unless required by applicable law or agreed to in writing, software
90# distributed under the License is distributed on an "AS IS" BASIS,
91# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92# See the License for the specific language governing permissions and
93# limitations under the License.
94
95import("//build/test.gni")
96
97module_output_path = "%(output_path)s"
98
99ohos_js_unittest("%(suite_name)s") {
100  module_out_path = module_output_path
101  hap_profile = "./src/main/config.json"
102  deps = [
103    ":%(suite_name)s_js_assets",
104    ":%(suite_name)s_resources",
105  ]
106
107  certificate_profile = "//test/testfwk/developer_test/signature/openharmony_sx.p7b"
108  hap_name = "%(suite_name)s"
109}
110ohos_js_assets("%(suite_name)s_js_assets") {
111  source_dir = "./src/main/js/default"
112}
113ohos_resources("%(suite_name)s_resources") {
114  sources = [ "./src/main/resources" ]
115  hap_profile = "./src/main/config.json"
116}
117
118group("unittest") {
119  testonly = true
120  deps = [ ":%(suite_name)s" ]
121}
122"""
123
124    @property
125    def build_gn_template(self):
126        return JsTestConst.BUILD_GN_FILE_TEMPLATE
127