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

Side by Side Diff: content/child/bluetooth/web_bluetooth_impl.cc

Issue 702593002: bluetooth: Initial simple mock content::WebBluetoothImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: CONTENT_CHILD_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ Created 6 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/child/bluetooth/web_bluetooth_impl.h ('k') | content/content_child.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/child/bluetooth/web_bluetooth_impl.h"
6
7 namespace content {
8
9 WebBluetoothImpl::WebBluetoothImpl()
10 : m_bluetoothMockDataSet(MockData::NOT_MOCKING),
11 m_bluetoothRequestDeviceRejectType(
12 blink::WebBluetoothError::NotFoundError) {
13 }
14
15 void WebBluetoothImpl::requestDevice(
16 blink::WebBluetoothRequestDeviceCallbacks* callbacks) {
17 // Mock implementation of blink::WebBluetooth until a more complete
18 // implementation is built out.
19 switch (m_bluetoothMockDataSet) {
20 case MockData::NOT_MOCKING: {
21 blink::WebBluetoothError* error = new blink::WebBluetoothError(
22 blink::WebBluetoothError::NotFoundError, "");
23 callbacks->onError(error);
24 break;
25 }
26 case MockData::REJECT: {
27 blink::WebBluetoothError* error =
28 new blink::WebBluetoothError(m_bluetoothRequestDeviceRejectType, "");
29 callbacks->onError(error);
30 break;
31 }
32 case MockData::RESOLVE: {
33 callbacks->onSuccess();
34 break;
35 }
36 }
37 }
38
39 void WebBluetoothImpl::SetBluetoothMockDataSetForTesting(
40 const std::string& name) {
41 if (name == "RejectRequestDevice_NotFoundError") {
42 m_bluetoothMockDataSet = MockData::REJECT;
43 m_bluetoothRequestDeviceRejectType =
44 blink::WebBluetoothError::NotFoundError;
45 } else if (name == "RejectRequestDevice_SecurityError") {
46 m_bluetoothMockDataSet = MockData::REJECT;
47 m_bluetoothRequestDeviceRejectType =
48 blink::WebBluetoothError::SecurityError;
49 } else if (name == "ResolveRequestDevice_Empty") {
50 m_bluetoothMockDataSet = MockData::RESOLVE;
51 } else {
52 m_bluetoothMockDataSet = MockData::NOT_MOCKING;
53 }
54 }
55
56 } // namespace content
OLDNEW
« no previous file with comments | « content/child/bluetooth/web_bluetooth_impl.h ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698