# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//testing/test.gni")

assert(is_chromeos, "ProximityAuth is Chrome OS only")

static_library("proximity_auth") {
  sources = [
    "bluetooth_low_energy_connection_finder.cc",
    "bluetooth_low_energy_connection_finder.h",
    "bluetooth_low_energy_setup_connection_finder.cc",
    "bluetooth_low_energy_setup_connection_finder.h",
    "messenger.h",
    "messenger_impl.cc",
    "messenger_impl.h",
    "messenger_observer.h",
    "metrics.cc",
    "metrics.h",
    "notification_controller.h",
    "proximity_auth_client.h",
    "proximity_auth_local_state_pref_manager.cc",
    "proximity_auth_local_state_pref_manager.h",
    "proximity_auth_pref_manager.h",
    "proximity_auth_pref_names.cc",
    "proximity_auth_pref_names.h",
    "proximity_auth_profile_pref_manager.cc",
    "proximity_auth_profile_pref_manager.h",
    "proximity_auth_system.cc",
    "proximity_auth_system.h",
    "proximity_monitor.h",
    "proximity_monitor_impl.cc",
    "proximity_monitor_impl.h",
    "proximity_monitor_observer.h",
    "remote_device_life_cycle.cc",
    "remote_device_life_cycle.h",
    "remote_device_life_cycle_impl.cc",
    "remote_device_life_cycle_impl.h",
    "remote_status_update.cc",
    "remote_status_update.h",
    "screenlock_bridge.cc",
    "screenlock_bridge.h",
    "screenlock_state.cc",
    "screenlock_state.h",
    "switches.cc",
    "switches.h",
    "unlock_manager.h",
    "unlock_manager_impl.cc",
    "unlock_manager_impl.h",
  ]

  deps = [
    "//base",
    "//chromeos",
    "//chromeos/components/proximity_auth/logging",
    "//chromeos/components/proximity_auth/public/interfaces",
    "//chromeos/services/secure_channel/public/cpp/client",
    "//chromeos/services/secure_channel/public/mojom",
    "//components/account_id",
    "//components/cryptauth",
    "//components/cryptauth/ble",
    "//components/pref_registry:pref_registry",
    "//components/prefs",
    "//device/bluetooth",
    "//net",
  ]
}

static_library("test_support") {
  testonly = true

  sources = [
    "fake_lock_handler.cc",
    "fake_lock_handler.h",
    "fake_remote_device_life_cycle.cc",
    "fake_remote_device_life_cycle.h",
    "mock_proximity_auth_client.cc",
    "mock_proximity_auth_client.h",
  ]

  public_deps = [
    ":proximity_auth",
  ]

  deps = [
    "//base",
    "//chromeos/components/proximity_auth/logging",
    "//chromeos/services/secure_channel/public/cpp/client",
    "//components/cryptauth:test_support",
    "//testing/gmock",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "bluetooth_low_energy_connection_finder_unittest.cc",
    "messenger_impl_unittest.cc",
    "proximity_auth_local_state_pref_manager_unittest.cc",
    "proximity_auth_profile_pref_manager_unittest.cc",
    "proximity_auth_system_unittest.cc",
    "proximity_monitor_impl_unittest.cc",
    "remote_device_life_cycle_impl_unittest.cc",
    "remote_status_update_unittest.cc",
    "unlock_manager_impl_unittest.cc",
  ]

  configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]

  deps = [
    ":proximity_auth",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//chromeos",
    "//chromeos/components/proximity_auth/logging",
    "//chromeos/components/proximity_auth/logging:unit_tests",
    "//chromeos/services/secure_channel/public/cpp/client:test_support",
    "//components/cryptauth:test_support",
    "//components/prefs:test_support",
    "//components/sync_preferences:test_support",
    "//device/bluetooth:mocks",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

# Note: This is a convenience target for ease of rapid iteration during
# development. It is not executed on any try or build bots.
test("proximity_auth_unittests") {
  sources = [
    "run_all_unittests.cc",
  ]
  deps = [
    ":unit_tests",
    "//base",
    "//base/test:test_support",
  ]
}
