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

Side by Side Diff: device/bluetooth/test/bluetooth_test.h

Issue 2377513004: bluetooth:android: Return the advertised name if advertising (Closed)
Patch Set: Format' Created 4 years, 1 month 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 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 5 #ifndef DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 6 #define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 26 matching lines...) Expand all
37 // 37 //
38 // Subclasses on each platform implement this, and are then typedef-ed to 38 // Subclasses on each platform implement this, and are then typedef-ed to
39 // BluetoothTest. 39 // BluetoothTest.
40 class BluetoothTestBase : public testing::Test { 40 class BluetoothTestBase : public testing::Test {
41 public: 41 public:
42 enum class Call { EXPECTED, NOT_EXPECTED }; 42 enum class Call { EXPECTED, NOT_EXPECTED };
43 43
44 static const std::string kTestAdapterName; 44 static const std::string kTestAdapterName;
45 static const std::string kTestAdapterAddress; 45 static const std::string kTestAdapterAddress;
46 46
47 static const std::string kTestDeviceName; 47 static const std::string kTestDeviceGapName;
48 static const std::string kTestDeviceAdvertisedName;
48 static const std::string kTestDeviceNameEmpty; 49 static const std::string kTestDeviceNameEmpty;
49 50
50 static const std::string kTestDeviceAddress1; 51 static const std::string kTestDeviceAddress1;
51 static const std::string kTestDeviceAddress2; 52 static const std::string kTestDeviceAddress2;
52 static const std::string kTestDeviceAddress3; 53 static const std::string kTestDeviceAddress3;
53 54
54 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.bluetooth.test 55 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.device.bluetooth.test
55 enum class TestRSSI { 56 enum class TestRSSI {
56 LOWEST = -81, 57 LOWEST = -81,
57 LOWER = -61, 58 LOWER = -61,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be 104 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be
104 // controlled by this test fixture. 105 // controlled by this test fixture.
105 virtual void InitWithFakeAdapter() {} 106 virtual void InitWithFakeAdapter() {}
106 107
107 // Configures the fake adapter to lack the necessary permissions to scan for 108 // Configures the fake adapter to lack the necessary permissions to scan for
108 // devices. Returns false if the current platform always has permission. 109 // devices. Returns false if the current platform always has permission.
109 virtual bool DenyPermission(); 110 virtual bool DenyPermission();
110 111
111 // Create a fake Low Energy device and discover it. 112 // Create a fake Low Energy device and discover it.
112 // |device_ordinal| selects between multiple fake device data sets to produce: 113 // |device_ordinal| selects between multiple fake device data sets to produce:
113 // 1: Name: kTestDeviceName 114 // 1: Name: kTestDeviceGapName
114 // Address: kTestDeviceAddress1 115 // Address: kTestDeviceAddress1
116 // TODO(crbug.com/630581): Add Advertised name to macOS.
117 // AdvertisedName: kTestDeviceAdvertisedName
115 // RSSI: kTestRSSI1 118 // RSSI: kTestRSSI1
116 // Advertised UUIDs: {kTestUUIDGenericAccess, kTestUUIDGenericAttribute} 119 // Advertised UUIDs: {kTestUUIDGenericAccess, kTestUUIDGenericAttribute}
117 // Service Data: {kTestUUIDHeartRate: [1]} 120 // Service Data: {kTestUUIDHeartRate: [1]}
118 // Tx Power: kTestTxPower1 121 // Tx Power: kTestTxPower1
119 // 2: Name: kTestDeviceName 122 // 2: Name: kTestDeviceGapName
120 // Address: kTestDeviceAddress1 123 // Address: kTestDeviceAddress1
121 // RSSI: kTestRSSI2 124 // RSSI: kTestRSSI2
122 // Advertised UUIDs: {kTestUUIDImmediateAlert, kTestUUIDLinkLoss} 125 // Advertised UUIDs: {kTestUUIDImmediateAlert, kTestUUIDLinkLoss}
123 // Service Data: {kTestUUIDHeartRate: [2], 126 // Service Data: {kTestUUIDHeartRate: [2],
124 // kTestUUIDImmediateAlert: [0]} 127 // kTestUUIDImmediateAlert: [0]}
125 // Tx Power: kTestTxPower2 128 // Tx Power: kTestTxPower2
126 // 3: Name: kTestDeviceNameEmpty 129 // 3: Name: kTestDeviceNameEmpty
127 // Address: kTestDeviceAddress1 130 // Address: kTestDeviceAddress1
128 // RSSI: kTestRSSI3 131 // RSSI: kTestRSSI3
129 // No Advertised UUIDs 132 // No Advertised UUIDs
130 // No Service Data 133 // No Service Data
131 // No Tx Power 134 // No Tx Power
132 // 4: Name: kTestDeviceNameEmpty 135 // 4: Name: kTestDeviceNameEmpty
133 // Address: kTestDeviceAddress2 136 // Address: kTestDeviceAddress2
134 // RSSI: kTestRSSI4 137 // RSSI: kTestRSSI4
135 // No Advertised UUIDs 138 // No Advertised UUIDs
136 // No Service Data 139 // No Service Data
137 // No Tx Power 140 // No Tx Power
138 // 5: No name device 141 // 5: No name device
139 // Address: kTestDeviceAddress1 142 // Address: kTestDeviceAddress1
140 // RSSI: kTestRSSI5 143 // RSSI: kTestRSSI5
141 // No Advertised UUIDs 144 // No Advertised UUIDs
142 // No Service Data 145 // No Service Data
143 // No Tx Power 146 // No Tx Power
144 // 6: Name: kTestDeviceName 147 // 6: Name: kTestDeviceGapName
145 // Address: kTestDeviceAddress2 148 // Address: kTestDeviceAddress2
146 // RSSI: kTestRSSI1, 149 // RSSI: kTestRSSI1,
147 // No Advertised UUIDs 150 // No Advertised UUIDs
148 // No Service Data 151 // No Service Data
149 // No Tx Power 152 // No Tx Power
150 // Supports BR/EDR and LE. 153 // Supports BR/EDR and LE.
151 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); 154 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal);
152 155
153 // Create a fake classic device and discover it. The device will have 156 // Create a fake classic device and discover it. The device will have
154 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. 157 // name kTestDeviceGapName, no advertised UUIDs and address
158 // kTestDeviceAddress3.
155 virtual BluetoothDevice* SimulateClassicDevice(); 159 virtual BluetoothDevice* SimulateClassicDevice();
156 160
157 // Remembers |device|'s platform specific object to be used in a 161 // Remembers |device|'s platform specific object to be used in a
158 // subsequent call to methods such as SimulateGattServicesDiscovered that 162 // subsequent call to methods such as SimulateGattServicesDiscovered that
159 // accept a nullptr value to select this remembered characteristic. This 163 // accept a nullptr value to select this remembered characteristic. This
160 // enables tests where the platform attempts to reference device 164 // enables tests where the platform attempts to reference device
161 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. 165 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice.
162 virtual void RememberDeviceForSubsequentAction(BluetoothDevice* device) {} 166 virtual void RememberDeviceForSubsequentAction(BluetoothDevice* device) {}
163 167
164 // Simulates success of implementation details of CreateGattConnection. 168 // Simulates success of implementation details of CreateGattConnection.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 int actual_error_callback_calls_ = 0; 486 int actual_error_callback_calls_ = 0;
483 bool unexpected_success_callback_ = false; 487 bool unexpected_success_callback_ = false;
484 bool unexpected_error_callback_ = false; 488 bool unexpected_error_callback_ = false;
485 489
486 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; 490 base::WeakPtrFactory<BluetoothTestBase> weak_factory_;
487 }; 491 };
488 492
489 } // namespace device 493 } // namespace device
490 494
491 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 495 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698