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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
890 } | 890 } |
891 #endif // defined(OS_ANDROID) | 891 #endif // defined(OS_ANDROID) |
892 | 892 |
893 #if defined(OS_ANDROID) | 893 #if defined(OS_ANDROID) |
894 // Tests multiple StartNotifySession success. | 894 // Tests multiple StartNotifySession success. |
895 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) { | 895 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Multiple) { |
896 ASSERT_NO_FATAL_FAILURE( | 896 ASSERT_NO_FATAL_FAILURE( |
897 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); | 897 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); |
898 SimulateGattDescriptor( | 898 SimulateGattDescriptor( |
899 characteristic1_, | 899 characteristic1_, |
900 /* Client Characteristic Configuration descriptor's standard UUID: */ | 900 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() |
901 "00002902-0000-1000-8000-00805F9B34FB"); | 901 .canonical_value()); |
902 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); | 902 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); |
903 | 903 |
904 characteristic1_->StartNotifySession( | 904 characteristic1_->StartNotifySession( |
905 GetNotifyCallback(Call::EXPECTED), | 905 GetNotifyCallback(Call::EXPECTED), |
906 GetGattErrorCallback(Call::NOT_EXPECTED)); | 906 GetGattErrorCallback(Call::NOT_EXPECTED)); |
907 characteristic1_->StartNotifySession( | 907 characteristic1_->StartNotifySession( |
908 GetNotifyCallback(Call::EXPECTED), | 908 GetNotifyCallback(Call::EXPECTED), |
909 GetGattErrorCallback(Call::NOT_EXPECTED)); | 909 GetGattErrorCallback(Call::NOT_EXPECTED)); |
910 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | 910 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
911 EXPECT_EQ(0, callback_count_); | 911 EXPECT_EQ(0, callback_count_); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 characteristic1_->GetDescriptor(c1_id1)); | 970 characteristic1_->GetDescriptor(c1_id1)); |
971 | 971 |
972 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). | 972 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). |
973 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); | 973 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); |
974 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); | 974 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); |
975 // ... but not uuid 3 | 975 // ... but not uuid 3 |
976 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); | 976 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); |
977 } | 977 } |
978 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 978 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
979 | 979 |
980 #if defined(OS_ANDROID) || defined(OS_WIN) | |
981 TEST_F(BluetoothGattCharacteristicTest, GetDescriptorsForUUID) { | |
982 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); | |
983 | |
984 // Add several Descriptors: | |
985 BluetoothUUID id1("11111111-0000-1000-8000-00805f9b34fb"); | |
986 BluetoothUUID id2("22222222-0000-1000-8000-00805f9b34fb"); | |
987 BluetoothUUID id3("33333333-0000-1000-8000-00805f9b34fb"); | |
988 SimulateGattDescriptor(characteristic1_, id1.canonical_value()); | |
989 SimulateGattDescriptor(characteristic1_, id2.canonical_value()); | |
990 SimulateGattDescriptor(characteristic2_, id3.canonical_value()); | |
991 SimulateGattDescriptor(characteristic2_, id3.canonical_value()); | |
992 | |
993 EXPECT_EQ(id1, characteristic1_->GetDescriptorsForUUID(id1).at(0)->GetUUID()); | |
994 EXPECT_EQ(id2, characteristic1_->GetDescriptorsForUUID(id2).at(0)->GetUUID()); | |
995 EXPECT_EQ(id3, characteristic2_->GetDescriptorsForUUID(id3).at(0)->GetUUID()); | |
996 EXPECT_EQ(id3, characteristic2_->GetDescriptorsForUUID(id3).at(1)->GetUUID()); | |
ortuno
2016/03/13 20:41:44
Add EXPECT_NE(characteristic2_->GetDescriptorsForU
scheib
2016/03/25 00:13:57
Done.
| |
997 EXPECT_EQ(1u, characteristic1_->GetDescriptorsForUUID(id1).size()); | |
998 EXPECT_EQ(1u, characteristic1_->GetDescriptorsForUUID(id2).size()); | |
999 EXPECT_EQ(2u, characteristic2_->GetDescriptorsForUUID(id3).size()); | |
1000 | |
1001 EXPECT_EQ(0u, characteristic2_->GetDescriptorsForUUID(id1).size()); | |
1002 EXPECT_EQ(0u, characteristic2_->GetDescriptorsForUUID(id2).size()); | |
1003 EXPECT_EQ(0u, characteristic1_->GetDescriptorsForUUID(id3).size()); | |
1004 } | |
1005 #endif // defined(OS_ANDROID) || defined(OS_WIN) | |
1006 | |
980 } // namespace device | 1007 } // namespace device |
OLD | NEW |