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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/bluetooth/web_bluetooth_impl.cc
diff --git a/content/child/bluetooth/web_bluetooth_impl.cc b/content/child/bluetooth/web_bluetooth_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..406ae7d3a594141c9d079ee02c89586d2afd84a8
--- /dev/null
+++ b/content/child/bluetooth/web_bluetooth_impl.cc
@@ -0,0 +1,56 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/child/bluetooth/web_bluetooth_impl.h"
+
+namespace content {
+
+WebBluetoothImpl::WebBluetoothImpl()
+ : m_bluetoothMockDataSet(MockData::NOT_MOCKING),
+ m_bluetoothRequestDeviceRejectType(
+ blink::WebBluetoothError::NotFoundError) {
+}
+
+void WebBluetoothImpl::requestDevice(
+ blink::WebBluetoothRequestDeviceCallbacks* callbacks) {
+ // Mock implementation of blink::WebBluetooth until a more complete
+ // implementation is built out.
+ switch (m_bluetoothMockDataSet) {
+ case MockData::NOT_MOCKING: {
+ blink::WebBluetoothError* error = new blink::WebBluetoothError(
+ blink::WebBluetoothError::NotFoundError, "");
+ callbacks->onError(error);
+ break;
+ }
+ case MockData::REJECT: {
+ blink::WebBluetoothError* error =
+ new blink::WebBluetoothError(m_bluetoothRequestDeviceRejectType, "");
+ callbacks->onError(error);
+ break;
+ }
+ case MockData::RESOLVE: {
+ callbacks->onSuccess();
+ break;
+ }
+ }
+}
+
+void WebBluetoothImpl::SetBluetoothMockDataSetForTesting(
+ const std::string& name) {
+ if (name == "RejectRequestDevice_NotFoundError") {
+ m_bluetoothMockDataSet = MockData::REJECT;
+ m_bluetoothRequestDeviceRejectType =
+ blink::WebBluetoothError::NotFoundError;
+ } else if (name == "RejectRequestDevice_SecurityError") {
+ m_bluetoothMockDataSet = MockData::REJECT;
+ m_bluetoothRequestDeviceRejectType =
+ blink::WebBluetoothError::SecurityError;
+ } else if (name == "ResolveRequestDevice_Empty") {
+ m_bluetoothMockDataSet = MockData::RESOLVE;
+ } else {
+ m_bluetoothMockDataSet = MockData::NOT_MOCKING;
+ }
+}
+
+} // namespace content
« 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