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

source_set("affiliation_match_helper") {
  sources = [
    "affiliated_match_helper.cc",
    "affiliated_match_helper.h",
  ]
  deps = []
  public_deps = [
    "//base",
    "//components/affiliations/core/browser:affiliations",
    "//components/password_manager/core/browser:password_form",
    "//components/password_manager/core/browser/password_store:password_store_interface",
  ]
}

source_set("affiliation_fetching") {
  sources = [
    "password_affiliation_source_adapter.cc",
    "password_affiliation_source_adapter.h",
  ]
  deps = [
    "//components/affiliations/core/browser:affiliations",
    "//components/password_manager/core/browser",
    "//components/password_manager/core/browser:password_form",
    "//components/password_manager/core/browser/features:password_features",
    "//components/password_manager/core/common:features",
    "//net",
    "//url",
  ]
  if (!is_android) {
    sources += [
      "passkey_affiliation_source_adapter.cc",
      "passkey_affiliation_source_adapter.h",
    ]
    deps += [ "//components/webauthn/core/browser:passkey_model" ]
  }
  configs += [ "//build/config/compiler:wexit_time_destructors" ]
}

source_set("test_support") {
  testonly = true
  sources = [
    "mock_affiliated_match_helper.cc",
    "mock_affiliated_match_helper.h",
  ]
  deps = [
    "//base",
    "//components/affiliations/core/browser:affiliations",
    "//components/affiliations/core/browser:test_support",
    "//components/password_manager/core/browser:password_form",
    "//components/password_manager/core/browser/affiliation:affiliation_match_helper",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]
}

# TODO: Clean up deps here - maybe merge targets.
source_set("unit_tests") {
  testonly = true
  sources = [ "affiliated_match_helper_unittest.cc" ]
  deps = [
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//components/affiliations/core/browser:affiliation_proto",
    "//components/affiliations/core/browser:affiliations",
    "//components/affiliations/core/browser:test_support",
    "//components/password_manager/core/browser:password_form",
    "//components/password_manager/core/browser/affiliation:affiliation_match_helper",
    "//components/password_manager/core/browser/password_store:password_store_interface",
    "//components/password_manager/core/common",
    "//components/password_manager/core/common:features",
    "//components/variations:test_support",
    "//services/network:test_support",
    "//services/network/public/mojom",
    "//sql:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//url",
  ]
}

source_set("affiliation_fetching_unittests") {
  testonly = true
  sources = [ "password_affiliation_source_adapter_unittest.cc" ]
  deps = [
    ":affiliation_fetching",
    ":test_support",
    "//base",
    "//components/affiliations/core/browser:affiliations",
    "//components/affiliations/core/browser:test_support",
    "//components/password_manager/core/browser",
    "//components/password_manager/core/browser:test_support",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (!is_android) {
    sources += [ "passkey_affiliation_source_adapter_unittest.cc" ]
    deps += [ "//components/webauthn/core/browser:test_support" ]
  }
}
