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

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

Issue 1156573005: bluetooth: Browser-side implementation of getCharacteristic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-get-primary-service-initial
Patch Set: Fix histograms.xml and bad_messages.h merge conflict Created 5 years, 6 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 3c3dda085ed562654e58879c000ca5d54eca2361..7f3563fe98c6fe9414363da271b42ac815098454 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
@@ -23,6 +23,7 @@ using device::BluetoothUUID;
using device::MockBluetoothAdapter;
using device::MockBluetoothDevice;
using device::MockBluetoothDiscoverySession;
+using device::MockBluetoothGattCharacteristic;
using device::MockBluetoothGattConnection;
using device::MockBluetoothGattService;
using testing::Between;
@@ -64,7 +65,8 @@ ACTION_P(GetMockDevice, adapter) {
}
return NULL;
}
-}
+
+} // namespace
namespace content {
@@ -174,10 +176,18 @@ LayoutTestBluetoothAdapterProvider::GetEmptyDevice(
list.push_back(BluetoothUUID("1801"));
ON_CALL(*empty_device, GetUUIDs()).WillByDefault(Return(list));
- empty_device->AddMockService(
- GetMockService(empty_device.get(), "1800" /* Generic Access */));
- empty_device->AddMockService(
- GetMockService(empty_device.get(), "1801" /* Generic Attribute */));
+ scoped_ptr<NiceMock<MockBluetoothGattService>> generic_access(
+ GetGattService(empty_device.get(), "1800" /* Generic Access */));
+ generic_access->AddMockCharacteristic(
+ GetGattCharacteristic(generic_access.get(), "2A00" /* Device Name */));
+
+ scoped_ptr<NiceMock<MockBluetoothGattService>> generic_attribute(
+ GetGattService(empty_device.get(), "1801" /* Generic Attribute */));
+ generic_attribute->AddMockCharacteristic(GetGattCharacteristic(
+ generic_attribute.get(), "2A05" /* Service Changed */));
+
+ empty_device->AddMockService(generic_access.Pass());
+ empty_device->AddMockService(generic_attribute.Pass());
// Using Invoke allows the device returned from this method to be futher
// modified and have more services added to it. The call to ::GetGattServices
@@ -187,6 +197,13 @@ LayoutTestBluetoothAdapterProvider::GetEmptyDevice(
.WillByDefault(
Invoke(empty_device.get(), &MockBluetoothDevice::GetMockServices));
+ // The call to BluetoothDevice::GetGattService will invoke ::GetMockService
+ // which returns a service matching the identifier provided if the service
+ // was added to the mock.
+ ON_CALL(*empty_device, GetGattService(_))
+ .WillByDefault(
+ Invoke(empty_device.get(), &MockBluetoothDevice::GetMockService));
+
return empty_device.Pass();
}
@@ -223,11 +240,27 @@ LayoutTestBluetoothAdapterProvider::GetUnconnectableDevice(
// static
scoped_ptr<NiceMock<MockBluetoothGattService>>
-LayoutTestBluetoothAdapterProvider::GetMockService(MockBluetoothDevice* device,
+LayoutTestBluetoothAdapterProvider::GetGattService(MockBluetoothDevice* device,
const std::string& uuid) {
- return make_scoped_ptr(new NiceMock<MockBluetoothGattService>(
- device, uuid /* identifier */, BluetoothUUID(uuid), true /* is_primary */,
- false /* is_local */));
+ scoped_ptr<NiceMock<MockBluetoothGattService>> service(
+ new NiceMock<MockBluetoothGattService>(
+ device, uuid /* identifier */, BluetoothUUID(uuid),
+ true /* is_primary */, false /* is_local */));
+
+ ON_CALL(*service, GetCharacteristics())
+ .WillByDefault(Invoke(service.get(),
+ &MockBluetoothGattService::GetMockCharacteristics));
+ return service.Pass();
+}
+
+// static
+scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>>
+LayoutTestBluetoothAdapterProvider::GetGattCharacteristic(
+ MockBluetoothGattService* service,
+ const std::string& uuid) {
+ return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>(
+ service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */,
+ NULL /* properties */, NULL /* permissions */));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698