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 "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin der.h" | 5 #include "components/cryptauth/ble/bluetooth_low_energy_characteristics_finder.h " |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "components/proximity_auth/ble/remote_attribute.h" | 11 #include "components/cryptauth/ble/remote_attribute.h" |
12 #include "device/bluetooth/bluetooth_adapter_factory.h" | 12 #include "device/bluetooth/bluetooth_adapter_factory.h" |
13 #include "device/bluetooth/bluetooth_uuid.h" | 13 #include "device/bluetooth/bluetooth_uuid.h" |
14 #include "device/bluetooth/test/mock_bluetooth_adapter.h" | 14 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
15 #include "device/bluetooth/test/mock_bluetooth_device.h" | 15 #include "device/bluetooth/test/mock_bluetooth_device.h" |
16 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" | 16 #include "device/bluetooth/test/mock_bluetooth_gatt_characteristic.h" |
17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" | 17 #include "device/bluetooth/test/mock_bluetooth_gatt_service.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 using testing::_; | 21 using testing::_; |
22 using testing::AtLeast; | 22 using testing::AtLeast; |
23 using testing::NiceMock; | 23 using testing::NiceMock; |
24 using testing::Return; | 24 using testing::Return; |
25 using testing::StrictMock; | 25 using testing::StrictMock; |
26 using testing::SaveArg; | 26 using testing::SaveArg; |
27 | 27 |
28 namespace proximity_auth { | 28 namespace cryptauth { |
29 namespace { | 29 namespace { |
30 | 30 |
31 const char kDeviceName[] = "Device name"; | 31 const char kDeviceName[] = "Device name"; |
32 const char kBluetoothAddress[] = "11:22:33:44:55:66"; | 32 const char kBluetoothAddress[] = "11:22:33:44:55:66"; |
33 | 33 |
34 const char kServiceUUID[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEEF"; | 34 const char kServiceUUID[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEEF"; |
35 const char kToPeripheralCharUUID[] = "FBAE09F2-0482-11E5-8418-1697F925EC7B"; | 35 const char kToPeripheralCharUUID[] = "FBAE09F2-0482-11E5-8418-1697F925EC7B"; |
36 const char kFromPeripheralCharUUID[] = "5539ED10-0483-11E5-8418-1697F925EC7B"; | 36 const char kFromPeripheralCharUUID[] = "5539ED10-0483-11E5-8418-1697F925EC7B"; |
37 | 37 |
38 const char kToPeripheralCharID[] = "to peripheral id"; | 38 const char kToPeripheralCharID[] = "to peripheral id"; |
39 const char kFromPeripheralCharID[] = "from peripheral id"; | 39 const char kFromPeripheralCharID[] = "from peripheral id"; |
40 | 40 |
41 const device::BluetoothRemoteGattCharacteristic::Properties | 41 const device::BluetoothRemoteGattCharacteristic::Properties |
42 kCharacteristicProperties = | 42 kCharacteristicProperties = |
43 device::BluetoothRemoteGattCharacteristic::PROPERTY_BROADCAST | | 43 device::BluetoothRemoteGattCharacteristic::PROPERTY_BROADCAST | |
44 device::BluetoothRemoteGattCharacteristic::PROPERTY_READ | | 44 device::BluetoothRemoteGattCharacteristic::PROPERTY_READ | |
45 device::BluetoothRemoteGattCharacteristic:: | 45 device::BluetoothRemoteGattCharacteristic:: |
46 PROPERTY_WRITE_WITHOUT_RESPONSE | | 46 PROPERTY_WRITE_WITHOUT_RESPONSE | |
47 device::BluetoothRemoteGattCharacteristic::PROPERTY_INDICATE; | 47 device::BluetoothRemoteGattCharacteristic::PROPERTY_INDICATE; |
48 | 48 |
49 const char kOtherCharUUID[] = "09731422-048A-11E5-8418-1697F925EC7B"; | 49 const char kOtherCharUUID[] = "09731422-048A-11E5-8418-1697F925EC7B"; |
50 const char kOtherCharID[] = "other id"; | 50 const char kOtherCharID[] = "other id"; |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 class ProximityAuthBluetoothLowEnergyCharacteristicFinderTest | 53 class ProximityAuthBluetoothLowEnergyCharacteristicFinderTest |
Kyle Horimoto
2017/01/14 00:00:13
nit: Just realized that you forgot to rename these
| |
54 : public testing::Test { | 54 : public testing::Test { |
55 protected: | 55 protected: |
56 ProximityAuthBluetoothLowEnergyCharacteristicFinderTest() | 56 ProximityAuthBluetoothLowEnergyCharacteristicFinderTest() |
57 : adapter_(new NiceMock<device::MockBluetoothAdapter>), | 57 : adapter_(new NiceMock<device::MockBluetoothAdapter>), |
58 success_callback_(base::Bind( | 58 success_callback_(base::Bind( |
59 &ProximityAuthBluetoothLowEnergyCharacteristicFinderTest:: | 59 &ProximityAuthBluetoothLowEnergyCharacteristicFinderTest:: |
60 OnCharacteristicsFound, | 60 OnCharacteristicsFound, |
61 base::Unretained(this))), | 61 base::Unretained(this))), |
62 error_callback_(base::Bind( | 62 error_callback_(base::Bind( |
63 &ProximityAuthBluetoothLowEnergyCharacteristicFinderTest:: | 63 &ProximityAuthBluetoothLowEnergyCharacteristicFinderTest:: |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 static_cast<device::BluetoothAdapter::Observer*>(&characteristic_finder); | 285 static_cast<device::BluetoothAdapter::Observer*>(&characteristic_finder); |
286 | 286 |
287 EXPECT_EQ(kToPeripheralCharID, found_to_char.id); | 287 EXPECT_EQ(kToPeripheralCharID, found_to_char.id); |
288 EXPECT_EQ(kFromPeripheralCharID, found_from_char.id); | 288 EXPECT_EQ(kFromPeripheralCharID, found_from_char.id); |
289 | 289 |
290 EXPECT_CALL(*service_, GetUUID()) | 290 EXPECT_CALL(*service_, GetUUID()) |
291 .WillOnce(Return(device::BluetoothUUID(kServiceUUID))); | 291 .WillOnce(Return(device::BluetoothUUID(kServiceUUID))); |
292 observer->GattDiscoveryCompleteForService(adapter_.get(), service_.get()); | 292 observer->GattDiscoveryCompleteForService(adapter_.get(), service_.get()); |
293 } | 293 } |
294 | 294 |
295 } // namespace proximity_auth | 295 } // namespace cryptauth |
OLD | NEW |