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

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: Address jyasskin's comments 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..2fe5b03ba6a44d3b0f3b23374bf6f06360430680 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
@@ -4,6 +4,7 @@
#include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h"
+#include "base/strings/stringprintf.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
@@ -113,6 +114,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 +247,18 @@ LayoutTestBluetoothAdapterProvider::
return adapter.Pass();
}
+scoped_refptr<NiceMock<MockBluetoothAdapter>>
+LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() {
+ scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(GetEmptyAdapter());
+
+ for (int error = BluetoothDevice::ERROR_UNKNOWN;
+ 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 +353,24 @@ 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(errorUUID(error_code)));
+
+ scoped_ptr<testing::NiceMock<MockBluetoothDevice>> device(
+ GetBaseDevice(adapter, device_name, uuids, canonicalAddress(error_code)));
+
+ 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) {
@@ -368,6 +401,17 @@ LayoutTestBluetoothAdapterProvider::GetBaseGATTService(
return service.Pass();
}
+// static
+std::string LayoutTestBluetoothAdapterProvider::errorUUID(uint32_t alias) {
+ return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias);
+}
+
+// static
+std::string LayoutTestBluetoothAdapterProvider::canonicalAddress(int addr) {
+ return BluetoothDevice::CanonicalizeAddress(
+ base::StringPrintf("%012x", addr));
+}
+
// The functions after this haven't been updated to the new design yet.
// static

Powered by Google App Engine
This is Rietveld 408576698