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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc

Issue 2051333004: Implement BluetoothGattNotifySession::Stop on Android, 2nd attempt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error on windows Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 EXPECT_EQ(0, error_callback_count_); 1015 EXPECT_EQ(0, error_callback_count_);
1016 base::RunLoop().RunUntilIdle(); 1016 base::RunLoop().RunUntilIdle();
1017 EXPECT_EQ(1, error_callback_count_); 1017 EXPECT_EQ(1, error_callback_count_);
1018 1018
1019 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); 1019 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1020 ASSERT_EQ(0u, notify_sessions_.size()); 1020 ASSERT_EQ(0u, notify_sessions_.size());
1021 } 1021 }
1022 #endif // defined(OS_ANDROID) 1022 #endif // defined(OS_ANDROID)
1023 1023
1024 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1024 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1025 // Tests StartNotifySession success on a characteristic enabling Notify. 1025 // Tests StartNotifySession success on a characteristic that enabled Notify.
1026 TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession) { 1026 TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession) {
1027 if (!PlatformSupportsLowEnergy()) { 1027 if (!PlatformSupportsLowEnergy()) {
1028 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1028 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1029 return; 1029 return;
1030 } 1030 }
1031 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 1031 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1032 /* properties: NOTIFY */ 0x10, 1032 /* properties: NOTIFY */ 0x10,
1033 /* expected_config_descriptor_value: NOTIFY */ 1)); 1033 /* expected_config_descriptor_value: NOTIFY */ 1));
1034 } 1034 }
1035 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1035 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1036 1036
1037 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1037 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1038 // Tests StartNotifySession success on a characteristic enabling Indicate. 1038 // Tests StartNotifySession success on a characteristic that enabled Indicate.
1039 TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_OnIndicate) { 1039 TEST_F(BluetoothRemoteGattCharacteristicTest, StartNotifySession_OnIndicate) {
1040 if (!PlatformSupportsLowEnergy()) { 1040 if (!PlatformSupportsLowEnergy()) {
1041 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1041 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1042 return; 1042 return;
1043 } 1043 }
1044 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 1044 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1045 /* properties: INDICATE */ 0x20, 1045 /* properties: INDICATE */ 0x20,
1046 /* expected_config_descriptor_value: INDICATE */ 2)); 1046 /* expected_config_descriptor_value: INDICATE */ 2));
1047 } 1047 }
1048 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1048 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1049 1049
1050 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1050 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1051 // Tests StartNotifySession success on a characteristic enabling Notify & 1051 // Tests StartNotifySession success on a characteristic that enabled Notify &
1052 // Indicate. 1052 // Indicate.
1053 TEST_F(BluetoothRemoteGattCharacteristicTest, 1053 TEST_F(BluetoothRemoteGattCharacteristicTest,
1054 StartNotifySession_OnNotifyAndIndicate) { 1054 StartNotifySession_OnNotifyAndIndicate) {
1055 if (!PlatformSupportsLowEnergy()) { 1055 if (!PlatformSupportsLowEnergy()) {
1056 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1056 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1057 return; 1057 return;
1058 } 1058 }
1059 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 1059 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1060 /* properties: NOTIFY and INDICATE bits set */ 0x30, 1060 /* properties: NOTIFY and INDICATE bits set */ 0x30,
1061 /* expected_config_descriptor_value: NOTIFY */ 1)); 1061 /* expected_config_descriptor_value: NOTIFY */ 1));
(...skipping 19 matching lines...) Expand all
1081 #endif // !defined(OS_MACOSX) 1081 #endif // !defined(OS_MACOSX)
1082 1082
1083 characteristic1_->StartNotifySession( 1083 characteristic1_->StartNotifySession(
1084 GetNotifyCallback(Call::EXPECTED), 1084 GetNotifyCallback(Call::EXPECTED),
1085 GetGattErrorCallback(Call::NOT_EXPECTED)); 1085 GetGattErrorCallback(Call::NOT_EXPECTED));
1086 characteristic1_->StartNotifySession( 1086 characteristic1_->StartNotifySession(
1087 GetNotifyCallback(Call::EXPECTED), 1087 GetNotifyCallback(Call::EXPECTED),
1088 GetGattErrorCallback(Call::NOT_EXPECTED)); 1088 GetGattErrorCallback(Call::NOT_EXPECTED));
1089 EXPECT_EQ(0, callback_count_); 1089 EXPECT_EQ(0, callback_count_);
1090 SimulateGattNotifySessionStarted(characteristic1_); 1090 SimulateGattNotifySessionStarted(characteristic1_);
1091 base::RunLoop().RunUntilIdle();
1091 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); 1092 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1092 EXPECT_EQ(2, callback_count_); 1093 EXPECT_EQ(2, callback_count_);
1093 EXPECT_EQ(0, error_callback_count_); 1094 EXPECT_EQ(0, error_callback_count_);
1094 ASSERT_EQ(2u, notify_sessions_.size()); 1095 ASSERT_EQ(2u, notify_sessions_.size());
1095 ASSERT_TRUE(notify_sessions_[0]); 1096 ASSERT_TRUE(notify_sessions_[0]);
1096 ASSERT_TRUE(notify_sessions_[1]); 1097 ASSERT_TRUE(notify_sessions_[1]);
1097 EXPECT_EQ(characteristic1_->GetIdentifier(), 1098 EXPECT_EQ(characteristic1_->GetIdentifier(),
1098 notify_sessions_[0]->GetCharacteristicIdentifier()); 1099 notify_sessions_[0]->GetCharacteristicIdentifier());
1099 EXPECT_EQ(characteristic1_->GetIdentifier(), 1100 EXPECT_EQ(characteristic1_->GetIdentifier(),
1100 notify_sessions_[1]->GetCharacteristicIdentifier()); 1101 notify_sessions_[1]->GetCharacteristicIdentifier());
(...skipping 22 matching lines...) Expand all
1123 #endif // !defined(OS_MACOSX) 1124 #endif // !defined(OS_MACOSX)
1124 1125
1125 characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED), 1126 characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED),
1126 GetGattErrorCallback(Call::EXPECTED)); 1127 GetGattErrorCallback(Call::EXPECTED));
1127 characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED), 1128 characteristic1_->StartNotifySession(GetNotifyCallback(Call::NOT_EXPECTED),
1128 GetGattErrorCallback(Call::EXPECTED)); 1129 GetGattErrorCallback(Call::EXPECTED));
1129 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); 1130 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1130 EXPECT_EQ(0, callback_count_); 1131 EXPECT_EQ(0, callback_count_);
1131 SimulateGattNotifySessionStartError( 1132 SimulateGattNotifySessionStartError(
1132 characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED); 1133 characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED);
1134 base::RunLoop().RunUntilIdle();
1133 EXPECT_EQ(0, callback_count_); 1135 EXPECT_EQ(0, callback_count_);
1134 EXPECT_EQ(2, error_callback_count_); 1136 EXPECT_EQ(2, error_callback_count_);
1135 ASSERT_EQ(0u, notify_sessions_.size()); 1137 ASSERT_EQ(0u, notify_sessions_.size());
1136 EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED, 1138 EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
1137 last_gatt_error_code_); 1139 last_gatt_error_code_);
1138 } 1140 }
1139 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) 1141 #endif // defined(OS_ANDROID) || defined(OS_MACOSX)
1140 1142
1141 #if defined(OS_ANDROID) 1143 #if defined(OS_ANDROID)
1142 // Tests StartNotifySession completing after chrome objects are deleted. 1144 // Tests StartNotifySession completing after chrome objects are deleted.
(...skipping 19 matching lines...) Expand all
1162 1164
1163 SimulateGattNotifySessionStarted(/* use remembered characteristic */ nullptr); 1165 SimulateGattNotifySessionStarted(/* use remembered characteristic */ nullptr);
1164 EXPECT_EQ(0, callback_count_); 1166 EXPECT_EQ(0, callback_count_);
1165 EXPECT_EQ(1, error_callback_count_); 1167 EXPECT_EQ(1, error_callback_count_);
1166 ASSERT_EQ(0u, notify_sessions_.size()); 1168 ASSERT_EQ(0u, notify_sessions_.size());
1167 EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED, 1169 EXPECT_EQ(BluetoothRemoteGattService::GATT_ERROR_FAILED,
1168 last_gatt_error_code_); 1170 last_gatt_error_code_);
1169 } 1171 }
1170 #endif // defined(OS_ANDROID) 1172 #endif // defined(OS_ANDROID)
1171 1173
1174 #if defined(OS_ANDROID)
1175 // Tests StartNotifySession completing before chrome objects are deleted.
1176 TEST_F(BluetoothRemoteGattCharacteristicTest,
1177 StartNotifySession_BeforeDeleted) {
1178 ASSERT_NO_FATAL_FAILURE(
1179 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1180 SimulateGattDescriptor(
1181 characteristic1_,
1182 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1183 .canonical_value());
1184 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1185
1186 characteristic1_->StartNotifySession(
1187 GetNotifyCallback(Call::EXPECTED),
1188 GetGattErrorCallback(Call::NOT_EXPECTED));
1189 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1190 EXPECT_EQ(0, callback_count_);
1191
1192 SimulateGattNotifySessionStarted(characteristic1_);
1193 ASSERT_EQ(1u, notify_sessions_.size());
1194
1195 std::string characteristic_identifier = characteristic1_->GetIdentifier();
1196
1197 EXPECT_EQ(characteristic_identifier,
1198 notify_sessions_[0]->GetCharacteristicIdentifier());
1199 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1200 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1201
1202 DeleteDevice(device_); // TODO(576906) delete only the characteristic.
1203
1204 base::RunLoop().RunUntilIdle();
1205 EXPECT_TRUE("Did not crash!");
1206 ASSERT_TRUE(notify_sessions_[0]);
1207 EXPECT_EQ(characteristic_identifier,
1208 notify_sessions_[0]->GetCharacteristicIdentifier());
1209 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1210 }
1211 #endif // defined(OS_ANDROID)
1212
1172 #if defined(OS_MACOSX) || defined(OS_WIN) 1213 #if defined(OS_MACOSX) || defined(OS_WIN)
1173 // Tests StartNotifySession reentrant in start notify session success callback 1214 // Tests StartNotifySession reentrant in start notify session success callback
1174 // and the reentrant start notify session success. 1215 // and the reentrant start notify session success.
1175 TEST_F(BluetoothRemoteGattCharacteristicTest, 1216 TEST_F(BluetoothRemoteGattCharacteristicTest,
1176 StartNotifySession_Reentrant_Success_Success) { 1217 StartNotifySession_Reentrant_Success_Success) {
1177 if (!PlatformSupportsLowEnergy()) { 1218 if (!PlatformSupportsLowEnergy()) {
1178 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1219 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1179 return; 1220 return;
1180 } 1221 }
1181 ASSERT_NO_FATAL_FAILURE( 1222 ASSERT_NO_FATAL_FAILURE(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 // Simulate reentrant StartNotifySession request from 1321 // Simulate reentrant StartNotifySession request from
1281 // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback. 1322 // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback.
1282 SimulateGattNotifySessionStarted(characteristic1_); 1323 SimulateGattNotifySessionStarted(characteristic1_);
1283 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); 1324 EXPECT_EQ(0, gatt_notify_characteristic_attempts_);
1284 EXPECT_EQ(0, callback_count_); 1325 EXPECT_EQ(0, callback_count_);
1285 EXPECT_EQ(2, error_callback_count_); 1326 EXPECT_EQ(2, error_callback_count_);
1286 ASSERT_EQ(0u, notify_sessions_.size()); 1327 ASSERT_EQ(0u, notify_sessions_.size());
1287 } 1328 }
1288 #endif // defined(OS_WIN) 1329 #endif // defined(OS_WIN)
1289 1330
1331 #if defined(OS_ANDROID)
1332 // Tests StopNotifySession success on a characteristic that enabled Notify.
1333 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession) {
1334 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1335 /* properties: NOTIFY */ 0x10,
1336 /* expected_config_descriptor_value: NOTIFY */ 1));
1337 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
1338
1339 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1340 SimulateGattNotifySessionStopped(characteristic1_);
1341 base::RunLoop().RunUntilIdle();
1342
1343 // Check that the right values were written to the descriptor.
1344 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1345 ASSERT_EQ(2u, last_write_value_.size());
1346 EXPECT_EQ(0, last_write_value_[0]);
1347 EXPECT_EQ(0, last_write_value_[1]);
1348
1349 // Check that the notify session is inactive.
1350 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1351 EXPECT_FALSE(characteristic1_->IsNotifying());
1352 }
1353 #endif // defined(OS_ANDROID)
1354
1355 #if defined(OS_ANDROID)
1356 // Tests that deleted sessions are stopped.
1357 TEST_F(BluetoothRemoteGattCharacteristicTest,
1358 StopNotifySession_SessionDeleted) {
1359 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1360 /* properties: NOTIFY */ 0x10,
1361 /* expected_config_descriptor_value: NOTIFY */ 1));
1362 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
1363
1364 notify_sessions_.clear();
1365 SimulateGattNotifySessionStopped(characteristic1_);
1366 base::RunLoop().RunUntilIdle();
1367
1368 // Check that the right values were written to the descriptor.
1369 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1370 ASSERT_EQ(2u, last_write_value_.size());
1371 EXPECT_EQ(0, last_write_value_[0]);
1372 EXPECT_EQ(0, last_write_value_[1]);
1373
1374 // Check that the notify session is inactive.
1375 EXPECT_FALSE(characteristic1_->IsNotifying());
1376 }
1377 #endif // defined(OS_ANDROID)
1378
1379 #if defined(OS_ANDROID)
1380 // Tests that deleting the sessions before the stop callbacks have been
1381 // invoked does not cause problems.
1382 TEST_F(BluetoothRemoteGattCharacteristicTest,
1383 StopNotifySession_SessionDeleted2) {
1384 ASSERT_NO_FATAL_FAILURE(
1385 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1386
1387 #if !defined(OS_MACOSX)
1388 // TODO(624017) enable for macosx
1389 SimulateGattDescriptor(
1390 characteristic1_,
1391 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1392 .canonical_value());
1393 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1394 #endif
1395
1396 // Start notify sessions.
1397 characteristic1_->StartNotifySession(
1398 GetNotifyCheckForPrecedingCalls(0),
1399 GetGattErrorCallback(Call::NOT_EXPECTED));
1400 characteristic1_->StartNotifySession(
1401 GetNotifyCheckForPrecedingCalls(1),
1402 GetGattErrorCallback(Call::NOT_EXPECTED));
1403 EXPECT_EQ(0, callback_count_);
1404 SimulateGattNotifySessionStarted(characteristic1_);
1405 base::RunLoop().RunUntilIdle();
1406 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1407 EXPECT_EQ(2, callback_count_);
1408 EXPECT_EQ(0, error_callback_count_);
1409 ASSERT_EQ(2u, notify_sessions_.size());
1410 ASSERT_TRUE(notify_sessions_[0]);
1411 ASSERT_TRUE(notify_sessions_[1]);
1412 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1413 EXPECT_EQ(characteristic1_, notify_sessions_[1]->GetCharacteristic());
1414 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1415 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1416 EXPECT_TRUE(characteristic1_->IsNotifying());
1417
1418 // Queue up stop events.
1419 notify_sessions_[1]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1420 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1421
1422 // Delete the notify sessions.
1423 notify_sessions_.clear();
1424
1425 // Run the stop events.
1426 base::RunLoop().RunUntilIdle();
1427 SimulateGattNotifySessionStopped(characteristic1_);
1428 base::RunLoop().RunUntilIdle();
1429
1430 // Check that the state is correct.
1431 EXPECT_TRUE("Did not crash!");
1432 EXPECT_FALSE(characteristic1_->IsNotifying());
1433 }
1434 #endif // defined(OS_ANDROID)
1435
1436 #if defined(OS_ANDROID)
1437 // Tests that deleted sessions are stopped.
1438 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_AfterDeleted) {
1439 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1440 /* properties: NOTIFY */ 0x10,
1441 /* expected_config_descriptor_value: NOTIFY */ 1));
1442
1443 // Check that the session is correctly setup
1444 std::string characteristic_identifier = characteristic1_->GetIdentifier();
1445 EXPECT_EQ(characteristic_identifier,
1446 notify_sessions_[0]->GetCharacteristicIdentifier());
1447 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1448 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1449
1450 DeleteDevice(device_); // TODO(576906) delete only the characteristic.
1451
1452 ResetEventCounts();
1453 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1454
1455 // Check that the callback does not arrive synchronously.
1456 EXPECT_EQ(0, callback_count_);
1457
1458 // Trigger the stop callback
1459 base::RunLoop().RunUntilIdle();
1460 EXPECT_EQ(1, callback_count_);
1461
1462 EXPECT_TRUE("Did not crash!");
1463 ASSERT_TRUE(notify_sessions_[0]);
1464 EXPECT_EQ(characteristic_identifier,
1465 notify_sessions_[0]->GetCharacteristicIdentifier());
1466 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1467 }
1468 #endif // defined(OS_ANDROID)
1469
1470 #if defined(OS_ANDROID)
1471 // Tests StopNotifySession success on a characteristic that enabled Indicate.
1472 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_OnIndicate) {
1473 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1474 /* properties: INDICATE */ 0x20,
1475 /* expected_config_descriptor_value: INDICATE */ 2));
1476 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
1477
1478 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1479 SimulateGattNotifySessionStopped(characteristic1_);
1480 base::RunLoop().RunUntilIdle();
1481
1482 // Check that the right values were written to the descriptor.
1483 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1484 ASSERT_EQ(2u, last_write_value_.size());
1485 EXPECT_EQ(0, last_write_value_[0]);
1486 EXPECT_EQ(0, last_write_value_[1]);
1487
1488 // Check that the notify session is inactive.
1489 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1490 EXPECT_FALSE(characteristic1_->IsNotifying());
1491 }
1492 #endif // defined(OS_ANDROID)
1493
1494 #if defined(OS_ANDROID)
1495 // Tests StopNotifySession success on a characteristic that enabled Notify &
1496 // Indicate.
1497 TEST_F(BluetoothRemoteGattCharacteristicTest,
1498 StopNotifySession_OnNotifyAndIndicate) {
1499 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1500 /* properties: NOTIFY and INDICATE bits set */ 0x30,
1501 /* expected_config_descriptor_value: INDICATE */ 1));
1502 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
1503
1504 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1505 SimulateGattNotifySessionStopped(characteristic1_);
1506 base::RunLoop().RunUntilIdle();
1507
1508 // Check that the right values were written to the descriptor.
1509 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1510 ASSERT_EQ(2u, last_write_value_.size());
1511 EXPECT_EQ(0, last_write_value_[0]);
1512 EXPECT_EQ(0, last_write_value_[1]);
1513
1514 // Check that the notify session is inactive.
1515 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1516 EXPECT_FALSE(characteristic1_->IsNotifying());
1517 }
1518 #endif // defined(OS_ANDROID)
1519
1520 #if defined(OS_ANDROID)
1521 // Tests StopNotifySession error
1522 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Error) {
1523 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1524 /* properties: NOTIFY */ 0x10,
1525 /* expected_config_descriptor_value: NOTIFY */ 1));
1526
1527 // Check that the notify session is active.
1528 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1529 EXPECT_EQ(characteristic1_->GetIdentifier(),
1530 notify_sessions_[0]->GetCharacteristicIdentifier());
1531 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1532 EXPECT_TRUE(characteristic1_->IsNotifying());
1533
1534 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED));
1535 SimulateGattNotifySessionStopError(
1536 characteristic1_, BluetoothRemoteGattService::GATT_ERROR_UNKNOWN);
1537 base::RunLoop().RunUntilIdle();
1538
1539 // Check that the notify session is inactive.
1540 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1541 EXPECT_FALSE(characteristic1_->IsNotifying());
1542 }
1543 #endif // defined(OS_ANDROID)
1544
1545 #if defined(OS_ANDROID)
1546 // Tests multiple StopNotifySession calls for a single session.
1547 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple1) {
1548 ASSERT_NO_FATAL_FAILURE(
1549 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1550
1551 #if !defined(OS_MACOSX)
1552 // TODO(624017) enable for macosx
1553 SimulateGattDescriptor(
1554 characteristic1_,
1555 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1556 .canonical_value());
1557 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1558 #endif
1559
1560 // Start notify session
1561 characteristic1_->StartNotifySession(
1562 GetNotifyCallback(Call::EXPECTED),
1563 GetGattErrorCallback(Call::NOT_EXPECTED));
1564 EXPECT_EQ(0, callback_count_);
1565 SimulateGattNotifySessionStarted(characteristic1_);
1566 base::RunLoop().RunUntilIdle();
1567 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1568 EXPECT_EQ(1, callback_count_);
1569 EXPECT_EQ(0, error_callback_count_);
1570 ASSERT_EQ(1u, notify_sessions_.size());
1571 ASSERT_TRUE(notify_sessions_[0]);
1572 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1573 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1574 EXPECT_TRUE(characteristic1_->IsNotifying());
1575
1576 // Stop the notify session twice
1577 ResetEventCounts();
1578 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(0));
1579 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1));
1580 SimulateGattNotifySessionStopped(characteristic1_);
1581 base::RunLoop().RunUntilIdle();
1582
1583 // Check that the notify session is inactive.
1584 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1585 EXPECT_FALSE(characteristic1_->IsNotifying());
1586 }
1587 #endif // defined(OS_ANDROID)
1588
1589 #if defined(OS_ANDROID)
1590 // Tests multiple StartNotifySession calls and multiple StopNotifySession calls.
1591 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Multiple2) {
1592 ASSERT_NO_FATAL_FAILURE(
1593 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1594
1595 #if !defined(OS_MACOSX)
1596 // TODO(624017) enable for macosx
1597 SimulateGattDescriptor(
1598 characteristic1_,
1599 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1600 .canonical_value());
1601 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1602 #endif
1603
1604 // Start notify sessions
1605 characteristic1_->StartNotifySession(
1606 GetNotifyCheckForPrecedingCalls(0),
1607 GetGattErrorCallback(Call::NOT_EXPECTED));
1608 characteristic1_->StartNotifySession(
1609 GetNotifyCheckForPrecedingCalls(1),
1610 GetGattErrorCallback(Call::NOT_EXPECTED));
1611 EXPECT_EQ(0, callback_count_);
1612 SimulateGattNotifySessionStarted(characteristic1_);
1613 base::RunLoop().RunUntilIdle();
1614 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
1615 EXPECT_EQ(2, callback_count_);
1616 EXPECT_EQ(0, error_callback_count_);
1617 ASSERT_EQ(2u, notify_sessions_.size());
1618 ASSERT_TRUE(notify_sessions_[0]);
1619 ASSERT_TRUE(notify_sessions_[1]);
1620 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1621 EXPECT_EQ(characteristic1_, notify_sessions_[1]->GetCharacteristic());
1622 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1623 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1624 EXPECT_TRUE(characteristic1_->IsNotifying());
1625
1626 // Stop the notify sessions
1627 notify_sessions_[1]->Stop(GetStopNotifyCheckForPrecedingCalls(2));
1628 base::RunLoop().RunUntilIdle();
1629 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1630 EXPECT_FALSE(notify_sessions_[1]->IsActive());
1631 EXPECT_TRUE(characteristic1_->IsNotifying());
1632
1633 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(3));
1634 SimulateGattNotifySessionStopped(characteristic1_);
1635 base::RunLoop().RunUntilIdle();
1636
1637 // Check that the notify sessions is inactive.
1638 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1639 EXPECT_FALSE(notify_sessions_[1]->IsActive());
1640 EXPECT_FALSE(characteristic1_->IsNotifying());
1641 }
1642 #endif // defined(OS_ANDROID)
1643
1644 #if defined(OS_ANDROID)
1645 // Tests starting a new notify session before the previous stop request
1646 // resolves.
1647 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStart) {
1648 ASSERT_NO_FATAL_FAILURE(
1649 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1650 SimulateGattDescriptor(
1651 characteristic1_,
1652 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1653 .canonical_value());
1654 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1655
1656 // Start notify session
1657 ResetEventCounts();
1658 characteristic1_->StartNotifySession(
1659 GetNotifyCheckForPrecedingCalls(0),
1660 GetGattErrorCallback(Call::NOT_EXPECTED));
1661 SimulateGattNotifySessionStarted(characteristic1_);
1662 base::RunLoop().RunUntilIdle();
1663 ASSERT_EQ(1u, notify_sessions_.size());
1664 ASSERT_TRUE(notify_sessions_[0]);
1665 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1666
1667 // Stop the notify session
1668 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1));
1669
1670 // Start another notify session
1671 characteristic1_->StartNotifySession(
1672 GetNotifyCheckForPrecedingCalls(2),
1673 GetGattErrorCallback(Call::NOT_EXPECTED));
1674
1675 SimulateGattNotifySessionStopped(characteristic1_);
1676 base::RunLoop().RunUntilIdle();
1677 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1678
1679 SimulateGattNotifySessionStarted(characteristic1_);
1680 base::RunLoop().RunUntilIdle();
1681 ASSERT_EQ(2u, notify_sessions_.size());
1682 ASSERT_TRUE(notify_sessions_[0]);
1683 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1684 ASSERT_TRUE(notify_sessions_[1]);
1685 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1686 EXPECT_TRUE(characteristic1_->IsNotifying());
1687 }
1688 #endif // defined(OS_ANDROID)
1689
1690 #if defined(OS_ANDROID)
1691 TEST_F(BluetoothRemoteGattCharacteristicTest,
1692 StopNotifySession_StartStopStart) {
1693 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1694 /* properties: NOTIFY */ 0x10,
1695 /* expected_config_descriptor_value: NOTIFY */ 1));
1696
1697 // Check that the initial notify session is active.
1698 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1699 EXPECT_EQ(characteristic1_->GetIdentifier(),
1700 notify_sessions_[0]->GetCharacteristicIdentifier());
1701 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1702 EXPECT_TRUE(characteristic1_->IsNotifying());
1703
1704 // Queue up the first event.
1705 ResetEventCounts();
1706 characteristic1_->StartNotifySession(
1707 GetNotifyCheckForPrecedingCalls(0),
1708 GetGattErrorCallback(Call::NOT_EXPECTED));
1709
1710 // Queue up the second event.
1711 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1));
1712
1713 // Queue up the third event.
1714 characteristic1_->StartNotifySession(
1715 GetNotifyCheckForPrecedingCalls(2),
1716 GetGattErrorCallback(Call::NOT_EXPECTED));
1717
1718 // Run the event loop to resolve all three events.
1719 base::RunLoop().RunUntilIdle();
1720
1721 // Check the state of all the sessions.
1722 ASSERT_EQ(3u, notify_sessions_.size());
1723 EXPECT_EQ(characteristic1_->GetIdentifier(),
1724 notify_sessions_[0]->GetCharacteristicIdentifier());
1725 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1726 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1727
1728 EXPECT_EQ(characteristic1_->GetIdentifier(),
1729 notify_sessions_[1]->GetCharacteristicIdentifier());
1730 EXPECT_EQ(characteristic1_, notify_sessions_[1]->GetCharacteristic());
1731 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1732
1733 EXPECT_EQ(characteristic1_->GetIdentifier(),
1734 notify_sessions_[2]->GetCharacteristicIdentifier());
1735 EXPECT_EQ(characteristic1_, notify_sessions_[2]->GetCharacteristic());
1736 EXPECT_TRUE(notify_sessions_[2]->IsActive());
1737
1738 EXPECT_TRUE(characteristic1_->IsNotifying());
1739 }
1740 #endif
1741
1742 #if defined(OS_ANDROID)
1743 // Tests starting a new notify session before the previous stop requests
1744 // resolve.
1745 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_StopStopStart) {
1746 ASSERT_NO_FATAL_FAILURE(
1747 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1748 SimulateGattDescriptor(
1749 characteristic1_,
1750 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1751 .canonical_value());
1752 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1753
1754 // Start notify session
1755 ResetEventCounts();
1756 characteristic1_->StartNotifySession(
1757 GetNotifyCheckForPrecedingCalls(0),
1758 GetGattErrorCallback(Call::NOT_EXPECTED));
1759 SimulateGattNotifySessionStarted(characteristic1_);
1760 base::RunLoop().RunUntilIdle();
1761 ASSERT_EQ(1u, notify_sessions_.size());
1762 ASSERT_TRUE(notify_sessions_[0]);
1763 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1764 EXPECT_EQ(1, gatt_write_descriptor_attempts_);
1765
1766 // Stop the notify session twice
1767 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1));
1768 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(2));
1769
1770 // Check that the right values were written to the descriptor.
1771 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1772 ASSERT_EQ(2u, last_write_value_.size());
1773 EXPECT_EQ(0, last_write_value_[0]);
1774 EXPECT_EQ(0, last_write_value_[1]);
1775
1776 // Start another notify session
1777 characteristic1_->StartNotifySession(
1778 GetNotifyCheckForPrecedingCalls(3),
1779 GetGattErrorCallback(Call::NOT_EXPECTED));
1780
1781 // Check that nothing was written by the StartNotifySession call above
1782 EXPECT_EQ(2, gatt_write_descriptor_attempts_);
1783
1784 SimulateGattNotifySessionStopped(characteristic1_);
1785 base::RunLoop().RunUntilIdle();
1786 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1787
1788 SimulateGattNotifySessionStarted(characteristic1_);
1789 base::RunLoop().RunUntilIdle();
1790
1791 // Check that the right values were written to the descriptor.
1792 EXPECT_EQ(3, gatt_write_descriptor_attempts_);
1793 ASSERT_EQ(2u, last_write_value_.size());
1794 EXPECT_EQ(1, last_write_value_[0]);
1795 EXPECT_EQ(0, last_write_value_[1]);
1796
1797 // Check the notify state
1798 ASSERT_EQ(2u, notify_sessions_.size());
1799 ASSERT_TRUE(notify_sessions_[0]);
1800 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1801 ASSERT_TRUE(notify_sessions_[1]);
1802 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1803 EXPECT_TRUE(characteristic1_->IsNotifying());
1804 }
1805 #endif // defined(OS_ANDROID)
1806
1807 #if defined(OS_ANDROID)
1808 TEST_F(BluetoothRemoteGattCharacteristicTest,
1809 StopNotifySession_Reentrant_Success_Stop) {
1810 ASSERT_NO_FATAL_FAILURE(
1811 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10));
1812 SimulateGattDescriptor(
1813 characteristic1_,
1814 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid()
1815 .canonical_value());
1816 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
1817
1818 // Start notify session
1819 characteristic1_->StartNotifySession(
1820 base::Bind(
1821 [](BluetoothRemoteGattCharacteristic::NotifySessionCallback
1822 notifyCallback,
1823 base::Closure stopNotifyCallback,
1824 std::unique_ptr<BluetoothGattNotifySession> session) {
1825 BluetoothGattNotifySession* s = session.get();
1826 notifyCallback.Run(std::move(session));
1827 s->Stop(stopNotifyCallback);
1828 },
1829 GetNotifyCallback(Call::EXPECTED),
1830 GetStopNotifyCallback(Call::EXPECTED)),
1831 GetGattErrorCallback(Call::NOT_EXPECTED));
1832
1833 SimulateGattNotifySessionStarted(characteristic1_);
1834 base::RunLoop().RunUntilIdle();
1835 ASSERT_EQ(1u, notify_sessions_.size());
1836 ASSERT_TRUE(notify_sessions_[0]);
1837 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1838 EXPECT_TRUE(characteristic1_->IsNotifying());
1839
1840 SimulateGattNotifySessionStopped(characteristic1_);
1841 base::RunLoop().RunUntilIdle();
1842 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1843 EXPECT_FALSE(characteristic1_->IsNotifying());
1844 }
1845 #endif
1846
1847 #if defined(OS_ANDROID)
1848 TEST_F(BluetoothRemoteGattCharacteristicTest,
1849 StopNotifySession_Reentrant_Stop_StartSuccess) {
1850 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1851 /* properties: NOTIFY */ 0x10,
1852 /* expected_config_descriptor_value: NOTIFY */ 1));
1853
1854 // Check that the notify session is active.
1855 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1856 EXPECT_EQ(characteristic1_->GetIdentifier(),
1857 notify_sessions_[0]->GetCharacteristicIdentifier());
1858 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1859 EXPECT_TRUE(characteristic1_->IsNotifying());
1860
1861 notify_sessions_[0]->Stop(base::Bind(
1862 [](BluetoothRemoteGattCharacteristic* characteristic,
1863 BluetoothRemoteGattCharacteristic::NotifySessionCallback
1864 notifyCallback,
1865 BluetoothRemoteGattCharacteristic::ErrorCallback errorCallback) {
1866 characteristic->StartNotifySession(notifyCallback, errorCallback);
1867 },
1868 characteristic1_, GetNotifyCallback(Call::EXPECTED),
1869 GetGattErrorCallback(Call::NOT_EXPECTED)));
1870
1871 SimulateGattNotifySessionStopped(characteristic1_);
1872 base::RunLoop().RunUntilIdle();
1873 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1874 EXPECT_FALSE(characteristic1_->IsNotifying());
1875
1876 SimulateGattNotifySessionStarted(characteristic1_);
1877 base::RunLoop().RunUntilIdle();
1878 ASSERT_EQ(2u, notify_sessions_.size());
1879 ASSERT_TRUE(notify_sessions_[0]);
1880 ASSERT_TRUE(notify_sessions_[1]);
1881 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1882 EXPECT_EQ(characteristic1_, notify_sessions_[1]->GetCharacteristic());
1883 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1884 EXPECT_TRUE(notify_sessions_[1]->IsActive());
1885 EXPECT_TRUE(characteristic1_->IsNotifying());
1886 }
1887 #endif
1888
1889 #if defined(OS_ANDROID)
1890 TEST_F(BluetoothRemoteGattCharacteristicTest,
1891 StopNotifySession_Reentrant_Stop_StartError) {
1892 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1893 /* properties: NOTIFY */ 0x10,
1894 /* expected_config_descriptor_value: NOTIFY */ 1));
1895
1896 // Check that the notify session is active.
1897 EXPECT_TRUE(notify_sessions_[0]->IsActive());
1898 EXPECT_EQ(characteristic1_->GetIdentifier(),
1899 notify_sessions_[0]->GetCharacteristicIdentifier());
1900 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1901 EXPECT_TRUE(characteristic1_->IsNotifying());
1902
1903 notify_sessions_[0]->Stop(base::Bind(
1904 [](BluetoothRemoteGattCharacteristic* characteristic,
1905 BluetoothRemoteGattCharacteristic::NotifySessionCallback
1906 notifyCallback,
1907 BluetoothRemoteGattCharacteristic::ErrorCallback errorCallback) {
1908 characteristic->StartNotifySession(notifyCallback, errorCallback);
1909 },
1910 characteristic1_, GetNotifyCallback(Call::NOT_EXPECTED),
1911 GetGattErrorCallback(Call::EXPECTED)));
1912
1913 SimulateGattNotifySessionStopped(characteristic1_);
1914 base::RunLoop().RunUntilIdle();
1915 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1916 EXPECT_FALSE(characteristic1_->IsNotifying());
1917
1918 SimulateGattNotifySessionStartError(
1919 characteristic1_, BluetoothRemoteGattService::GATT_ERROR_FAILED);
1920 base::RunLoop().RunUntilIdle();
1921 ASSERT_EQ(1u, notify_sessions_.size());
1922 ASSERT_TRUE(notify_sessions_[0]);
1923 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic());
1924 EXPECT_FALSE(notify_sessions_[0]->IsActive());
1925 EXPECT_FALSE(characteristic1_->IsNotifying());
1926 }
1927 #endif
1928
1290 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) 1929 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN)
1291 // Tests Characteristic Value changes during a Notify Session. 1930 // Tests Characteristic Value changes during a Notify Session.
1292 TEST_F(BluetoothRemoteGattCharacteristicTest, GattCharacteristicValueChanged) { 1931 TEST_F(BluetoothRemoteGattCharacteristicTest, GattCharacteristicValueChanged) {
1293 if (!PlatformSupportsLowEnergy()) { 1932 if (!PlatformSupportsLowEnergy()) {
1294 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; 1933 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test.";
1295 return; 1934 return;
1296 } 1935 }
1297 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( 1936 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate(
1298 /* properties: NOTIFY */ 0x10, 1937 /* properties: NOTIFY */ 0x10,
1299 /* expected_config_descriptor_value: NOTIFY */ 1)); 1938 /* expected_config_descriptor_value: NOTIFY */ 1));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); 2054 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size());
1416 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); 2055 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size());
1417 2056
1418 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); 2057 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size());
1419 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); 2058 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size());
1420 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); 2059 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size());
1421 } 2060 }
1422 #endif // defined(OS_ANDROID) || defined(OS_WIN) 2061 #endif // defined(OS_ANDROID) || defined(OS_WIN)
1423 2062
1424 } // namespace device 2063 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698