| 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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 SimulateGattNotifySessionStopped(characteristic1_); | 1507 SimulateGattNotifySessionStopped(characteristic1_); |
| 1508 base::RunLoop().RunUntilIdle(); | 1508 base::RunLoop().RunUntilIdle(); |
| 1509 | 1509 |
| 1510 // Check that the state is correct. | 1510 // Check that the state is correct. |
| 1511 EXPECT_TRUE("Did not crash!"); | 1511 EXPECT_TRUE("Did not crash!"); |
| 1512 EXPECT_FALSE(characteristic1_->IsNotifying()); | 1512 EXPECT_FALSE(characteristic1_->IsNotifying()); |
| 1513 } | 1513 } |
| 1514 #endif // defined(OS_ANDROID) | 1514 #endif // defined(OS_ANDROID) |
| 1515 | 1515 |
| 1516 #if defined(OS_ANDROID) | 1516 #if defined(OS_ANDROID) |
| 1517 // Tests that cancelling StopNotifySession works. |
| 1518 // TODO(crbug.com/633191): Enable on macOS when SubscribeToNotifications is |
| 1519 // implemented. |
| 1520 // TODO(crbug.com/636270): Enable on Windows when SubscribeToNotifications is |
| 1521 // implemented. |
| 1522 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_Cancelled) { |
| 1523 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1524 /* properties: NOTIFY */ 0x10, |
| 1525 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 1526 |
| 1527 // Check that the session is correctly setup. |
| 1528 std::string characteristic_identifier = characteristic1_->GetIdentifier(); |
| 1529 EXPECT_EQ(characteristic_identifier, |
| 1530 notify_sessions_[0]->GetCharacteristicIdentifier()); |
| 1531 EXPECT_EQ(characteristic1_, notify_sessions_[0]->GetCharacteristic()); |
| 1532 EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| 1533 |
| 1534 // Queue a Stop request. |
| 1535 notify_sessions_[0]->Stop(GetStopNotifyCallback(Call::EXPECTED)); |
| 1536 |
| 1537 // Cancel Stop by deleting the device before Stop finishes. |
| 1538 DeleteDevice(device_); // TODO(576906) delete only the characteristic. |
| 1539 } |
| 1540 #endif // defined(OS_ANDROID) |
| 1541 |
| 1542 #if defined(OS_ANDROID) |
| 1517 // Tests that deleted sessions are stopped. | 1543 // Tests that deleted sessions are stopped. |
| 1518 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_AfterDeleted) { | 1544 TEST_F(BluetoothRemoteGattCharacteristicTest, StopNotifySession_AfterDeleted) { |
| 1519 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 1545 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 1520 /* properties: NOTIFY */ 0x10, | 1546 /* properties: NOTIFY */ 0x10, |
| 1521 /* expected_config_descriptor_value: NOTIFY */ 1)); | 1547 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 1522 | 1548 |
| 1523 // Check that the session is correctly setup | 1549 // Check that the session is correctly setup |
| 1524 std::string characteristic_identifier = characteristic1_->GetIdentifier(); | 1550 std::string characteristic_identifier = characteristic1_->GetIdentifier(); |
| 1525 EXPECT_EQ(characteristic_identifier, | 1551 EXPECT_EQ(characteristic_identifier, |
| 1526 notify_sessions_[0]->GetCharacteristicIdentifier()); | 1552 notify_sessions_[0]->GetCharacteristicIdentifier()); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); | 2160 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); |
| 2135 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); | 2161 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); |
| 2136 | 2162 |
| 2137 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); | 2163 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); |
| 2138 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); | 2164 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); |
| 2139 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); | 2165 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); |
| 2140 } | 2166 } |
| 2141 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 2167 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 2142 | 2168 |
| 2143 } // namespace device | 2169 } // namespace device |
| OLD | NEW |