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

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 merge conflicts 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 scoped_ptr<NiceMock<MockBluetoothGattService>> generic_attribute( 184 std::string value_str("Empty Mock Device name");
185 GetGattService(empty_device.get(), "1801" /* Generic Attribute */)); 185 std::vector<uint8_t> value(value_str.begin(), value_str.end());
186 generic_attribute->AddMockCharacteristic(GetGattCharacteristic( 186 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _))
187 generic_attribute.get(), "2A05" /* Service Changed */)); 187 .WillByDefault(RunCallback<0>(value));
188
189 generic_access->AddMockCharacteristic(device_name.Pass());
190
191 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> reconnection_address(
192 GetGattCharacteristic(generic_access.get(),
193 "2A03" /* Reconnection Address */));
194
195 ON_CALL(*reconnection_address, ReadRemoteCharacteristic(_, _))
196 .WillByDefault(
197 RunCallback<1>(BluetoothGattService::GATT_ERROR_NOT_PERMITTED));
198
199 generic_access->AddMockCharacteristic(reconnection_address.Pass());
188 200
189 empty_device->AddMockService(generic_access.Pass()); 201 empty_device->AddMockService(generic_access.Pass());
190 empty_device->AddMockService(generic_attribute.Pass());
191 202
192 // Using Invoke allows the device returned from this method to be futher 203 // 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 204 // modified and have more services added to it. The call to ::GetGattServices
194 // will invoke ::GetMockServices, returning all services added up to that 205 // will invoke ::GetMockServices, returning all services added up to that
195 // time. 206 // time.
196 ON_CALL(*empty_device, GetGattServices()) 207 ON_CALL(*empty_device, GetGattServices())
197 .WillByDefault( 208 .WillByDefault(
198 Invoke(empty_device.get(), &MockBluetoothDevice::GetMockServices)); 209 Invoke(empty_device.get(), &MockBluetoothDevice::GetMockServices));
199 210
200 // The call to BluetoothDevice::GetGattService will invoke ::GetMockService 211 // The call to BluetoothDevice::GetGattService will invoke ::GetMockService
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 LayoutTestBluetoothAdapterProvider::GetGattService(MockBluetoothDevice* device, 254 LayoutTestBluetoothAdapterProvider::GetGattService(MockBluetoothDevice* device,
244 const std::string& uuid) { 255 const std::string& uuid) {
245 scoped_ptr<NiceMock<MockBluetoothGattService>> service( 256 scoped_ptr<NiceMock<MockBluetoothGattService>> service(
246 new NiceMock<MockBluetoothGattService>( 257 new NiceMock<MockBluetoothGattService>(
247 device, uuid /* identifier */, BluetoothUUID(uuid), 258 device, uuid /* identifier */, BluetoothUUID(uuid),
248 true /* is_primary */, false /* is_local */)); 259 true /* is_primary */, false /* is_local */));
249 260
250 ON_CALL(*service, GetCharacteristics()) 261 ON_CALL(*service, GetCharacteristics())
251 .WillByDefault(Invoke(service.get(), 262 .WillByDefault(Invoke(service.get(),
252 &MockBluetoothGattService::GetMockCharacteristics)); 263 &MockBluetoothGattService::GetMockCharacteristics));
264
265 ON_CALL(*service, GetCharacteristic(_))
266 .WillByDefault(Invoke(service.get(),
267 &MockBluetoothGattService::GetMockCharacteristic));
268
253 return service.Pass(); 269 return service.Pass();
254 } 270 }
255 271
256 // static 272 // static
257 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>> 273 scoped_ptr<NiceMock<MockBluetoothGattCharacteristic>>
258 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic( 274 LayoutTestBluetoothAdapterProvider::GetGattCharacteristic(
259 MockBluetoothGattService* service, 275 MockBluetoothGattService* service,
260 const std::string& uuid) { 276 const std::string& uuid) {
261 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>( 277 return make_scoped_ptr(new NiceMock<MockBluetoothGattCharacteristic>(
262 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */, 278 service, uuid /* identifier */, BluetoothUUID(uuid), false /* is_local */,
263 NULL /* properties */, NULL /* permissions */)); 279 NULL /* properties */, NULL /* permissions */));
264 } 280 }
265 281
266 } // namespace content 282 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698