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

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: Use PRIx64 macro instead of 'lx' 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
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b31c78e797e1cf0ff06c5ac056bef0452ae82b72 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,8 @@
#include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h"
+#include "base/format_macros.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 +115,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 +248,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 +354,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, makeMACAddress(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 +402,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::makeMACAddress(uint64_t addr) {
+ return BluetoothDevice::CanonicalizeAddress(
+ base::StringPrintf("%012" PRIx64, addr));
+}
+
// The functions after this haven't been updated to the new design yet.
// static
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698