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 "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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 ASSERT_TRUE(notify_sessions_[1]); | 889 ASSERT_TRUE(notify_sessions_[1]); |
| 890 EXPECT_EQ(characteristic1_->GetIdentifier(), | 890 EXPECT_EQ(characteristic1_->GetIdentifier(), |
| 891 notify_sessions_[0]->GetCharacteristicIdentifier()); | 891 notify_sessions_[0]->GetCharacteristicIdentifier()); |
| 892 EXPECT_EQ(characteristic1_->GetIdentifier(), | 892 EXPECT_EQ(characteristic1_->GetIdentifier(), |
| 893 notify_sessions_[1]->GetCharacteristicIdentifier()); | 893 notify_sessions_[1]->GetCharacteristicIdentifier()); |
| 894 EXPECT_TRUE(notify_sessions_[0]->IsActive()); | 894 EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| 895 EXPECT_TRUE(notify_sessions_[1]->IsActive()); | 895 EXPECT_TRUE(notify_sessions_[1]->IsActive()); |
| 896 } | 896 } |
| 897 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 897 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 898 | 898 |
| 899 #if defined(OS_WIN) | |
| 900 // Tests StartNotifySession reentrant in start notify session error callback. | |
| 901 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_Reentrant) { | |
|
scheib
2016/03/19 04:58:07
Please test all 4 combinations of
initial callba
gogerald1
2016/04/21 21:05:22
Done. "success, error" looks impossible in current
| |
| 902 ASSERT_NO_FATAL_FAILURE( | |
| 903 FakeCharacteristicBoilerplate(/* properties: NOTIFY */ 0x10)); | |
| 904 SimulateGattDescriptor( | |
| 905 characteristic1_, | |
| 906 /* Client Characteristic Configuration descriptor's standard UUID: */ | |
| 907 "00002902-0000-1000-8000-00805F9B34FB"); | |
|
scheib
2016/03/19 04:58:07
BluetoothGattDescriptor::ClientCharacteristicConfi
gogerald1
2016/04/21 21:05:22
Done.
| |
| 908 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); | |
| 909 | |
| 910 SimulateGattCharacteristicSetNotifyWillFailAsynchronouslyOnce( | |
| 911 characteristic1_); | |
| 912 | |
| 913 characteristic1_->StartNotifySession( | |
| 914 GetNotifyCallback(Call::NOT_EXPECTED), | |
| 915 GetReentrantStartNotifySessionErrorCallback(Call::EXPECTED, | |
| 916 characteristic1_)); | |
| 917 EXPECT_EQ(0, callback_count_); | |
| 918 SimulateGattNotifySessionStarted(characteristic1_); | |
| 919 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); | |
| 920 EXPECT_EQ(0, callback_count_); | |
| 921 EXPECT_EQ(1, error_callback_count_); | |
| 922 ASSERT_EQ(0u, notify_sessions_.size()); | |
| 923 | |
| 924 // Simulate reentrant StartNotifySession request from | |
| 925 // BluetoothTestBase::ReentrantStartNotifySessionErrorCallback. | |
| 926 SimulateGattNotifySessionStarted(characteristic1_); | |
| 927 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 928 EXPECT_EQ(1, callback_count_); | |
| 929 ASSERT_EQ(1u, notify_sessions_.size()); | |
| 930 ASSERT_TRUE(notify_sessions_[0]); | |
| 931 EXPECT_EQ(characteristic1_->GetIdentifier(), | |
| 932 notify_sessions_[0]->GetCharacteristicIdentifier()); | |
| 933 EXPECT_TRUE(notify_sessions_[0]->IsActive()); | |
| 934 } | |
| 935 #endif // defined(OS_WIN) | |
| 936 | |
| 899 #if defined(OS_ANDROID) || defined(OS_WIN) | 937 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 900 // Tests Characteristic Value changes during a Notify Session. | 938 // Tests Characteristic Value changes during a Notify Session. |
| 901 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) { | 939 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) { |
| 902 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 940 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 903 /* properties: NOTIFY */ 0x10, | 941 /* properties: NOTIFY */ 0x10, |
| 904 /* expected_config_descriptor_value: NOTIFY */ 1)); | 942 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 905 | 943 |
| 906 TestBluetoothAdapterObserver observer(adapter_); | 944 TestBluetoothAdapterObserver observer(adapter_); |
| 907 | 945 |
| 908 std::vector<uint8_t> test_vector1, test_vector2; | 946 std::vector<uint8_t> test_vector1, test_vector2; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 988 | 1026 |
| 989 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). | 1027 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). |
| 990 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); | 1028 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); |
| 991 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); | 1029 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); |
| 992 // ... but not uuid 3 | 1030 // ... but not uuid 3 |
| 993 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); | 1031 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); |
| 994 } | 1032 } |
| 995 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 1033 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 996 | 1034 |
| 997 } // namespace device | 1035 } // namespace device |
| OLD | NEW |