# Copyright (c) 2020 Project CHIP Authors
#
# 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_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/nlunit_test.gni")

import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/src/app/icd/icd.gni")

static_library("helpers") {
  output_name = "libMessagingTestHelpers"
  output_dir = "${root_out_dir}/lib"

  sources = [
    "MessagingContext.cpp",
    "MessagingContext.h",
  ]

  cflags = [ "-Wconversion" ]

  deps = [
    "${chip_root}/src/credentials/tests:cert_test_vectors",
    "${chip_root}/src/lib/support:testing",
    "${chip_root}/src/messaging",
    "${chip_root}/src/protocols",
    "${chip_root}/src/transport",
    "${chip_root}/src/transport/tests:helpers",
  ]

  # MessagingContext exposes nl-test compatible setup/teardown functions, specifically
  # they return nltest specific SUCCESS/FAILURE constants hence this dependency.
  #
  # Once all tests are moved to pw_unittest/gtest, this dependency should be removed
  public_deps = [ "${nlunit_test_root}:nlunit-test" ]
}

chip_test_suite_using_nltest("tests") {
  output_name = "libMessagingLayerTests"

  test_sources = [
    "TestAbortExchangesForFabric.cpp",
    "TestExchange.cpp",
    "TestExchangeMgr.cpp",
    "TestReliableMessageProtocol.cpp",
  ]

  if (chip_device_platform != "esp32" && chip_device_platform != "mbed" &&
      chip_device_platform != "nrfconnect" && chip_device_platform != "nxp") {
    test_sources += [ "TestExchangeHolder.cpp" ]
  }

  if (chip_device_platform == "linux") {
    test_sources += [ "TestMessagingLayer.cpp" ]
  }

  cflags = [ "-Wconversion" ]

  public_deps = [
    ":helpers",
    "${chip_root}/src/inet/tests:helpers",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/lib/support:test_utils",
    "${chip_root}/src/lib/support:testing_nlunit",
    "${chip_root}/src/messaging",
    "${chip_root}/src/protocols",
    "${chip_root}/src/transport",
    "${chip_root}/src/transport/raw/tests:helpers",
    "${nlunit_test_root}:nlunit-test",
  ]

  if (chip_enable_icd_server) {
    public_deps += [ "${chip_root}/src/app/icd/server:configuration-data" ]
  }
}
