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

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

Issue 1572873002: bluetooth: android: Code cleanup fixing comments, typos, simplified names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "device/bluetooth/bluetooth_gatt_service.h" 12 #include "device/bluetooth/bluetooth_gatt_service.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #if defined(OS_ANDROID) 15 #if defined(OS_ANDROID)
16 #include "device/bluetooth/test/bluetooth_test_android.h" 16 #include "device/bluetooth/test/bluetooth_test_android.h"
17 #elif defined(OS_MACOSX) 17 #elif defined(OS_MACOSX)
18 #include "device/bluetooth/test/bluetooth_test_mac.h" 18 #include "device/bluetooth/test/bluetooth_test_mac.h"
19 #endif 19 #endif
20 20
21 namespace device { 21 namespace device {
22 22
23 #if defined(OS_ANDROID) || defined(OS_MACOSX) 23 #if defined(OS_ANDROID) || defined(OS_MACOSX)
24 class BluetoothGattCharacteristicTest : public BluetoothTest { 24 class BluetoothGattCharacteristicTest : public BluetoothTest {
25 public: 25 public:
26 // Create adapter_, device_, service, and provides. 26 // Creates adapter_, device_, service_, characteristic1_, & characteristic2_.
27 void FakeCharacteristicBoilerplate() { 27 void FakeCharacteristicBoilerplate() {
28 InitWithFakeAdapter(); 28 InitWithFakeAdapter();
29 StartLowEnergyDiscoverySession(); 29 StartLowEnergyDiscoverySession();
30 device_ = DiscoverLowEnergyDevice(3); 30 device_ = DiscoverLowEnergyDevice(3);
31 device_->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED), 31 device_->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
32 GetConnectErrorCallback(Call::NOT_EXPECTED)); 32 GetConnectErrorCallback(Call::NOT_EXPECTED));
33 SimulateGattConnection(device_); 33 SimulateGattConnection(device_);
34 std::vector<std::string> services; 34 std::vector<std::string> services;
35 std::string uuid("00000000-0000-1000-8000-00805f9b34fb"); 35 std::string uuid("00000000-0000-1000-8000-00805f9b34fb");
36 services.push_back(uuid); 36 services.push_back(uuid);
37 SimulateGattServicesDiscovered(device_, services); 37 SimulateGattServicesDiscovered(device_, services);
38 ASSERT_EQ(1u, device_->GetGattServices().size()); 38 ASSERT_EQ(1u, device_->GetGattServices().size());
39 service_ = device_->GetGattServices()[0]; 39 service_ = device_->GetGattServices()[0];
40 SimulateGattCharacteristic(service_, uuid, /* properties */ 0); 40 SimulateGattCharacteristic(service_, uuid, /* properties */ 0);
41 SimulateGattCharacteristic(service_, uuid, /* properties */ 0); 41 SimulateGattCharacteristic(service_, uuid, /* properties */ 0);
42 ASSERT_EQ(2u, service_->GetCharacteristics().size());
42 characteristic1_ = service_->GetCharacteristics()[0]; 43 characteristic1_ = service_->GetCharacteristics()[0];
43 characteristic2_ = service_->GetCharacteristics()[1]; 44 characteristic2_ = service_->GetCharacteristics()[1];
44 ASSERT_EQ(2u, service_->GetCharacteristics().size());
45 ResetEventCounts(); 45 ResetEventCounts();
46 } 46 }
47 47
48 BluetoothDevice* device_ = nullptr; 48 BluetoothDevice* device_ = nullptr;
49 BluetoothGattService* service_ = nullptr; 49 BluetoothGattService* service_ = nullptr;
50 BluetoothGattCharacteristic* characteristic1_ = nullptr; 50 BluetoothGattCharacteristic* characteristic1_ = nullptr;
51 BluetoothGattCharacteristic* characteristic2_ = nullptr; 51 BluetoothGattCharacteristic* characteristic2_ = nullptr;
52 }; 52 };
53 #endif 53 #endif
54 54
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } // namespace device 704 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698