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

Unified Diff: device/bluetooth/bluetooth_gatt_characteristic_unittest.cc

Issue 1739383002: Implement read & write remote GATT characteristic value for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix conversion from 'size_t' to 'ULONG' error on trybot Created 4 years, 10 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_characteristic_unittest.cc
diff --git a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
index 96e3f52557da378c94c35ec319d9cd04b8f8534c..2266df5a50b61ba0fc1033cc138521bbeaa043aa 100644
--- a/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_characteristic_unittest.cc
@@ -264,10 +264,11 @@ TEST_F(BluetoothGattCharacteristicTest, GetService) {
}
#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic and GetValue with empty value buffer.
TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::EXPECTED),
@@ -282,12 +283,13 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) {
EXPECT_EQ(empty_vector, last_read_value_);
EXPECT_EQ(empty_vector, characteristic1_->GetValue());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic with empty value buffer.
TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
std::vector<uint8_t> empty_vector;
characteristic1_->WriteRemoteCharacteristic(
@@ -298,12 +300,13 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Empty) {
EXPECT_EQ(empty_vector, last_write_value_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic completing after Chrome objects are deleted.
TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::NOT_EXPECTED),
@@ -317,13 +320,14 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_AfterDeleted) {
empty_vector);
EXPECT_TRUE("Did not crash!");
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic completing after Chrome objects are deleted.
TEST_F(BluetoothGattCharacteristicTest,
WriteRemoteCharacteristic_AfterDeleted) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
std::vector<uint8_t> empty_vector;
characteristic1_->WriteRemoteCharacteristic(
@@ -336,12 +340,13 @@ TEST_F(BluetoothGattCharacteristicTest,
SimulateGattCharacteristicWrite(/* use remembered characteristic */ nullptr);
EXPECT_TRUE("Did not crash!");
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic and GetValue with non-empty value buffer.
TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::EXPECTED),
@@ -359,12 +364,13 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic) {
EXPECT_EQ(test_vector, last_read_value_);
EXPECT_EQ(test_vector, characteristic1_->GetValue());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic with non-empty value buffer.
TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
std::vector<uint8_t> test_vector(values, values + arraysize(values));
@@ -377,12 +383,13 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic) {
EXPECT_EQ(test_vector, last_write_value_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic and GetValue multiple times.
TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::EXPECTED),
@@ -410,12 +417,13 @@ TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Twice) {
EXPECT_EQ(empty_vector, last_read_value_);
EXPECT_EQ(empty_vector, characteristic1_->GetValue());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic multiple times.
TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
std::vector<uint8_t> test_vector(values, values + arraysize(values));
@@ -441,21 +449,19 @@ TEST_F(BluetoothGattCharacteristicTest, WriteRemoteCharacteristic_Twice) {
EXPECT_EQ(0, error_callback_count_);
EXPECT_EQ(empty_vector, last_write_value_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic on two characteristics.
TEST_F(BluetoothGattCharacteristicTest,
ReadRemoteCharacteristic_MultipleCharacteristics) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
- characteristic2_->ReadRemoteCharacteristic(
- GetReadValueCallback(Call::EXPECTED),
- GetGattErrorCallback(Call::NOT_EXPECTED));
- EXPECT_EQ(2, gatt_read_characteristic_attempts_);
+ EXPECT_EQ(1, gatt_read_characteristic_attempts_);
EXPECT_EQ(0, callback_count_);
EXPECT_EQ(0, error_callback_count_);
@@ -464,6 +470,13 @@ TEST_F(BluetoothGattCharacteristicTest,
SimulateGattCharacteristicRead(characteristic1_, test_vector1);
EXPECT_EQ(test_vector1, last_read_value_);
+ characteristic2_->ReadRemoteCharacteristic(
scheib 2016/03/02 05:59:05 This changes the test meaning, in that two read ch
gogerald1 2016/03/02 23:56:29 Done.
+ GetReadValueCallback(Call::EXPECTED),
+ GetGattErrorCallback(Call::NOT_EXPECTED));
+ EXPECT_EQ(2, gatt_read_characteristic_attempts_);
+ EXPECT_EQ(1, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+
std::vector<uint8_t> test_vector2;
test_vector2.push_back(222);
SimulateGattCharacteristicRead(characteristic2_, test_vector2);
@@ -474,19 +487,24 @@ TEST_F(BluetoothGattCharacteristicTest,
EXPECT_EQ(test_vector1, characteristic1_->GetValue());
EXPECT_EQ(test_vector2, characteristic2_->GetValue());
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic on two characteristics.
TEST_F(BluetoothGattCharacteristicTest,
WriteRemoteCharacteristic_MultipleCharacteristics) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
std::vector<uint8_t> test_vector1;
test_vector1.push_back(111);
characteristic1_->WriteRemoteCharacteristic(
test_vector1, GetCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
+ EXPECT_EQ(1, gatt_write_characteristic_attempts_);
+ EXPECT_EQ(0, callback_count_);
+ EXPECT_EQ(0, error_callback_count_);
+ SimulateGattCharacteristicWrite(characteristic1_);
scheib 2016/03/02 05:59:05 Similar to above, this changes the test logic -- e
gogerald1 2016/03/02 23:56:29 Done.
EXPECT_EQ(test_vector1, last_write_value_);
std::vector<uint8_t> test_vector2;
@@ -494,24 +512,22 @@ TEST_F(BluetoothGattCharacteristicTest,
characteristic2_->WriteRemoteCharacteristic(
test_vector2, GetCallback(Call::EXPECTED),
GetGattErrorCallback(Call::NOT_EXPECTED));
- EXPECT_EQ(test_vector2, last_write_value_);
-
EXPECT_EQ(2, gatt_write_characteristic_attempts_);
- EXPECT_EQ(0, callback_count_);
+ EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
-
- SimulateGattCharacteristicWrite(characteristic1_);
SimulateGattCharacteristicWrite(characteristic2_);
+ EXPECT_EQ(test_vector2, last_write_value_);
EXPECT_EQ(2, callback_count_);
EXPECT_EQ(0, error_callback_count_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests ReadRemoteCharacteristic asynchronous error.
TEST_F(BluetoothGattCharacteristicTest, ReadError) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_READ));
characteristic1_->ReadRemoteCharacteristic(
GetReadValueCallback(Call::NOT_EXPECTED),
@@ -523,12 +539,13 @@ TEST_F(BluetoothGattCharacteristicTest, ReadError) {
EXPECT_EQ(BluetoothGattService::GATT_ERROR_INVALID_LENGTH,
last_gatt_error_code_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(OS_WIN)
// Tests WriteRemoteCharacteristic asynchronous error.
TEST_F(BluetoothGattCharacteristicTest, WriteError) {
- ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
+ ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(
+ BluetoothGattCharacteristic::PROPERTY_WRITE));
std::vector<uint8_t> empty_vector;
characteristic1_->WriteRemoteCharacteristic(
@@ -542,7 +559,7 @@ TEST_F(BluetoothGattCharacteristicTest, WriteError) {
EXPECT_EQ(BluetoothGattService::GATT_ERROR_INVALID_LENGTH,
last_gatt_error_code_);
}
-#endif // defined(OS_ANDROID)
+#endif // defined(OS_ANDROID) || defined(OS_WIN)
#if defined(OS_ANDROID)
// Tests ReadRemoteCharacteristic synchronous error.
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_low_energy_win.h » ('j') | device/bluetooth/bluetooth_low_energy_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698