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

Unified Diff: device/bluetooth/test/bluetooth_test.h

Issue 1256313002: bluetooth: android: Implement & test CreateGattConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split tests up into smaller tests Created 5 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/test/bluetooth_test.h
diff --git a/device/bluetooth/test/bluetooth_test.h b/device/bluetooth/test/bluetooth_test.h
index 7a0ed0e29f4d06d278ab356f50088815ea90a80d..0f9a8e0041725af95068469559a3863bce1d949b 100644
--- a/device/bluetooth/test/bluetooth_test.h
+++ b/device/bluetooth/test/bluetooth_test.h
@@ -6,9 +6,12 @@
#define DEVICE_BLUETOOTH_TEST_BLUETOOTH_TEST_H_
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "device/bluetooth/bluetooth_adapter.h"
+#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
+#include "device/bluetooth/bluetooth_gatt_connection.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
@@ -66,15 +69,32 @@ class BluetoothTestBase : public testing::Test {
// kTestDeviceAddress2.
virtual void DiscoverLowEnergyDevice(int device_ordinal){};
+ // Simulates success of implementation details of CreateGattConnection.
+ virtual void CompleteGattConnection(BluetoothDevice* device){};
+
+ // Simulates failure of CreateGattConnection with the given error code.
+ virtual void FailGattConnection(BluetoothDevice* device,
+ BluetoothDevice::ConnectErrorCode){};
+
+ // Simulates GattConnection disconnecting.
+ virtual void CompleteGattDisconnection(BluetoothDevice* device){};
+
+ // Remove the device from the adapter and delete it.
+ 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 ErrorCallback();
+ void ConnectErrorCallback(enum BluetoothDevice::ConnectErrorCode);
// Accessors to get callbacks bound to this fixture:
base::Closure GetCallback();
BluetoothAdapter::DiscoverySessionCallback GetDiscoverySessionCallback();
+ BluetoothDevice::GattConnectionCallback GetGattConnectionCallback();
BluetoothAdapter::ErrorCallback GetErrorCallback();
+ BluetoothDevice::ConnectErrorCallback GetConnectErrorCallback();
// A Message loop is required by some implementations that will PostTasks and
// by base::RunLoop().RunUntilIdle() use in this fixuture.
@@ -82,9 +102,14 @@ class BluetoothTestBase : public testing::Test {
scoped_refptr<BluetoothAdapter> adapter_;
ScopedVector<BluetoothDiscoverySession> discovery_sessions_;
+ ScopedVector<BluetoothGattConnection> gatt_connections_;
+ enum BluetoothDevice::ConnectErrorCode last_connect_error_code_ =
+ BluetoothDevice::ERROR_UNKNOWN;
int callback_count_ = 0;
int error_callback_count_ = 0;
- bool run_message_loop_to_wait_for_callbacks_ = true;
+ int gatt_connection_attempt_count_ = 0;
+ int gatt_disconnection_attempt_count_ = 0;
+ base::WeakPtrFactory<BluetoothTestBase> weak_factory_;
};
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698