| Index: device/bluetooth/bluetooth_device_unittest.cc
|
| diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc
|
| index 964d8a38cd565bd98272ae2770b66750af584d7c..37f8b7b82413cf0b2f4149f8028b2fc062469f01 100644
|
| --- a/device/bluetooth/bluetooth_device_unittest.cc
|
| +++ b/device/bluetooth/bluetooth_device_unittest.cc
|
| @@ -122,8 +122,8 @@ TEST_F(BluetoothTest, CreateGattConnection) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
| EXPECT_EQ(1, callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| @@ -144,8 +144,8 @@ TEST_F(BluetoothTest, BluetoothGattConnection) {
|
|
|
| // CreateGattConnection
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| SimulateGattConnection(device);
|
| EXPECT_EQ(1, callback_count_);
|
| @@ -156,10 +156,10 @@ TEST_F(BluetoothTest, BluetoothGattConnection) {
|
|
|
| // Connect again once already connected.
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| EXPECT_EQ(0, gatt_connection_attempts_);
|
| EXPECT_EQ(2, callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| @@ -205,8 +205,8 @@ TEST_F(BluetoothTest,
|
| // CreateGattConnection, & multiple connections from platform only invoke
|
| // callbacks once:
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
| SimulateGattConnection(device);
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| @@ -231,15 +231,15 @@ TEST_F(BluetoothTest, BluetoothGattConnection_AlreadyConnected) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| // Be already connected:
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
| EXPECT_TRUE(gatt_connections_[0]->IsConnected());
|
|
|
| // Then CreateGattConnection:
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| EXPECT_EQ(0, gatt_connection_attempts_);
|
| EXPECT_EQ(1, callback_count_);
|
| EXPECT_EQ(0, error_callback_count_);
|
| @@ -256,8 +256,8 @@ TEST_F(BluetoothTest,
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| // Create connection:
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
|
|
| // Disconnect connection:
|
| @@ -265,8 +265,8 @@ TEST_F(BluetoothTest,
|
| SimulateGattDisconnection(device);
|
|
|
| // Create 2nd connection:
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
|
|
| EXPECT_FALSE(gatt_connections_[0]->IsConnected())
|
| @@ -284,10 +284,10 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectWhenObjectsDestroyed) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| // Create multiple connections and simulate connection complete:
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
|
|
| // Delete all CreateGattConnection objects, observe disconnection:
|
| @@ -305,10 +305,10 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| // Create multiple connections and simulate connection complete:
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| SimulateGattConnection(device);
|
|
|
| // Disconnect all CreateGattConnection objects & create a new connection.
|
| @@ -319,8 +319,8 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectInProgress) {
|
| EXPECT_EQ(1, gatt_disconnection_attempts_);
|
|
|
| // Create a connection.
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| EXPECT_EQ(0, gatt_connection_attempts_); // No connection attempt.
|
| EXPECT_EQ(1, callback_count_); // Device is assumed still connected.
|
| EXPECT_EQ(0, error_callback_count_);
|
| @@ -346,8 +346,8 @@ TEST_F(BluetoothTest, BluetoothGattConnection_SimulateDisconnect) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
|
| + GetConnectErrorCallback(Call::EXPECTED));
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| SimulateGattDisconnection(device);
|
| EXPECT_EQ(0, callback_count_);
|
| @@ -366,8 +366,8 @@ TEST_F(BluetoothTest, BluetoothGattConnection_DisconnectGatt_SimulateConnect) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| device->DisconnectGatt();
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| EXPECT_EQ(1, gatt_disconnection_attempts_);
|
| @@ -391,8 +391,8 @@ TEST_F(BluetoothTest,
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
|
| + GetConnectErrorCallback(Call::EXPECTED));
|
| device->DisconnectGatt();
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| EXPECT_EQ(1, gatt_disconnection_attempts_);
|
| @@ -414,8 +414,8 @@ TEST_F(BluetoothTest, BluetoothGattConnection_ErrorAfterConnection) {
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
|
|
| ResetEventCounts();
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::NOT_EXPECTED),
|
| + GetConnectErrorCallback(Call::EXPECTED));
|
| EXPECT_EQ(1, gatt_connection_attempts_);
|
| SimulateGattConnectionError(device, BluetoothDevice::ERROR_AUTH_FAILED);
|
| SimulateGattConnectionError(device, BluetoothDevice::ERROR_FAILED);
|
| @@ -432,8 +432,8 @@ TEST_F(BluetoothTest, GattServices_ObserversCalls) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| TestBluetoothAdapterObserver observer(adapter_);
|
| ResetEventCounts();
|
| SimulateGattConnection(device);
|
| @@ -454,8 +454,8 @@ TEST_F(BluetoothTest, GetGattServices_and_GetGattService) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| ResetEventCounts();
|
| SimulateGattConnection(device);
|
| EXPECT_EQ(1, gatt_discovery_attempts_);
|
| @@ -483,8 +483,8 @@ TEST_F(BluetoothTest, GetGattServices_DiscoveryError) {
|
| InitWithFakeAdapter();
|
| StartLowEnergyDiscoverySession();
|
| BluetoothDevice* device = DiscoverLowEnergyDevice(3);
|
| - device->CreateGattConnection(GetGattConnectionCallback(),
|
| - GetConnectErrorCallback());
|
| + device->CreateGattConnection(GetGattConnectionCallback(Call::EXPECTED),
|
| + GetConnectErrorCallback(Call::NOT_EXPECTED));
|
| ResetEventCounts();
|
| SimulateGattConnection(device);
|
| EXPECT_EQ(1, gatt_discovery_attempts_);
|
|
|