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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 2085293002: bluetooth: Call GattCharacteristicValueChanged after a read succeeds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Add windows Created 4 years, 6 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_remote_gatt_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
index cc2186403f75d4fa8947fbfdec457d925a7a5e7c..31cbda1d7681d590fddd6312c73e622efc538a5d 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -383,8 +383,7 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic) {
GetReadValueCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
- uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
- std::vector<uint8_t> test_vector(values, values + arraysize(values));
+ std::vector<uint8_t> test_vector = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
SimulateGattCharacteristicRead(characteristic1_, test_vector);
// Duplicate read reported from OS shouldn't cause a problem:
@@ -398,6 +397,32 @@ TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic) {
#endif // defined(OS_ANDROID) || defined(OS_WIN)
#if defined(OS_ANDROID) || defined(OS_WIN)
+// Tests that ReadRemoteCharacteristic results in a
+// GattCharacteristicValueChanged call.
+TEST_F(BluetoothRemoteGattCharacteristicTest,
+ ReadRemoteCharacteristic_GattCharacteristicValueChanged) {
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothRemoteGattCharacteristic::PROPERTY_READ));
+
+ TestBluetoothAdapterObserver observer(adapter_);
+
+ characteristic1_->ReadRemoteCharacteristic(
+ GetReadValueCallback(Call::EXPECTED),
+ GetGattErrorCallback(Call::NOT_EXPECTED));
+
+ std::vector<uint8_t> test_vector = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
+ SimulateGattCharacteristicRead(characteristic1_, test_vector);
+
+ // TODO(http://crbug.com/580406): Make sure GattCharacteristicValueChanged
scheib 2016/06/23 20:36:48 You can probably do this with not so much extra wo
ortuno 2016/06/23 22:57:40 I tried using a lambda for the callback but it fai
+ // is called before the callback is run.
+ EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count());
+ EXPECT_EQ(1, gatt_read_characteristic_attempts_);
+ EXPECT_EQ(test_vector, last_read_value_);
scheib 2016/06/23 20:36:48 Can simplify this test to just the observer.gatt_c
ortuno 2016/06/23 22:57:41 Changed to more appropriate checks.
+ EXPECT_EQ(test_vector, characteristic1_->GetValue());
+}
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
+
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic with non-empty value buffer.
TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) {
ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(

Powered by Google App Engine
This is Rietveld 408576698