From cf69c87d950fa46af226d0f30ef6f88000e5604c Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Mon, 18 Dec 2023 11:40:09 -0800 Subject: [PATCH] Cleanup FakeAccountManager. - Remove unnecessary deps. PiperOrigin-RevId: 591964328 --- fastpair/internal/fast_pair_seeker_impl_test.cc | 17 ++--------------- .../fastpair/fast_pair_pairer_impl_test.cc | 14 +------------- fastpair/pairing/pairer_broker_impl_test.cc | 14 +------------- .../server_access/fast_pair_client_impl_test.cc | 14 +------------- 4 files changed, 5 insertions(+), 54 deletions(-) diff --git a/fastpair/internal/fast_pair_seeker_impl_test.cc b/fastpair/internal/fast_pair_seeker_impl_test.cc index 6738784a..f3e11089 100644 --- a/fastpair/internal/fast_pair_seeker_impl_test.cc +++ b/fastpair/internal/fast_pair_seeker_impl_test.cc @@ -26,7 +26,6 @@ #include "absl/status/status.h" #include "absl/strings/escaping.h" #include "fastpair/common/fast_pair_device.h" -#include "fastpair/common/fast_pair_prefs.h" #include "fastpair/fast_pair_events.h" #include "fastpair/fast_pair_seeker.h" #include "fastpair/message_stream/fake_gatt_callbacks.h" @@ -41,8 +40,6 @@ #include "internal/platform/logging.h" #include "internal/platform/medium_environment.h" #include "internal/platform/single_thread_executor.h" -#include "internal/platform/task_runner_impl.h" -#include "internal/test/google3_only/fake_authentication_manager.h" namespace nearby { namespace fastpair { @@ -85,12 +82,7 @@ class FastPairRepositoryObserver : public FastPairRepository::Observer { class FastPairSeekerImplTest : public testing::Test { protected: - FastPairSeekerImplTest() { - task_runner_ = std::make_unique(1); - preferences_manager_ = std::make_unique( - kFastPairPreferencesFilePath); - authentication_manager_ = std::make_unique(); - } + FastPairSeekerImplTest() = default; void SetUp() override { NEARBY_LOG_SET_SEVERITY(VERBOSE); @@ -98,9 +90,7 @@ class FastPairSeekerImplTest : public testing::Test { kModelId, absl::HexStringToBytes(kBobPublicKey)); repository_->SetResultOfIsDeviceSavedToAccount( absl::NotFoundError("not found")); - account_manager_ = std::make_unique( - preferences_manager_.get(), prefs::kNearbyFastPairUsersName, - authentication_manager_.get(), task_runner_.get()); + account_manager_ = std::make_unique(); AccountManager::Account account; account.id = kTestAccountId; account_manager_->SetAccount(account); @@ -116,9 +106,6 @@ class FastPairSeekerImplTest : public testing::Test { MediumEnvironmentStarter env_; SingleThreadExecutor executor_; - std::unique_ptr preferences_manager_; - std::unique_ptr authentication_manager_; - std::unique_ptr task_runner_; std::unique_ptr account_manager_; FastPairDeviceRepository devices_{&executor_}; std::unique_ptr repository_; diff --git a/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc b/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc index d2eac0e5..8fa4dbde 100644 --- a/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc +++ b/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc @@ -34,7 +34,6 @@ #include "fastpair/common/account_key.h" #include "fastpair/common/device_metadata.h" #include "fastpair/common/fast_pair_device.h" -#include "fastpair/common/fast_pair_prefs.h" #include "fastpair/common/fast_pair_version.h" #include "fastpair/common/protocol.h" #include "fastpair/crypto/decrypted_passkey.h" @@ -54,8 +53,6 @@ #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" #include "internal/platform/single_thread_executor.h" -#include "internal/platform/task_runner_impl.h" -#include "internal/test/google3_only/fake_authentication_manager.h" namespace nearby { namespace fastpair { @@ -137,18 +134,12 @@ class FastPairPairerImplTest : public testing::Test { FastPairPairerImplTest() { FastPairDataEncryptorImpl::Factory::SetFactoryForTesting( &fake_data_encryptor_factory_); - task_runner_ = std::make_unique(1); - preferences_manager_ = std::make_unique( - kFastPairPreferencesFilePath); - authentication_manager_ = std::make_unique(); } void SetUp() override { env_.Start(); // Setups seeker device. mediums_ = std::make_unique(); - account_manager_ = std::make_unique( - preferences_manager_.get(), prefs::kNearbyFastPairUsersName, - authentication_manager_.get(), task_runner_.get()); + account_manager_ = std::make_unique(); // Setups provider device. adapter_provider_ = std::make_unique(); @@ -384,9 +375,6 @@ class FastPairPairerImplTest : public testing::Test { private: MediumEnvironment& env_{MediumEnvironment::Instance()}; Mutex mutex_; - std::unique_ptr preferences_manager_; - std::unique_ptr authentication_manager_; - std::unique_ptr task_runner_; std::unique_ptr bt_provider_; std::unique_ptr adapter_provider_; std::unique_ptr gatt_server_; diff --git a/fastpair/pairing/pairer_broker_impl_test.cc b/fastpair/pairing/pairer_broker_impl_test.cc index d1d98648..334e290a 100644 --- a/fastpair/pairing/pairer_broker_impl_test.cc +++ b/fastpair/pairing/pairer_broker_impl_test.cc @@ -24,7 +24,6 @@ #include "gtest/gtest.h" #include "absl/functional/bind_front.h" #include "fastpair//handshake/fast_pair_handshake_lookup.h" -#include "fastpair/common/fast_pair_prefs.h" #include "fastpair/common/pair_failure.h" #include "fastpair/crypto/decrypted_passkey.h" #include "fastpair/crypto/decrypted_response.h" @@ -42,8 +41,6 @@ #include "internal/platform/ble_v2.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" -#include "internal/platform/task_runner_impl.h" -#include "internal/test/google3_only/fake_authentication_manager.h" namespace nearby { namespace fastpair { @@ -180,19 +177,13 @@ class PairerBrokerImplTest : public testing::Test { PairerBrokerImplTest() { FastPairDataEncryptorImpl::Factory::SetFactoryForTesting( &fake_data_encryptor_factory_); - task_runner_ = std::make_unique(1); - preferences_manager_ = std::make_unique( - kFastPairPreferencesFilePath); - authentication_manager_ = std::make_unique(); } void SetUp() override { env_.Start(); // Setups seeker device. mediums_ = std::make_unique(); - account_manager_ = std::make_unique( - preferences_manager_.get(), prefs::kNearbyFastPairUsersName, - authentication_manager_.get(), task_runner_.get()); + account_manager_ = std::make_unique(); // Setups provider device. adapter_provider_ = std::make_unique(); @@ -416,9 +407,6 @@ class PairerBrokerImplTest : public testing::Test { private: MediumEnvironment& env_{MediumEnvironment::Instance()}; Mutex mutex_; - std::unique_ptr preferences_manager_; - std::unique_ptr authentication_manager_; - std::unique_ptr task_runner_; std::unique_ptr bt_provider_; std::unique_ptr adapter_provider_; std::unique_ptr gatt_server_; diff --git a/fastpair/server_access/fast_pair_client_impl_test.cc b/fastpair/server_access/fast_pair_client_impl_test.cc index 255cfa18..80665de0 100644 --- a/fastpair/server_access/fast_pair_client_impl_test.cc +++ b/fastpair/server_access/fast_pair_client_impl_test.cc @@ -36,7 +36,6 @@ #include "fastpair/common/account_key.h" #include "fastpair/common/device_metadata.h" #include "fastpair/common/fast_pair_device.h" -#include "fastpair/common/fast_pair_prefs.h" #include "fastpair/common/fast_pair_switches.h" #include "fastpair/common/protocol.h" #include "fastpair/proto/data.proto.h" @@ -45,7 +44,6 @@ #include "fastpair/proto/proto_builder.h" #include "fastpair/server_access/fast_pair_client.h" #include "fastpair/server_access/fast_pair_http_notifier.h" -#include "internal/account/account_manager.h" #include "internal/account/fake_account_manager.h" #include "internal/auth/auth_status_util.h" #include "internal/auth/authentication_manager.h" @@ -55,9 +53,6 @@ #include "internal/network/http_status_code.h" #include "internal/network/url.h" #include "internal/platform/device_info.h" -#include "internal/platform/task_runner.h" -#include "internal/platform/task_runner_impl.h" -#include "internal/preferences/preferences_manager.h" #include "internal/test/fake_device_info.h" #include "internal/test/google3_only/fake_authentication_manager.h" @@ -147,16 +142,11 @@ class FastPairClientImplTest : public ::testing::Test, public FastPairHttpNotifier::Observer { protected: FastPairClientImplTest() { - preferences_manager_ = std::make_unique( - kFastPairPreferencesFilePath); authentication_manager_ = std::make_unique(); AccountManager::Account account; account.id = kTestAccountId; - account_manager_ = std::make_unique( - preferences_manager_.get(), prefs::kNearbyFastPairUsersName, - authentication_manager_.get(), task_runner_.get()); + account_manager_ = std::make_unique(); account_manager_->SetAccount(account); - task_runner_ = std::make_unique(1); device_info_ = std::make_unique(); } @@ -235,12 +225,10 @@ class FastPairClientImplTest : public ::testing::Test, std::optional delete_device_request_; std::optional delete_device_response_; - std::unique_ptr preferences_manager_; std::unique_ptr authentication_manager_; std::unique_ptr account_manager_; std::unique_ptr fast_pair_client_; std::unique_ptr device_info_; - std::unique_ptr task_runner_; ::testing::NiceMock* http_client_; std::unique_ptr mock_http_client_; FastPairHttpNotifier notifier_;