| 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 "device/bluetooth/bluetooth_gatt_characteristic.h" | 5 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 int properties1 = service->GetCharacteristics()[0]->GetProperties(); | 175 int properties1 = service->GetCharacteristics()[0]->GetProperties(); |
| 176 int properties2 = service->GetCharacteristics()[1]->GetProperties(); | 176 int properties2 = service->GetCharacteristics()[1]->GetProperties(); |
| 177 if (properties2 == 0) | 177 if (properties2 == 0) |
| 178 std::swap(properties1, properties2); | 178 std::swap(properties1, properties2); |
| 179 EXPECT_EQ(0, properties1); | 179 EXPECT_EQ(0, properties1); |
| 180 EXPECT_EQ(7, properties2); | 180 EXPECT_EQ(7, properties2); |
| 181 } | 181 } |
| 182 #endif // defined(OS_ANDROID) | 182 #endif // defined(OS_ANDROID) |
| 183 | 183 |
| 184 #if defined(OS_ANDROID) | 184 #if defined(OS_ANDROID) |
| 185 // Tests GetService. |
| 186 TEST_F(BluetoothGattCharacteristicTest, GetService) { |
| 187 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); |
| 188 |
| 189 EXPECT_EQ(service_, characteristic1_->GetService()); |
| 190 EXPECT_EQ(service_, characteristic2_->GetService()); |
| 191 } |
| 192 #endif // defined(OS_ANDROID) |
| 193 |
| 194 #if defined(OS_ANDROID) |
| 185 // Tests ReadRemoteCharacteristic and GetValue with empty value buffer. | 195 // Tests ReadRemoteCharacteristic and GetValue with empty value buffer. |
| 186 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) { | 196 TEST_F(BluetoothGattCharacteristicTest, ReadRemoteCharacteristic_Empty) { |
| 187 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); | 197 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); |
| 188 | 198 |
| 189 characteristic1_->ReadRemoteCharacteristic( | 199 characteristic1_->ReadRemoteCharacteristic( |
| 190 GetReadValueCallback(Call::EXPECTED), | 200 GetReadValueCallback(Call::EXPECTED), |
| 191 GetGattErrorCallback(Call::NOT_EXPECTED)); | 201 GetGattErrorCallback(Call::NOT_EXPECTED)); |
| 192 EXPECT_EQ(1, gatt_read_characteristic_attempts_); | 202 EXPECT_EQ(1, gatt_read_characteristic_attempts_); |
| 193 std::vector<uint8_t> empty_vector; | 203 std::vector<uint8_t> empty_vector; |
| 194 SimulateGattCharacteristicRead(characteristic1_, empty_vector); | 204 SimulateGattCharacteristicRead(characteristic1_, empty_vector); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 758 |
| 749 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). | 759 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). |
| 750 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); | 760 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); |
| 751 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); | 761 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); |
| 752 // ... but not uuid 3 | 762 // ... but not uuid 3 |
| 753 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); | 763 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); |
| 754 } | 764 } |
| 755 #endif // defined(OS_ANDROID) | 765 #endif // defined(OS_ANDROID) |
| 756 | 766 |
| 757 } // namespace device | 767 } // namespace device |
| OLD | NEW |