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

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

Issue 2248913002: bluetooth: Implement RSSI and Tx Power on macOS and Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-refactor-adv-data
Patch Set: Clean up Created 4 years, 3 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 #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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 kTestDeviceName;
48 static const std::string kTestDeviceNameEmpty; 48 static const std::string kTestDeviceNameEmpty;
49 49
50 static const std::string kTestDeviceAddress1; 50 static const std::string kTestDeviceAddress1;
51 static const std::string kTestDeviceAddress2; 51 static const std::string kTestDeviceAddress2;
52 static const std::string kTestDeviceAddress3; 52 static const std::string kTestDeviceAddress3;
53 53
54 enum { kTestRSSI1 = -81 };
55 enum { kTestRSSI2 = -61 };
56 enum { kTestRSSI3 = -41 };
57 enum { kTestRSSI4 = -21 };
58 enum { kTestRSSI5 = -1 };
59
60 enum { kTestTxPower1 = -40 };
61 enum { kTestTxPower2 = -20 };
62
54 static const std::string kTestUUIDGenericAccess; 63 static const std::string kTestUUIDGenericAccess;
55 static const std::string kTestUUIDGenericAttribute; 64 static const std::string kTestUUIDGenericAttribute;
56 static const std::string kTestUUIDImmediateAlert; 65 static const std::string kTestUUIDImmediateAlert;
57 static const std::string kTestUUIDLinkLoss; 66 static const std::string kTestUUIDLinkLoss;
58 static const std::string kTestUUIDHeartRate; 67 static const std::string kTestUUIDHeartRate;
59 68
60 BluetoothTestBase(); 69 BluetoothTestBase();
61 ~BluetoothTestBase() override; 70 ~BluetoothTestBase() override;
62 71
63 // Checks that no unexpected calls have been made to callbacks. 72 // Checks that no unexpected calls have been made to callbacks.
(...skipping 24 matching lines...) Expand all
88 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be 97 // Initializes the BluetoothAdapter |adapter_| with a fake adapter that can be
89 // controlled by this test fixture. 98 // controlled by this test fixture.
90 virtual void InitWithFakeAdapter() {} 99 virtual void InitWithFakeAdapter() {}
91 100
92 // Configures the fake adapter to lack the necessary permissions to scan for 101 // Configures the fake adapter to lack the necessary permissions to scan for
93 // devices. Returns false if the current platform always has permission. 102 // devices. Returns false if the current platform always has permission.
94 virtual bool DenyPermission(); 103 virtual bool DenyPermission();
95 104
96 // Create a fake Low Energy device and discover it. 105 // Create a fake Low Energy device and discover it.
97 // |device_ordinal| selects between multiple fake device data sets to produce: 106 // |device_ordinal| selects between multiple fake device data sets to produce:
98 // 1: kTestDeviceName with advertised UUIDs kTestUUIDGenericAccess, 107 // 1: kTestDeviceName with address kTestDeviceAddress1, RSSI of kTestRSSI1,
Jeffrey Yasskin 2016/08/24 04:32:02 Could you write these as: // 1: Name: kTestDevi
ortuno 2016/08/24 21:29:09 Done.
99 // kTestUUIDGenericAttribute, address kTestDeviceAddress1 and service 108 // advertised UUIDs kTestUUIDGenericAccess, kTestUUIDGenericAttribute,
100 // data of {kTestUUIDHeartRate: [1]}. 109 // service data of {kTestUUIDHeartRate: [1]} and a Tx Power of
101 // 2: kTestDeviceName with advertised UUIDs kTestUUIDImmediateAlert, 110 // kTestTxPower1.
102 // kTestUUIDLinkLoss, address kTestDeviceAddress1 and service data of 111 // 2: kTestDeviceName with address kTestDeviceAddress1, RSSI of kTestRSSI2,
103 // {kTestUUIDHeartRate: [2], kTestUUIDImmediateAlert: [0]}. 112 // advertised UUIDs kTestUUIDImmediateAlert, kTestUUIDLinkLoss, service
104 // 3: kTestDeviceNameEmpty with no advertised UUIDs and address 113 // data of {kTestUUIDHeartRate: [2], kTestUUIDImmediateAlert: [0]} and
105 // kTestDeviceAddress1. 114 // Tx Power of kTestTxPower2.
106 // 4: kTestDeviceNameEmpty with no advertised UUIDs and address 115 // 3: kTestDeviceNameEmpty with address kTestDeviceAddress1, RSSI of
107 // kTestDeviceAddress2. 116 // kTestRSSI3, no advertised UUIDs, no service data, and no Tx Power.
108 // 5: Device with no name, with no advertised UUIDs and address 117 // 4: kTestDeviceNameEmpty with address kTestDeviceAddress2, RSSI of
109 // kTestDeviceAddress1. 118 // kTestRSSI4, no advertised UUIDs, no service data and no Tx Power.
110 // 6: kTestDeviceName with no advertised UUIDs and address 119 // 5: No name device with address kTestDeviceAddress1, RSSI of kTestRSSI5,
111 // kTestDeviceAddress2, but which also supports BR/EDR. 120 // no advertised UUIDs, no service data and no Tx Power.
121 // 6: kTestDeviceName with address kTestDeviceAddress2, RSSI of kTestRSSI1,
122 // no advertised UUIDs, no service data, no Tx Power but which also
123 // supports BR/EDR.
112 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); 124 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal);
113 125
114 // Create a fake classic device and discover it. The device will have 126 // Create a fake classic device and discover it. The device will have
115 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. 127 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3.
116 virtual BluetoothDevice* SimulateClassicDevice(); 128 virtual BluetoothDevice* SimulateClassicDevice();
117 129
118 // Remembers |device|'s platform specific object to be used in a 130 // Remembers |device|'s platform specific object to be used in a
119 // subsequent call to methods such as SimulateGattServicesDiscovered that 131 // subsequent call to methods such as SimulateGattServicesDiscovered that
120 // accept a nullptr value to select this remembered characteristic. This 132 // accept a nullptr value to select this remembered characteristic. This
121 // enables tests where the platform attempts to reference device 133 // enables tests where the platform attempts to reference device
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 int actual_error_callback_calls_ = 0; 455 int actual_error_callback_calls_ = 0;
444 bool unexpected_success_callback_ = false; 456 bool unexpected_success_callback_ = false;
445 bool unexpected_error_callback_ = false; 457 bool unexpected_error_callback_ = false;
446 458
447 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; 459 base::WeakPtrFactory<BluetoothTestBase> weak_factory_;
448 }; 460 };
449 461
450 } // namespace device 462 } // namespace device
451 463
452 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 464 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698