# 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",
  ]
}

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

  test_sources = []

  if (chip_device_platform != "efr32") {
    # TODO(#10447): ReliableMessage Test has HF, and ExchangeMgr hangs on EFR32.
    # And TestAbortExchangesForFabric does not link on EFR32 for some reason.
    test_sources += [
      "TestAbortExchangesForFabric.cpp",
      "TestExchangeMgr.cpp",
      "TestReliableMessageProtocol.cpp",
    ]

    if (chip_device_platform != "esp32" && chip_device_platform != "mbed" &&
        chip_device_platform != "nrfconnect") {
      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" ]
  }
}
