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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 characteristic1_->StartNotifySession( | 91 characteristic1_->StartNotifySession( |
| 92 GetNotifyCallback(Call::NOT_EXPECTED), | 92 GetNotifyCallback(Call::NOT_EXPECTED), |
| 93 GetGattErrorCallback(Call::EXPECTED)); | 93 GetGattErrorCallback(Call::EXPECTED)); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 characteristic1_->StartNotifySession( | 97 characteristic1_->StartNotifySession( |
| 98 GetNotifyCallback(Call::EXPECTED), | 98 GetNotifyCallback(Call::EXPECTED), |
| 99 GetGattErrorCallback(Call::NOT_EXPECTED)); | 99 GetGattErrorCallback(Call::NOT_EXPECTED)); |
| 100 | 100 |
| 101 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 102 EXPECT_EQ(0, callback_count_); | 101 EXPECT_EQ(0, callback_count_); |
| 103 SimulateGattNotifySessionStarted(characteristic1_); | 102 SimulateGattNotifySessionStarted(characteristic1_); |
| 103 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | |
| 104 EXPECT_EQ(1, callback_count_); | 104 EXPECT_EQ(1, callback_count_); |
| 105 EXPECT_EQ(0, error_callback_count_); | 105 EXPECT_EQ(0, error_callback_count_); |
| 106 ASSERT_EQ(1u, notify_sessions_.size()); | 106 ASSERT_EQ(1u, notify_sessions_.size()); |
| 107 ASSERT_TRUE(notify_sessions_[0]); | 107 ASSERT_TRUE(notify_sessions_[0]); |
| 108 EXPECT_EQ(characteristic1_->GetIdentifier(), | 108 EXPECT_EQ(characteristic1_->GetIdentifier(), |
| 109 notify_sessions_[0]->GetCharacteristicIdentifier()); | 109 notify_sessions_[0]->GetCharacteristicIdentifier()); |
| 110 EXPECT_TRUE(notify_sessions_[0]->IsActive()); | 110 EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| 111 | 111 |
| 112 // Verify the Client Characteristic Configuration descriptor was written to. | 112 // Verify the Client Characteristic Configuration descriptor was written to. |
| 113 EXPECT_EQ(1, gatt_write_descriptor_attempts_); | 113 EXPECT_EQ(1, gatt_write_descriptor_attempts_); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 last_gatt_error_code_); | 736 last_gatt_error_code_); |
| 737 | 737 |
| 738 // Initial read should still succeed: | 738 // Initial read should still succeed: |
| 739 ResetEventCounts(); | 739 ResetEventCounts(); |
| 740 SimulateGattCharacteristicRead(characteristic1_, empty_vector); | 740 SimulateGattCharacteristicRead(characteristic1_, empty_vector); |
| 741 EXPECT_EQ(1, callback_count_); | 741 EXPECT_EQ(1, callback_count_); |
| 742 EXPECT_EQ(0, error_callback_count_); | 742 EXPECT_EQ(0, error_callback_count_); |
| 743 } | 743 } |
| 744 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 744 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 745 | 745 |
| 746 #if defined(OS_ANDROID) | 746 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 747 // StartNotifySession fails if characteristic doesn't have Notify or Indicate | 747 // StartNotifySession fails if characteristic doesn't have Notify or Indicate |
| 748 // property. | 748 // property. |
| 749 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) { | 749 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoNotifyOrIndicate) { |
| 750 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 750 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 751 /* properties: NOTIFY */ 0x10, | 751 /* properties: NOTIFY */ 0x10, |
| 752 /* expected_config_descriptor_value: NOTIFY */ 1, | 752 /* expected_config_descriptor_value: NOTIFY */ 1, |
| 753 StartNotifySetupError::CHARACTERISTIC_PROPERTIES)); | 753 StartNotifySetupError::CHARACTERISTIC_PROPERTIES)); |
| 754 | 754 |
| 755 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); | 755 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
| 756 | 756 |
| 757 // The expected error callback is asynchronous: | 757 // The expected error callback is asynchronous: |
| 758 EXPECT_EQ(0, error_callback_count_); | 758 EXPECT_EQ(0, error_callback_count_); |
| 759 base::RunLoop().RunUntilIdle(); | 759 RunUntilIdle(); |
| 760 EXPECT_EQ(1, error_callback_count_); | 760 EXPECT_EQ(1, error_callback_count_); |
| 761 } | 761 } |
| 762 #endif // defined(OS_ANDROID) | 762 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 763 | 763 |
| 764 #if defined(OS_ANDROID) | 764 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 765 // StartNotifySession fails if the characteristic is missing the Client | 765 // StartNotifySession fails if the characteristic is missing the Client |
| 766 // Characteristic Configuration descriptor. | 766 // Characteristic Configuration descriptor. |
| 767 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) { | 767 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_NoConfigDescriptor) { |
| 768 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 768 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 769 /* properties: NOTIFY */ 0x10, | 769 /* properties: NOTIFY */ 0x10, |
| 770 /* expected_config_descriptor_value: NOTIFY */ 1, | 770 /* expected_config_descriptor_value: NOTIFY */ 1, |
| 771 StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING)); | 771 StartNotifySetupError::CONFIG_DESCRIPTOR_MISSING)); |
| 772 | 772 |
| 773 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); | 773 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
| 774 | 774 |
| 775 // The expected error callback is asynchronous: | 775 // The expected error callback is asynchronous: |
| 776 EXPECT_EQ(0, error_callback_count_); | 776 EXPECT_EQ(0, error_callback_count_); |
| 777 base::RunLoop().RunUntilIdle(); | 777 RunUntilIdle(); |
| 778 EXPECT_EQ(1, error_callback_count_); | 778 EXPECT_EQ(1, error_callback_count_); |
| 779 } | 779 } |
| 780 #endif // defined(OS_ANDROID) | 780 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 781 | 781 |
| 782 #if defined(OS_ANDROID) | 782 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 783 // StartNotifySession fails synchronously when failing to set a characteristic | 783 // StartNotifySession fails synchronously when failing to set a characteristic |
| 784 // to enable notifications. | 784 // to enable notifications. |
| 785 // Android: This is mBluetoothGatt.setCharacteristicNotification failing. | 785 // Android: This is mBluetoothGatt.setCharacteristicNotification failing. |
| 786 TEST_F(BluetoothGattCharacteristicTest, | 786 TEST_F(BluetoothGattCharacteristicTest, |
| 787 StartNotifySession_FailToSetCharacteristicNotification) { | 787 StartNotifySession_FailToSetCharacteristicNotification) { |
| 788 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 788 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 789 /* properties: NOTIFY */ 0x10, | 789 /* properties: NOTIFY */ 0x10, |
| 790 /* expected_config_descriptor_value: NOTIFY */ 1, | 790 /* expected_config_descriptor_value: NOTIFY */ 1, |
| 791 StartNotifySetupError::SET_NOTIFY)); | 791 StartNotifySetupError::SET_NOTIFY)); |
| 792 | 792 |
| 793 // The expected error callback is asynchronous: | 793 // The expected error callback is asynchronous: |
| 794 EXPECT_EQ(0, error_callback_count_); | 794 EXPECT_EQ(0, error_callback_count_); |
| 795 base::RunLoop().RunUntilIdle(); | 795 RunUntilIdle(); |
| 796 EXPECT_EQ(1, error_callback_count_); | 796 EXPECT_EQ(1, error_callback_count_); |
| 797 | 797 |
| 798 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); | 798 EXPECT_EQ(0, gatt_notify_characteristic_attempts_); |
| 799 ASSERT_EQ(0u, notify_sessions_.size()); | 799 ASSERT_EQ(0u, notify_sessions_.size()); |
| 800 } | 800 } |
| 801 #endif // defined(OS_ANDROID) | 801 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 802 | 802 |
| 803 #if defined(OS_ANDROID) | 803 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 804 // Tests StartNotifySession descriptor write synchronous failure. | 804 // Tests StartNotifySession descriptor write synchronous failure. |
| 805 TEST_F(BluetoothGattCharacteristicTest, | 805 TEST_F(BluetoothGattCharacteristicTest, |
| 806 StartNotifySession_WriteDescriptorSynchronousError) { | 806 StartNotifySession_WriteDescriptorSynchronousError) { |
| 807 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 807 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 808 /* properties: NOTIFY */ 0x10, | 808 /* properties: NOTIFY */ 0x10, |
| 809 /* expected_config_descriptor_value: NOTIFY */ 1, | 809 /* expected_config_descriptor_value: NOTIFY */ 1, |
| 810 StartNotifySetupError::WRITE_DESCRIPTOR)); | 810 StartNotifySetupError::WRITE_DESCRIPTOR)); |
| 811 | 811 |
| 812 // The expected error callback is asynchronous: | 812 // The expected error callback is asynchronous: |
| 813 EXPECT_EQ(0, error_callback_count_); | 813 EXPECT_EQ(0, error_callback_count_); |
| 814 base::RunLoop().RunUntilIdle(); | 814 RunUntilIdle(); |
| 815 EXPECT_EQ(1, error_callback_count_); | 815 EXPECT_EQ(1, error_callback_count_); |
| 816 | 816 |
| 817 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | 817 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| 818 ASSERT_EQ(0u, notify_sessions_.size()); | 818 ASSERT_EQ(0u, notify_sessions_.size()); |
| 819 } | 819 } |
| 820 #endif // defined(OS_ANDROID) | 820 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 821 | 821 |
| 822 #if defined(OS_ANDROID) | 822 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 823 // Tests StartNotifySession success on a characteristic enabling Notify. | 823 // Tests StartNotifySession success on a characteristic enabling Notify. |
| 824 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) { | 824 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession) { |
| 825 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 825 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 826 /* properties: NOTIFY */ 0x10, | 826 /* properties: NOTIFY */ 0x10, |
| 827 /* expected_config_descriptor_value: NOTIFY */ 1)); | 827 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 828 } | 828 } |
| 829 #endif // defined(OS_ANDROID) | 829 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 830 | 830 |
| 831 #if defined(OS_ANDROID) | 831 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 832 // Tests StartNotifySession success on a characteristic enabling Indicate. | 832 // Tests StartNotifySession success on a characteristic enabling Indicate. |
| 833 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) { | 833 TEST_F(BluetoothGattCharacteristicTest, StartNotifySession_OnIndicate) { |
| 834 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 834 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 835 /* properties: INDICATE */ 0x20, | 835 /* properties: INDICATE */ 0x20, |
| 836 /* expected_config_descriptor_value: INDICATE */ 2)); | 836 /* expected_config_descriptor_value: INDICATE */ 2)); |
| 837 } | 837 } |
| 838 #endif // defined(OS_ANDROID) | 838 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 839 | 839 |
| 840 #if defined(OS_ANDROID) | 840 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 841 // Tests StartNotifySession success on a characteristic enabling Notify & | 841 // Tests StartNotifySession success on a characteristic enabling Notify & |
| 842 // Indicate. | 842 // Indicate. |
| 843 TEST_F(BluetoothGattCharacteristicTest, | 843 TEST_F(BluetoothGattCharacteristicTest, |
| 844 StartNotifySession_OnNotifyAndIndicate) { | 844 StartNotifySession_OnNotifyAndIndicate) { |
| 845 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 845 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 846 /* properties: NOTIFY and INDICATE bits set */ 0x30, | 846 /* properties: NOTIFY and INDICATE bits set */ 0x30, |
| 847 /* expected_config_descriptor_value: NOTIFY */ 1)); | 847 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 848 } | 848 } |
| 849 #endif // defined(OS_ANDROID) | 849 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 850 | 850 |
| 851 #if defined(OS_ANDROID) | 851 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 852 // Tests Characteristic Value changes during a Notify Session. | 852 // Tests Characteristic Value changes during a Notify Session. |
| 853 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) { | 853 TEST_F(BluetoothGattCharacteristicTest, GattCharacteristicValueChanged) { |
| 854 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 854 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 855 /* properties: NOTIFY */ 0x10, | 855 /* properties: NOTIFY */ 0x10, |
| 856 /* expected_config_descriptor_value: NOTIFY */ 1)); | 856 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 857 | 857 |
| 858 TestBluetoothAdapterObserver observer(adapter_); | 858 TestBluetoothAdapterObserver observer(adapter_); |
| 859 | 859 |
| 860 std::vector<uint8_t> test_vector1, test_vector2; | 860 std::vector<uint8_t> test_vector1, test_vector2; |
| 861 test_vector1.push_back(111); | 861 test_vector1.push_back(111); |
| 862 test_vector2.push_back(222); | 862 test_vector2.push_back(222); |
| 863 | 863 |
| 864 SimulateGattCharacteristicChanged(characteristic1_, test_vector1); | 864 SimulateGattCharacteristicChanged(characteristic1_, test_vector1); |
| 865 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); | 865 EXPECT_EQ(1, observer.gatt_characteristic_value_changed_count()); |
| 866 EXPECT_EQ(test_vector1, characteristic1_->GetValue()); | 866 EXPECT_EQ(test_vector1, characteristic1_->GetValue()); |
| 867 | 867 |
| 868 SimulateGattCharacteristicChanged(characteristic1_, test_vector2); | 868 SimulateGattCharacteristicChanged(characteristic1_, test_vector2); |
| 869 EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count()); | 869 EXPECT_EQ(2, observer.gatt_characteristic_value_changed_count()); |
| 870 EXPECT_EQ(test_vector2, characteristic1_->GetValue()); | 870 EXPECT_EQ(test_vector2, characteristic1_->GetValue()); |
| 871 } | 871 } |
| 872 #endif // defined(OS_ANDROID) | 872 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 873 | 873 |
| 874 #if defined(OS_ANDROID) | 874 #if defined(OS_ANDROID) |
| 875 // Tests Characteristic Value changing after a Notify Session and objects being | 875 // Tests Characteristic Value changing after a Notify Session and objects being |
| 876 // destroyed. | 876 // destroyed. |
| 877 TEST_F(BluetoothGattCharacteristicTest, | 877 TEST_F(BluetoothGattCharacteristicTest, |
| 878 GattCharacteristicValueChanged_AfterDeleted) { | 878 GattCharacteristicValueChanged_AfterDeleted) { |
| 879 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( | 879 ASSERT_NO_FATAL_FAILURE(StartNotifyBoilerplate( |
| 880 /* properties: NOTIFY */ 0x10, | 880 /* properties: NOTIFY */ 0x10, |
| 881 /* expected_config_descriptor_value: NOTIFY */ 1)); | 881 /* expected_config_descriptor_value: NOTIFY */ 1)); |
| 882 | 882 |
| 883 RememberCharacteristicForSubsequentAction(characteristic1_); | 883 RememberCharacteristicForSubsequentAction(characteristic1_); |
| 884 DeleteDevice(device_); | 884 DeleteDevice(device_); |
| 885 | 885 |
| 886 std::vector<uint8_t> empty_vector; | 886 std::vector<uint8_t> empty_vector; |
| 887 SimulateGattCharacteristicChanged(/* use remembered characteristic */ nullptr, | 887 SimulateGattCharacteristicChanged(/* use remembered characteristic */ nullptr, |
| 888 empty_vector); | 888 empty_vector); |
| 889 EXPECT_TRUE("Did not crash!"); | 889 EXPECT_TRUE("Did not crash!"); |
| 890 } | 890 } |
| 891 #endif // defined(OS_ANDROID) | 891 #endif // defined(OS_ANDROID) |
| 892 | 892 |
| 893 #if defined(OS_ANDROID) | 893 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 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 /* Client Characteristic Configuration descriptor's standard UUID: */ |
| 901 "00002902-0000-1000-8000-00805F9B34FB"); | 901 "00002902-0000-1000-8000-00805F9B34FB"); |
| 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 | |
| 911 EXPECT_EQ(0, callback_count_); | |
| 912 SimulateGattNotifySessionStarted(characteristic1_); | |
| 910 #if defined(OS_ANDROID) | 913 #if defined(OS_ANDROID) |
| 911 // TODO(crbug.com/551634): Decide when implementing IsNotifying if Android | 914 // TODO(crbug.com/551634): Decide when implementing IsNotifying if Android |
| 912 // should trust the notification request always worked, or if we should always | 915 // should trust the notification request always worked, or if we should always |
| 913 // redundantly set the value to the OS. | 916 // redundantly set the value to the OS. |
| 914 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); | 917 EXPECT_EQ(2, gatt_notify_characteristic_attempts_); |
| 915 #else | 918 #else |
| 916 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); | 919 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); |
| 917 #endif | 920 #endif |
| 918 EXPECT_EQ(0, callback_count_); | |
| 919 SimulateGattNotifySessionStarted(characteristic1_); | |
| 920 EXPECT_EQ(2, callback_count_); | 921 EXPECT_EQ(2, callback_count_); |
| 921 EXPECT_EQ(0, error_callback_count_); | 922 EXPECT_EQ(0, error_callback_count_); |
| 922 ASSERT_EQ(2u, notify_sessions_.size()); | 923 ASSERT_EQ(2u, notify_sessions_.size()); |
| 923 ASSERT_TRUE(notify_sessions_[0]); | 924 ASSERT_TRUE(notify_sessions_[0]); |
| 924 ASSERT_TRUE(notify_sessions_[1]); | 925 ASSERT_TRUE(notify_sessions_[1]); |
| 925 EXPECT_EQ(characteristic1_->GetIdentifier(), | 926 EXPECT_EQ(characteristic1_->GetIdentifier(), |
| 926 notify_sessions_[0]->GetCharacteristicIdentifier()); | 927 notify_sessions_[0]->GetCharacteristicIdentifier()); |
| 927 EXPECT_EQ(characteristic1_->GetIdentifier(), | 928 EXPECT_EQ(characteristic1_->GetIdentifier(), |
| 928 notify_sessions_[1]->GetCharacteristicIdentifier()); | 929 notify_sessions_[1]->GetCharacteristicIdentifier()); |
| 929 EXPECT_TRUE(notify_sessions_[0]->IsActive()); | 930 EXPECT_TRUE(notify_sessions_[0]->IsActive()); |
| 930 EXPECT_TRUE(notify_sessions_[1]->IsActive()); | 931 EXPECT_TRUE(notify_sessions_[1]->IsActive()); |
| 931 } | 932 } |
| 932 #endif // defined(OS_ANDROID) | 933 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
|
ortuno
2016/03/07 18:48:44
These test only cover starting notifications. Sinc
gogerald1
2016/03/07 22:52:48
Done.
| |
| 933 | 934 |
| 934 #if defined(OS_ANDROID) || defined(OS_WIN) | 935 #if defined(OS_ANDROID) || defined(OS_WIN) |
| 935 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) { | 936 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) { |
| 936 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); | 937 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate()); |
| 937 | 938 |
| 938 EXPECT_EQ(0u, characteristic1_->GetDescriptors().size()); | 939 EXPECT_EQ(0u, characteristic1_->GetDescriptors().size()); |
| 939 } | 940 } |
| 940 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 941 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 941 | 942 |
| 942 #if defined(OS_ANDROID) || defined(OS_WIN) | 943 #if defined(OS_ANDROID) || defined(OS_WIN) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 | 979 |
| 979 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). | 980 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). |
| 980 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); | 981 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); |
| 981 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); | 982 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); |
| 982 // ... but not uuid 3 | 983 // ... but not uuid 3 |
| 983 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); | 984 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); |
| 984 } | 985 } |
| 985 #endif // defined(OS_ANDROID) || defined(OS_WIN) | 986 #endif // defined(OS_ANDROID) || defined(OS_WIN) |
| 986 | 987 |
| 987 } // namespace device | 988 } // namespace device |
| OLD | NEW |