| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 552 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| 553 // Tests WriteRemoteCharacteristic with non-empty value buffer. | 553 // Tests WriteRemoteCharacteristic with non-empty value buffer. |
| 554 TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) { | 554 TEST_F(BluetoothRemoteGattCharacteristicTest, WriteRemoteCharacteristic) { |
| 555 if (!PlatformSupportsLowEnergy()) { | 555 if (!PlatformSupportsLowEnergy()) { |
| 556 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 556 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 557 return; | 557 return; |
| 558 } | 558 } |
| 559 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( | 559 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate( |
| 560 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE)); | 560 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE)); |
| 561 | 561 |
| 562 TestBluetoothAdapterObserver observer(adapter_); |
| 563 |
| 562 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; | 564 uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff}; |
| 563 std::vector<uint8_t> test_vector(values, values + arraysize(values)); | 565 std::vector<uint8_t> test_vector(values, values + arraysize(values)); |
| 564 characteristic1_->WriteRemoteCharacteristic( | 566 characteristic1_->WriteRemoteCharacteristic( |
| 565 test_vector, GetCallback(Call::EXPECTED), | 567 test_vector, GetCallback(Call::EXPECTED), |
| 566 GetGattErrorCallback(Call::NOT_EXPECTED)); | 568 GetGattErrorCallback(Call::NOT_EXPECTED)); |
| 567 | 569 |
| 568 SimulateGattCharacteristicWrite(characteristic1_); | 570 SimulateGattCharacteristicWrite(characteristic1_); |
| 569 | 571 |
| 570 EXPECT_EQ(1, gatt_write_characteristic_attempts_); | 572 EXPECT_EQ(1, gatt_write_characteristic_attempts_); |
| 573 #if !defined(OS_WIN) |
| 574 // TODO(crbug.com/653291): remove this #if once the bug on windows is fixed. |
| 575 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); |
| 576 #endif |
| 571 EXPECT_EQ(test_vector, last_write_value_); | 577 EXPECT_EQ(test_vector, last_write_value_); |
| 572 } | 578 } |
| 573 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 579 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| 574 | 580 |
| 575 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 581 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| 576 // Tests ReadRemoteCharacteristic and GetValue multiple times. | 582 // Tests ReadRemoteCharacteristic and GetValue multiple times. |
| 577 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { | 583 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { |
| 578 if (!PlatformSupportsLowEnergy()) { | 584 if (!PlatformSupportsLowEnergy()) { |
| 579 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 585 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 580 return; | 586 return; |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); | 2137 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); |
| 2132 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); | 2138 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); |
| 2133 | 2139 |
| 2134 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); | 2140 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); |
| 2135 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); | 2141 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); |
| 2136 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); | 2142 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); |
| 2137 } | 2143 } |
| 2138 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 2144 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 2139 | 2145 |
| 2140 } // namespace device | 2146 } // namespace device |
| OLD | NEW |