# 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("${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/lib/support/tests:pw-test-macros",
    "${chip_root}/src/messaging",
    "${chip_root}/src/protocols",
    "${chip_root}/src/transport",
    "${chip_root}/src/transport/tests:helpers",
  ]
}

chip_test_suite("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/core:string-builder-adapters",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/lib/support:test_utils",
    "${chip_root}/src/messaging",
    "${chip_root}/src/protocols",
    "${chip_root}/src/transport",
    "${chip_root}/src/transport/raw/tests:helpers",
  ]

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