Index: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp |
diff --git a/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..87bfdf0012bc2ccf42e4b311fe4e272f5ee87286 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp |
@@ -0,0 +1,59 @@ |
+// Copyright 2016 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/remoteplayback/RemotePlayback.h" |
+ |
+#include "bindings/core/v8/ExceptionStatePlaceholder.h" |
+#include "bindings/core/v8/V8BindingForTesting.h" |
+#include "core/html/HTMLMediaElement.h" |
+#include "core/html/HTMLVideoElement.h" |
+#include "core/testing/DummyPageHolder.h" |
+#include "platform/testing/UnitTestHelpers.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace blink { |
+ |
+class MockFunction : public ScriptFunction { |
+ public: |
+ static MockFunction* create(ScriptState* scriptState) { |
+ return new MockFunction(scriptState); |
+ } |
+ |
+ v8::Local<v8::Function> bind() { return bindToV8Function(); } |
+ |
+ MOCK_METHOD1(call, ScriptValue(ScriptValue)); |
+ |
+ private: |
+ explicit MockFunction(ScriptState* scriptState) |
+ : ScriptFunction(scriptState) {} |
+}; |
+ |
+class RemotePlaybackTest : public ::testing::Test { |
+ protected: |
+ void cancelPrompt(RemotePlayback* remotePlayback) { |
+ remotePlayback->promptCancelled(); |
+ } |
+}; |
+ |
+TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) { |
+ V8TestingScope scope; |
+ |
+ auto pageHolder = DummyPageHolder::create(); |
+ |
+ HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
+ RemotePlayback* remotePlayback = RemotePlayback::create(*element); |
+ |
+ MockFunction* resolve = MockFunction::create(scope.getScriptState()); |
+ MockFunction* reject = MockFunction::create(scope.getScriptState()); |
+ |
+ EXPECT_CALL(*resolve, call(::testing::_)).Times(0); |
+ EXPECT_CALL(*reject, call(::testing::_)).Times(1); |
+ |
+ remotePlayback->prompt(scope.getScriptState()) |
+ .then(resolve->bind(), reject->bind()); |
+ cancelPrompt(remotePlayback); |
+} |
+ |
+} // namespace blink |