Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: device/bluetooth/bluetooth_gatt_characteristic_unittest.cc

Issue 1712593002: bluetooth: android: Confirm the notify session after the descriptor has been written. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Vincent's comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 /* Client Characteristic Configuration descriptor's standard UUID: */ 867 /* Client Characteristic Configuration descriptor's standard UUID: */
868 "00002902-0000-1000-8000-00805F9B34FB"); 868 "00002902-0000-1000-8000-00805F9B34FB");
869 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size()); 869 ASSERT_EQ(1u, characteristic1_->GetDescriptors().size());
870 870
871 characteristic1_->StartNotifySession( 871 characteristic1_->StartNotifySession(
872 GetNotifyCallback(Call::EXPECTED), 872 GetNotifyCallback(Call::EXPECTED),
873 GetGattErrorCallback(Call::NOT_EXPECTED)); 873 GetGattErrorCallback(Call::NOT_EXPECTED));
874 characteristic1_->StartNotifySession( 874 characteristic1_->StartNotifySession(
875 GetNotifyCallback(Call::EXPECTED), 875 GetNotifyCallback(Call::EXPECTED),
876 GetGattErrorCallback(Call::NOT_EXPECTED)); 876 GetGattErrorCallback(Call::NOT_EXPECTED));
877 #if defined(OS_ANDROID)
878 // TODO(crbug.com/551634): Decide when implementing IsNotifying if Android
879 // should trust the notification request always worked, or if we should always
880 // redundantly set the value to the OS.
881 EXPECT_EQ(2, gatt_notify_characteristic_attempts_);
882 #else
883 EXPECT_EQ(1, gatt_notify_characteristic_attempts_); 877 EXPECT_EQ(1, gatt_notify_characteristic_attempts_);
884 #endif
885 EXPECT_EQ(0, callback_count_); 878 EXPECT_EQ(0, callback_count_);
886 SimulateGattNotifySessionStarted(characteristic1_); 879 SimulateGattNotifySessionStarted(characteristic1_);
887 EXPECT_EQ(2, callback_count_); 880 EXPECT_EQ(2, callback_count_);
888 EXPECT_EQ(0, error_callback_count_); 881 EXPECT_EQ(0, error_callback_count_);
889 ASSERT_EQ(2u, notify_sessions_.size()); 882 ASSERT_EQ(2u, notify_sessions_.size());
890 ASSERT_TRUE(notify_sessions_[0]); 883 ASSERT_TRUE(notify_sessions_[0]);
891 ASSERT_TRUE(notify_sessions_[1]); 884 ASSERT_TRUE(notify_sessions_[1]);
892 EXPECT_EQ(characteristic1_->GetIdentifier(), 885 EXPECT_EQ(characteristic1_->GetIdentifier(),
893 notify_sessions_[0]->GetCharacteristicIdentifier()); 886 notify_sessions_[0]->GetCharacteristicIdentifier());
894 EXPECT_EQ(characteristic1_->GetIdentifier(), 887 EXPECT_EQ(characteristic1_->GetIdentifier(),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 938
946 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order). 939 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order).
947 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1); 940 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1);
948 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2); 941 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2);
949 // ... but not uuid 3 942 // ... but not uuid 3
950 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3); 943 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3);
951 } 944 }
952 #endif // defined(OS_ANDROID) 945 #endif // defined(OS_ANDROID)
953 946
954 } // namespace device 947 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698