Index: device/bluetooth/bluetooth_gatt_chromeos_unittest.cc |
diff --git a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc |
index 2947f16c9e6d7cdeb35bd482cfbdb3eeeb4b5a67..89f84dfc32bb207aa5804d52d87919979586ee7a 100644 |
--- a/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc |
+++ b/device/bluetooth/bluetooth_gatt_chromeos_unittest.cc |
@@ -953,6 +953,56 @@ TEST_F(BluetoothGattChromeOSTest, GattCharacteristicValue) { |
EXPECT_EQ(4, error_callback_count_); |
EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count_); |
EXPECT_TRUE(ValuesEqual(characteristic->GetValue(), last_read_value_)); |
+ |
+ // Test long-running actions. |
+ fake_bluetooth_gatt_characteristic_client_->SetExtraProcessing(1); |
+ characteristic = service->GetCharacteristic( |
+ fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() |
+ .value()); |
+ ASSERT_TRUE(characteristic); |
+ EXPECT_EQ( |
+ fake_bluetooth_gatt_characteristic_client_->GetBodySensorLocationPath() |
+ .value(), |
+ characteristic->GetIdentifier()); |
+ EXPECT_EQ(kBodySensorLocationUUID, characteristic->GetUUID()); |
+ characteristic->ReadRemoteCharacteristic( |
+ base::Bind(&BluetoothGattChromeOSTest::ValueCallback, |
+ base::Unretained(this)), |
+ base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, |
+ base::Unretained(this))); |
armansito
2014/10/01 20:08:22
Add new line before comments, here and below.
Marie Janssen
2014/10/01 22:22:22
Done.
|
+ // Callback counts shouldn't change, this one will be delayed until after |
+ // tne next one. |
+ EXPECT_EQ(2, success_callback_count_); |
+ EXPECT_EQ(4, error_callback_count_); |
+ EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count_); |
+ // Next read should error because IN_PROGRESS |
+ characteristic->ReadRemoteCharacteristic( |
+ base::Bind(&BluetoothGattChromeOSTest::ValueCallback, |
+ base::Unretained(this)), |
+ base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, |
+ base::Unretained(this))); |
+ EXPECT_EQ(5, error_callback_count_); |
+ EXPECT_EQ(BluetoothGattService::GattErrorCode::GATT_ERROR_IN_PROGRESS, |
armansito
2014/10/01 20:08:22
Interesting, this works in C++? BluetoothGattServi
Marie Janssen
2014/10/01 22:22:22
Done.
|
+ last_service_error_); |
+ // But previous call finished. |
+ EXPECT_EQ(3, success_callback_count_); |
+ EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count_); |
+ EXPECT_TRUE(ValuesEqual(characteristic->GetValue(), last_read_value_)); |
+ fake_bluetooth_gatt_characteristic_client_->SetExtraProcessing(0); |
+ |
+ // Test unauthorized actions. |
+ fake_bluetooth_gatt_characteristic_client_->SetAuthorized(false); |
+ characteristic->ReadRemoteCharacteristic( |
+ base::Bind(&BluetoothGattChromeOSTest::ValueCallback, |
+ base::Unretained(this)), |
+ base::Bind(&BluetoothGattChromeOSTest::ServiceErrorCallback, |
+ base::Unretained(this))); |
+ EXPECT_EQ(3, success_callback_count_); |
+ EXPECT_EQ(6, error_callback_count_); |
+ EXPECT_EQ(BluetoothGattService::GattErrorCode::GATT_ERROR_NOT_AUTHORIZED, |
+ last_service_error_); |
+ EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count_); |
+ fake_bluetooth_gatt_characteristic_client_->SetAuthorized(true); |
} |
TEST_F(BluetoothGattChromeOSTest, GattCharacteristicProperties) { |