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

Side by Side Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlaybackTest.cpp

Issue 2338173005: [Blink, RemotePlayback] Dismissing the dialog rejects with NotAllowedError. (Closed)
Patch Set: Fixed base class exports for WIN build Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/remoteplayback/RemotePlayback.h"
6
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/html/HTMLMediaElement.h"
10 #include "core/html/HTMLVideoElement.h"
11 #include "core/testing/DummyPageHolder.h"
12 #include "platform/testing/UnitTestHelpers.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace blink {
17
18 class MockFunction : public ScriptFunction {
19 public:
20 static MockFunction* create(ScriptState* scriptState) {
21 return new MockFunction(scriptState);
22 }
23
24 v8::Local<v8::Function> bind() { return bindToV8Function(); }
25
26 MOCK_METHOD1(call, ScriptValue(ScriptValue));
27
28 private:
29 explicit MockFunction(ScriptState* scriptState)
30 : ScriptFunction(scriptState) {}
31 };
32
33 class RemotePlaybackTest : public ::testing::Test {
34 protected:
35 void cancelPrompt(RemotePlayback* remotePlayback) {
36 remotePlayback->promptCancelled();
37 }
38 };
39
40 TEST_F(RemotePlaybackTest, PromptCancelledRejectsWithNotAllowedError) {
41 V8TestingScope scope;
42
43 auto pageHolder = DummyPageHolder::create();
44
45 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document());
46 RemotePlayback* remotePlayback = RemotePlayback::create(*element);
47
48 MockFunction* resolve = MockFunction::create(scope.getScriptState());
49 MockFunction* reject = MockFunction::create(scope.getScriptState());
50
51 EXPECT_CALL(*resolve, call(::testing::_)).Times(0);
52 EXPECT_CALL(*reject, call(::testing::_)).Times(1);
53
54 remotePlayback->prompt(scope.getScriptState())
55 .then(resolve->bind(), reject->bind());
56 cancelPrompt(remotePlayback);
57 }
58
59 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698