summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscheib <scheib@chromium.org>2015-10-17 22:43:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-18 05:44:06 +0000
commit9cb5c67582d72026ed2db2a5001eb3bc494ec89f (patch)
treeb1b751e06b8b0e6fc5a01eac2d0a7f5f69b76a78
parentbc7f7ea4421a3a91012c174b96db4b3e5260c386 (diff)
downloadchromium_src-9cb5c67582d72026ed2db2a5001eb3bc494ec89f.zip
chromium_src-9cb5c67582d72026ed2db2a5001eb3bc494ec89f.tar.gz
chromium_src-9cb5c67582d72026ed2db2a5001eb3bc494ec89f.tar.bz2
bluetooth: mac: Only test Low Energy discovery sessions.
Previously simultaneous Low Energy and Classic discovery sessions were used. However, no fake for Mac exists yet for Classic discovery sessions. This resulted in Classic discovery sessions returning in an error. BUG=541710 Review URL: https://codereview.chromium.org/1412023002 Cr-Commit-Position: refs/heads/master@{#354700}
-rw-r--r--device/bluetooth/bluetooth_adapter_unittest.cc19
-rw-r--r--device/bluetooth/bluetooth_device_unittest.cc30
-rw-r--r--device/bluetooth/bluetooth_gatt_service_unittest.cc2
-rw-r--r--device/bluetooth/test/bluetooth_test.cc8
-rw-r--r--device/bluetooth/test/bluetooth_test.h6
5 files changed, 29 insertions, 36 deletions
diff --git a/device/bluetooth/bluetooth_adapter_unittest.cc b/device/bluetooth/bluetooth_adapter_unittest.cc
index 8d022dc..4683582 100644
--- a/device/bluetooth/bluetooth_adapter_unittest.cc
+++ b/device/bluetooth/bluetooth_adapter_unittest.cc
@@ -457,8 +457,7 @@ TEST_F(BluetoothTest, DiscoverySession) {
InitWithFakeAdapter();
EXPECT_FALSE(adapter_->IsDiscovering());
- adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
- GetErrorCallback());
+ StartLowEnergyDiscoverySession();
EXPECT_EQ(1, callback_count_);
EXPECT_EQ(0, error_callback_count_);
EXPECT_TRUE(adapter_->IsDiscovering());
@@ -485,12 +484,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDevice) {
TestBluetoothAdapterObserver observer(adapter_);
// Start discovery and find a device.
- scoped_ptr<BluetoothDiscoveryFilter> discovery_filter(
- new BluetoothDiscoveryFilter(
- BluetoothDiscoveryFilter::Transport::TRANSPORT_LE));
- adapter_->StartDiscoverySessionWithFilter(discovery_filter.Pass(),
- GetDiscoverySessionCallback(),
- GetErrorCallback());
+ StartLowEnergyDiscoverySession();
DiscoverLowEnergyDevice(1);
EXPECT_EQ(1, observer.device_added_count());
BluetoothDevice* device = adapter_->GetDevice(observer.last_device_address());
@@ -509,8 +503,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceTwice) {
TestBluetoothAdapterObserver observer(adapter_);
// Start discovery and find a device.
- adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
- GetErrorCallback());
+ StartLowEnergyDiscoverySession();
DiscoverLowEnergyDevice(1);
EXPECT_EQ(1, observer.device_added_count());
BluetoothDevice* device = adapter_->GetDevice(observer.last_device_address());
@@ -536,8 +529,7 @@ TEST_F(BluetoothTest, DiscoverLowEnergyDeviceWithUpdatedUUIDs) {
TestBluetoothAdapterObserver observer(adapter_);
// Start discovery and find a device.
- adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
- GetErrorCallback());
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(1);
// Check the initial UUIDs:
@@ -584,8 +576,7 @@ TEST_F(BluetoothTest, DiscoverMultipleLowEnergyDevices) {
TestBluetoothAdapterObserver observer(adapter_);
// Start discovery and find a device.
- adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
- GetErrorCallback());
+ StartLowEnergyDiscoverySession();
DiscoverLowEnergyDevice(1);
DiscoverLowEnergyDevice(4);
EXPECT_EQ(2, observer.device_added_count());
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc
index c6066ca..6a2f261 100644
--- a/device/bluetooth/bluetooth_device_unittest.cc
+++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -72,7 +72,7 @@ TEST_F(BluetoothTest, LowEnergyDeviceProperties) {
return;
}
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(1);
ASSERT_TRUE(device);
EXPECT_EQ(0x1F00u, device->GetBluetoothClass());
@@ -97,7 +97,7 @@ TEST_F(BluetoothTest, LowEnergyDeviceNoUUIDs) {
return;
}
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ASSERT_TRUE(device);
BluetoothDevice::UUIDList uuids = device->GetUUIDs();
@@ -116,7 +116,7 @@ TEST_F(BluetoothTest, LowEnergyDeviceNoUUIDs) {
// Basic CreateGattConnection test.
TEST_F(BluetoothTest, CreateGattConnection) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ResetEventCounts();
@@ -136,7 +136,7 @@ TEST_F(BluetoothTest, CreateGattConnection) {
// functions even when some Disconnect and the BluetoothDevice is destroyed.
TEST_F(BluetoothTest, BluetoothGattConnection) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
std::string device_address = device->GetAddress();
@@ -197,7 +197,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection) {
TEST_F(BluetoothTest,
BluetoothGattConnection_ConnectWithMultipleOSConnections) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
// CreateGattConnection, & multiple connections from platform only invoke
@@ -225,7 +225,7 @@ TEST_F(BluetoothTest,
// Calls CreateGattConnection after already connected.
TEST_F(BluetoothTest, BluetoothGattConnection_AlreadyConnected) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
// Be already connected:
@@ -250,7 +250,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_AlreadyConnected) {
TEST_F(BluetoothTest,
BluetoothGattConnection_NewConnectionLeavesPreviousDisconnected) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
// Create connection:
@@ -278,7 +278,7 @@ TEST_F(BluetoothTest,
// Deletes BluetoothGattConnection causing disconnection.
TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectWhenObjectsDestroyed) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
// Create multiple connections and simulate connection complete:
@@ -299,7 +299,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectWhenObjectsDestroyed) {
// Starts process of disconnecting and then calls BluetoothGattConnection.
TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
// Create multiple connections and simulate connection complete:
@@ -340,7 +340,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) {
// before it ever connects.
TEST_F(BluetoothTest, BluetoothGattConnection_SimulateDisconnect) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ResetEventCounts();
@@ -360,7 +360,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_SimulateDisconnect) {
// Calls CreateGattConnection & DisconnectGatt, then simulates connection.
TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_SimulateConnect) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ResetEventCounts();
@@ -385,7 +385,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_SimulateConnect) {
TEST_F(BluetoothTest,
BluetoothGattConnection_DisconnectGatt_SimulateDisconnect) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ResetEventCounts();
@@ -408,7 +408,7 @@ TEST_F(BluetoothTest,
// multiple errors should only invoke callbacks once.
TEST_F(BluetoothTest, BluetoothGattConnection_ErrorAfterConnection) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
ResetEventCounts();
@@ -428,7 +428,7 @@ TEST_F(BluetoothTest, BluetoothGattConnection_ErrorAfterConnection) {
#if defined(OS_ANDROID)
TEST_F(BluetoothTest, SimulateGattServicesDiscovered) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
device->CreateGattConnection(GetGattConnectionCallback(),
GetConnectErrorCallback());
@@ -449,7 +449,7 @@ TEST_F(BluetoothTest, SimulateGattServicesDiscovered) {
#if defined(OS_ANDROID)
TEST_F(BluetoothTest, SimulateGattServicesDiscoveryError) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
device->CreateGattConnection(GetGattConnectionCallback(),
GetConnectErrorCallback());
diff --git a/device/bluetooth/bluetooth_gatt_service_unittest.cc b/device/bluetooth/bluetooth_gatt_service_unittest.cc
index 91fd214..c6b8733 100644
--- a/device/bluetooth/bluetooth_gatt_service_unittest.cc
+++ b/device/bluetooth/bluetooth_gatt_service_unittest.cc
@@ -17,7 +17,7 @@ namespace device {
#if defined(OS_ANDROID)
TEST_F(BluetoothTest, GetUUIDAndGetIdentifier) {
InitWithFakeAdapter();
- StartDiscoverySession();
+ StartLowEnergyDiscoverySession();
BluetoothDevice* device = DiscoverLowEnergyDevice(3);
device->CreateGattConnection(GetGattConnectionCallback(),
GetConnectErrorCallback());
diff --git a/device/bluetooth/test/bluetooth_test.cc b/device/bluetooth/test/bluetooth_test.cc
index 40de9b3..c5368ec 100644
--- a/device/bluetooth/test/bluetooth_test.cc
+++ b/device/bluetooth/test/bluetooth_test.cc
@@ -30,9 +30,11 @@ BluetoothTestBase::BluetoothTestBase() : weak_factory_(this) {}
BluetoothTestBase::~BluetoothTestBase() {
}
-void BluetoothTestBase::StartDiscoverySession() {
- adapter_->StartDiscoverySession(GetDiscoverySessionCallback(),
- GetErrorCallback());
+void BluetoothTestBase::StartLowEnergyDiscoverySession() {
+ adapter_->StartDiscoverySessionWithFilter(
+ make_scoped_ptr(new BluetoothDiscoveryFilter(
+ BluetoothDiscoveryFilter::Transport::TRANSPORT_LE)),
+ GetDiscoverySessionCallback(), GetErrorCallback());
base::RunLoop().RunUntilIdle();
}
diff --git a/device/bluetooth/test/bluetooth_test.h b/device/bluetooth/test/bluetooth_test.h
index 11e6b6b..6271313 100644
--- a/device/bluetooth/test/bluetooth_test.h
+++ b/device/bluetooth/test/bluetooth_test.h
@@ -43,9 +43,9 @@ class BluetoothTestBase : public testing::Test {
BluetoothTestBase();
~BluetoothTestBase() override;
- // Calls adapter_->StartDiscoverySession with this fixture's callbacks, and
- // then RunLoop().RunUntilIdle().
- void StartDiscoverySession();
+ // Calls adapter_->StartDiscoverySessionWithFilter with Low Energy transport,
+ // and this fixture's callbacks. Then RunLoop().RunUntilIdle().
+ void StartLowEnergyDiscoverySession();
// Check if Low Energy is available. On Mac, we require OS X >= 10.10.
virtual bool PlatformSupportsLowEnergy() = 0;