# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//arkcompiler/ets_runtime/test/test_helper.gni")

hot_reload_test_list = [
  # "check_import",
  # "same_methodname",
  "class_inheritance",
  "class_mem_func",
  "class_same_mem_func",
  "class_mem_var",
  "class_name",
  "closure",
  "global_func",
  "global_var",
  "import_export",
  "lazy_import",
  "print_string",
  "record_not_same",
  "module_var",
  "module_func",
  "module_class",
  "module_class_inheritance",
]

hot_reload_cold_patch_test_list = []

if (!is_debug) {
  hot_reload_cold_patch_test_list += [
    "cold_classmemfunc",
    "cold_closure",
    "cold_printstring",
    "cold_classmemvar",
  ]

  hot_reload_test_list += [
    "multi_classconstpool",
    "multi_closureconstpool",
    "multi_constructorconstpool",
    "multi_funccallconstpool",
    "multi_funcconstpool",
    "multiconstpool_multifunc",
  ]
}

hot_patch_test_list = [
  "add_callfunction",
  # "external_method",
]

host_quickfix_test_action("multi_patch") {
  extra_patches = [
    "patch1",
    "patch2",
  ]
  entry_point = "--entry-point=base"
}

foreach(testcase, hot_reload_test_list) {
  host_quickfix_test_action("${testcase}") {
    entry_point = "--entry-point=base"
    if (!is_debug) {
      is_gen_js_by_script = true
    }
  }
}

foreach(testcase, hot_patch_test_list) {
  host_quickfix_test_action("${testcase}") {
    entry_point = "--entry-point=base"
    is_hotpatch = true
  }
}

foreach(testcase, hot_reload_cold_patch_test_list) {
  host_quickfix_test_action("${testcase}") {
    entry_point = "--entry-point=base:coldpatch"
  }
}

group("ark_quickfix_test") {
  testonly = true

  deps = []
  foreach(testcase, hot_reload_test_list) {
    deps += [ ":${testcase}QuickfixAction" ]
  }

  foreach(testcase, hot_patch_test_list) {
    deps += [ ":${testcase}QuickfixAction" ]
  }

  foreach(testcase, hot_reload_cold_patch_test_list) {
    deps += [ ":${testcase}QuickfixAction" ]
  }

  deps += [ ":multi_patchQuickfixAction" ]
}