132a6e48fSopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
232a6e48fSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
332a6e48fSopenharmony_ci# you may not use this file except in compliance with the License.
432a6e48fSopenharmony_ci# You may obtain a copy of the License at
532a6e48fSopenharmony_ci#
632a6e48fSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
732a6e48fSopenharmony_ci#
832a6e48fSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
932a6e48fSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1032a6e48fSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1132a6e48fSopenharmony_ci# See the License for the specific language governing permissions and
1232a6e48fSopenharmony_ci# limitations under the License.
1332a6e48fSopenharmony_ci
1432a6e48fSopenharmony_ciimport("//build/test.gni")
1532a6e48fSopenharmony_ciimport("//foundation/graphic/graphic_surface/graphic_surface_config.gni")
1632a6e48fSopenharmony_ci
1732a6e48fSopenharmony_ciif (graphic_2d_ext_delegator && graphic_2d_ext_delegator_gni != "") {
1832a6e48fSopenharmony_ci  import("${graphic_2d_ext_delegator_gni}")
1932a6e48fSopenharmony_ci}
2032a6e48fSopenharmony_ci
2132a6e48fSopenharmony_cimodule_out_path = "graphic_surface/surface"
2232a6e48fSopenharmony_ci
2332a6e48fSopenharmony_cigroup("unittest") {
2432a6e48fSopenharmony_ci  testonly = true
2532a6e48fSopenharmony_ci
2632a6e48fSopenharmony_ci  deps = [
2732a6e48fSopenharmony_ci    ":buffer_client_producer_remote_test",
2832a6e48fSopenharmony_ci    ":buffer_queue_consumer_test",
2932a6e48fSopenharmony_ci    ":buffer_queue_producer_remote_test",
3032a6e48fSopenharmony_ci    ":buffer_queue_producer_test",
3132a6e48fSopenharmony_ci    ":buffer_queue_test",
3232a6e48fSopenharmony_ci    ":buffer_shared_test",
3332a6e48fSopenharmony_ci    ":buffer_utils_test",
3432a6e48fSopenharmony_ci    ":consumer_surface_delegator_test",
3532a6e48fSopenharmony_ci    ":consumer_surface_test",
3632a6e48fSopenharmony_ci    ":metadata_helper_test",
3732a6e48fSopenharmony_ci    ":native_buffer_test",
3832a6e48fSopenharmony_ci    ":native_window_test",
3932a6e48fSopenharmony_ci    ":producer_surface_delegator_test",
4032a6e48fSopenharmony_ci    ":producer_surface_test",
4132a6e48fSopenharmony_ci    ":surface_buffer_impl_test",
4232a6e48fSopenharmony_ci    ":surface_utils_test",
4332a6e48fSopenharmony_ci    ":transact_surface_delegator_stub_test",
4432a6e48fSopenharmony_ci  ]
4532a6e48fSopenharmony_ci}
4632a6e48fSopenharmony_ci
4732a6e48fSopenharmony_ci## UnitTest producer_surface_delegator_test {{{
4832a6e48fSopenharmony_ciohos_unittest("producer_surface_delegator_test") {
4932a6e48fSopenharmony_ci  module_out_path = module_out_path
5032a6e48fSopenharmony_ci
5132a6e48fSopenharmony_ci  sources = []
5232a6e48fSopenharmony_ci  if (graphic_2d_ext_delegator &&
5332a6e48fSopenharmony_ci      defined(libsurface_ext_test_producer_delegator_src)) {
5432a6e48fSopenharmony_ci    sources += libsurface_ext_test_producer_delegator_src
5532a6e48fSopenharmony_ci  } else {
5632a6e48fSopenharmony_ci    sources += [ "producer_surface_delegator_test.cpp" ]
5732a6e48fSopenharmony_ci  }
5832a6e48fSopenharmony_ci
5932a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
6032a6e48fSopenharmony_ci  external_deps = [ "bounds_checking_function:libsec_shared" ]
6132a6e48fSopenharmony_ci}
6232a6e48fSopenharmony_ci
6332a6e48fSopenharmony_ci## UnitTest producer_surface_delegator_test }}}
6432a6e48fSopenharmony_ci
6532a6e48fSopenharmony_ci## UnitTest consumer_surface_delegator_test {{{
6632a6e48fSopenharmony_ciohos_unittest("consumer_surface_delegator_test") {
6732a6e48fSopenharmony_ci  module_out_path = module_out_path
6832a6e48fSopenharmony_ci
6932a6e48fSopenharmony_ci  sources = []
7032a6e48fSopenharmony_ci  if (graphic_2d_ext_delegator &&
7132a6e48fSopenharmony_ci      defined(libsurface_ext_test_consumer_delegator_src)) {
7232a6e48fSopenharmony_ci    sources += libsurface_ext_test_consumer_delegator_src
7332a6e48fSopenharmony_ci  } else {
7432a6e48fSopenharmony_ci    sources += [ "consumer_surface_delegator_test.cpp" ]
7532a6e48fSopenharmony_ci  }
7632a6e48fSopenharmony_ci
7732a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
7832a6e48fSopenharmony_ci  external_deps = [ "bounds_checking_function:libsec_shared" ]
7932a6e48fSopenharmony_ci}
8032a6e48fSopenharmony_ci
8132a6e48fSopenharmony_ci## UnitTest consumer_surface_delegator_test }}}
8232a6e48fSopenharmony_ci
8332a6e48fSopenharmony_ci## UnitTest transact_surface_delegator_stub_test {{{
8432a6e48fSopenharmony_ciohos_unittest("transact_surface_delegator_stub_test") {
8532a6e48fSopenharmony_ci  module_out_path = module_out_path
8632a6e48fSopenharmony_ci
8732a6e48fSopenharmony_ci  sources = []
8832a6e48fSopenharmony_ci  if (graphic_2d_ext_delegator &&
8932a6e48fSopenharmony_ci      defined(libsurface_ext_test_transact_delegator_src)) {
9032a6e48fSopenharmony_ci    sources += libsurface_ext_test_transact_delegator_src
9132a6e48fSopenharmony_ci  } else {
9232a6e48fSopenharmony_ci    sources += [ "transact_surface_delegator_stub_test.cpp" ]
9332a6e48fSopenharmony_ci  }
9432a6e48fSopenharmony_ci
9532a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
9632a6e48fSopenharmony_ci  external_deps = [ "bounds_checking_function:libsec_shared" ]
9732a6e48fSopenharmony_ci}
9832a6e48fSopenharmony_ci
9932a6e48fSopenharmony_ci## UnitTest transact_surface_delegator_stub_test }}}
10032a6e48fSopenharmony_ci
10132a6e48fSopenharmony_ci## UnitTest buffer_client_producer_remote_test {{{
10232a6e48fSopenharmony_ciohos_unittest("buffer_client_producer_remote_test") {
10332a6e48fSopenharmony_ci  module_out_path = module_out_path
10432a6e48fSopenharmony_ci
10532a6e48fSopenharmony_ci  sources = [ "buffer_client_producer_remote_test.cpp" ]
10632a6e48fSopenharmony_ci
10732a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
10832a6e48fSopenharmony_ci}
10932a6e48fSopenharmony_ci
11032a6e48fSopenharmony_ci## UnitTest buffer_client_producer_remote_test }}}
11132a6e48fSopenharmony_ci
11232a6e48fSopenharmony_ci## UnitTest buffer_queue_consumer_test {{{
11332a6e48fSopenharmony_ciohos_unittest("buffer_queue_consumer_test") {
11432a6e48fSopenharmony_ci  module_out_path = module_out_path
11532a6e48fSopenharmony_ci
11632a6e48fSopenharmony_ci  sources = [ "buffer_queue_consumer_test.cpp" ]
11732a6e48fSopenharmony_ci
11832a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
11932a6e48fSopenharmony_ci}
12032a6e48fSopenharmony_ci
12132a6e48fSopenharmony_ci## UnitTest buffer_queue_consumer_test }}}
12232a6e48fSopenharmony_ci
12332a6e48fSopenharmony_ci## UnitTest buffer_queue_producer_remote_test {{{
12432a6e48fSopenharmony_ciohos_unittest("buffer_queue_producer_remote_test") {
12532a6e48fSopenharmony_ci  module_out_path = module_out_path
12632a6e48fSopenharmony_ci
12732a6e48fSopenharmony_ci  sources = [ "buffer_queue_producer_remote_test.cpp" ]
12832a6e48fSopenharmony_ci
12932a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
13032a6e48fSopenharmony_ci}
13132a6e48fSopenharmony_ci
13232a6e48fSopenharmony_ci## UnitTest buffer_queue_producer_remote_test }}}
13332a6e48fSopenharmony_ci
13432a6e48fSopenharmony_ci## UnitTest buffer_queue_producer_test {{{
13532a6e48fSopenharmony_ciohos_unittest("buffer_queue_producer_test") {
13632a6e48fSopenharmony_ci  module_out_path = module_out_path
13732a6e48fSopenharmony_ci
13832a6e48fSopenharmony_ci  sources = [ "buffer_queue_producer_test.cpp" ]
13932a6e48fSopenharmony_ci
14032a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
14132a6e48fSopenharmony_ci}
14232a6e48fSopenharmony_ci
14332a6e48fSopenharmony_ci## UnitTest buffer_queue_producer_test }}}
14432a6e48fSopenharmony_ci
14532a6e48fSopenharmony_ci## UnitTest buffer_queue_test {{{
14632a6e48fSopenharmony_ciohos_unittest("buffer_queue_test") {
14732a6e48fSopenharmony_ci  module_out_path = module_out_path
14832a6e48fSopenharmony_ci
14932a6e48fSopenharmony_ci  sources = [ "buffer_queue_test.cpp" ]
15032a6e48fSopenharmony_ci
15132a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
15232a6e48fSopenharmony_ci}
15332a6e48fSopenharmony_ci
15432a6e48fSopenharmony_ci## UnitTest buffer_queue_test }}}
15532a6e48fSopenharmony_ci
15632a6e48fSopenharmony_ci## UnitTest buffer_shared_test {{{
15732a6e48fSopenharmony_ciohos_unittest("buffer_shared_test") {
15832a6e48fSopenharmony_ci  module_out_path = module_out_path
15932a6e48fSopenharmony_ci
16032a6e48fSopenharmony_ci  sources = [ "buffer_shared_test.cpp" ]
16132a6e48fSopenharmony_ci
16232a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
16332a6e48fSopenharmony_ci}
16432a6e48fSopenharmony_ci
16532a6e48fSopenharmony_ci## UnitTest buffer_shared_test }}}
16632a6e48fSopenharmony_ci
16732a6e48fSopenharmony_ci## UnitTest consumer_surface_test {{{
16832a6e48fSopenharmony_ciohos_unittest("consumer_surface_test") {
16932a6e48fSopenharmony_ci  module_out_path = module_out_path
17032a6e48fSopenharmony_ci
17132a6e48fSopenharmony_ci  sources = [ "consumer_surface_test.cpp" ]
17232a6e48fSopenharmony_ci
17332a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
17432a6e48fSopenharmony_ci
17532a6e48fSopenharmony_ci  external_deps = [
17632a6e48fSopenharmony_ci    "bounds_checking_function:libsec_shared",
17732a6e48fSopenharmony_ci    "drivers_interface_display:display_commontype_idl_headers_1.1",
17832a6e48fSopenharmony_ci  ]
17932a6e48fSopenharmony_ci}
18032a6e48fSopenharmony_ci
18132a6e48fSopenharmony_ci## UnitTest consumer_surface_test }}}
18232a6e48fSopenharmony_ci
18332a6e48fSopenharmony_ci## UnitTest producer_surface_test {{{
18432a6e48fSopenharmony_ciohos_unittest("producer_surface_test") {
18532a6e48fSopenharmony_ci  module_out_path = module_out_path
18632a6e48fSopenharmony_ci
18732a6e48fSopenharmony_ci  sources = [ "producer_surface_test.cpp" ]
18832a6e48fSopenharmony_ci
18932a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
19032a6e48fSopenharmony_ci  external_deps = [ "bounds_checking_function:libsec_shared" ]
19132a6e48fSopenharmony_ci}
19232a6e48fSopenharmony_ci
19332a6e48fSopenharmony_ci## UnitTest producer_surface_test }}}
19432a6e48fSopenharmony_ci
19532a6e48fSopenharmony_ci## UnitTest surface_buffer_impl_test {{{
19632a6e48fSopenharmony_ciohos_unittest("surface_buffer_impl_test") {
19732a6e48fSopenharmony_ci  module_out_path = module_out_path
19832a6e48fSopenharmony_ci
19932a6e48fSopenharmony_ci  sources = [ "surface_buffer_impl_test.cpp" ]
20032a6e48fSopenharmony_ci
20132a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
20232a6e48fSopenharmony_ci
20332a6e48fSopenharmony_ci  external_deps = [
20432a6e48fSopenharmony_ci    "bounds_checking_function:libsec_shared",
20532a6e48fSopenharmony_ci    "drivers_interface_display:display_commontype_idl_headers_1.1",
20632a6e48fSopenharmony_ci  ]
20732a6e48fSopenharmony_ci}
20832a6e48fSopenharmony_ci
20932a6e48fSopenharmony_ci## UnitTest surface_buffer_impl_test }}}
21032a6e48fSopenharmony_ci
21132a6e48fSopenharmony_ci## UnitTest surface_utils_test {{{
21232a6e48fSopenharmony_ciohos_unittest("surface_utils_test") {
21332a6e48fSopenharmony_ci  module_out_path = module_out_path
21432a6e48fSopenharmony_ci
21532a6e48fSopenharmony_ci  sources = [ "surface_utils_test.cpp" ]
21632a6e48fSopenharmony_ci
21732a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
21832a6e48fSopenharmony_ci  external_deps = [ "bounds_checking_function:libsec_shared" ]
21932a6e48fSopenharmony_ci}
22032a6e48fSopenharmony_ci
22132a6e48fSopenharmony_ci## UnitTest surface_utils_test }}}
22232a6e48fSopenharmony_ci
22332a6e48fSopenharmony_ci## UnitTest native_window_test {{{
22432a6e48fSopenharmony_ciohos_unittest("native_window_test") {
22532a6e48fSopenharmony_ci  module_out_path = module_out_path
22632a6e48fSopenharmony_ci
22732a6e48fSopenharmony_ci  sources = [ "native_window_test.cpp" ]
22832a6e48fSopenharmony_ci  external_deps = [
22932a6e48fSopenharmony_ci    "bounds_checking_function:libsec_shared",
23032a6e48fSopenharmony_ci    "ipc:ipc_capi",
23132a6e48fSopenharmony_ci  ]
23232a6e48fSopenharmony_ci
23332a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
23432a6e48fSopenharmony_ci}
23532a6e48fSopenharmony_ci
23632a6e48fSopenharmony_ci## UnitTest native_window_test }}}
23732a6e48fSopenharmony_ci
23832a6e48fSopenharmony_ci## UnitTest metadata_helper_test {{{
23932a6e48fSopenharmony_ciohos_unittest("metadata_helper_test") {
24032a6e48fSopenharmony_ci  module_out_path = module_out_path
24132a6e48fSopenharmony_ci
24232a6e48fSopenharmony_ci  sources = [ "metadata_helper_test.cpp" ]
24332a6e48fSopenharmony_ci
24432a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
24532a6e48fSopenharmony_ci
24632a6e48fSopenharmony_ci  external_deps = [
24732a6e48fSopenharmony_ci    "c_utils:utils",
24832a6e48fSopenharmony_ci    "drivers_interface_display:display_commontype_idl_headers",
24932a6e48fSopenharmony_ci    "hilog:libhilog",
25032a6e48fSopenharmony_ci  ]
25132a6e48fSopenharmony_ci}
25232a6e48fSopenharmony_ci
25332a6e48fSopenharmony_ci## UnitTest metadata_helper_test }}}
25432a6e48fSopenharmony_ci
25532a6e48fSopenharmony_ci## UnitTest native_buffer_test {{{
25632a6e48fSopenharmony_ciohos_unittest("native_buffer_test") {
25732a6e48fSopenharmony_ci  module_out_path = module_out_path
25832a6e48fSopenharmony_ci
25932a6e48fSopenharmony_ci  sources = [ "native_buffer_test.cpp" ]
26032a6e48fSopenharmony_ci
26132a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
26232a6e48fSopenharmony_ci
26332a6e48fSopenharmony_ci  external_deps = [
26432a6e48fSopenharmony_ci    "c_utils:utils",
26532a6e48fSopenharmony_ci    "hilog:libhilog",
26632a6e48fSopenharmony_ci  ]
26732a6e48fSopenharmony_ci}
26832a6e48fSopenharmony_ci
26932a6e48fSopenharmony_ci## UnitTest native_buffer_test }}}
27032a6e48fSopenharmony_ci
27132a6e48fSopenharmony_ci## UnitTest buffer_utils_test {{{
27232a6e48fSopenharmony_ciohos_unittest("buffer_utils_test") {
27332a6e48fSopenharmony_ci  module_out_path = module_out_path
27432a6e48fSopenharmony_ci
27532a6e48fSopenharmony_ci  sources = [ "buffer_utils_test.cpp" ]
27632a6e48fSopenharmony_ci
27732a6e48fSopenharmony_ci  deps = [ ":surface_test_common" ]
27832a6e48fSopenharmony_ci}
27932a6e48fSopenharmony_ci
28032a6e48fSopenharmony_ci## UnitTest buffer_utils_test }}}
28132a6e48fSopenharmony_ci
28232a6e48fSopenharmony_ci## Build surface_test_common.a {{{
28332a6e48fSopenharmony_ciconfig("surface_test_common_public_config") {
28432a6e48fSopenharmony_ci  include_dirs = [ "../../include" ]
28532a6e48fSopenharmony_ci
28632a6e48fSopenharmony_ci  cflags = [
28732a6e48fSopenharmony_ci    "-Wall",
28832a6e48fSopenharmony_ci    "-Werror",
28932a6e48fSopenharmony_ci    "-g3",
29032a6e48fSopenharmony_ci    "-Dprivate=public",
29132a6e48fSopenharmony_ci    "-Dprotected=public",
29232a6e48fSopenharmony_ci  ]
29332a6e48fSopenharmony_ci}
29432a6e48fSopenharmony_ci
29532a6e48fSopenharmony_ciohos_static_library("surface_test_common") {
29632a6e48fSopenharmony_ci  visibility = [ ":*" ]
29732a6e48fSopenharmony_ci  testonly = true
29832a6e48fSopenharmony_ci
29932a6e48fSopenharmony_ci  public_configs = [ ":surface_test_common_public_config" ]
30032a6e48fSopenharmony_ci
30132a6e48fSopenharmony_ci  public_deps = [
30232a6e48fSopenharmony_ci    "$graphic_surface_root/buffer_handle:buffer_handle",
30332a6e48fSopenharmony_ci    "$graphic_surface_root/surface:surface",
30432a6e48fSopenharmony_ci    "$graphic_surface_root/sync_fence:sync_fence",
30532a6e48fSopenharmony_ci    "$graphic_surface_root/test_header:test_header",
30632a6e48fSopenharmony_ci  ]
30732a6e48fSopenharmony_ci
30832a6e48fSopenharmony_ci  public_external_deps = [
30932a6e48fSopenharmony_ci    "access_token:libaccesstoken_sdk",
31032a6e48fSopenharmony_ci    "access_token:libnativetoken",
31132a6e48fSopenharmony_ci    "access_token:libtoken_setproc",
31232a6e48fSopenharmony_ci    "c_utils:utils",
31332a6e48fSopenharmony_ci    "hilog:libhilog",
31432a6e48fSopenharmony_ci    "ipc:ipc_single",
31532a6e48fSopenharmony_ci    "samgr:samgr_proxy",
31632a6e48fSopenharmony_ci  ]
31732a6e48fSopenharmony_ci
31832a6e48fSopenharmony_ci  subsystem_name = "graphic"
31932a6e48fSopenharmony_ci  part_name = "graphic_surface"
32032a6e48fSopenharmony_ci}
32132a6e48fSopenharmony_ci## Build surface_test_common.a }}}
322