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

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

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
« no previous file with comments | « device/bluetooth/test/bluetooth_test.h ('k') | device/bluetooth/test/bluetooth_test_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/bluetooth_test.cc
diff --git a/device/bluetooth/test/bluetooth_test.cc b/device/bluetooth/test/bluetooth_test.cc
index 45425fa2ccb41e711329589a2545dd288f2c7a89..188aaa9ae7155a44defc9beff18d04f5722ca6a6 100644
--- a/device/bluetooth/test/bluetooth_test.cc
+++ b/device/bluetooth/test/bluetooth_test.cc
@@ -25,12 +25,15 @@ const std::string BluetoothTestBase::kTestUUIDGenericAttribute = "1801";
const std::string BluetoothTestBase::kTestUUIDImmediateAlert = "1802";
const std::string BluetoothTestBase::kTestUUIDLinkLoss = "1803";
-BluetoothTestBase::BluetoothTestBase() {
-}
+BluetoothTestBase::BluetoothTestBase() : weak_factory_(this) {}
BluetoothTestBase::~BluetoothTestBase() {
}
+void BluetoothTestBase::DeleteDevice(BluetoothDevice* device) {
+ adapter_->DeleteDeviceForTesting(device->GetAddress());
+}
+
void BluetoothTestBase::Callback() {
++callback_count_;
}
@@ -41,22 +44,47 @@ void BluetoothTestBase::DiscoverySessionCallback(
discovery_sessions_.push_back(discovery_session.release());
}
+void BluetoothTestBase::GattConnectionCallback(
+ scoped_ptr<BluetoothGattConnection> connection) {
+ ++callback_count_;
+ gatt_connections_.push_back(connection.release());
+}
+
void BluetoothTestBase::ErrorCallback() {
++error_callback_count_;
}
+void BluetoothTestBase::ConnectErrorCallback(
+ enum BluetoothDevice::ConnectErrorCode error_code) {
+ ++error_callback_count_;
+ last_connect_error_code_ = error_code;
+}
+
base::Closure BluetoothTestBase::GetCallback() {
- return base::Bind(&BluetoothTestBase::Callback, base::Unretained(this));
+ return base::Bind(&BluetoothTestBase::Callback, weak_factory_.GetWeakPtr());
}
BluetoothAdapter::DiscoverySessionCallback
BluetoothTestBase::GetDiscoverySessionCallback() {
return base::Bind(&BluetoothTestBase::DiscoverySessionCallback,
- base::Unretained(this));
+ weak_factory_.GetWeakPtr());
+}
+
+BluetoothDevice::GattConnectionCallback
+BluetoothTestBase::GetGattConnectionCallback() {
+ return base::Bind(&BluetoothTestBase::GattConnectionCallback,
+ weak_factory_.GetWeakPtr());
}
BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() {
- return base::Bind(&BluetoothTestBase::ErrorCallback, base::Unretained(this));
+ return base::Bind(&BluetoothTestBase::ErrorCallback,
+ weak_factory_.GetWeakPtr());
+}
+
+BluetoothDevice::ConnectErrorCallback
+BluetoothTestBase::GetConnectErrorCallback() {
+ return base::Bind(&BluetoothTestBase::ConnectErrorCallback,
+ weak_factory_.GetWeakPtr());
}
} // namespace device
« no previous file with comments | « device/bluetooth/test/bluetooth_test.h ('k') | device/bluetooth/test/bluetooth_test_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698