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

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

Issue 1574773002: bluetooth: android: Initial basic Descriptors implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-code-cleanup-
Patch Set: Addressed jyasskin. Created 4 years, 11 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 ASSERT_TRUE(notify_sessions_[1]); 694 ASSERT_TRUE(notify_sessions_[1]);
695 EXPECT_EQ(characteristic1_->GetIdentifier(), 695 EXPECT_EQ(characteristic1_->GetIdentifier(),
696 notify_sessions_[0]->GetCharacteristicIdentifier()); 696 notify_sessions_[0]->GetCharacteristicIdentifier());
697 EXPECT_EQ(characteristic1_->GetIdentifier(), 697 EXPECT_EQ(characteristic1_->GetIdentifier(),
698 notify_sessions_[1]->GetCharacteristicIdentifier()); 698 notify_sessions_[1]->GetCharacteristicIdentifier());
699 EXPECT_TRUE(notify_sessions_[0]->IsActive()); 699 EXPECT_TRUE(notify_sessions_[0]->IsActive());
700 EXPECT_TRUE(notify_sessions_[1]->IsActive()); 700 EXPECT_TRUE(notify_sessions_[1]->IsActive());
701 } 701 }
702 #endif // defined(OS_ANDROID) 702 #endif // defined(OS_ANDROID)
703 703
704 #if defined(OS_ANDROID)
705 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_FindNone) {
706 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
707
708 EXPECT_EQ(0u, characteristic1_->GetDescriptors().size());
709 }
710 #endif // defined(OS_ANDROID)
711
712 #if defined(OS_ANDROID)
713 TEST_F(BluetoothGattCharacteristicTest, GetDescriptors_and_GetDescriptor) {
714 ASSERT_NO_FATAL_FAILURE(FakeCharacteristicBoilerplate());
715
716 // Add several Descriptors:
717 BluetoothUUID uuid1("11111111-0000-1000-8000-00805f9b34fb");
718 BluetoothUUID uuid2("22222222-0000-1000-8000-00805f9b34fb");
719 BluetoothUUID uuid3("33333333-0000-1000-8000-00805f9b34fb");
720 BluetoothUUID uuid4("44444444-0000-1000-8000-00805f9b34fb");
721 SimulateGattDescriptor(characteristic1_, uuid1.canonical_value());
722 SimulateGattDescriptor(characteristic1_, uuid2.canonical_value());
723 SimulateGattDescriptor(characteristic2_, uuid3.canonical_value());
724 SimulateGattDescriptor(characteristic2_, uuid4.canonical_value());
725
726 // Verify that GetDescriptor can retrieve descriptors again by ID,
727 // and that the same Descriptor is returned when searched by ID.
728 EXPECT_EQ(2u, characteristic1_->GetDescriptors().size());
729 EXPECT_EQ(2u, characteristic2_->GetDescriptors().size());
730 std::string c1_id1 = characteristic1_->GetDescriptors()[0]->GetIdentifier();
731 std::string c1_id2 = characteristic1_->GetDescriptors()[1]->GetIdentifier();
732 std::string c2_id1 = characteristic2_->GetDescriptors()[0]->GetIdentifier();
733 std::string c2_id2 = characteristic2_->GetDescriptors()[1]->GetIdentifier();
734 BluetoothUUID c1_uuid1 = characteristic1_->GetDescriptors()[0]->GetUUID();
735 BluetoothUUID c1_uuid2 = characteristic1_->GetDescriptors()[1]->GetUUID();
736 BluetoothUUID c2_uuid1 = characteristic2_->GetDescriptors()[0]->GetUUID();
737 BluetoothUUID c2_uuid2 = characteristic2_->GetDescriptors()[1]->GetUUID();
738 EXPECT_EQ(c1_uuid1, characteristic1_->GetDescriptor(c1_id1)->GetUUID());
739 EXPECT_EQ(c1_uuid2, characteristic1_->GetDescriptor(c1_id2)->GetUUID());
740 EXPECT_EQ(c2_uuid1, characteristic2_->GetDescriptor(c2_id1)->GetUUID());
741 EXPECT_EQ(c2_uuid2, characteristic2_->GetDescriptor(c2_id2)->GetUUID());
742
743 // Multiple GetDescriptor calls for an ID return the same object:
744 EXPECT_EQ(characteristic1_->GetDescriptor(c1_id1)->GetUUID(),
Jeffrey Yasskin 2016/01/12 23:25:59 Remove "->GetUUID()". Could you also check that i
scheib 2016/01/12 23:54:46 Done.
745 characteristic1_->GetDescriptor(c1_id1)->GetUUID());
746
747 // Characteristic 1 has descriptor uuids 1 and 2 (we don't know the order).
748 EXPECT_TRUE(c1_uuid1 == uuid1 || c1_uuid2 == uuid1);
749 EXPECT_TRUE(c1_uuid1 == uuid2 || c1_uuid2 == uuid2);
750 // ... but not uuid 3
751 EXPECT_FALSE(c1_uuid1 == uuid3 || c1_uuid2 == uuid3);
752 }
753 #endif // defined(OS_ANDROID)
754
704 } // namespace device 755 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698