| OLD | NEW |
| 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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1415 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1416 // Tests StopNotifySession success on a characteristic that enabled Notify. | 1416 // Tests StopNotifySession success on a characteristic that enabled Notify. |
| 1417 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession) { | 1417 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession) { |
| 1418 if (!PlatformSupportsLowEnergy()) { | 1418 if (!PlatformSupportsLowEnergy()) { |
| 1419 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1419 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1420 return; | 1420 return; |
| 1421 } | 1421 } |
| 1422 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 1422 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1423 /* properties: NOTIFY */ 0x10, | 1423 /* properties: NOTIFY */ 0x10, |
| 1424 /* expected_config_descriptor_value: NOTIFY */ 1)); | 1424 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 1425 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1425 ExpectedChangeNotifyValueAttempts(1); |
| 1426 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1426 ExpectedNotifyValue(NotifyValueState::NOTIFY); |
| 1427 // the CCC descriptor. | |
| 1428 #if !defined(OS_MACOSX) | |
| 1429 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | |
| 1430 #else | |
| 1431 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 1432 EXPECT_TRUE(last_notify_value); | |
| 1433 #endif // !defined(OS_MACOSX) | |
| 1434 | 1427 |
| 1435 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); | 1428 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); |
| 1436 SimulateGattNotifySessionStopped(characteristic1_); | 1429 SimulateGattNotifySessionStopped(characteristic1_); |
| 1437 base::RunLoop().RunUntilIdle(); | 1430 base::RunLoop().RunUntilIdle(); |
| 1438 | 1431 |
| 1439 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1432 ExpectedChangeNotifyValueAttempts(2); |
| 1440 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1433 ExpectedNotifyValue(NotifyValueState::NONE); |
| 1441 // the CCC descriptor. | |
| 1442 #if !defined(OS_MACOSX) | |
| 1443 // Check that the right values were written to the descriptor. | |
| 1444 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 1445 ASSERT_EQ(2u, last_write_value_.size()); | |
| 1446 EXPECT_EQ(0, last_write_value_[0]); | |
| 1447 EXPECT_EQ(0, last_write_value_[1]); | |
| 1448 #else | |
| 1449 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 1450 EXPECT_FALSE(last_notify_value); | |
| 1451 #endif // !defined(OS_MACOSX) | |
| 1452 | 1434 |
| 1453 // Check that the notify session is inactive. | 1435 // Check that the notify session is inactive. |
| 1454 EXPECT_FALSE(notify_sessions_[0]->IsActive()); | 1436 EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| 1455 EXPECT_FALSE(characteristic1_->IsNotifying()); | 1437 EXPECT_FALSE(characteristic1_->IsNotifying()); |
| 1456 } | 1438 } |
| 1457 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1439 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1458 | 1440 |
| 1459 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1441 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1460 // Tests that deleted sessions are stopped. | 1442 // Tests that deleted sessions are stopped. |
| 1461 TEST_F(BluetoothRemoteGattCharacteristicTest, | 1443 TEST_F(BluetoothRemoteGattCharacteristicTest, |
| 1462 StopNotifySession_SessionDeleted) { | 1444 StopNotifySession_SessionDeleted) { |
| 1463 if (!PlatformSupportsLowEnergy()) { | 1445 if (!PlatformSupportsLowEnergy()) { |
| 1464 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1446 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1465 return; | 1447 return; |
| 1466 } | 1448 } |
| 1467 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 1449 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1468 /* properties: NOTIFY */ 0x10, | 1450 /* properties: NOTIFY */ 0x10, |
| 1469 /* expected_config_descriptor_value: NOTIFY */ 1)); | 1451 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 1470 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1452 ExpectedChangeNotifyValueAttempts(1); |
| 1471 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1453 ExpectedNotifyValue(NotifyValueState::NOTIFY); |
| 1472 // the CCC descriptor. | |
| 1473 #if !defined(OS_MACOSX) | |
| 1474 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | |
| 1475 #else | |
| 1476 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 1477 EXPECT_TRUE(last_notify_value); | |
| 1478 #endif // !defined(OS_MACOSX) | |
| 1479 | 1454 |
| 1480 notify_sessions_.clear(); | 1455 notify_sessions_.clear(); |
| 1481 SimulateGattNotifySessionStopped(characteristic1_); | 1456 SimulateGattNotifySessionStopped(characteristic1_); |
| 1482 base::RunLoop().RunUntilIdle(); | 1457 base::RunLoop().RunUntilIdle(); |
| 1483 | 1458 |
| 1484 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1459 ExpectedChangeNotifyValueAttempts(2); |
| 1485 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1460 ExpectedNotifyValue(NotifyValueState::NONE); |
| 1486 // the CCC descriptor. | |
| 1487 #if !defined(OS_MACOSX) | |
| 1488 // Check that the right values were written to the descriptor. | |
| 1489 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 1490 ASSERT_EQ(2u, last_write_value_.size()); | |
| 1491 EXPECT_EQ(0, last_write_value_[0]); | |
| 1492 EXPECT_EQ(0, last_write_value_[1]); | |
| 1493 #else | |
| 1494 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 1495 EXPECT_FALSE(last_notify_value); | |
| 1496 #endif // !defined(OS_MACOSX) | |
| 1497 | 1461 |
| 1498 // Check that the notify session is inactive. | 1462 // Check that the notify session is inactive. |
| 1499 EXPECT_FALSE(characteristic1_->IsNotifying()); | 1463 EXPECT_FALSE(characteristic1_->IsNotifying()); |
| 1500 } | 1464 } |
| 1501 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1465 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1502 | 1466 |
| 1503 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1467 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1504 // Tests that deleting the sessions before the stop callbacks have been | 1468 // Tests that deleting the sessions before the stop callbacks have been |
| 1505 // invoked does not cause problems. | 1469 // invoked does not cause problems. |
| 1506 TEST_F(BluetoothRemoteGattCharacteristicTest, | 1470 TEST_F(BluetoothRemoteGattCharacteristicTest, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1591 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1628 // Tests StopNotifySession success on a characteristic that enabled Indicate. | 1592 // Tests StopNotifySession success on a characteristic that enabled Indicate. |
| 1629 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_OnIndicate) { | 1593 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_OnIndicate) { |
| 1630 if (!PlatformSupportsLowEnergy()) { | 1594 if (!PlatformSupportsLowEnergy()) { |
| 1631 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1595 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1632 return; | 1596 return; |
| 1633 } | 1597 } |
| 1634 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 1598 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1635 /* properties: INDICATE */ 0x20, | 1599 /* properties: INDICATE */ 0x20, |
| 1636 /* expected_config_descriptor_value: INDICATE */ 2)); | 1600 /* expected_config_descriptor_value: INDICATE */ 2)); |
| 1637 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1601 ExpectedChangeNotifyValueAttempts(1); |
| 1638 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1602 ExpectedNotifyValue(NotifyValueState::INDICATE); |
| 1639 // the CCC descriptor. | |
| 1640 #if !defined(OS_MACOSX) | |
| 1641 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | |
| 1642 #else | |
| 1643 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 1644 EXPECT_TRUE(last_notify_value); | |
| 1645 #endif // !defined(OS_MACOSX) | |
| 1646 | 1603 |
| 1647 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); | 1604 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); |
| 1648 SimulateGattNotifySessionStopped(characteristic1_); | 1605 SimulateGattNotifySessionStopped(characteristic1_); |
| 1649 base::RunLoop().RunUntilIdle(); | 1606 base::RunLoop().RunUntilIdle(); |
| 1650 | 1607 |
| 1651 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1608 ExpectedChangeNotifyValueAttempts(2); |
| 1652 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1609 ExpectedNotifyValue(NotifyValueState::NONE); |
| 1653 // the CCC descriptor. | |
| 1654 #if !defined(OS_MACOSX) | |
| 1655 // Check that the right values were written to the descriptor. | |
| 1656 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 1657 ASSERT_EQ(2u, last_write_value_.size()); | |
| 1658 EXPECT_EQ(0, last_write_value_[0]); | |
| 1659 EXPECT_EQ(0, last_write_value_[1]); | |
| 1660 #else | |
| 1661 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 1662 EXPECT_FALSE(last_notify_value); | |
| 1663 #endif // !defined(OS_MACOSX) | |
| 1664 | 1610 |
| 1665 // Check that the notify session is inactive. | 1611 // Check that the notify session is inactive. |
| 1666 EXPECT_FALSE(notify_sessions_[0]->IsActive()); | 1612 EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| 1667 EXPECT_FALSE(characteristic1_->IsNotifying()); | 1613 EXPECT_FALSE(characteristic1_->IsNotifying()); |
| 1668 } | 1614 } |
| 1669 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1615 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1670 | 1616 |
| 1671 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1617 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1672 // Tests StopNotifySession success on a characteristic that enabled Notify & | 1618 // Tests StopNotifySession success on a characteristic that enabled Notify & |
| 1673 // Indicate. | 1619 // Indicate. |
| 1674 TEST_F(BluetoothRemoteGattCharacteristicTest, | 1620 TEST_F(BluetoothRemoteGattCharacteristicTest, |
| 1675 StopNotifySession_OnNotifyAndIndicate) { | 1621 StopNotifySession_OnNotifyAndIndicate) { |
| 1676 if (!PlatformSupportsLowEnergy()) { | 1622 if (!PlatformSupportsLowEnergy()) { |
| 1677 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 1623 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 1678 return; | 1624 return; |
| 1679 } | 1625 } |
| 1680 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 1626 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1681 /* properties: NOTIFY and INDICATE bits set */ 0x30, | 1627 /* properties: NOTIFY and INDICATE bits set */ 0x30, |
| 1682 /* expected_config_descriptor_value: INDICATE */ 1)); | 1628 /* expected_config_descriptor_value: INDICATE */ 1)); |
| 1683 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1629 ExpectedChangeNotifyValueAttempts(1); |
| 1684 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1630 ExpectedNotifyValue(NotifyValueState::NOTIFY); |
| 1685 // the CCC descriptor. | |
| 1686 #if !defined(OS_MACOSX) | |
| 1687 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | |
| 1688 #else | |
| 1689 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 1690 EXPECT_TRUE(last_notify_value); | |
| 1691 #endif // !defined(OS_MACOSX) | |
| 1692 | 1631 |
| 1693 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); | 1632 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); |
| 1694 SimulateGattNotifySessionStopped(characteristic1_); | 1633 SimulateGattNotifySessionStopped(characteristic1_); |
| 1695 base::RunLoop().RunUntilIdle(); | 1634 base::RunLoop().RunUntilIdle(); |
| 1696 | 1635 |
| 1697 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1636 ExpectedChangeNotifyValueAttempts(2); |
| 1698 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1637 ExpectedNotifyValue(NotifyValueState::NONE); |
| 1699 // the CCC descriptor. | |
| 1700 #if !defined(OS_MACOSX) | |
| 1701 // Check that the right values were written to the descriptor. | |
| 1702 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 1703 ASSERT_EQ(2u, last_write_value_.size()); | |
| 1704 EXPECT_EQ(0, last_write_value_[0]); | |
| 1705 EXPECT_EQ(0, last_write_value_[1]); | |
| 1706 #else | |
| 1707 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 1708 EXPECT_FALSE(last_notify_value); | |
| 1709 #endif // !defined(OS_MACOSX) | |
| 1710 | 1638 |
| 1711 // Check that the notify session is inactive. | 1639 // Check that the notify session is inactive. |
| 1712 EXPECT_FALSE(notify_sessions_[0]->IsActive()); | 1640 EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| 1713 EXPECT_FALSE(characteristic1_->IsNotifying()); | 1641 EXPECT_FALSE(characteristic1_->IsNotifying()); |
| 1714 } | 1642 } |
| 1715 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1643 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1716 | 1644 |
| 1717 #if defined(OS_ANDROID) || defined(OS_MACOSX) | 1645 #if defined(OS_ANDROID) || defined(OS_MACOSX) |
| 1718 // Tests StopNotifySession error | 1646 // Tests StopNotifySession error |
| 1719 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Error) { | 1647 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Error) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 // Start notify session | 1897 // Start notify session |
| 1970 ResetEventCounts(); | 1898 ResetEventCounts(); |
| 1971 characteristic1_->StartNotifySession( | 1899 characteristic1_->StartNotifySession( |
| 1972 GetNotifyCheckForPrecedingCalls(0), | 1900 GetNotifyCheckForPrecedingCalls(0), |
| 1973 GetGattErrorCallback(Call::NOT_EXPECTED)); | 1901 GetGattErrorCallback(Call::NOT_EXPECTED)); |
| 1974 SimulateGattNotifySessionStarted(characteristic1_); | 1902 SimulateGattNotifySessionStarted(characteristic1_); |
| 1975 base::RunLoop().RunUntilIdle(); | 1903 base::RunLoop().RunUntilIdle(); |
| 1976 ASSERT_EQ(1u, notify_sessions_.size()); | 1904 ASSERT_EQ(1u, notify_sessions_.size()); |
| 1977 ASSERT_TRUE(notify_sessions_[0]); | 1905 ASSERT_TRUE(notify_sessions_[0]); |
| 1978 EXPECT_TRUE(notify_sessions_[0]->IsActive()); | 1906 EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| 1979 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1907 ExpectedChangeNotifyValueAttempts(1); |
| 1980 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1908 ExpectedNotifyValue(NotifyValueState::NOTIFY); |
| 1981 // the CCC descriptor. | |
| 1982 #if !defined(OS_MACOSX) | |
| 1983 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | |
| 1984 #else | |
| 1985 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 1986 EXPECT_TRUE(last_notify_value); | |
| 1987 #endif // !defined(OS_MACOSX) | |
| 1988 | 1909 |
| 1989 // Stop the notify session twice | 1910 // Stop the notify session twice |
| 1990 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1)); | 1911 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(1)); |
| 1991 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(2)); | 1912 notify_sessions_[0]->Stop(GetStopNotifyCheckForPrecedingCalls(2)); |
| 1992 | 1913 |
| 1993 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1914 ExpectedChangeNotifyValueAttempts(2); |
| 1994 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1915 ExpectedNotifyValue(NotifyValueState::NONE); |
| 1995 // the CCC descriptor. | |
| 1996 #if !defined(OS_MACOSX) | |
| 1997 // Check that the right values were written to the descriptor. | |
| 1998 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 1999 ASSERT_EQ(2u, last_write_value_.size()); | |
| 2000 EXPECT_EQ(0, last_write_value_[0]); | |
| 2001 EXPECT_EQ(0, last_write_value_[1]); | |
| 2002 #else | |
| 2003 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 2004 EXPECT_FALSE(last_notify_value); | |
| 2005 #endif // !defined(OS_MACOSX) | |
| 2006 | 1916 |
| 2007 // Start another notify session | 1917 // Start another notify session |
| 2008 characteristic1_->StartNotifySession( | 1918 characteristic1_->StartNotifySession( |
| 2009 GetNotifyCheckForPrecedingCalls(3), | 1919 GetNotifyCheckForPrecedingCalls(3), |
| 2010 GetGattErrorCallback(Call::NOT_EXPECTED)); | 1920 GetGattErrorCallback(Call::NOT_EXPECTED)); |
| 2011 | 1921 |
| 2012 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1922 ExpectedChangeNotifyValueAttempts(2); |
| 2013 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1923 ExpectedNotifyValue(NotifyValueState::NONE); |
| 2014 // the CCC descriptor. | |
| 2015 #if !defined(OS_MACOSX) | |
| 2016 // Check that nothing was written by the StartNotifySession call above | |
| 2017 EXPECT_EQ(2, gatt_write_descriptor_attempts_); | |
| 2018 #else | |
| 2019 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | |
| 2020 #endif // !defined(OS_MACOSX) | |
| 2021 | 1924 |
| 2022 SimulateGattNotifySessionStopped(characteristic1_); | 1925 SimulateGattNotifySessionStopped(characteristic1_); |
| 2023 base::RunLoop().RunUntilIdle(); | 1926 base::RunLoop().RunUntilIdle(); |
| 2024 EXPECT_FALSE(notify_sessions_[0]->IsActive()); | 1927 EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| 2025 | 1928 |
| 2026 SimulateGattNotifySessionStarted(characteristic1_); | 1929 SimulateGattNotifySessionStarted(characteristic1_); |
| 2027 base::RunLoop().RunUntilIdle(); | 1930 base::RunLoop().RunUntilIdle(); |
| 2028 | 1931 |
| 2029 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | 1932 ExpectedChangeNotifyValueAttempts(3); |
| 2030 // setNotifyValue:forCharacteristic:] which handles all interactions with | 1933 ExpectedNotifyValue(NotifyValueState::NOTIFY); |
| 2031 // the CCC descriptor. | |
| 2032 #if !defined(OS_MACOSX) | |
| 2033 // Check that the right values were written to the descriptor. | |
| 2034 EXPECT_EQ(3, gatt_write_descriptor_attempts_); | |
| 2035 ASSERT_EQ(2u, last_write_value_.size()); | |
| 2036 EXPECT_EQ(1, last_write_value_[0]); | |
| 2037 EXPECT_EQ(0, last_write_value_[1]); | |
| 2038 #else | |
| 2039 EXPECT_EQ(3, gatt_notify_characteristic_attempts_); | |
| 2040 EXPECT_TRUE(last_notify_value); | |
| 2041 #endif // !defined(OS_MACOSX) | |
| 2042 | 1934 |
| 2043 // Check the notify state | 1935 // Check the notify state |
| 2044 ASSERT_EQ(2u, notify_sessions_.size()); | 1936 ASSERT_EQ(2u, notify_sessions_.size()); |
| 2045 ASSERT_TRUE(notify_sessions_[0]); | 1937 ASSERT_TRUE(notify_sessions_[0]); |
| 2046 EXPECT_FALSE(notify_sessions_[0]->IsActive()); | 1938 EXPECT_FALSE(notify_sessions_[0]->IsActive()); |
| 2047 ASSERT_TRUE(notify_sessions_[1]); | 1939 ASSERT_TRUE(notify_sessions_[1]); |
| 2048 EXPECT_TRUE(notify_sessions_[1]->IsActive()); | 1940 EXPECT_TRUE(notify_sessions_[1]->IsActive()); |
| 2049 EXPECT_TRUE(characteristic1_->IsNotifying()); | 1941 EXPECT_TRUE(characteristic1_->IsNotifying()); |
| 2050 } | 1942 } |
| 2051 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) | 1943 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); | 2204 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); |
| 2313 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); | 2205 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); |
| 2314 | 2206 |
| 2315 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); | 2207 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); |
| 2316 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); | 2208 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); |
| 2317 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); | 2209 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); |
| 2318 } | 2210 } |
| 2319 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 2211 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 2320 | 2212 |
| 2321 } // namespace device | 2213 } // namespace device |
| OLD | NEW |