| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // setup stage to test. | 64 // setup stage to test. |
| 65 void StartNotifyBoilerplate( | 65 void StartNotifyBoilerplate( |
| 66 int properties, | 66 int properties, |
| 67 uint16_t expected_config_descriptor_value, | 67 uint16_t expected_config_descriptor_value, |
| 68 StartNotifySetupError error = StartNotifySetupError::NONE) { | 68 StartNotifySetupError error = StartNotifySetupError::NONE) { |
| 69 if (error == StartNotifySetupError::CHARACTERISTIC_PROPERTIES) { | 69 if (error == StartNotifySetupError::CHARACTERISTIC_PROPERTIES) { |
| 70 properties = 0; | 70 properties = 0; |
| 71 } | 71 } |
| 72 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(properties)); | 72 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate(properties)); |
| 73 | 73 |
| 74 #if !defined(OS_MACOSX) | |
| 75 // macOS: Not applicable. CoreBluetooth exposes -[CBPeripheral | |
| 76 // setNotifyValue:forCharacteristic:] which handles all interactions with | |
| 77 // the CCC descriptor. | |
| 78 size_t expected_descriptors_count = 0; | 74 size_t expected_descriptors_count = 0; |
| 79 if (error != StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING) { | 75 if (error != StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING) { |
| 80 SimulateGattDescriptor( | 76 SimulateGattDescriptor( |
| 81 characteristic1_, | 77 characteristic1_, |
| 82 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() | 78 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() |
| 83 .canonical_value()); | 79 .canonical_value()); |
| 84 expected_descriptors_count++; | 80 expected_descriptors_count++; |
| 85 } | 81 } |
| 86 if (error == StartNotifySetupError::CONFIG_DESCRIPTOR_DUPLICATE) { | 82 if (error == StartNotifySetupError::CONFIG_DESCRIPTOR_DUPLICATE) { |
| 87 SimulateGattDescriptor( | 83 SimulateGattDescriptor( |
| 88 characteristic1_, | 84 characteristic1_, |
| 89 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() | 85 BluetoothRemoteGattDescriptor::ClientCharacteristicConfigurationUuid() |
| 90 .canonical_value()); | 86 .canonical_value()); |
| 91 expected_descriptors_count++; | 87 expected_descriptors_count++; |
| 92 } | 88 } |
| 93 ASSERT_EQ(expected_descriptors_count, | 89 ASSERT_EQ(expected_descriptors_count, |
| 94 characteristic1_->GetDescriptors().size()); | 90 characteristic1_->GetDescriptors().size()); |
| 95 #endif // !defined(OS_MACOSX) | |
| 96 | 91 |
| 97 if (error == StartNotifySetupError::SET_NOTIFY) { | 92 if (error == StartNotifySetupError::SET_NOTIFY) { |
| 98 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 93 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
| 99 characteristic1_); | 94 characteristic1_); |
| 100 } | 95 } |
| 101 | 96 |
| 102 if (error == StartNotifySetupError::WRITE_DESCRIPTOR) { | 97 if (error == StartNotifySetupError::WRITE_DESCRIPTOR) { |
| 103 SimulateGattDescriptorWriteWillFailSynchronouslyOnce( | 98 SimulateGattDescriptorWriteWillFailSynchronouslyOnce( |
| 104 characteristic1_->GetDescriptors()[0]); | 99 characteristic1_->GetDescriptors()[0]); |
| 105 } | 100 } |
| (...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2139 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); | 2134 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); |
| 2140 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); | 2135 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); |
| 2141 | 2136 |
| 2142 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); | 2137 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); |
| 2143 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); | 2138 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); |
| 2144 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); | 2139 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); |
| 2145 } | 2140 } |
| 2146 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 2141 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 2147 | 2142 |
| 2148 } // namespace device | 2143 } // namespace device |
| OLD | NEW |