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

Unified Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc

Issue 1247553002: bluetooth: Implement FailingConnectionsAdapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-tests-small-5
Patch Set: Created 5 years, 5 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: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
diff --git a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
index 7b0f79a6ff8b06b94d3b4d15a3fb3cdb7357a4ed..083d693a893295a08ea5bcec61704930a48767a3 100644
--- a/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
+++ b/content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc
@@ -42,6 +42,12 @@ const char kGenericAccessServiceUUID[] = "1800";
const char kGenericAttributeServiceUUID[] = "1801";
const char kGlucoseServiceUUID[] = "1808";
const char kHeartRateServiceUUID[] = "180d";
+// UUID prefix for devices that return connection errors.
+const char kPrefixConnectionErrorUUID[] = "0000000";
+// Base Errors UUID. It's used so that we can filter devices and characteristics
+// that return errors. See UnconnectableDevice and ErrorsDevice.
+const char kBaseErrorUUID[] = "-97e5-4cd7-b9f1-f5a427670c59";
+const char kAddressPrefix[] = "00:00:00:00:0";
// Invokes Run() on the k-th argument of the function with no arguments.
ACTION_TEMPLATE(RunCallback,
@@ -113,6 +119,8 @@ LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
return GetMissingServiceGenericAccessAdapter();
else if (fake_adapter_name == "MissingCharacteristicGenericAccessAdapter")
return GetMissingCharacteristicGenericAccessAdapter();
+ else if (fake_adapter_name == "FailingConnectionsAdapter")
+ return GetFailingConnectionsAdapter();
else if (fake_adapter_name == "")
return NULL;
@@ -244,6 +252,18 @@ LayoutTestBluetoothAdapterProvider::
return adapter.Pass();
}
+scoped_refptr<NiceMock<MockBluetoothAdapter>>
+LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() {
+ scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(GetEmptyAdapter());
+
+ for (int error = BluetoothDevice::ERROR_UNKNOWN;
ortuno 2015/07/21 21:32:43 Is this a good way of doing it? I've heard that yo
Jeffrey Yasskin 2015/07/21 23:08:58 This is fine. If the relevant enum had a COUNT mem
+ error <= BluetoothDevice::ERROR_UNSUPPORTED_DEVICE; error++) {
+ adapter->AddMockDevice(GetUnconnectableDevice(
+ adapter.get(), static_cast<BluetoothDevice::ConnectErrorCode>(error)));
+ }
+ return adapter.Pass();
+}
+
// static
scoped_ptr<NiceMock<MockBluetoothDevice>>
LayoutTestBluetoothAdapterProvider::GetBaseDevice(
@@ -338,6 +358,26 @@ LayoutTestBluetoothAdapterProvider::GetConnectableDeviceNew(
// static
scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
+LayoutTestBluetoothAdapterProvider::GetUnconnectableDevice(
+ MockBluetoothAdapter* adapter,
+ BluetoothDevice::ConnectErrorCode error_code,
+ const std::string& device_name) {
+ BluetoothDevice::UUIDList uuids;
+ uuids.push_back(BluetoothUUID(kPrefixConnectionErrorUUID +
Jeffrey Yasskin 2015/07/21 23:08:58 I think this should use StringPrintf("%08x-97e5-4c
ortuno 2015/07/22 01:06:20 Done.
+ std::to_string(error_code) + kBaseErrorUUID));
+
+ scoped_ptr<testing::NiceMock<MockBluetoothDevice>> device(
+ GetBaseDevice(adapter, device_name, uuids,
+ kAddressPrefix + std::to_string(error_code)));
Jeffrey Yasskin 2015/07/21 23:08:58 Similarly, a format string instead of string conca
ortuno 2015/07/22 01:06:20 Done.
+
+ ON_CALL(*device, CreateGattConnection(_, _))
+ .WillByDefault(RunCallback<1 /* error_callback */>(error_code));
+
+ return device.Pass();
+}
+
+// static
+scoped_ptr<testing::NiceMock<device::MockBluetoothDevice>>
LayoutTestBluetoothAdapterProvider::GetGenericAccessDevice(
MockBluetoothAdapter* adapter,
const std::string& device_name) {

Powered by Google App Engine
This is Rietveld 408576698