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

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

Issue 1464443002: bluetooth: android: Add BluetoothDevice::ConnectErrorCode enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: VI Created 4 years, 11 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 <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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 adapter->AddMockDevice(std::move(device)); 481 adapter->AddMockDevice(std::move(device));
482 482
483 return adapter; 483 return adapter;
484 } 484 }
485 485
486 // static 486 // static
487 scoped_refptr<NiceMockBluetoothAdapter> 487 scoped_refptr<NiceMockBluetoothAdapter>
488 LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() { 488 LayoutTestBluetoothAdapterProvider::GetFailingConnectionsAdapter() {
489 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter()); 489 scoped_refptr<NiceMockBluetoothAdapter> adapter(GetEmptyAdapter());
490 490
491 for (int error = BluetoothDevice::ERROR_UNKNOWN; 491 for (int error = 0; error < BluetoothDevice::NUM_CONNECT_ERROR_CODES;
492 error <= BluetoothDevice::ERROR_UNSUPPORTED_DEVICE; error++) { 492 error++) {
493 adapter->AddMockDevice(GetUnconnectableDevice( 493 adapter->AddMockDevice(GetUnconnectableDevice(
494 adapter.get(), static_cast<BluetoothDevice::ConnectErrorCode>(error))); 494 adapter.get(), static_cast<BluetoothDevice::ConnectErrorCode>(error)));
495 } 495 }
496 496
497 return adapter; 497 return adapter;
498 } 498 }
499 499
500 // static 500 // static
501 scoped_refptr<NiceMockBluetoothAdapter> 501 scoped_refptr<NiceMockBluetoothAdapter>
502 LayoutTestBluetoothAdapterProvider::GetFailingGATTOperationsAdapter() { 502 LayoutTestBluetoothAdapterProvider::GetFailingGATTOperationsAdapter() {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 } 825 }
826 826
827 // Helper functions 827 // Helper functions
828 828
829 // static 829 // static
830 std::string LayoutTestBluetoothAdapterProvider::errorUUID(uint32_t alias) { 830 std::string LayoutTestBluetoothAdapterProvider::errorUUID(uint32_t alias) {
831 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias); 831 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias);
832 } 832 }
833 833
834 // static 834 // static
835 BluetoothUUID LayoutTestBluetoothAdapterProvider::connectErrorUUID(
836 BluetoothDevice::ConnectErrorCode error_code) {
837 // Case values listed in alphabetical order.
838 // Associated UUIDs are defined in layout tests and should remain stable
839 // even if BluetoothDevice enum values change.
840 switch (error_code) {
841 case BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID:
842 return BluetoothUUID("0008");
843 case BluetoothDevice::ERROR_AUTH_CANCELED:
844 return BluetoothUUID("0004");
845 case BluetoothDevice::ERROR_AUTH_FAILED:
846 return BluetoothUUID("0003");
847 case BluetoothDevice::ERROR_AUTH_REJECTED:
848 return BluetoothUUID("0005");
849 case BluetoothDevice::ERROR_AUTH_TIMEOUT:
850 return BluetoothUUID("0006");
851 case BluetoothDevice::ERROR_CONNECTION_CONGESTED:
852 return BluetoothUUID("0009");
853 case BluetoothDevice::ERROR_FAILED:
854 return BluetoothUUID("0002");
855 case BluetoothDevice::ERROR_INPROGRESS:
856 return BluetoothUUID("0001");
857 case BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION:
858 return BluetoothUUID("000a");
859 case BluetoothDevice::ERROR_OFFSET_INVALID:
860 return BluetoothUUID("000b");
861 case BluetoothDevice::ERROR_READ_NOT_PERMITTED:
862 return BluetoothUUID("000c");
863 case BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED:
864 return BluetoothUUID("000d");
865 case BluetoothDevice::ERROR_UNKNOWN:
866 return BluetoothUUID("0000");
867 case BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
868 return BluetoothUUID("0007");
869 case BluetoothDevice::ERROR_WRITE_NOT_PERMITTED:
870 return BluetoothUUID("000e");
871 case BluetoothDevice::NUM_CONNECT_ERROR_CODES:
872 NOTREACHED();
873 return BluetoothUUID();
874 }
875 NOTREACHED();
876 return BluetoothUUID();
877 }
878
879 // static
835 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { 880 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {
836 return BluetoothDevice::CanonicalizeAddress( 881 return BluetoothDevice::CanonicalizeAddress(
837 base::StringPrintf("%012" PRIx64, addr)); 882 base::StringPrintf("%012" PRIx64, addr));
838 } 883 }
839 884
840 } // namespace content 885 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698