diff options
author | scheib <scheib@chromium.org> | 2015-09-24 14:39:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-24 21:39:58 +0000 |
commit | 4fc1ee087598de11a4e6a2fb8353c7b13291bd91 (patch) | |
tree | 516daab9f059cb961ba2cb13318c361c5289b93b /device/bluetooth/bluetooth_adapter_unittest.cc | |
parent | 1bea9c094d22597369af2574e26e961735fa610c (diff) | |
download | chromium_src-4fc1ee087598de11a4e6a2fb8353c7b13291bd91.zip chromium_src-4fc1ee087598de11a4e6a2fb8353c7b13291bd91.tar.gz chromium_src-4fc1ee087598de11a4e6a2fb8353c7b13291bd91.tar.bz2 |
bluetooth: Android: Refactor BluetoothTest, simplifying tests.
+ Remove unneeded RunUntilIdle() after
+ StartDiscoverySession()
+ DiscoverLowEnergyDevice()
+ DiscoverLowEnergyDevice() returns BluetoothDevice*, removing the need
for an observer to find it.
+ ResetEventCounts() clears all 4 current event counters, in the future
would apply to any others that need to be created.
Review URL: https://codereview.chromium.org/1351903003
Cr-Commit-Position: refs/heads/master@{#350672}
Diffstat (limited to 'device/bluetooth/bluetooth_adapter_unittest.cc')
-rw-r--r-- | device/bluetooth/bluetooth_adapter_unittest.cc | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/device/bluetooth/bluetooth_adapter_unittest.cc b/device/bluetooth/bluetooth_adapter_unittest.cc index c4a1513..8d022dc 100644 --- a/device/bluetooth/bluetooth_adapter_unittest.cc +++ b/device/bluetooth/bluetooth_adapter_unittest.cc @@ -459,16 +459,15 @@ TEST_F(BluetoothTest, DiscoverySession) { adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(1, callback_count_--); + EXPECT_EQ(1, callback_count_); EXPECT_EQ(0, error_callback_count_); EXPECT_TRUE(adapter_->IsDiscovering()); ASSERT_EQ((size_t)1, discovery_sessions_.size()); EXPECT_TRUE(discovery_sessions_[0]->IsActive()); + ResetEventCounts(); discovery_sessions_[0]->Stop(GetCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(1, callback_count_--); + EXPECT_EQ(1, callback_count_); EXPECT_EQ(0, error_callback_count_); EXPECT_FALSE(adapter_->IsDiscovering()); EXPECT_FALSE(discovery_sessions_[0]->IsActive()); @@ -492,9 +491,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDevice) { adapter_->StartDiscoverySessionWithFilter(discovery_filter.Pass(), GetDiscoverySessionCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); DiscoverLowEnergyDevice(1); - base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, observer.device_added_count()); BluetoothDevice* device = adapter_->GetDevice(observer.last_device_address()); EXPECT_TRUE(device); @@ -514,9 +511,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceTwice) { // Start discovery and find a device. adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); DiscoverLowEnergyDevice(1); - base::RunLoop().RunUntilIdle(); EXPECT_EQ(1, observer.device_added_count()); BluetoothDevice* device = adapter_->GetDevice(observer.last_device_address()); EXPECT_TRUE(device); @@ -543,10 +538,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceWithUpdatedUUIDs) { // Start discovery and find a device. adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); - DiscoverLowEnergyDevice(1); - base::RunLoop().RunUntilIdle(); - BluetoothDevice* device = observer.last_device(); + BluetoothDevice* device = DiscoverLowEnergyDevice(1); // Check the initial UUIDs: EXPECT_TRUE( @@ -557,7 +549,6 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceWithUpdatedUUIDs) { // Discover same device again with updated UUIDs: observer.Reset(); DiscoverLowEnergyDevice(2); - base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, observer.device_added_count()); EXPECT_EQ(1, observer.device_changed_count()); EXPECT_EQ(1u, adapter_->GetDevices().size()); @@ -572,7 +563,6 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceWithUpdatedUUIDs) { // Discover same device again with empty UUIDs: observer.Reset(); DiscoverLowEnergyDevice(3); - base::RunLoop().RunUntilIdle(); EXPECT_EQ(0, observer.device_added_count()); EXPECT_EQ(1, observer.device_changed_count()); EXPECT_EQ(1u, adapter_->GetDevices().size()); @@ -596,10 +586,8 @@ TEST_F(BluetoothTest, DiscoverMultipleLowEnergyDevices) { // Start discovery and find a device. adapter_->StartDiscoverySession(GetDiscoverySessionCallback(), GetErrorCallback()); - base::RunLoop().RunUntilIdle(); DiscoverLowEnergyDevice(1); DiscoverLowEnergyDevice(4); - base::RunLoop().RunUntilIdle(); EXPECT_EQ(2, observer.device_added_count()); EXPECT_EQ(2u, adapter_->GetDevices().size()); } |