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

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

Issue 1469783002: Cleanup: Correctly spell success(ful). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format media Created 5 years, 1 month 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/browser/safe_util_win.h ('k') | courgette/courgette.h » ('j') | 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return device; 102 return device;
103 } 103 }
104 return NULL; 104 return NULL;
105 } 105 }
106 106
107 std::set<BluetoothUUID> GetUUIDs( 107 std::set<BluetoothUUID> GetUUIDs(
108 const device::BluetoothDiscoveryFilter* filter) { 108 const device::BluetoothDiscoveryFilter* filter) {
109 std::set<BluetoothUUID> result; 109 std::set<BluetoothUUID> result;
110 filter->GetUUIDs(result); 110 filter->GetUUIDs(result);
111 return result; 111 return result;
112 }; 112 }
113 113
114 // Notifies the adapter's observers that the services have been discovered. 114 // Notifies the adapter's observers that the services have been discovered.
115 void NotifyServicesDiscovered(MockBluetoothAdapter* adapter, 115 void NotifyServicesDiscovered(MockBluetoothAdapter* adapter,
116 MockBluetoothDevice* device) { 116 MockBluetoothDevice* device) {
117 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter->GetObservers(), 117 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter->GetObservers(),
118 GattServicesDiscovered(adapter, device)); 118 GattServicesDiscovered(adapter, device));
119 } 119 }
120 120
121 } // namespace 121 } // namespace
122 122
123 namespace content { 123 namespace content {
124 124
125 // static 125 // static
126 scoped_refptr<BluetoothAdapter> 126 scoped_refptr<BluetoothAdapter>
127 LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter( 127 LayoutTestBluetoothAdapterProvider::GetBluetoothAdapter(
128 const std::string& fake_adapter_name) { 128 const std::string& fake_adapter_name) {
129 if (fake_adapter_name == "BaseAdapter") 129 if (fake_adapter_name == "BaseAdapter")
130 return GetBaseAdapter(); 130 return GetBaseAdapter();
131 else if (fake_adapter_name == "NotPresentAdapter") 131 if (fake_adapter_name == "NotPresentAdapter")
132 return GetNotPresentAdapter(); 132 return GetNotPresentAdapter();
133 else if (fake_adapter_name == "NotPoweredAdapter") 133 if (fake_adapter_name == "NotPoweredAdapter")
134 return GetNotPoweredAdapter(); 134 return GetNotPoweredAdapter();
135 else if (fake_adapter_name == "ScanFilterCheckingAdapter") 135 if (fake_adapter_name == "ScanFilterCheckingAdapter")
136 return GetScanFilterCheckingAdapter(); 136 return GetScanFilterCheckingAdapter();
137 else if (fake_adapter_name == "EmptyAdapter") 137 if (fake_adapter_name == "EmptyAdapter")
138 return GetEmptyAdapter(); 138 return GetEmptyAdapter();
139 else if (fake_adapter_name == "FailStartDiscoveryAdapter") 139 if (fake_adapter_name == "FailStartDiscoveryAdapter")
140 return GetFailStartDiscoveryAdapter(); 140 return GetFailStartDiscoveryAdapter();
141 else if (fake_adapter_name == "GlucoseHeartRateAdapter") 141 if (fake_adapter_name == "GlucoseHeartRateAdapter")
142 return GetGlucoseHeartRateAdapter(); 142 return GetGlucoseHeartRateAdapter();
143 else if (fake_adapter_name == "UnicodeDeviceAdapter") 143 if (fake_adapter_name == "UnicodeDeviceAdapter")
144 return GetUnicodeDeviceAdapter(); 144 return GetUnicodeDeviceAdapter();
145 else if (fake_adapter_name == "MissingServiceHeartRateAdapter") 145 if (fake_adapter_name == "MissingServiceHeartRateAdapter")
146 return GetMissingServiceHeartRateAdapter(); 146 return GetMissingServiceHeartRateAdapter();
147 else if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter") 147 if (fake_adapter_name == "MissingCharacteristicHeartRateAdapter")
148 return GetMissingCharacteristicHeartRateAdapter(); 148 return GetMissingCharacteristicHeartRateAdapter();
149 else if (fake_adapter_name == "HeartRateAdapter") 149 if (fake_adapter_name == "HeartRateAdapter")
150 return GetHeartRateAdapter(); 150 return GetHeartRateAdapter();
151 else if (fake_adapter_name == "FailingConnectionsAdapter") 151 if (fake_adapter_name == "FailingConnectionsAdapter")
152 return GetFailingConnectionsAdapter(); 152 return GetFailingConnectionsAdapter();
153 else if (fake_adapter_name == "FailingGATTOperationsAdapter") 153 if (fake_adapter_name == "FailingGATTOperationsAdapter")
154 return GetFailingGATTOperationsAdapter(); 154 return GetFailingGATTOperationsAdapter();
155 else if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter") 155 if (fake_adapter_name == "SecondDiscoveryFindsHeartRateAdapter")
156 return GetSecondDiscoveryFindsHeartRateAdapter(); 156 return GetSecondDiscoveryFindsHeartRateAdapter();
157 else if (fake_adapter_name == "DelayedServicesDiscoveryAdapter") 157 if (fake_adapter_name == "DelayedServicesDiscoveryAdapter")
158 return GetDelayedServicesDiscoveryAdapter(); 158 return GetDelayedServicesDiscoveryAdapter();
159 else if (fake_adapter_name == "") 159 if (fake_adapter_name.empty())
160 return nullptr; 160 return nullptr;
161 161
162 if (base::StartsWith(fake_adapter_name, "PowerValueAdapter", 162 if (base::StartsWith(fake_adapter_name, "PowerValueAdapter",
163 base::CompareCase::SENSITIVE)) { 163 base::CompareCase::SENSITIVE)) {
164 std::vector<StringPiece> args = 164 std::vector<StringPiece> args =
165 base::SplitStringPiece(fake_adapter_name, ":", base::KEEP_WHITESPACE, 165 base::SplitStringPiece(fake_adapter_name, ":", base::KEEP_WHITESPACE,
166 base::SPLIT_WANT_NONEMPTY); 166 base::SPLIT_WANT_NONEMPTY);
167 DCHECK(args[0] == "PowerValueAdapter"); 167 DCHECK(args[0] == "PowerValueAdapter");
168 DCHECK(args.size() == 3) << "Should contain AdapterName:TxPower:RSSI"; 168 DCHECK(args.size() == 3) << "Should contain AdapterName:TxPower:RSSI";
169 169
(...skipping 17 matching lines...) Expand all
187 DCHECK(args.size() == 3) 187 DCHECK(args.size() == 3)
188 << "Should contain AdapterName:TxPowerPresent:RSSIPResent"; 188 << "Should contain AdapterName:TxPowerPresent:RSSIPResent";
189 DCHECK(args[1] == "true" || args[1] == "false"); 189 DCHECK(args[1] == "true" || args[1] == "false");
190 DCHECK(args[2] == "true" || args[2] == "false"); 190 DCHECK(args[2] == "true" || args[2] == "false");
191 191
192 return GetPowerPresenceAdapter(args[1] == "true" /* tx_power_present */, 192 return GetPowerPresenceAdapter(args[1] == "true" /* tx_power_present */,
193 args[2] == "true" /* rssi_present */); 193 args[2] == "true" /* rssi_present */);
194 } 194 }
195 195
196 NOTREACHED() << fake_adapter_name; 196 NOTREACHED() << fake_adapter_name;
197 return NULL; 197 return nullptr;
198 } 198 }
199 199
200 // Adapters 200 // Adapters
201 201
202 // static 202 // static
203 scoped_refptr<NiceMockBluetoothAdapter> 203 scoped_refptr<NiceMockBluetoothAdapter>
204 LayoutTestBluetoothAdapterProvider::GetBaseAdapter() { 204 LayoutTestBluetoothAdapterProvider::GetBaseAdapter() {
205 scoped_refptr<NiceMockBluetoothAdapter> adapter( 205 scoped_refptr<NiceMockBluetoothAdapter> adapter(
206 new NiceMockBluetoothAdapter()); 206 new NiceMockBluetoothAdapter());
207 207
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // Read response. 690 // Read response.
691 std::string device_name_str = device->GetDeviceName(); 691 std::string device_name_str = device->GetDeviceName();
692 std::vector<uint8_t> device_name_value(device_name_str.begin(), 692 std::vector<uint8_t> device_name_value(device_name_str.begin(),
693 device_name_str.end()); 693 device_name_str.end());
694 694
695 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _)) 695 ON_CALL(*device_name, ReadRemoteCharacteristic(_, _))
696 .WillByDefault(RunCallback<0>(device_name_value)); 696 .WillByDefault(RunCallback<0>(device_name_value));
697 697
698 // Write response. 698 // Write response.
699 ON_CALL(*device_name, WriteRemoteCharacteristic(_, _, _)) 699 ON_CALL(*device_name, WriteRemoteCharacteristic(_, _, _))
700 .WillByDefault(RunCallback<1 /* sucess callback */>()); 700 .WillByDefault(RunCallback<1 /* success callback */>());
701 701
702 generic_access->AddMockCharacteristic(device_name.Pass()); 702 generic_access->AddMockCharacteristic(device_name.Pass());
703 703
704 return generic_access; 704 return generic_access;
705 } 705 }
706 706
707 // static 707 // static
708 scoped_ptr<NiceMockBluetoothGattService> 708 scoped_ptr<NiceMockBluetoothGattService>
709 LayoutTestBluetoothAdapterProvider::GetHeartRateService( 709 LayoutTestBluetoothAdapterProvider::GetHeartRateService(
710 MockBluetoothAdapter* adapter, 710 MockBluetoothAdapter* adapter,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias); 829 return base::StringPrintf("%08x-97e5-4cd7-b9f1-f5a427670c59", alias);
830 } 830 }
831 831
832 // static 832 // static
833 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) { 833 std::string LayoutTestBluetoothAdapterProvider::makeMACAddress(uint64_t addr) {
834 return BluetoothDevice::CanonicalizeAddress( 834 return BluetoothDevice::CanonicalizeAddress(
835 base::StringPrintf("%012" PRIx64, addr)); 835 base::StringPrintf("%012" PRIx64, addr));
836 } 836 }
837 837
838 } // namespace content 838 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/safe_util_win.h ('k') | courgette/courgette.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698