Index: third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp |
diff --git a/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp b/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..313c70c69ce5530ddeb040587c9b9949da314095 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/bluetooth/FakeLECentralManager.cpp |
@@ -0,0 +1,60 @@ |
+// Copyright 2017 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 "modules/bluetooth/FakeLECentralManager.h" |
+ |
+#include "bindings/core/v8/ScriptPromise.h" |
+#include "bindings/core/v8/ScriptPromiseResolver.h" |
+#include "core/dom/DOMException.h" |
+#include "modules/bluetooth/FakeLEPeripheral.h" |
+#include "modules/bluetooth/FakeCentralOptions.h" |
+ |
+namespace blink { |
+ |
+FakeLECentralManager::FakeLECentralManager() { |
+} |
+ |
+ScriptPromise FakeLECentralManager::simulateAdvertisementReceived(ScriptState* scriptState, const ScanResult&) { |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ resolver->resolve(FakeLEPeripheral::create()); |
+ return promise; |
+} |
+ |
+ScriptPromise FakeLECentralManager::addConnectedLEPeripheral(ScriptState* scriptState, const FakeLEPeripheralOptions&) { |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ resolver->resolve(FakeLEPeripheral::create()); |
+ return promise; |
+} |
+ |
+ScriptPromise FakeLECentralManager::setState(ScriptState* scriptState, String newState) { |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ resolver->resolve(); |
+ return promise; |
+} |
+ |
+ScriptPromise FakeLECentralManager::getStartScanCalls(ScriptState* scriptState) { |
+ return ScriptPromise::rejectWithDOMException( |
+ scriptState, DOMException::create(NotSupportedError, "Not supported")); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ resolver->resolve(0); |
+ return promise; |
+} |
+ |
+ScriptPromise FakeLECentralManager::getStopScanCalls(ScriptState* scriptState) { |
+ return ScriptPromise::rejectWithDOMException( |
+ scriptState, DOMException::create(NotSupportedError, "Not supported")); |
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
+ ScriptPromise promise = resolver->promise(); |
+ resolver->resolve(1); |
+ return promise; |
+} |
+ |
+DEFINE_TRACE(FakeLECentralManager) { |
+} |
+ |
+} // namespace blink |