From 68739bab45685ced03d8210dd8da9138498975cd Mon Sep 17 00:00:00 2001 From: Qin Wang Date: Fri, 10 Feb 2023 12:33:49 -0800 Subject: [PATCH] Fix flacky test: fastpair_controller_test PiperOrigin-RevId: 508727920 --- fastpair/fast_pair_controller_impl_test.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/fastpair/fast_pair_controller_impl_test.cc b/fastpair/fast_pair_controller_impl_test.cc index e676d977..b77d0311 100644 --- a/fastpair/fast_pair_controller_impl_test.cc +++ b/fastpair/fast_pair_controller_impl_test.cc @@ -26,16 +26,13 @@ namespace fastpair { namespace FastPairControllerUnitTests { class FastPairControllerImplTest : public ::testing::Test { public: - FastPairControllerImplTest() = default; - ~FastPairControllerImplTest() override = default; - void SetUp() override { controller_ = CreateController(); } + void SetUp() override { + controller_.reset(); + controller_ = std::make_unique(); + } protected: - std::unique_ptr CreateController() { - auto controller = std::make_unique(); - return controller; - } - std::unique_ptr controller_; + std::shared_ptr controller_; MediumEnvironment& env_{MediumEnvironment::Instance()}; }; @@ -45,6 +42,7 @@ TEST_F(FastPairControllerImplTest, StartScanningSuccess) { EXPECT_FALSE(controller_->IsPairing()); EXPECT_FALSE(controller_->IsServerAccessing()); controller_->StartScan(); + SystemClock::Sleep(absl::Milliseconds(200)); EXPECT_TRUE(controller_->IsScanning()); env_.Stop(); }