# 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/platform/device.gni")

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

  sources = [
    "AppTestContext.cpp",
    "AppTestContext.h",
    "integration/RequiredPrivilegeStubs.cpp",
  ]

  cflags = [ "-Wconversion" ]

  deps = [
    "${chip_root}/src/access",
    "${chip_root}/src/app",
    "${chip_root}/src/lib/support",
    "${chip_root}/src/messaging/tests:helpers",
    "${chip_root}/src/transport/raw/tests:helpers",
  ]
}

source_set("binding-test-srcs") {
  sources = [
    "${chip_root}/src/app/clusters/bindings/PendingNotificationMap.cpp",
    "${chip_root}/src/app/clusters/bindings/PendingNotificationMap.h",
    "${chip_root}/src/app/util/binding-table.cpp",
    "${chip_root}/src/app/util/binding-table.h",
  ]

  public_deps = [
    "${chip_root}/src/app/util/mock:mock_ember",
    "${chip_root}/src/lib/core",
  ]
}

source_set("icd-management-test-srcs") {
  sources = [
    "${chip_root}/src/app/util/IcdMonitoringTable.cpp",
    "${chip_root}/src/app/util/IcdMonitoringTable.h",
  ]

  public_deps = [
    "${chip_root}/src/app/common:cluster-objects",
    "${chip_root}/src/lib/core",
  ]
}

source_set("ota-requestor-test-srcs") {
  sources = [
    "${chip_root}/src/app/clusters/ota-requestor/DefaultOTARequestorStorage.cpp",
    "${chip_root}/src/app/clusters/ota-requestor/DefaultOTARequestorStorage.h",
    "${chip_root}/src/app/clusters/ota-requestor/OTARequestorStorage.h",
  ]

  public_deps = [
    "${chip_root}/src/app/common:cluster-objects",
    "${chip_root}/src/lib/core",
  ]
}

source_set("time-sync-data-provider-test-srcs") {
  sources = [ "${chip_root}/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp" ]

  public_deps = [
    "${chip_root}/src/app/common:cluster-objects",
    "${chip_root}/src/lib/core",
  ]
}

source_set("scenes-table-test-srcs") {
  sources = [
    "${chip_root}/src/app/clusters/scenes-server/ExtensionFieldSets.h",
    "${chip_root}/src/app/clusters/scenes-server/ExtensionFieldSetsImpl.cpp",
    "${chip_root}/src/app/clusters/scenes-server/ExtensionFieldSetsImpl.h",
    "${chip_root}/src/app/clusters/scenes-server/SceneTable.h",
    "${chip_root}/src/app/clusters/scenes-server/SceneTableImpl.cpp",
    "${chip_root}/src/app/clusters/scenes-server/SceneTableImpl.h",
  ]

  public_deps = [
    "${chip_root}/src/app",
    "${chip_root}/src/app/common:cluster-objects",
    "${chip_root}/src/app/util/mock:mock_ember",
    "${chip_root}/src/lib/core",
  ]
}

chip_test_suite("tests") {
  output_name = "libAppTests"

  test_sources = [
    "TestAclEvent.cpp",
    "TestAttributePathExpandIterator.cpp",
    "TestAttributePersistenceProvider.cpp",
    "TestAttributeValueDecoder.cpp",
    "TestAttributeValueEncoder.cpp",
    "TestBindingTable.cpp",
    "TestBuilderParser.cpp",
    "TestClusterInfo.cpp",
    "TestCommandInteraction.cpp",
    "TestCommandPathParams.cpp",
    "TestDataModelSerialization.cpp",
    "TestDefaultOTARequestorStorage.cpp",
    "TestEventLoggingNoUTCTime.cpp",
    "TestEventOverflow.cpp",
    "TestEventPathParams.cpp",
    "TestExtensionFieldSets.cpp",
    "TestFabricScopedEventLogging.cpp",
    "TestICDManager.cpp",
    "TestIcdMonitoringTable.cpp",
    "TestInteractionModelEngine.cpp",
    "TestMessageDef.cpp",
    "TestNumericAttributeTraits.cpp",
    "TestPendingNotificationMap.cpp",
    "TestReadInteraction.cpp",
    "TestReportingEngine.cpp",
    "TestSceneTable.cpp",
    "TestStatusIB.cpp",
    "TestStatusResponseMessage.cpp",
    "TestTimeSyncDataProvider.cpp",
    "TestTimedHandler.cpp",
    "TestWriteInteraction.cpp",
  ]

  if (!chip_fake_platform) {
    test_sources += [ "TestFailSafeContext.cpp" ]
  }

  test_sources += [ "TestAclAttribute.cpp" ]

  #
  # On NRF platforms, the allocation of a large number of pbufs in this test
  # to exercise chunking causes it to run out of memory. For now, disable it there.
  #
  if (chip_device_platform != "nrfconnect") {
    test_sources += [ "TestBufferedReadCallback.cpp" ]
    test_sources += [ "TestClusterStateCache.cpp" ]
  }

  # On NRF, Open IoT SDK and fake platforms we do not have a realtime clock available, so
  # TestEventLogging.cpp would be testing the same thing as
  # TestEventLoggingNoUTCTime, but it's not set up to deal with the timestamps
  # being that low.
  if (chip_device_platform != "nrfconnect" &&
      chip_device_platform != "openiotsdk" && chip_device_platform != "fake") {
    test_sources += [ "TestEventLogging.cpp" ]
  }

  cflags = [ "-Wconversion" ]

  public_deps = [
    ":binding-test-srcs",
    ":icd-management-test-srcs",
    ":ota-requestor-test-srcs",
    ":scenes-table-test-srcs",
    ":time-sync-data-provider-test-srcs",
    "${chip_root}/src/app",
    "${chip_root}/src/app/common:cluster-objects",
    "${chip_root}/src/app/icd:manager-srcs",
    "${chip_root}/src/app/tests:helpers",
    "${chip_root}/src/app/util/mock:mock_ember",
    "${chip_root}/src/lib/core",
    "${chip_root}/src/lib/support:testing",
    "${nlunit_test_root}:nlunit-test",
  ]

  if (chip_config_network_layer_ble &&
      (chip_device_platform == "linux" || chip_device_platform == "darwin")) {
    test_sources += [ "TestCommissionManager.cpp" ]
    public_deps += [ "${chip_root}/src/app/server" ]
  }

  if (chip_persist_subscriptions) {
    test_sources += [ "TestSimpleSubscriptionResumptionStorage.cpp" ]
  }
}
