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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsOrientationLockDelegateTest.cpp

Issue 2795783004: Move core MediaControls implementation to modules/media_controls/. (Closed)
Patch Set: rebase Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/modules/media_controls/MediaControlsOrientationLockDelegate.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/html/shadow/MediaControlsOrientationLockDelegate.h" 5 #include "modules/media_controls/MediaControlsOrientationLockDelegate.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/DocumentUserGestureToken.h" 8 #include "core/dom/DocumentUserGestureToken.h"
9 #include "core/dom/Fullscreen.h" 9 #include "core/dom/Fullscreen.h"
10 #include "core/frame/ScreenOrientationController.h" 10 #include "core/frame/ScreenOrientationController.h"
11 #include "core/html/HTMLAudioElement.h" 11 #include "core/html/HTMLAudioElement.h"
12 #include "core/html/HTMLVideoElement.h" 12 #include "core/html/HTMLVideoElement.h"
13 #include "core/html/shadow/MediaControls.h"
14 #include "core/loader/EmptyClients.h" 13 #include "core/loader/EmptyClients.h"
15 #include "core/testing/DummyPageHolder.h" 14 #include "core/testing/DummyPageHolder.h"
15 #include "modules/media_controls/MediaControlsImpl.h"
16 #include "platform/UserGestureIndicator.h" 16 #include "platform/UserGestureIndicator.h"
17 #include "platform/testing/EmptyWebMediaPlayer.h" 17 #include "platform/testing/EmptyWebMediaPlayer.h"
18 #include "platform/testing/UnitTestHelpers.h" 18 #include "platform/testing/UnitTestHelpers.h"
19 #include "public/platform/WebSize.h" 19 #include "public/platform/WebSize.h"
20 #include "public/platform/modules/screen_orientation/WebLockOrientationCallback. h" 20 #include "public/platform/modules/screen_orientation/WebLockOrientationCallback. h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using ::testing::_; 24 using ::testing::_;
25 using ::testing::Return; 25 using ::testing::Return;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void TearDown() override { 127 void TearDown() override {
128 ::testing::Mock::VerifyAndClear(&screenOrientationController()); 128 ::testing::Mock::VerifyAndClear(&screenOrientationController());
129 129
130 RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled( 130 RuntimeEnabledFeatures::setVideoFullscreenOrientationLockEnabled(
131 m_previousVideoFullscreenOrientationLockValue); 131 m_previousVideoFullscreenOrientationLockValue);
132 } 132 }
133 133
134 static bool hasDelegate(const MediaControls& mediaControls) { 134 static bool hasDelegate(const MediaControls& mediaControls) {
135 return !!mediaControls.m_orientationLockDelegate; 135 return !!static_cast<const MediaControlsImpl*>(&mediaControls)
136 ->m_orientationLockDelegate;
136 } 137 }
137 138
138 void simulateEnterFullscreen() { 139 void simulateEnterFullscreen() {
139 UserGestureIndicator gesture(DocumentUserGestureToken::create(&document())); 140 UserGestureIndicator gesture(DocumentUserGestureToken::create(&document()));
140 141
141 Fullscreen::requestFullscreen(video()); 142 Fullscreen::requestFullscreen(video());
142 Fullscreen::from(document()).didEnterFullscreen(); 143 Fullscreen::from(document()).didEnterFullscreen();
143 testing::runPendingTasks(); 144 testing::runPendingTasks();
144 } 145 }
145 146
(...skipping 12 matching lines...) Expand all
158 } 159 }
159 160
160 void simulateVideoReadyState(HTMLMediaElement::ReadyState state) { 161 void simulateVideoReadyState(HTMLMediaElement::ReadyState state) {
161 video().setReadyState(state); 162 video().setReadyState(state);
162 } 163 }
163 164
164 void simulateVideoNetworkState(HTMLMediaElement::NetworkState state) { 165 void simulateVideoNetworkState(HTMLMediaElement::NetworkState state) {
165 video().setNetworkState(state); 166 video().setNetworkState(state);
166 } 167 }
167 168
169 MediaControlsImpl* mediaControls() const {
170 return static_cast<MediaControlsImpl*>(m_video->mediaControls());
171 }
172
168 void checkStatePendingFullscreen() const { 173 void checkStatePendingFullscreen() const {
169 EXPECT_EQ(MediaControlsOrientationLockDelegate::State::PendingFullscreen, 174 EXPECT_EQ(MediaControlsOrientationLockDelegate::State::PendingFullscreen,
170 m_video->mediaControls()->m_orientationLockDelegate->m_state); 175 mediaControls()->m_orientationLockDelegate->m_state);
171 } 176 }
172 177
173 void checkStatePendingMetadata() const { 178 void checkStatePendingMetadata() const {
174 EXPECT_EQ(MediaControlsOrientationLockDelegate::State::PendingMetadata, 179 EXPECT_EQ(MediaControlsOrientationLockDelegate::State::PendingMetadata,
175 m_video->mediaControls()->m_orientationLockDelegate->m_state); 180 mediaControls()->m_orientationLockDelegate->m_state);
176 } 181 }
177 182
178 void checkStateMaybeLockedFullscreen() const { 183 void checkStateMaybeLockedFullscreen() const {
179 EXPECT_EQ( 184 EXPECT_EQ(
180 MediaControlsOrientationLockDelegate::State::MaybeLockedFullscreen, 185 MediaControlsOrientationLockDelegate::State::MaybeLockedFullscreen,
181 m_video->mediaControls()->m_orientationLockDelegate->m_state); 186 mediaControls()->m_orientationLockDelegate->m_state);
182 } 187 }
183 188
184 bool delegateWillUnlockFullscreen() const { 189 bool delegateWillUnlockFullscreen() const {
185 return m_video->mediaControls() 190 return mediaControls()
186 ->m_orientationLockDelegate->m_shouldUnlockOrientation; 191 ->m_orientationLockDelegate->m_shouldUnlockOrientation;
187 } 192 }
188 193
189 WebScreenOrientationLockType computeOrientationLock() const { 194 WebScreenOrientationLockType computeOrientationLock() const {
190 return m_video->mediaControls() 195 return mediaControls()->m_orientationLockDelegate->computeOrientationLock();
191 ->m_orientationLockDelegate->computeOrientationLock();
192 } 196 }
193 197
194 MockChromeClient& chromeClient() const { return *m_chromeClient; } 198 MockChromeClient& chromeClient() const { return *m_chromeClient; }
195 199
196 HTMLVideoElement& video() const { return *m_video; } 200 HTMLVideoElement& video() const { return *m_video; }
197 Document& document() const { return m_pageHolder->document(); } 201 Document& document() const { return m_pageHolder->document(); }
198 MockScreenOrientationController& screenOrientationController() const { 202 MockScreenOrientationController& screenOrientationController() const {
199 return *m_screenOrientationController; 203 return *m_screenOrientationController;
200 } 204 }
201 MockVideoWebMediaPlayer& mockWebMediaPlayer() const { 205 MockVideoWebMediaPlayer& mockWebMediaPlayer() const {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); 394 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock());
391 395
392 screenInfo.orientationType = WebScreenOrientationLandscapeSecondary; 396 screenInfo.orientationType = WebScreenOrientationLandscapeSecondary;
393 EXPECT_CALL(chromeClient(), screenInfo()) 397 EXPECT_CALL(chromeClient(), screenInfo())
394 .Times(1) 398 .Times(1)
395 .WillOnce(Return(screenInfo)); 399 .WillOnce(Return(screenInfo));
396 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); 400 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock());
397 } 401 }
398 402
399 } // namespace blink 403 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/media_controls/MediaControlsOrientationLockDelegate.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698