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

Unified Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp

Issue 2338173005: [Blink, RemotePlayback] Dismissing the dialog rejects with NotAllowedError. (Closed)
Patch Set: Added modules export to RemotePlayback Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9bb5f0090ed0cf9b4179445bdb3dee57ac3aa783
--- /dev/null
+++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp
@@ -0,0 +1,62 @@
+// 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/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:
+ explicit MockFunction(ScriptState* scriptState) : ScriptFunction(scriptState)
+ {
+ }
+
+ MOCK_METHOD1(call, ScriptValue(ScriptValue));
+
+ v8::Local<v8::Function> bind()
+ {
+ return bindToV8Function();
+ }
+};
+
+class RemotePlaybackTest : public ::testing::Test {
+protected:
+ void cancelPrompt(RemotePlayback* remotePlayback)
+ {
+ remotePlayback->promptCancelled();
+ };
mlamouri (slow - plz ping) 2016/10/01 14:56:30 Don't think this ; is needed.
whywhat 2016/10/04 19:23:45 Done.
+};
+
+TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError)
+{
+ auto pageHolder = DummyPageHolder::create();
+ auto documentBody = pageHolder->document().body();
mlamouri (slow - plz ping) 2016/10/01 14:56:30 style: I'm not 100% sure this is style-required bu
whywhat 2016/10/04 19:23:45 DummyPageHolder::create seems fine (returns a smar
+ documentBody->setInnerHTML("<video>", ASSERT_NO_EXCEPTION);
+ testing::runPendingTasks();
+
+ HTMLMediaElement* element = toHTMLMediaElement(documentBody->firstChild());
mlamouri (slow - plz ping) 2016/10/01 14:56:30 Instead of adding a video element to the document
whywhat 2016/10/04 19:23:45 Yep, that's better.
+ auto remotePlayback = RemotePlayback::create(*element);
mlamouri (slow - plz ping) 2016/10/01 14:56:30 ditto
whywhat 2016/10/04 19:23:45 Done.
+
+ V8TestingScope scope;
+
+ MockFunction resolve(scope.getScriptState());
+ MockFunction reject(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
« no previous file with comments | « third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698