Commit 290ac0ba authored by sacomoto's avatar sacomoto Committed by Commit bot

Adding BLE connection finder unit tests.

Adds unit tests for the proximity_auth::BluetoothLowEnergyConnectionFinder
class.

BUG=485123

Review URL: https://codereview.chromium.org/1129983004

Cr-Commit-Position: refs/heads/master@{#330918}
parent e4cf3208
...@@ -428,6 +428,7 @@ ...@@ -428,6 +428,7 @@
'precache/core/precache_url_table_unittest.cc', 'precache/core/precache_url_table_unittest.cc',
], ],
'proximity_auth_unittest_sources': [ 'proximity_auth_unittest_sources': [
'proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc',
'proximity_auth/bluetooth_connection_finder_unittest.cc', 'proximity_auth/bluetooth_connection_finder_unittest.cc',
'proximity_auth/bluetooth_connection_unittest.cc', 'proximity_auth/bluetooth_connection_unittest.cc',
'proximity_auth/bluetooth_throttler_impl_unittest.cc', 'proximity_auth/bluetooth_throttler_impl_unittest.cc',
......
...@@ -67,6 +67,7 @@ source_set("unit_tests") { ...@@ -67,6 +67,7 @@ source_set("unit_tests") {
deps = [ deps = [
":proximity_auth", ":proximity_auth",
"ble:unit_tests",
"cryptauth:unit_tests", "cryptauth:unit_tests",
"logging:unit_tests", "logging:unit_tests",
"//base/test:test_support", "//base/test:test_support",
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//testing/test.gni")
source_set("ble") { source_set("ble") {
sources = [ sources = [
"bluetooth_low_energy_connection.cc", "bluetooth_low_energy_connection.cc",
...@@ -21,3 +23,21 @@ source_set("ble") { ...@@ -21,3 +23,21 @@ source_set("ble") {
"//net", "//net",
] ]
} }
source_set("unit_tests") {
testonly = true
sources = [
"bluetooth_low_energy_connection_finder_unittest.cc",
]
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
deps = [
":ble",
"//components/proximity_auth",
"//base/test:test_support",
"//device/bluetooth:mocks",
"//testing/gmock",
"//testing/gtest",
]
}
...@@ -48,7 +48,6 @@ class BluetoothLowEnergyConnectionFinder ...@@ -48,7 +48,6 @@ class BluetoothLowEnergyConnectionFinder
Connection::Status old_status, Connection::Status old_status,
Connection::Status new_status) override; Connection::Status new_status) override;
protected:
// device::BluetoothAdapter::Observer: // device::BluetoothAdapter::Observer:
void DeviceAdded(device::BluetoothAdapter* adapter, void DeviceAdded(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override; device::BluetoothDevice* device) override;
...@@ -57,6 +56,12 @@ class BluetoothLowEnergyConnectionFinder ...@@ -57,6 +56,12 @@ class BluetoothLowEnergyConnectionFinder
void DeviceRemoved(device::BluetoothAdapter* adapter, void DeviceRemoved(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override; device::BluetoothDevice* device) override;
protected:
// Creates a proximity_auth::Connection based on |gatt_connection|. Exposed
// for testing.
virtual scoped_ptr<Connection> CreateConnection(
scoped_ptr<device::BluetoothGattConnection> gatt_connection);
private: private:
// Callback to be called when the Bluetooth adapter is initialized. // Callback to be called when the Bluetooth adapter is initialized.
void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter);
...@@ -100,10 +105,6 @@ class BluetoothLowEnergyConnectionFinder ...@@ -100,10 +105,6 @@ class BluetoothLowEnergyConnectionFinder
// be called once the connection is established. // be called once the connection is established.
void CreateGattConnection(device::BluetoothDevice* remote_device); void CreateGattConnection(device::BluetoothDevice* remote_device);
// Creates a connection with |remote_device|.
scoped_ptr<Connection> CreateConnection(
scoped_ptr<device::BluetoothGattConnection> gatt_connection);
// The uuid of the service it looks for to establish a GattConnection. // The uuid of the service it looks for to establish a GattConnection.
device::BluetoothUUID remote_service_uuid_; device::BluetoothUUID remote_service_uuid_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment