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

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

Issue 2554253002: bluetooth: web: Rename Blacklist to Blocklist (Closed)
Patch Set: Created 4 years 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 NiceMockBluetoothGattConnection; 56 NiceMockBluetoothGattConnection;
57 typedef testing::NiceMock<MockBluetoothGattService> 57 typedef testing::NiceMock<MockBluetoothGattService>
58 NiceMockBluetoothGattService; 58 NiceMockBluetoothGattService;
59 typedef testing::NiceMock<MockBluetoothGattNotifySession> 59 typedef testing::NiceMock<MockBluetoothGattNotifySession>
60 NiceMockBluetoothGattNotifySession; 60 NiceMockBluetoothGattNotifySession;
61 61
62 namespace { 62 namespace {
63 // Bluetooth UUIDs suitable to pass to BluetoothUUID(): 63 // Bluetooth UUIDs suitable to pass to BluetoothUUID():
64 // Services: 64 // Services:
65 const char kBatteryServiceUUID[] = "180f"; 65 const char kBatteryServiceUUID[] = "180f";
66 const char kBlacklistTestServiceUUID[] = "611c954a-263b-4f4a-aab6-01ddb953f985"; 66 const char kBlocklistTestServiceUUID[] = "611c954a-263b-4f4a-aab6-01ddb953f985";
67 const char kDeviceInformationServiceUUID[] = "180a"; 67 const char kDeviceInformationServiceUUID[] = "180a";
68 const char kGenericAccessServiceUUID[] = "1800"; 68 const char kGenericAccessServiceUUID[] = "1800";
69 const char kGlucoseServiceUUID[] = "1808"; 69 const char kGlucoseServiceUUID[] = "1808";
70 const char kHealthThermometerUUID[] = "1809"; 70 const char kHealthThermometerUUID[] = "1809";
71 const char kHeartRateServiceUUID[] = "180d"; 71 const char kHeartRateServiceUUID[] = "180d";
72 const char kHumanInterfaceDeviceServiceUUID[] = "1812"; 72 const char kHumanInterfaceDeviceServiceUUID[] = "1812";
73 const char kRequestDisconnectionServiceUUID[] = 73 const char kRequestDisconnectionServiceUUID[] =
74 "01d7d889-7451-419f-aeb8-d65e7b9277af"; 74 "01d7d889-7451-419f-aeb8-d65e7b9277af";
75 const char kTxPowerServiceUUID[] = "1804"; 75 const char kTxPowerServiceUUID[] = "1804";
76 // Characteristics: 76 // Characteristics:
77 const char kBlacklistExcludeReadsCharacteristicUUID[] = 77 const char kBlocklistExcludeReadsCharacteristicUUID[] =
78 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135"; 78 "bad1c9a2-9a5b-4015-8b60-1579bbbf2135";
79 const char kRequestDisconnectionCharacteristicUUID[] = 79 const char kRequestDisconnectionCharacteristicUUID[] =
80 "01d7d88a-7451-419f-aeb8-d65e7b9277af"; 80 "01d7d88a-7451-419f-aeb8-d65e7b9277af";
81 const char kBodySensorLocation[] = "2a38"; 81 const char kBodySensorLocation[] = "2a38";
82 const char kDeviceNameUUID[] = "2a00"; 82 const char kDeviceNameUUID[] = "2a00";
83 const char kMeasurementIntervalUUID[] = "2a21"; 83 const char kMeasurementIntervalUUID[] = "2a21";
84 const char kHeartRateMeasurementUUID[] = "2a37"; 84 const char kHeartRateMeasurementUUID[] = "2a37";
85 const char kSerialNumberStringUUID[] = "2a25"; 85 const char kSerialNumberStringUUID[] = "2a25";
86 const char kPeripheralPrivacyFlagUUID[] = "2a02"; 86 const char kPeripheralPrivacyFlagUUID[] = "2a02";
87 87
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 221 }
222 if (fake_adapter_name == "DisconnectingDuringStopNotifySessionAdapter") { 222 if (fake_adapter_name == "DisconnectingDuringStopNotifySessionAdapter") {
223 return GetStopNotifySessionFinishesAfterReconnectionAdapter( 223 return GetStopNotifySessionFinishesAfterReconnectionAdapter(
224 true /* disconnect */); 224 true /* disconnect */);
225 } 225 }
226 if (fake_adapter_name == 226 if (fake_adapter_name ==
227 "StopNotifySessionFinishesAfterReconnectionAdapter") { 227 "StopNotifySessionFinishesAfterReconnectionAdapter") {
228 return GetStopNotifySessionFinishesAfterReconnectionAdapter( 228 return GetStopNotifySessionFinishesAfterReconnectionAdapter(
229 false /* disconnect */); 229 false /* disconnect */);
230 } 230 }
231 if (fake_adapter_name == "BlacklistTestAdapter") 231 if (fake_adapter_name == "BlocklistTestAdapter")
232 return GetBlacklistTestAdapter(); 232 return GetBlocklistTestAdapter();
233 if (fake_adapter_name == "FailingConnectionsAdapter") 233 if (fake_adapter_name == "FailingConnectionsAdapter")
234 return GetFailingConnectionsAdapter(); 234 return GetFailingConnectionsAdapter();
235 if (fake_adapter_name == "FailingGATTOperationsAdapter") 235 if (fake_adapter_name == "FailingGATTOperationsAdapter")
236 return GetFailingGATTOperationsAdapter(); 236 return GetFailingGATTOperationsAdapter();
237 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") 237 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter")
238 return GetSecondDiscoveryFindsHeartRateAdapter(); 238 return GetSecondDiscoveryFindsHeartRateAdapter();
239 if (fake_adapter_name == "DeviceEventAdapter") 239 if (fake_adapter_name == "DeviceEventAdapter")
240 return GetDeviceEventAdapter(); 240 return GetDeviceEventAdapter();
241 if (fake_adapter_name == "DevicesRemovedAdapter") 241 if (fake_adapter_name == "DevicesRemovedAdapter")
242 return GetDevicesRemovedAdapter(); 242 return GetDevicesRemovedAdapter();
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 1067
1068 health_thermometer->AddMockCharacteristic(std::move(measurement_interval)); 1068 health_thermometer->AddMockCharacteristic(std::move(measurement_interval));
1069 device->AddMockService(std::move(health_thermometer)); 1069 device->AddMockService(std::move(health_thermometer));
1070 adapter->AddMockDevice(std::move(device)); 1070 adapter->AddMockDevice(std::move(device));
1071 1071
1072 return adapter; 1072 return adapter;
1073 } 1073 }
1074 1074
1075 // static 1075 // static
1076 scoped_refptr<NiceMockBluetoothAdapter> 1076 scoped_refptr<NiceMockBluetoothAdapter>
1077 LayoutTestBluetoothAdapterProvider::GetBlacklistTestAdapter() { 1077 LayoutTestBluetoothAdapterProvider::GetBlocklistTestAdapter() {
1078 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); 1078 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter());
1079 1079
1080 BluetoothDevice::UUIDList uuids; 1080 BluetoothDevice::UUIDList uuids;
1081 uuids.push_back(BluetoothUUID(kBlacklistTestServiceUUID)); 1081 uuids.push_back(BluetoothUUID(kBlocklistTestServiceUUID));
1082 uuids.push_back(BluetoothUUID(kDeviceInformationServiceUUID)); 1082 uuids.push_back(BluetoothUUID(kDeviceInformationServiceUUID));
1083 uuids.push_back(BluetoothUUID(kGenericAccessServiceUUID)); 1083 uuids.push_back(BluetoothUUID(kGenericAccessServiceUUID));
1084 uuids.push_back(BluetoothUUID(kHeartRateServiceUUID)); 1084 uuids.push_back(BluetoothUUID(kHeartRateServiceUUID));
1085 uuids.push_back(BluetoothUUID(kHumanInterfaceDeviceServiceUUID)); 1085 uuids.push_back(BluetoothUUID(kHumanInterfaceDeviceServiceUUID));
1086 1086
1087 std::unique_ptr<NiceMockBluetoothDevice> device( 1087 std::unique_ptr<NiceMockBluetoothDevice> device(
1088 GetConnectableDevice(adapter.get(), "Blacklist Test Device", uuids)); 1088 GetConnectableDevice(adapter.get(), "Blocklist Test Device", uuids));
1089 1089
1090 device->AddMockService(GetBlacklistTestService(device.get())); 1090 device->AddMockService(GetBlocklistTestService(device.get()));
1091 device->AddMockService(GetDeviceInformationService(device.get())); 1091 device->AddMockService(GetDeviceInformationService(device.get()));
1092 device->AddMockService(GetGenericAccessService(device.get())); 1092 device->AddMockService(GetGenericAccessService(device.get()));
1093 device->AddMockService(GetHeartRateService(adapter.get(), device.get())); 1093 device->AddMockService(GetHeartRateService(adapter.get(), device.get()));
1094 device->AddMockService(GetBaseGATTService("Human Interface Device", 1094 device->AddMockService(GetBaseGATTService("Human Interface Device",
1095 device.get(), 1095 device.get(),
1096 kHumanInterfaceDeviceServiceUUID)); 1096 kHumanInterfaceDeviceServiceUUID));
1097 adapter->AddMockDevice(std::move(device)); 1097 adapter->AddMockDevice(std::move(device));
1098 1098
1099 return adapter; 1099 return adapter;
1100 } 1100 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 1292
1293 ON_CALL(*service, GetCharacteristic(_)) 1293 ON_CALL(*service, GetCharacteristic(_))
1294 .WillByDefault(Invoke(service.get(), 1294 .WillByDefault(Invoke(service.get(),
1295 &MockBluetoothGattService::GetMockCharacteristic)); 1295 &MockBluetoothGattService::GetMockCharacteristic));
1296 1296
1297 return service; 1297 return service;
1298 } 1298 }
1299 1299
1300 // static 1300 // static
1301 std::unique_ptr<NiceMockBluetoothGattService> 1301 std::unique_ptr<NiceMockBluetoothGattService>
1302 LayoutTestBluetoothAdapterProvider::GetBlacklistTestService( 1302 LayoutTestBluetoothAdapterProvider::GetBlocklistTestService(
1303 device::MockBluetoothDevice* device) { 1303 device::MockBluetoothDevice* device) {
1304 std::unique_ptr<NiceMockBluetoothGattService> blacklist_test_service( 1304 std::unique_ptr<NiceMockBluetoothGattService> blocklist_test_service(
1305 GetBaseGATTService("Blacklist Test", device, kBlacklistTestServiceUUID)); 1305 GetBaseGATTService("Blocklist Test", device, kBlocklistTestServiceUUID));
1306 1306
1307 std::unique_ptr<NiceMockBluetoothGattCharacteristic> 1307 std::unique_ptr<NiceMockBluetoothGattCharacteristic>
1308 blacklist_exclude_reads_characteristic(GetBaseGATTCharacteristic( 1308 blocklist_exclude_reads_characteristic(GetBaseGATTCharacteristic(
1309 "Excluded Reads Characteristic", blacklist_test_service.get(), 1309 "Excluded Reads Characteristic", blocklist_test_service.get(),
1310 kBlacklistExcludeReadsCharacteristicUUID, 1310 kBlocklistExcludeReadsCharacteristicUUID,
1311 BluetoothRemoteGattCharacteristic::PROPERTY_READ | 1311 BluetoothRemoteGattCharacteristic::PROPERTY_READ |
1312 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE)); 1312 BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
1313 1313
1314 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect 1314 // Crash if ReadRemoteCharacteristic called. Not using GoogleMock's Expect
1315 // because this is used in layout tests that may not report a mock expectation 1315 // because this is used in layout tests that may not report a mock expectation
1316 // error correctly as a layout test failure. 1316 // error correctly as a layout test failure.
1317 ON_CALL(*blacklist_exclude_reads_characteristic, 1317 ON_CALL(*blocklist_exclude_reads_characteristic,
1318 ReadRemoteCharacteristic(_, _)) 1318 ReadRemoteCharacteristic(_, _))
1319 .WillByDefault( 1319 .WillByDefault(
1320 Invoke([](const BluetoothRemoteGattCharacteristic::ValueCallback&, 1320 Invoke([](const BluetoothRemoteGattCharacteristic::ValueCallback&,
1321 const BluetoothRemoteGattCharacteristic::ErrorCallback&) { 1321 const BluetoothRemoteGattCharacteristic::ErrorCallback&) {
1322 NOTREACHED(); 1322 NOTREACHED();
1323 })); 1323 }));
1324 1324
1325 // Write response. 1325 // Write response.
1326 ON_CALL(*blacklist_exclude_reads_characteristic, 1326 ON_CALL(*blocklist_exclude_reads_characteristic,
1327 WriteRemoteCharacteristic(_, _, _)) 1327 WriteRemoteCharacteristic(_, _, _))
1328 .WillByDefault(RunCallback<1 /* success callback */>()); 1328 .WillByDefault(RunCallback<1 /* success callback */>());
1329 1329
1330 blacklist_test_service->AddMockCharacteristic( 1330 blocklist_test_service->AddMockCharacteristic(
1331 std::move(blacklist_exclude_reads_characteristic)); 1331 std::move(blocklist_exclude_reads_characteristic));
1332 1332
1333 return blacklist_test_service; 1333 return blocklist_test_service;
1334 } 1334 }
1335 1335
1336 // static 1336 // static
1337 std::unique_ptr<NiceMockBluetoothGattService> 1337 std::unique_ptr<NiceMockBluetoothGattService>
1338 LayoutTestBluetoothAdapterProvider::GetDeviceInformationService( 1338 LayoutTestBluetoothAdapterProvider::GetDeviceInformationService(
1339 device::MockBluetoothDevice* device) { 1339 device::MockBluetoothDevice* device) {
1340 std::unique_ptr<NiceMockBluetoothGattService> device_information( 1340 std::unique_ptr<NiceMockBluetoothGattService> device_information(
1341 GetBaseGATTService("Device Information", device, 1341 GetBaseGATTService("Device Information", device,
1342 kDeviceInformationServiceUUID)); 1342 kDeviceInformationServiceUUID));
1343 1343
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 return BluetoothUUID(); 1666 return BluetoothUUID();
1667 } 1667 }
1668 1668
1669 // static 1669 // static
1670 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { 1670 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {
1671 return BluetoothDevice::CanonicalizeAddress( 1671 return BluetoothDevice::CanonicalizeAddress(
1672 base::StringPrintf("%012" PRIx64, addr)); 1672 base::StringPrintf("%012" PRIx64, addr));
1673 } 1673 }
1674 1674
1675 } // namespace content 1675 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698