diff options
Diffstat (limited to 'chromium/device/bluetooth/bluetooth_adapter_unittest.cc')
-rw-r--r-- | chromium/device/bluetooth/bluetooth_adapter_unittest.cc | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/chromium/device/bluetooth/bluetooth_adapter_unittest.cc b/chromium/device/bluetooth/bluetooth_adapter_unittest.cc index 55f6b2d8333..593c5782a30 100644 --- a/chromium/device/bluetooth/bluetooth_adapter_unittest.cc +++ b/chromium/device/bluetooth/bluetooth_adapter_unittest.cc @@ -14,6 +14,7 @@ #include "base/barrier_closure.h" #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/logging.h" #include "base/memory/ref_counted.h" #include "base/run_loop.h" #include "base/test/bind_test_util.h" @@ -131,12 +132,6 @@ class TestBluetoothAdapter final : public BluetoothAdapter { void TestErrorCallback() {} - void TestOnStartDiscoverySession( - std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { - ++callback_count_; - discovery_sessions_holder_.push(std::move(discovery_session)); - } - void OnStartDiscoverySessionQuitLoop( base::Closure run_loop_quit, std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { @@ -723,7 +718,7 @@ TEST_F(BluetoothTest, MAYBE_ConstructDefaultAdapter) { EXPECT_EQ(adapter_->IsPowered(), adapter_->IsPowered()); EXPECT_FALSE(adapter_->IsDiscoverable()); EXPECT_FALSE(adapter_->IsDiscovering()); -} +} // namespace device // TODO(scheib): Enable BluetoothTest fixture tests on all platforms. #if defined(OS_ANDROID) || defined(OS_MACOSX) @@ -1420,6 +1415,34 @@ TEST_F(BluetoothTest, MAYBE_TogglePowerBeforeScan) { EXPECT_TRUE(discovery_sessions_[0]->IsActive()); } +#if defined(OS_WIN) +TEST_P(BluetoothTestWinrtOnly, DiscoverySessionFailure) { + if (!PlatformSupportsLowEnergy()) { + LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; + return; + } + + InitWithFakeAdapter(); + TestBluetoothAdapterObserver observer(adapter_); + EXPECT_FALSE(adapter_->IsDiscovering()); + + StartLowEnergyDiscoverySession(); + EXPECT_EQ(1, callback_count_); + EXPECT_EQ(0, error_callback_count_); + EXPECT_TRUE(adapter_->IsDiscovering()); + EXPECT_EQ(1, observer.discovering_changed_count()); + EXPECT_TRUE(observer.last_discovering()); + ASSERT_EQ((size_t)1, discovery_sessions_.size()); + EXPECT_TRUE(discovery_sessions_[0]->IsActive()); + + SimulateLowEnergyDiscoveryFailure(); + EXPECT_FALSE(adapter_->IsDiscovering()); + EXPECT_FALSE(discovery_sessions_[0]->IsActive()); + EXPECT_EQ(2, observer.discovering_changed_count()); + EXPECT_FALSE(observer.last_discovering()); +} +#endif // defined(OS_WIN) + #if defined(OS_MACOSX) #define MAYBE_TurnOffAdapterWithConnectedDevice \ TurnOffAdapterWithConnectedDevice @@ -2093,9 +2116,15 @@ TEST_F(BluetoothTest, DiscoverConnectedLowEnergyDeviceTwice) { #endif // defined(OS_MACOSX) #if defined(OS_WIN) -INSTANTIATE_TEST_SUITE_P(All, BluetoothTestWinrt, ::testing::Bool()); +INSTANTIATE_TEST_SUITE_P(All, + BluetoothTestWinrt, + ::testing::ValuesIn(kBluetoothTestWinrtParamAll)); + +INSTANTIATE_TEST_SUITE_P( + All, + BluetoothTestWinrtOnly, + ::testing::ValuesIn(kBluetoothTestWinrtParamWinrtOnly)); -INSTANTIATE_TEST_SUITE_P(All, BluetoothTestWinrtOnly, ::testing::Values(true)); #endif // defined(OS_WIN) } // namespace device |