| 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 "core/html/shadow/MediaControlsOrientationLockDelegate.h" | 5 #include "core/html/shadow/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" | 13 #include "core/html/shadow/MediaControls.h" |
| 14 #include "core/loader/EmptyClients.h" | 14 #include "core/loader/EmptyClients.h" |
| 15 #include "core/testing/DummyPageHolder.h" | 15 #include "core/testing/DummyPageHolder.h" |
| 16 #include "platform/UserGestureIndicator.h" | 16 #include "platform/UserGestureIndicator.h" |
| 17 #include "platform/testing/EmptyWebMediaPlayer.h" |
| 17 #include "platform/testing/UnitTestHelpers.h" | 18 #include "platform/testing/UnitTestHelpers.h" |
| 18 #include "public/platform/WebMediaPlayer.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; |
| 26 | 26 |
| 27 namespace blink { | 27 namespace blink { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // WebLockOrientationCallback implementation that will not react to a success | 31 // WebLockOrientationCallback implementation that will not react to a success |
| 32 // nor a failure. | 32 // nor a failure. |
| 33 class DummyScreenOrientationCallback : public WebLockOrientationCallback { | 33 class DummyScreenOrientationCallback : public WebLockOrientationCallback { |
| 34 public: | 34 public: |
| 35 void onSuccess() override {} | 35 void onSuccess() override {} |
| 36 void onError(WebLockOrientationError) override {} | 36 void onError(WebLockOrientationError) override {} |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 class MockVideoWebMediaPlayer : public WebMediaPlayer { | 39 class MockVideoWebMediaPlayer : public EmptyWebMediaPlayer { |
| 40 public: | 40 public: |
| 41 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override{}; | 41 bool hasVideo() const override { return true; } |
| 42 void play() override{}; | |
| 43 void pause() override{}; | |
| 44 bool supportsSave() const override { return false; }; | |
| 45 void seek(double seconds) override{}; | |
| 46 void setRate(double) override{}; | |
| 47 void setVolume(double) override{}; | |
| 48 WebTimeRanges buffered() const override { return WebTimeRanges(); }; | |
| 49 WebTimeRanges seekable() const override { return WebTimeRanges(); }; | |
| 50 void setSinkId(const WebString& sinkId, | |
| 51 const WebSecurityOrigin&, | |
| 52 WebSetSinkIdCallbacks*) override{}; | |
| 53 bool hasVideo() const override { return true; }; | |
| 54 bool hasAudio() const override { return false; }; | |
| 55 bool paused() const override { return false; }; | |
| 56 bool seeking() const override { return false; }; | |
| 57 double duration() const override { return 0.0; }; | |
| 58 double currentTime() const override { return 0.0; }; | |
| 59 NetworkState getNetworkState() const override { return NetworkStateEmpty; }; | |
| 60 ReadyState getReadyState() const override { return ReadyStateHaveNothing; }; | |
| 61 WebString getErrorMessage() override { return WebString(); }; | |
| 62 bool didLoadingProgress() override { return false; }; | |
| 63 bool hasSingleSecurityOrigin() const override { return true; }; | |
| 64 bool didPassCORSAccessCheck() const override { return true; }; | |
| 65 double mediaTimeForTimeValue(double timeValue) const override { | |
| 66 return timeValue; | |
| 67 }; | |
| 68 unsigned decodedFrameCount() const override { return 0; }; | |
| 69 unsigned droppedFrameCount() const override { return 0; }; | |
| 70 size_t audioDecodedByteCount() const override { return 0; }; | |
| 71 size_t videoDecodedByteCount() const override { return 0; }; | |
| 72 void paint(WebCanvas*, const WebRect&, PaintFlags&) override{}; | |
| 73 | 42 |
| 74 MOCK_CONST_METHOD0(naturalSize, WebSize()); | 43 MOCK_CONST_METHOD0(naturalSize, WebSize()); |
| 75 }; | 44 }; |
| 76 | 45 |
| 77 class MockChromeClient : public EmptyChromeClient { | 46 class MockChromeClient : public EmptyChromeClient { |
| 78 public: | 47 public: |
| 79 MOCK_CONST_METHOD0(screenInfo, WebScreenInfo()); | 48 MOCK_CONST_METHOD0(screenInfo, WebScreenInfo()); |
| 80 }; | 49 }; |
| 81 | 50 |
| 82 class StubLocalFrameClient : public EmptyLocalFrameClient { | 51 class StubLocalFrameClient : public EmptyLocalFrameClient { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); | 388 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); |
| 420 | 389 |
| 421 screenInfo.orientationType = WebScreenOrientationLandscapeSecondary; | 390 screenInfo.orientationType = WebScreenOrientationLandscapeSecondary; |
| 422 EXPECT_CALL(chromeClient(), screenInfo()) | 391 EXPECT_CALL(chromeClient(), screenInfo()) |
| 423 .Times(1) | 392 .Times(1) |
| 424 .WillOnce(Return(screenInfo)); | 393 .WillOnce(Return(screenInfo)); |
| 425 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); | 394 EXPECT_EQ(WebScreenOrientationLockLandscape, computeOrientationLock()); |
| 426 } | 395 } |
| 427 | 396 |
| 428 } // namespace blink | 397 } // namespace blink |
| OLD | NEW |