| Index: device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
|
| diff --git a/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc b/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
|
| index 51fc4360e51739bdc4a7e34fb3276c5d58864435..4c16d53019d946fba31c2071a49724f71f94d839 100644
|
| --- a/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
|
| +++ b/device/bluetooth/bluez/bluetooth_gatt_bluez_unittest.cc
|
| @@ -1416,12 +1416,13 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
|
| EXPECT_TRUE(update_sessions_.empty());
|
| - EXPECT_TRUE(characteristic->IsNotifying());
|
| + EXPECT_FALSE(characteristic->IsNotifying());
|
|
|
| // Run the main loop. The initial call should complete. The queued call should
|
| // succeed immediately.
|
| base::RunLoop().Run();
|
|
|
| + EXPECT_TRUE(characteristic->IsNotifying());
|
| EXPECT_EQ(3, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
|
| @@ -1437,6 +1438,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
| EXPECT_TRUE(session->IsActive());
|
| session->Stop(base::Bind(&BluetoothGattBlueZTest::SuccessCallback,
|
| base::Unretained(this)));
|
| +
|
| + // Run message loop to stop the notify session.
|
| + base::RunLoop().Run();
|
| +
|
| EXPECT_EQ(4, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_FALSE(session->IsActive());
|
| @@ -1454,6 +1459,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
| // Clear the last session.
|
| update_sessions_.clear();
|
| EXPECT_TRUE(update_sessions_.empty());
|
| +
|
| + // Run message loop in order to do proper cleanup of sessions.
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| EXPECT_FALSE(characteristic->IsNotifying());
|
|
|
| success_callback_count_ = 0;
|
| @@ -1469,7 +1478,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
|
| EXPECT_TRUE(update_sessions_.empty());
|
| - EXPECT_TRUE(characteristic->IsNotifying());
|
| + EXPECT_FALSE(characteristic->IsNotifying());
|
|
|
| // Run the message loop. Notifications should begin.
|
| base::RunLoop().Run();
|
| @@ -1491,6 +1500,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessions) {
|
| base::Unretained(this)),
|
| base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback,
|
| base::Unretained(this)));
|
| +
|
| + // Run message loop to stop the notify session.
|
| + base::RunLoop().Run();
|
| +
|
| EXPECT_EQ(2, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(2U, update_sessions_.size());
|
| @@ -1564,7 +1577,7 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
| EXPECT_EQ(0, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
|
| - EXPECT_TRUE(characteristic->IsNotifying());
|
| + EXPECT_FALSE(characteristic->IsNotifying());
|
| EXPECT_TRUE(update_sessions_.empty());
|
|
|
| // Run the main loop. The initial call should complete. The queued calls
|
| @@ -1590,6 +1603,10 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
| base::Unretained(this)));
|
| EXPECT_EQ(5, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| +
|
| + // Run message loop to stop the notify session.
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| EXPECT_FALSE(characteristic->IsNotifying());
|
| EXPECT_EQ(4U, update_sessions_.size());
|
|
|
| @@ -1607,10 +1624,13 @@ TEST_F(BluetoothGattBlueZTest, NotifySessionsMadeInactive) {
|
| base::Bind(&BluetoothGattBlueZTest::ServiceErrorCallback,
|
| base::Unretained(this)));
|
|
|
| + // Run message loop to start the notify session.
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| EXPECT_EQ(0, success_callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
|
| - EXPECT_TRUE(characteristic->IsNotifying());
|
| + EXPECT_FALSE(characteristic->IsNotifying());
|
| EXPECT_TRUE(update_sessions_.empty());
|
|
|
| base::RunLoop().Run();
|
|
|