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

Unified Diff: Source/modules/bluetooth/testing/BluetoothMock.cpp

Issue 650613005: bluetooth: Initial WebBluetooth & WebBluetoothError. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Abandoned initial approach implementing BluetoothMock in Blink. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/bluetooth/testing/BluetoothMock.cpp
diff --git a/Source/modules/bluetooth/testing/BluetoothMock.cpp b/Source/modules/bluetooth/testing/BluetoothMock.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c61d3f6c5eae79379bba6d87dd1e3c43d47f6169
--- /dev/null
+++ b/Source/modules/bluetooth/testing/BluetoothMock.cpp
@@ -0,0 +1,34 @@
+// 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 "config.h"
+#include "modules/bluetooth/testing/BluetoothMock.h"
+
+namespace blink {
+
+BluetoothMock::BluetoothMock()
+ : m_bluetoothRequestDeviceWillReject(false)
+ , m_bluetoothRequestDeviceRejectType(WebBluetoothError::NotFoundError)
+{
+}
+
+void BluetoothMock::bluetoothRequestDeviceWillReject(WebBluetoothError::ErrorType e)
+{
+ m_bluetoothRequestDeviceWillReject = true;
+ m_bluetoothRequestDeviceRejectType = e;
+}
+
+void BluetoothMock::requestDevice(WebBluetoothRequestDeviceCallbacks* callbacks)
+{
+ if (m_bluetoothRequestDeviceWillReject) {
+ WebBluetoothError* error = new WebBluetoothError(
+ m_bluetoothRequestDeviceRejectType, "");
+ callbacks->onError(error);
+ } else {
+ callbacks->onSuccess();
+ }
+}
+
+} // namespace blink
+

Powered by Google App Engine
This is Rietveld 408576698