# Copyright (c) 2024 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("//build/test.gni")
import("//foundation/graphic/graphic_surface/graphic_surface_config.gni")

module_out_path = "graphic_surface/graphic_surface/surface"

group("unittest") {
  testonly = true

  deps = [
    ":native_window_buffer_test_st",
    ":native_window_clean_cache_test_st",
    ":native_window_test_st",
    ":surface_batch_opt_with_connect_strictly_test_st",
    ":surface_ipc_test_st",
    ":surface_ipc_with_connect_strictly_test_st",
    "attach_and_detach_buffer_test:systemtest",
    "buffer_with_present_timestamp_test:systemtest",
  ]
}

## SystemTest native_window_buffer_test {{{
ohos_unittest("native_window_buffer_test_st") {
  module_out_path = module_out_path

  sources = [ "native_window_buffer_test.cpp" ]

  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "cJSON:cjson_static",     
    "selinux_adapter:librestorecon",
    "samgr:samgr_proxy",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "bounds_checking_function:libsec_shared",
  ]
}

## SystemTest native_window_buffer_test }}}

## SystemTest native_window_test {{{
ohos_unittest("native_window_test_st") {
  module_out_path = module_out_path

  sources = [ "native_window_test.cpp" ]

  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "samgr:samgr_proxy",
    "c_utils:utils",
    "hilog:libhilog",
    "bounds_checking_function:libsec_shared",
    "eventhandler:libeventhandler",
  ]
}

## SystemTest native_window_test }}}

## SystemTest surface_ipc_test {{{
ohos_unittest("surface_ipc_test_st") {
  module_out_path = module_out_path

  sources = [ "surface_ipc_test.cpp" ]

  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "cJSON:cjson_static",     
    "selinux_adapter:librestorecon",
    "samgr:samgr_proxy",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
  ]
}

## SystemTest surface_ipc_test }}}

## SystemTest native_window_clean_cache_test {{{
ohos_unittest("native_window_clean_cache_test_st") {
  module_out_path = module_out_path

  sources = [ "clean_cache_test/native_window_clean_cache_test.cpp" ]
  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "cJSON:cjson_static",     
    "selinux_adapter:librestorecon",
    "samgr:samgr_proxy",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
  ]
}

## SystemTest surface_ipc_with_connect_strictly_test_st {{{
ohos_unittest("surface_ipc_with_connect_strictly_test_st") {
  module_out_path = module_out_path
  sources = [
    "connect_and_disconnect_test/surface_ipc_with_connect_strictly_test.cpp",
  ]
  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "cJSON:cjson_static",     
    "selinux_adapter:librestorecon",
    "samgr:samgr_proxy",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
  ]
}

## SystemTest surface_ipc_with_connect_strictly_test_st }}}

## SystemTest surface_ipc_with_connect_strictly_test_st {{{
ohos_unittest("surface_batch_opt_with_connect_strictly_test_st") {
  module_out_path = module_out_path
  sources = [ "connect_and_disconnect_test/surface_batch_opt_with_connect_strictly_test.cpp" ]
  deps = [
    ":surface_system_test_common",
    "$graphic_surface_root/surface:surface",
  ]
  external_deps = [
    "cJSON:cjson_static",     
    "selinux_adapter:librestorecon",
    "samgr:samgr_proxy",
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
  ]
}

## SystemTest surface_ipc_with_connect_strictly_test_st }}}

## Build surface_system_test_common.a {{{
config("surface_system_test_common_public_config") {
  include_dirs = [ "$graphic_surface_root/surface/include" ]

  cflags = [
    "-Wall",
    "-Werror",
    "-g3",
    "-Dprivate=public",
    "-Dprotected=public",
  ]
}

ohos_static_library("surface_system_test_common") {
  visibility = [ ":*" ]
  testonly = true

  public_configs = [ ":surface_system_test_common_public_config" ]

  deps = [
    "$graphic_surface_root/buffer_handle:buffer_handle",
    "$graphic_surface_root/surface:surface",
    "$graphic_surface_root/sync_fence:sync_fence",
    "$graphic_surface_root/test_header:test_header",
  ]

  external_deps = [
    "access_token:libaccesstoken_sdk",
    "access_token:libnativetoken",
    "access_token:libtoken_setproc",
    "c_utils:utils",
    "eventhandler:libeventhandler",
    "hilog:libhilog",
    "ipc:ipc_single",
    "samgr:samgr_proxy",
  ]

  subsystem_name = "graphic"
  part_name = "graphic_surface"
}
## Build surface_system_test_common.a }}}