Chromium Code Reviews| 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 EXPECT_EQ(0, observer.gatt_characteristic_value_changed_count()); | |
|
ortuno
2016/10/05 22:13:50
You can add a #if !defined(OS_WIN) and point to th
jlebel
2016/10/05 22:35:36
Done.
| |
| 571 EXPECT_EQ(test_vector, last_write_value_); | 574 EXPECT_EQ(test_vector, last_write_value_); |
| 572 } | 575 } |
| 573 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 576 #endif // defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| 574 | 577 |
| 575 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) | 578 #if defined(OS_ANDROID) || defined(OS_MACOSX) || defined(OS_WIN) |
| 576 // Tests ReadRemoteCharacteristic and GetValue multiple times. | 579 // Tests ReadRemoteCharacteristic and GetValue multiple times. |
| 577 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { | 580 TEST_F(BluetoothRemoteGattCharacteristicTest, ReadRemoteCharacteristic_Twice) { |
| 578 if (!PlatformSupportsLowEnergy()) { | 581 if (!PlatformSupportsLowEnergy()) { |
| 579 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; | 582 LOG(WARNING) << "Low Energy Bluetooth unavailable, skipping unit test."; |
| 580 return; | 583 return; |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2131 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); | 2134 EXPECT_EQ(1u, characteristic1_->GetDescriptorsByUUID(id2).size()); |
| 2132 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); | 2135 EXPECT_EQ(2u, characteristic2_->GetDescriptorsByUUID(id3).size()); |
| 2133 | 2136 |
| 2134 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); | 2137 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id1).size()); |
| 2135 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); | 2138 EXPECT_EQ(0u, characteristic2_->GetDescriptorsByUUID(id2).size()); |
| 2136 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); | 2139 EXPECT_EQ(0u, characteristic1_->GetDescriptorsByUUID(id3).size()); |
| 2137 } | 2140 } |
| 2138 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 2141 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 2139 | 2142 |
| 2140 } // namespace device | 2143 } // namespace device |
| OLD | NEW |