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

Side by Side Diff: content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.cc

Issue 1149883011: bluetooth: Browser-side implementation of readValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-get-characteristic-initial
Patch Set: Fix bad_messages.h and histrograms.xml 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h" 5 #include "content/shell/browser/layout_test/layout_test_bluetooth_adapter_provid er.h"
6 6
7 #include "device/bluetooth/bluetooth_adapter.h" 7 #include "device/bluetooth/bluetooth_adapter.h"
8 #include "device/bluetooth/bluetooth_device.h" 8 #include "device/bluetooth/bluetooth_device.h"
9 #include "device/bluetooth/bluetooth_discovery_session.h" 9 #include "device/bluetooth/bluetooth_discovery_session.h"
10 #include "device/bluetooth/bluetooth_uuid.h" 10 #include "device/bluetooth/bluetooth_uuid.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 ON_CALL(*empty_device, GetProductID()).WillByDefault(Return(1)); 171 ON_CALL(*empty_device, GetProductID()).WillByDefault(Return(1));
172 ON_CALL(*empty_device, GetDeviceID()).WillByDefault(Return(2)); 172 ON_CALL(*empty_device, GetDeviceID()).WillByDefault(Return(2));
173 173
174 BluetoothDevice::UUIDList list; 174 BluetoothDevice::UUIDList list;
175 list.push_back(BluetoothUUID("1800")); 175 list.push_back(BluetoothUUID("1800"));
176 list.push_back(BluetoothUUID("1801")); 176 list.push_back(BluetoothUUID("1801"));
177 ON_CALL(*empty_device, GetUUIDs()).WillByDefault(Return(list)); 177 ON_CALL(*empty_device, GetUUIDs()).WillByDefault(Return(list));
178 178
179 scoped_ptr<NiceMock<MockBluetoothGattService>> generic_access( 179 scoped_ptr<NiceMock<MockBluetoothGattService>> generic_access(
180 GetGattService(empty_device.get(), "1800" /* Generic Access */)); 180 GetGattService(empty_device.get(), "1800" /* Generic Access */));
181 generic_access->AddMockCharacteristic( 181 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> device_name(
182 GetGattCharacteristic(generic_access.get(), "2A00" /* Device Name */)); 182 GetGattCharacteristic(generic_access.get(), "2A00" /* Device Name */));
183 183
184 std::string value_str("Empty Mock Device name");
185 std::vector<uint8_t> value(value_str.begin(), value_str.end());
186 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _))
187 .WillByDefault(RunCallback<0>(value));
188 generic_access->AddMockCharacteristic(device_name.Pass());
189
184 scoped_ptr<NiceMock<MockBluetoothGattService>> generic_attribute( 190 scoped_ptr<NiceMock<MockBluetoothGattService>> generic_attribute(
185 GetGattService(empty_device.get(), "1801" /* Generic Attribute */)); 191 GetGattService(empty_device.get(), "1801" /* Generic Attribute */));
186 generic_attribute->AddMockCharacteristic(GetGattCharacteristic( 192 generic_attribute->AddMockCharacteristic(GetGattCharacteristic(
187 generic_attribute.get(), "2A05" /* Service Changed */)); 193 generic_attribute.get(), "2A05" /* Service Changed */));
188 194
189 empty_device->AddMockService(generic_access.Pass()); 195 empty_device->AddMockService(generic_access.Pass());
190 empty_device->AddMockService(generic_attribute.Pass()); 196 empty_device->AddMockService(generic_attribute.Pass());
191 197
192 // Using Invoke allows the device returned from this method to be futher 198 // Using Invoke allows the device returned from this method to be futher
193 // modified and have more services added to it. The call to ::GetGattServices 199 // modified and have more services added to it. The call to ::GetGattServices
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 LayoutTestBluetoothAdapterProvider::GetGattService(MockBluetoothDevice* device, 249 LayoutTestBluetoothAdapterProvider::GetGattService(MockBluetoothDevice* device,
244 const std::string& uuid) { 250 const std::string& uuid) {
245 scoped_ptr<NiceMock<MockBluetoothGattService>> service( 251 scoped_ptr<NiceMock<MockBluetoothGattService>> service(
246 new NiceMock<MockBluetoothGattService>( 252 new NiceMock<MockBluetoothGattService>(
247 device, uuid /* identifier */, BluetoothUUID(uuid), 253 device, uuid /* identifier */, BluetoothUUID(uuid),
248 true /* is_primary */, false /* is_local */)); 254 true /* is_primary */, false /* is_local */));
249 255
250 ON_CALL(*service, GetCharacteristics()) 256 ON_CALL(*service, GetCharacteristics())
251 .WillByDefault(Invoke(service.get(), 257 .WillByDefault(Invoke(service.get(),
252 &MockBluetoothGattService::GetMockCharacteristics)); 258 &MockBluetoothGattService::GetMockCharacteristics));
259
260 ON_CALL(*service, GetCharacteristic(_))
261 .WillByDefault(Invoke(service.get(),
262 &MockBluetoothGattService::GetMockCharacteristic));
263
253 return service.Pass(); 264 return service.Pass();
254 } 265 }
255 266
256 // static 267 // static
257 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> 268 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>>
258 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic( 269 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic(
259 MockBluetoothGattService* service, 270 MockBluetoothGattService* service,
260 const std::string& uuid) { 271 const std::string& uuid) {
261 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>( 272 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>(
262 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */, 273 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */,
263 NULL /* properties */, NULL /* permissions */)); 274 NULL /* properties */, NULL /* permissions */));
264 } 275 }
265 276
266 } // namespace content 277 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698