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

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

Issue 2499913002: bluetooth: android: Implement RetrieveGattConnectedDevicesWithFilter
Patch Set: rebase Created 4 years 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 27 matching lines...) Expand all
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 44 // List of devices that can be simulated with
45 // SimulateConnectedLowEnergyDevice(). 45 // SimulateConnectedLowEnergyDevice().
46 // GENERIC_DEVICE: 46 // GENERIC_DEVICE:
47 // - Name: kTestDeviceName 47 // - Name: kTestDeviceName
48 // - Address: kTestPeripheralUUID1 48 // - Address: kTestDeviceAddress1
49 // - Services: [ kTestUUIDGenericAccess ] 49 // - Services: [ kTestUUIDGenericAccess ]
50 // HEART_RATE_DEVICE: 50 // HEART_RATE_DEVICE:
51 // - Name: kTestDeviceName 51 // - Name: kTestDeviceName
52 // - Address: kTestPeripheralUUID2 52 // - Address: kTestDeviceAddress2
53 // - Services: [ kTestUUIDGenericAccess, kTestUUIDHeartRate] 53 // - Services: [ kTestUUIDGenericAccess, kTestUUIDHeartRate]
54 enum class ConnectedDeviceType { 54 enum class ConnectedDeviceType {
55 GENERIC_DEVICE, 55 GENERIC_DEVICE,
56 HEART_RATE_DEVICE, 56 HEART_RATE_DEVICE,
57 }; 57 };
58 58
59 static const std::string kTestAdapterName; 59 static const std::string kTestAdapterName;
60 static const std::string kTestAdapterAddress; 60 static const std::string kTestAdapterAddress;
61 61
62 static const std::string kTestDeviceName; 62 static const std::string kTestDeviceName;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // RSSI: kTestRSSI1, 161 // RSSI: kTestRSSI1,
162 // No Advertised UUIDs 162 // No Advertised UUIDs
163 // No Service Data 163 // No Service Data
164 // No Tx Power 164 // No Tx Power
165 // Supports BR/EDR and LE. 165 // Supports BR/EDR and LE.
166 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal); 166 virtual BluetoothDevice* SimulateLowEnergyDevice(int device_ordinal);
167 167
168 // Simulates a connected low energy device. Used before starting a low energy 168 // Simulates a connected low energy device. Used before starting a low energy
169 // discovey session. 169 // discovey session.
170 virtual void SimulateConnectedLowEnergyDevice( 170 virtual void SimulateConnectedLowEnergyDevice(
171 ConnectedDeviceType device_ordinal){}; 171 ConnectedDeviceType device_type){};
172 172
173 // 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
174 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3. 174 // name kTestDeviceName, no advertised UUIDs and address kTestDeviceAddress3.
175 virtual BluetoothDevice* SimulateClassicDevice(); 175 virtual BluetoothDevice* SimulateClassicDevice();
176 176
177 // Remembers |device|'s platform specific object to be used in a 177 // Remembers |device|'s platform specific object to be used in a
178 // subsequent call to methods such as SimulateGattServicesDiscovered that 178 // subsequent call to methods such as SimulateGattServicesDiscovered that
179 // accept a nullptr value to select this remembered characteristic. This 179 // accept a nullptr value to select this remembered characteristic. This
180 // enables tests where the platform attempts to reference device 180 // enables tests where the platform attempts to reference device
181 // 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.
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 ScopedVector<BluetoothGattConnection> gatt_connections_; 478 ScopedVector<BluetoothGattConnection> gatt_connections_;
479 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ = 479 enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ =
480 BluetoothDevice::ERROR_UNKNOWN; 480 BluetoothDevice::ERROR_UNKNOWN;
481 ScopedVector<BluetoothGattNotifySession> notify_sessions_; 481 ScopedVector<BluetoothGattNotifySession> notify_sessions_;
482 std::vector<uint8_t> last_read_value_; 482 std::vector<uint8_t> last_read_value_;
483 std::vector<uint8_t> last_write_value_; 483 std::vector<uint8_t> last_write_value_;
484 BluetoothRemoteGattService::GattErrorCode last_gatt_error_code_; 484 BluetoothRemoteGattService::GattErrorCode last_gatt_error_code_;
485 485
486 int callback_count_ = 0; 486 int callback_count_ = 0;
487 int error_callback_count_ = 0; 487 int error_callback_count_ = 0;
488 int manager_get_connected_devices_attempts_ = 0;
488 int gatt_connection_attempts_ = 0; 489 int gatt_connection_attempts_ = 0;
489 int gatt_disconnection_attempts_ = 0; 490 int gatt_disconnection_attempts_ = 0;
490 int gatt_discovery_attempts_ = 0; 491 int gatt_discovery_attempts_ = 0;
491 int gatt_notify_characteristic_attempts_ = 0; 492 int gatt_notify_characteristic_attempts_ = 0;
492 int gatt_read_characteristic_attempts_ = 0; 493 int gatt_read_characteristic_attempts_ = 0;
493 int gatt_write_characteristic_attempts_ = 0; 494 int gatt_write_characteristic_attempts_ = 0;
494 int gatt_read_descriptor_attempts_ = 0; 495 int gatt_read_descriptor_attempts_ = 0;
495 int gatt_write_descriptor_attempts_ = 0; 496 int gatt_write_descriptor_attempts_ = 0;
496 497
497 // The following values are used to make sure the correct callbacks 498 // The following values are used to make sure the correct callbacks
498 // have been called. They are not reset when calling ResetEventCounts(). 499 // have been called. They are not reset when calling ResetEventCounts().
499 int expected_success_callback_calls_ = 0; 500 int expected_success_callback_calls_ = 0;
500 int expected_error_callback_calls_ = 0; 501 int expected_error_callback_calls_ = 0;
501 int actual_success_callback_calls_ = 0; 502 int actual_success_callback_calls_ = 0;
502 int actual_error_callback_calls_ = 0; 503 int actual_error_callback_calls_ = 0;
503 bool unexpected_success_callback_ = false; 504 bool unexpected_success_callback_ = false;
504 bool unexpected_error_callback_ = false; 505 bool unexpected_error_callback_ = false;
505 506
506 base::WeakPtrFactory<BluetoothTestBase> weak_factory_; 507 base::WeakPtrFactory<BluetoothTestBase> weak_factory_;
507 }; 508 };
508 509
509 } // namespace device 510 } // namespace device
510 511
511 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_ 512 #endif // DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698