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

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

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Nit for the tests 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 23 matching lines...) Expand all
34 34
35 // A test fixture for Bluetooth that abstracts platform specifics for creating 35 // A test fixture for Bluetooth that abstracts platform specifics for creating
36 // and controlling fake low level objects. 36 // and controlling fake low level objects.
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 // List of devices that can be simulated with
45 // SimulateConnectedLowEnergyDevice().
46 // GENERIC_DEVICE:
47 // - Name: kTestDeviceName
48 // - Address: kTestPeripheralUUID1
49 // - Services: [ kTestUUIDGenericAccess ]
50 // HEART_RATE_DEVICE:
51 // - Name: kTestDeviceName
52 // - Address: kTestPeripheralUUID2
53 // - Services: [ kTestUUIDGenericAccess, kTestUUIDHeartRate]
54 enum class ConnectedDeviceType {
55 GENERIC_DEVICE,
56 HEART_RATE_DEVICE,
57 };
58
44 static const std::string kTestAdapterName; 59 static const std::string kTestAdapterName;
45 static const std::string kTestAdapterAddress; 60 static const std::string kTestAdapterAddress;
46 61
47 static const std::string kTestDeviceName; 62 static const std::string kTestDeviceName;
48 static const std::string kTestDeviceNameEmpty; 63 static const std::string kTestDeviceNameEmpty;
49 64
50 static const std::string kTestDeviceAddress1; 65 static const std::string kTestDeviceAddress1;
51 static const std::string kTestDeviceAddress2; 66 static const std::string kTestDeviceAddress2;
52 static const std::string kTestDeviceAddress3; 67 static const std::string kTestDeviceAddress3;
53 68
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // No Tx Power 158 // No Tx Power
144 // 6: Name: kTestDeviceName 159 // 6: Name: kTestDeviceName
145 // Address: kTestDeviceAddress2 160 // Address: kTestDeviceAddress2
146 // RSSI: kTestRSSI1, 161 // RSSI: kTestRSSI1,
147 // No Advertised UUIDs 162 // No Advertised UUIDs
148 // No Service Data 163 // No Service Data
149 // No Tx Power 164 // No Tx Power
150 // Supports BR/EDR and LE. 165 // Supports BR/EDR and LE.
151 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); 166 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal);
152 167
168 // Simulates a connected low energy device. Used before starting a low energy
169 // discovey session.
170 virtual void SimulateConnectedLowEnergyDevice(
171 ConnectedDeviceType device_ordinal){};
172
153 // Create a fake classic device and discover it. The device will have 173 // Create a fake classic device and discover it. The device will have
154 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. 174 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3.
155 virtual BluetoothDevice* SimulateClassicDevice(); 175 virtual BluetoothDevice* SimulateClassicDevice();
156 176
157 // Remembers |device|'s platform specific object to be used in a 177 // Remembers |device|'s platform specific object to be used in a
158 // subsequent call to methods such as SimulateGattServicesDiscovered that 178 // subsequent call to methods such as SimulateGattServicesDiscovered that
159 // accept a nullptr value to select this remembered characteristic. This 179 // accept a nullptr value to select this remembered characteristic. This
160 // enables tests where the platform attempts to reference device 180 // enables tests where the platform attempts to reference device
161 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice. 181 // objects after the Chrome objects have been deleted, e.g. with DeleteDevice.
162 virtual void RememberDeviceForSubsequentAction(BluetoothDevice* device) {} 182 virtual void RememberDeviceForSubsequentAction(BluetoothDevice* device) {}
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 int actual_error_callback_calls_ = 0; 502 int actual_error_callback_calls_ = 0;
483 bool unexpected_success_callback_ = false; 503 bool unexpected_success_callback_ = false;
484 bool unexpected_error_callback_ = false; 504 bool unexpected_error_callback_ = false;
485 505
486 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; 506 base::WeakPtrFactory<BluetoothTestBase> weak_factory_;
487 }; 507 };
488 508
489 } // namespace device 509 } // namespace device
490 510
491 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 511 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.mm ('k') | device/bluetooth/test/bluetooth_test_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698