Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Unified Diff: device/bluetooth/bluetooth_gatt_chromeos_unittest.cc

Issue 619973002: Add unit testing for more org.bluez.Error.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: execute delayed when setting delay to 0 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698