OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/remoteplayback/RemotePlayback.h" | 5 #include "modules/remoteplayback/RemotePlayback.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
9 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" | 9 #include "bindings/modules/v8/RemotePlaybackAvailabilityCallback.h" |
| 10 #include "core/dom/DocumentUserGestureToken.h" |
10 #include "core/html/HTMLMediaElement.h" | 11 #include "core/html/HTMLMediaElement.h" |
11 #include "core/html/HTMLVideoElement.h" | 12 #include "core/html/HTMLVideoElement.h" |
12 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
13 #include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h" | 14 #include "modules/remoteplayback/HTMLMediaElementRemotePlayback.h" |
14 #include "platform/UserGestureIndicator.h" | 15 #include "platform/UserGestureIndicator.h" |
15 #include "platform/testing/UnitTestHelpers.h" | 16 #include "platform/testing/UnitTestHelpers.h" |
16 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" | 17 #include "public/platform/modules/remoteplayback/WebRemotePlaybackState.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | 69 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
69 RemotePlayback* remotePlayback = | 70 RemotePlayback* remotePlayback = |
70 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); | 71 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); |
71 | 72 |
72 MockFunction* resolve = MockFunction::create(scope.getScriptState()); | 73 MockFunction* resolve = MockFunction::create(scope.getScriptState()); |
73 MockFunction* reject = MockFunction::create(scope.getScriptState()); | 74 MockFunction* reject = MockFunction::create(scope.getScriptState()); |
74 | 75 |
75 EXPECT_CALL(*resolve, call(::testing::_)).Times(0); | 76 EXPECT_CALL(*resolve, call(::testing::_)).Times(0); |
76 EXPECT_CALL(*reject, call(::testing::_)).Times(1); | 77 EXPECT_CALL(*reject, call(::testing::_)).Times(1); |
77 | 78 |
78 UserGestureIndicator indicator( | 79 UserGestureIndicator indicator(DocumentUserGestureToken::create( |
79 UserGestureToken::create(UserGestureToken::NewGesture)); | 80 &pageHolder->document(), UserGestureToken::NewGesture)); |
80 remotePlayback->prompt().then(resolve->bind(), reject->bind()); | 81 remotePlayback->prompt().then(resolve->bind(), reject->bind()); |
81 cancelPrompt(remotePlayback); | 82 cancelPrompt(remotePlayback); |
82 } | 83 } |
83 | 84 |
84 TEST_F(RemotePlaybackTest, StateChangeEvents) { | 85 TEST_F(RemotePlaybackTest, StateChangeEvents) { |
85 V8TestingScope scope; | 86 V8TestingScope scope; |
86 | 87 |
87 auto pageHolder = DummyPageHolder::create(); | 88 auto pageHolder = DummyPageHolder::create(); |
88 | 89 |
89 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | 90 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); | 125 HTMLMediaElement* element = HTMLVideoElement::create(pageHolder->document()); |
125 RemotePlayback* remotePlayback = | 126 RemotePlayback* remotePlayback = |
126 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); | 127 HTMLMediaElementRemotePlayback::remote(scope.getScriptState(), *element); |
127 | 128 |
128 MockFunction* resolve = MockFunction::create(scope.getScriptState()); | 129 MockFunction* resolve = MockFunction::create(scope.getScriptState()); |
129 MockFunction* reject = MockFunction::create(scope.getScriptState()); | 130 MockFunction* reject = MockFunction::create(scope.getScriptState()); |
130 | 131 |
131 EXPECT_CALL(*resolve, call(::testing::_)).Times(0); | 132 EXPECT_CALL(*resolve, call(::testing::_)).Times(0); |
132 EXPECT_CALL(*reject, call(::testing::_)).Times(1); | 133 EXPECT_CALL(*reject, call(::testing::_)).Times(1); |
133 | 134 |
134 UserGestureIndicator indicator( | 135 UserGestureIndicator indicator(DocumentUserGestureToken::create( |
135 UserGestureToken::create(UserGestureToken::NewGesture)); | 136 &pageHolder->document(), UserGestureToken::NewGesture)); |
136 remotePlayback->prompt().then(resolve->bind(), reject->bind()); | 137 remotePlayback->prompt().then(resolve->bind(), reject->bind()); |
137 HTMLMediaElementRemotePlayback::setBooleanAttribute( | 138 HTMLMediaElementRemotePlayback::setBooleanAttribute( |
138 HTMLNames::disableremoteplaybackAttr, *element, true); | 139 HTMLNames::disableremoteplaybackAttr, *element, true); |
139 } | 140 } |
140 | 141 |
141 TEST_F(RemotePlaybackTest, DisableRemotePlaybackCancelsAvailabilityCallbacks) { | 142 TEST_F(RemotePlaybackTest, DisableRemotePlaybackCancelsAvailabilityCallbacks) { |
142 V8TestingScope scope; | 143 V8TestingScope scope; |
143 | 144 |
144 auto pageHolder = DummyPageHolder::create(); | 145 auto pageHolder = DummyPageHolder::create(); |
145 | 146 |
(...skipping 18 matching lines...) Expand all Loading... |
164 | 165 |
165 remotePlayback->watchAvailability(availabilityCallback) | 166 remotePlayback->watchAvailability(availabilityCallback) |
166 .then(watchResolve->bind(), watchReject->bind()); | 167 .then(watchResolve->bind(), watchReject->bind()); |
167 | 168 |
168 HTMLMediaElementRemotePlayback::setBooleanAttribute( | 169 HTMLMediaElementRemotePlayback::setBooleanAttribute( |
169 HTMLNames::disableremoteplaybackAttr, *element, true); | 170 HTMLNames::disableremoteplaybackAttr, *element, true); |
170 setAvailability(remotePlayback, true); | 171 setAvailability(remotePlayback, true); |
171 } | 172 } |
172 | 173 |
173 } // namespace blink | 174 } // namespace blink |
OLD | NEW |