OLD | NEW |
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 if (fake_adapter_name == "FailingGATTOperationsAdapter") | 272 if (fake_adapter_name == "FailingGATTOperationsAdapter") |
273 return GetFailingGATTOperationsAdapter(); | 273 return GetFailingGATTOperationsAdapter(); |
274 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") | 274 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") |
275 return GetSecondDiscoveryFindsHeartRateAdapter(); | 275 return GetSecondDiscoveryFindsHeartRateAdapter(); |
276 if (fake_adapter_name == "DeviceEventAdapter") | 276 if (fake_adapter_name == "DeviceEventAdapter") |
277 return GetDeviceEventAdapter(); | 277 return GetDeviceEventAdapter(); |
278 if (fake_adapter_name == "DevicesRemovedAdapter") | 278 if (fake_adapter_name == "DevicesRemovedAdapter") |
279 return GetDevicesRemovedAdapter(); | 279 return GetDevicesRemovedAdapter(); |
280 if (fake_adapter_name == "DelayedServicesDiscoveryAdapter") | 280 if (fake_adapter_name == "DelayedServicesDiscoveryAdapter") |
281 return GetDelayedServicesDiscoveryAdapter(); | 281 return GetDelayedServicesDiscoveryAdapter(); |
| 282 // DJKim |
| 283 if (fake_adapter_name == "StopDiscoveryAdapterDiscoveringChanged") |
| 284 return GetStopDiscoveryAdapterDiscoveringChanged(); |
282 if (fake_adapter_name.empty()) | 285 if (fake_adapter_name.empty()) |
283 return nullptr; | 286 return nullptr; |
284 // New adapters that can be used when fuzzing the Web Bluetooth API | 287 // New adapters that can be used when fuzzing the Web Bluetooth API |
285 // should also be added to | 288 // should also be added to |
286 // src/third_party/WebKit/Source/modules/ | 289 // src/third_party/WebKit/Source/modules/ |
287 // bluetooth/testing/clusterfuzz/constraints.py. | 290 // bluetooth/testing/clusterfuzz/constraints.py. |
288 | 291 |
289 NOTREACHED() << fake_adapter_name; | 292 NOTREACHED() << fake_adapter_name; |
290 return nullptr; | 293 return nullptr; |
291 } | 294 } |
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 device::BluetoothRemoteGattCharacteristic::PROPERTY_READ); | 1732 device::BluetoothRemoteGattCharacteristic::PROPERTY_READ); |
1730 | 1733 |
1731 ON_CALL(*error_descriptor, ReadRemoteDescriptor(_, _)) | 1734 ON_CALL(*error_descriptor, ReadRemoteDescriptor(_, _)) |
1732 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); | 1735 .WillByDefault(RunCallback<1 /* error_callback */>(error_code)); |
1733 | 1736 |
1734 characteristic->AddMockDescriptor(std::move(error_descriptor)); | 1737 characteristic->AddMockDescriptor(std::move(error_descriptor)); |
1735 | 1738 |
1736 return characteristic; | 1739 return characteristic; |
1737 } | 1740 } |
1738 | 1741 |
| 1742 // static |
| 1743 scoped_refptr<NiceMockBluetoothAdapter> |
| 1744 LayoutTestBluetoothAdapterProvider::GetStopDiscoveryAdapterDiscoveringChanged()
{ |
| 1745 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPoweredAdapter()); |
| 1746 NiceMockBluetoothAdapter* adapter_ptr = adapter.get(); |
| 1747 |
| 1748 EXPECT_CALL(*adapter, StartDiscoverySessionWithFilterRaw(_, _, _)) |
| 1749 .WillOnce(RunCallbackWithResult<1 /* success_callback */>( |
| 1750 []() { return GetDiscoverySession(); })) |
| 1751 .WillOnce( |
| 1752 RunCallbackWithResult<1 /* success_callback */>([adapter_ptr]() { |
| 1753 // In the second discovery session, have the adapter discover a new |
| 1754 // device, shortly after the session starts. |
| 1755 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1756 FROM_HERE, |
| 1757 base::Bind(&AddDevice, make_scoped_refptr(adapter_ptr), |
| 1758 base::Passed(GetHeartRateDevice(adapter_ptr)))); |
| 1759 return GetDiscoverySession(); |
| 1760 })); |
| 1761 |
| 1762 return adapter; |
| 1763 } |
| 1764 |
1739 // Notify sessions | 1765 // Notify sessions |
1740 | 1766 |
1741 // static | 1767 // static |
1742 std::unique_ptr<NiceMockBluetoothGattNotifySession> | 1768 std::unique_ptr<NiceMockBluetoothGattNotifySession> |
1743 LayoutTestBluetoothAdapterProvider::GetBaseGATTNotifySession( | 1769 LayoutTestBluetoothAdapterProvider::GetBaseGATTNotifySession( |
1744 base::WeakPtr<device::BluetoothRemoteGattCharacteristic> characteristic) { | 1770 base::WeakPtr<device::BluetoothRemoteGattCharacteristic> characteristic) { |
1745 auto session = | 1771 auto session = |
1746 base::MakeUnique<NiceMockBluetoothGattNotifySession>(characteristic); | 1772 base::MakeUnique<NiceMockBluetoothGattNotifySession>(characteristic); |
1747 | 1773 |
1748 ON_CALL(*session, Stop(_)) | 1774 ON_CALL(*session, Stop(_)) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 return BluetoothUUID(); | 1833 return BluetoothUUID(); |
1808 } | 1834 } |
1809 | 1835 |
1810 // static | 1836 // static |
1811 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { | 1837 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { |
1812 return BluetoothDevice::CanonicalizeAddress( | 1838 return BluetoothDevice::CanonicalizeAddress( |
1813 base::StringPrintf("%012" PRIx64, addr)); | 1839 base::StringPrintf("%012" PRIx64, addr)); |
1814 } | 1840 } |
1815 | 1841 |
1816 } // namespace content | 1842 } // namespace content |
OLD | NEW |