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

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

Issue 2856093002: bluetooth: Clean up unused fake adapters (Closed)
Patch Set: Merge branch 'bluetooth-simulate-fake-central' into bluetooth-cleanup-unused-adapters Created 3 years, 7 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
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } // namespace 167 } // namespace
168 168
169 namespace content { 169 namespace content {
170 170
171 // static 171 // static
172 scoped_refptr<BluetoothAdapter> 172 scoped_refptr<BluetoothAdapter>
173 LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter( 173 LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
174 const std::string& fake_adapter_name) { 174 const std::string& fake_adapter_name) {
175 if (fake_adapter_name == "BaseAdapter") 175 if (fake_adapter_name == "BaseAdapter")
176 return GetBaseAdapter(); 176 return GetBaseAdapter();
177 if (fake_adapter_name == "NotPresentAdapter")
178 return GetNotPresentAdapter();
179 if (fake_adapter_name == "NotPoweredAdapter")
180 return GetNotPoweredAdapter();
181 if (fake_adapter_name == "ScanFilterCheckingAdapter") 177 if (fake_adapter_name == "ScanFilterCheckingAdapter")
182 return GetScanFilterCheckingAdapter(); 178 return GetScanFilterCheckingAdapter();
183 if (fake_adapter_name == "EmptyAdapter") 179 if (fake_adapter_name == "EmptyAdapter")
184 return GetEmptyAdapter(); 180 return GetEmptyAdapter();
185 if (fake_adapter_name == "FailStartDiscoveryAdapter") 181 if (fake_adapter_name == "FailStartDiscoveryAdapter")
186 return GetFailStartDiscoveryAdapter(); 182 return GetFailStartDiscoveryAdapter();
187 if (fake_adapter_name == "GlucoseHeartRateAdapter") 183 if (fake_adapter_name == "GlucoseHeartRateAdapter")
188 return GetGlucoseHeartRateAdapter(); 184 return GetGlucoseHeartRateAdapter();
189 if (fake_adapter_name == "UnicodeDeviceAdapter") 185 if (fake_adapter_name == "UnicodeDeviceAdapter")
190 return GetUnicodeDeviceAdapter(); 186 return GetUnicodeDeviceAdapter();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 scoped_refptr<NiceMockBluetoothAdapter> 290 scoped_refptr<NiceMockBluetoothAdapter>
295 LayoutTestBluetoothAdapterProvider::GetPresentAdapter() { 291 LayoutTestBluetoothAdapterProvider::GetPresentAdapter() {
296 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetBaseAdapter()); 292 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetBaseAdapter());
297 ON_CALL(*adapter, IsPresent()).WillByDefault(Return(true)); 293 ON_CALL(*adapter, IsPresent()).WillByDefault(Return(true));
298 294
299 return adapter; 295 return adapter;
300 } 296 }
301 297
302 // static 298 // static
303 scoped_refptr<NiceMockBluetoothAdapter> 299 scoped_refptr<NiceMockBluetoothAdapter>
304 LayoutTestBluetoothAdapterProvider::GetNotPresentAdapter() {
305 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetBaseAdapter());
306 ON_CALL(*adapter, IsPresent()).WillByDefault(Return(false));
307
308 return adapter;
309 }
310
311 // static
312 scoped_refptr<NiceMockBluetoothAdapter>
313 LayoutTestBluetoothAdapterProvider::GetPoweredAdapter() { 300 LayoutTestBluetoothAdapterProvider::GetPoweredAdapter() {
314 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPresentAdapter()); 301 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPresentAdapter());
315 ON_CALL(*adapter, IsPowered()).WillByDefault(Return(true)); 302 ON_CALL(*adapter, IsPowered()).WillByDefault(Return(true));
316 303
317 return adapter; 304 return adapter;
318 } 305 }
319 306
320 // static 307 // static
321 scoped_refptr<NiceMockBluetoothAdapter> 308 scoped_refptr<NiceMockBluetoothAdapter>
322 LayoutTestBluetoothAdapterProvider::GetNotPoweredAdapter() {
323 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPresentAdapter());
324 ON_CALL(*adapter, IsPowered()).WillByDefault(Return(false));
325
326 return adapter;
327 }
328
329 // static
330 scoped_refptr<NiceMockBluetoothAdapter>
331 LayoutTestBluetoothAdapterProvider::GetScanFilterCheckingAdapter() { 309 LayoutTestBluetoothAdapterProvider::GetScanFilterCheckingAdapter() {
332 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPoweredAdapter()); 310 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetPoweredAdapter());
333 MockBluetoothAdapter* adapter_ptr = adapter.get(); 311 MockBluetoothAdapter* adapter_ptr = adapter.get();
334 312
335 // This fails the test with an error message listing actual and expected UUIDs 313 // This fails the test with an error message listing actual and expected UUIDs
336 // if StartDiscoverySessionWithFilter() is called with the wrong argument. 314 // if StartDiscoverySessionWithFilter() is called with the wrong argument.
337 EXPECT_CALL( 315 EXPECT_CALL(
338 *adapter, 316 *adapter,
339 StartDiscoverySessionWithFilterRaw( 317 StartDiscoverySessionWithFilterRaw(
340 ResultOf(&GetUUIDs, ElementsAre(BluetoothUUID(kGlucoseServiceUUID), 318 ResultOf(&GetUUIDs, ElementsAre(BluetoothUUID(kGlucoseServiceUUID),
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias); 1717 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias);
1740 } 1718 }
1741 1719
1742 // static 1720 // static
1743 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { 1721 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {
1744 return BluetoothDevice::CanonicalizeAddress( 1722 return BluetoothDevice::CanonicalizeAddress(
1745 base::StringPrintf("%012" PRIx64, addr)); 1723 base::StringPrintf("%012" PRIx64, addr));
1746 } 1724 }
1747 1725
1748 } // namespace content 1726 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_bluetooth_adapter_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698