Index: device/bluetooth/test/bluetooth_test.h |
diff --git a/device/bluetooth/test/bluetooth_test.h b/device/bluetooth/test/bluetooth_test.h |
index e6ccc6c5b9ab58ca1d9866943cdd836f823557bb..bca816e6705cdb1e0f20f9e2431bf189d297b679 100644 |
--- a/device/bluetooth/test/bluetooth_test.h |
+++ b/device/bluetooth/test/bluetooth_test.h |
@@ -29,6 +29,8 @@ class BluetoothDevice; |
// BluetoothTest. |
class BluetoothTestBase : public testing::Test { |
public: |
+ enum class Call { EXPECTED, NOT_EXPECTED }; |
+ |
static const std::string kTestAdapterName; |
static const std::string kTestAdapterAddress; |
@@ -46,10 +48,19 @@ class BluetoothTestBase : public testing::Test { |
BluetoothTestBase(); |
~BluetoothTestBase() override; |
+ // Checks that no unexpected calls have been made to callbacks. |
+ void TearDown() override; |
+ |
// Calls adapter_->StartDiscoverySessionWithFilter with Low Energy transport, |
- // and this fixture's callbacks. Then RunLoop().RunUntilIdle(). |
+ // and this fixture's callbacks. The success callback is expected to be |
+ // called. Then RunLoop().RunUntilIdle(). |
scheib
2015/11/20 23:08:20
// Calls adapter_->StartDiscoverySessionWithFilter
ortuno
2015/11/21 01:12:49
Done.
|
void StartLowEnergyDiscoverySession(); |
+ // Calls adapter_->StartDiscoverySessionWithFilter with Low Energy transport, |
+ // and this fixture's callbacks. The error callback is expected to be called. |
+ // Then RunLoop().RunUntilIdle(). |
+ void StartLowEnergyDiscoverySessionExpectedToFail(); |
+ |
// Check if Low Energy is available. On Mac, we require OS X >= 10.10. |
virtual bool PlatformSupportsLowEnergy() = 0; |
@@ -148,31 +159,38 @@ class BluetoothTestBase : public testing::Test { |
virtual void DeleteDevice(BluetoothDevice* device); |
// Callbacks that increment |callback_count_|, |error_callback_count_|: |
- void Callback(); |
- void DiscoverySessionCallback(scoped_ptr<BluetoothDiscoverySession>); |
- void GattConnectionCallback(scoped_ptr<BluetoothGattConnection>); |
- void NotifyCallback(scoped_ptr<BluetoothGattNotifySession>); |
- void ReadValueCallback(const std::vector<uint8>& value); |
- void ErrorCallback(); |
- void ConnectErrorCallback(enum BluetoothDevice::ConnectErrorCode); |
- void GattErrorCallback(BluetoothGattService::GattErrorCode); |
+ void Callback(Call expected); |
+ void DiscoverySessionCallback(Call expected, |
+ scoped_ptr<BluetoothDiscoverySession>); |
+ void GattConnectionCallback(Call expected, |
+ scoped_ptr<BluetoothGattConnection>); |
+ void NotifyCallback(Call expected, scoped_ptr<BluetoothGattNotifySession>); |
+ void ReadValueCallback(Call expected, const std::vector<uint8>& value); |
+ void ErrorCallback(Call expected); |
+ void ConnectErrorCallback(Call expected, |
+ enum BluetoothDevice::ConnectErrorCode); |
+ void GattErrorCallback(Call expected, BluetoothGattService::GattErrorCode); |
// Accessors to get callbacks bound to this fixture: |
- base::Closure GetCallback(); |
- BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback(); |
- BluetoothDevice::GattConnectionCallback GetGattConnectionCallback(); |
- BluetoothGattCharacteristic::NotifySessionCallback GetNotifyCallback(); |
- BluetoothGattCharacteristic::ValueCallback GetReadValueCallback(); |
- BluetoothAdapter::ErrorCallback GetErrorCallback(); |
- BluetoothDevice::ConnectErrorCallback GetConnectErrorCallback(); |
+ base::Closure GetCallback(Call expected); |
+ BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback( |
+ Call expected); |
+ BluetoothDevice::GattConnectionCallback GetGattConnectionCallback( |
+ Call expected); |
+ BluetoothGattCharacteristic::NotifySessionCallback GetNotifyCallback( |
+ Call expected); |
+ BluetoothGattCharacteristic::ValueCallback GetReadValueCallback( |
+ Call expected); |
+ BluetoothAdapter::ErrorCallback GetErrorCallback(Call expected); |
+ BluetoothDevice::ConnectErrorCallback GetConnectErrorCallback(Call expected); |
base::Callback<void(BluetoothGattService::GattErrorCode)> |
- GetGattErrorCallback(); |
+ GetGattErrorCallback(Call expected); |
// Reset all event count members to 0. |
void ResetEventCounts(); |
// A Message loop is required by some implementations that will PostTasks and |
- // by base::RunLoop().RunUntilIdle() use in this fixuture. |
+ // by base::RunLoop().RunUntilIdle() use in this fixture. |
base::MessageLoop message_loop_; |
scoped_refptr<BluetoothAdapter> adapter_; |
@@ -186,6 +204,7 @@ class BluetoothTestBase : public testing::Test { |
BluetoothGattService::GattErrorCode last_gatt_error_code_; |
int callback_count_ = 0; |
int error_callback_count_ = 0; |
+ bool unexpected_callback_ = false; |
int gatt_connection_attempts_ = 0; |
int gatt_disconnection_attempts_ = 0; |
int gatt_discovery_attempts_ = 0; |