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

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

Issue 1236073003: bluetooth: Tests refactoring: BaseAdapter, FailStartDiscoveryAdapter... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-origin
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
« 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 aad6fe5f25b66b485fecd18dd64f7a7537ff2367..f74e692acb97e5310326869525612c045b8a32d0 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
@@ -91,9 +91,8 @@ namespace content {
scoped_refptr<BluetoothAdapter>
LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
const std::string& fake_adapter_name) {
- if (fake_adapter_name == "EmptyAdapter")
- return GetEmptyAdapter();
- else if (fake_adapter_name == "SingleEmptyDeviceAdapter")
+ // Old Adapters
+ if (fake_adapter_name == "SingleEmptyDeviceAdapter")
return GetSingleEmptyDeviceAdapter();
else if (fake_adapter_name == "ConnectableDeviceAdapter")
return GetConnectableDeviceAdapter();
@@ -103,6 +102,13 @@ LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
return GetScanFilterCheckingAdapter();
else if (fake_adapter_name == "MultiDeviceAdapter")
return GetMultiDeviceAdapter();
+ // New adapters
+ else if (fake_adapter_name == "BaseAdapter")
+ return GetBaseAdapter();
+ else if (fake_adapter_name == "EmptyAdapter")
+ return GetEmptyAdapter();
+ else if (fake_adapter_name == "FailStartDiscoveryAdapter")
+ return GetFailStartDiscoveryAdapter();
else if (fake_adapter_name == "")
return NULL;
@@ -112,14 +118,10 @@ LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
// static
scoped_refptr<NiceMock<MockBluetoothAdapter>>
-LayoutTestBluetoothAdapterProvider::GetEmptyAdapter() {
+LayoutTestBluetoothAdapterProvider::GetBaseAdapter() {
scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(
new NiceMock<MockBluetoothAdapter>());
- ON_CALL(*adapter, StartDiscoverySessionWithFilterRaw(_, _, _))
- .WillByDefault(RunCallbackWithResult<1 /* success_callback */>(
- []() { return GetDiscoverySession(); }));
-
// Using Invoke allows the adapter returned from this method to be futher
// modified and have devices added to it. The call to ::GetDevices will
// invoke ::GetConstMockDevices, returning all devices added up to that time.
@@ -136,6 +138,43 @@ LayoutTestBluetoothAdapterProvider::GetEmptyAdapter() {
// static
scoped_refptr<NiceMock<MockBluetoothAdapter>>
+LayoutTestBluetoothAdapterProvider::GetFailStartDiscoveryAdapter() {
+ scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(GetBaseAdapter());
+
+ ON_CALL(*adapter, StartDiscoverySessionWithFilterRaw(_, _, _))
+ .WillByDefault(RunCallback<2 /* error_callback */>());
+
+ return adapter.Pass();
+}
+
+// static
+scoped_refptr<NiceMock<MockBluetoothAdapter>>
+LayoutTestBluetoothAdapterProvider::GetEmptyAdapter() {
+ scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(GetBaseAdapter());
+
+ ON_CALL(*adapter, StartDiscoverySessionWithFilterRaw(_, _, _))
+ .WillByDefault(RunCallbackWithResult<1 /* success_callback */>(
+ []() { return GetDiscoverySession(); }));
+
+ return adapter.Pass();
+}
+
+// static
+scoped_ptr<NiceMock<MockBluetoothDiscoverySession>>
+LayoutTestBluetoothAdapterProvider::GetDiscoverySession() {
+ scoped_ptr<NiceMock<MockBluetoothDiscoverySession>> discovery_session(
+ new NiceMock<MockBluetoothDiscoverySession>());
+
+ ON_CALL(*discovery_session, Stop(_, _))
+ .WillByDefault(RunCallback<0 /* success_callback */>());
+
+ return discovery_session.Pass();
+}
+
+// The functions after this haven't been updated to the new design yet.
+
+// static
+scoped_refptr<NiceMock<MockBluetoothAdapter>>
LayoutTestBluetoothAdapterProvider::GetScanFilterCheckingAdapter() {
scoped_refptr<NiceMock<MockBluetoothAdapter>> adapter(
new NiceMock<MockBluetoothAdapter>());
@@ -228,18 +267,6 @@ LayoutTestBluetoothAdapterProvider::GetUnconnectableDeviceAdapter() {
}
// static
-scoped_ptr<NiceMock<MockBluetoothDiscoverySession>>
-LayoutTestBluetoothAdapterProvider::GetDiscoverySession() {
- scoped_ptr<NiceMock<MockBluetoothDiscoverySession>> discovery_session(
- new NiceMock<MockBluetoothDiscoverySession>());
-
- ON_CALL(*discovery_session, Stop(_, _))
- .WillByDefault(RunCallback<0 /* success_callback */>());
-
- return discovery_session.Pass();
-}
-
-// static
scoped_ptr<NiceMock<MockBluetoothDevice>>
LayoutTestBluetoothAdapterProvider::GetEmptyDevice(
MockBluetoothAdapter* adapter,
« 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