| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/HTMLVideoElement.h" | 5 #include "core/html/HTMLVideoElement.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/loader/EmptyClients.h" | 9 #include "core/loader/EmptyClients.h" |
| 10 #include "core/page/NetworkStateNotifier.h" | 10 #include "core/page/NetworkStateNotifier.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 size_t audioDecodedByteCount() const override { return 0; }; | 57 size_t audioDecodedByteCount() const override { return 0; }; |
| 58 size_t videoDecodedByteCount() const override { return 0; }; | 58 size_t videoDecodedByteCount() const override { return 0; }; |
| 59 void paint(WebCanvas*, const WebRect&, PaintFlags&) override{}; | 59 void paint(WebCanvas*, const WebRect&, PaintFlags&) override{}; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class MockWebMediaPlayer : public EmptyWebMediaPlayer { | 62 class MockWebMediaPlayer : public EmptyWebMediaPlayer { |
| 63 public: | 63 public: |
| 64 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy)); | 64 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy)); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class StubFrameLoaderClient : public EmptyLocalFrameClient { | 67 class StubLocalFrameClient : public EmptyLocalFrameClient { |
| 68 public: | 68 public: |
| 69 static StubFrameLoaderClient* create() { return new StubFrameLoaderClient; } | 69 static StubLocalFrameClient* create() { return new StubLocalFrameClient; } |
| 70 | 70 |
| 71 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( | 71 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( |
| 72 HTMLMediaElement&, | 72 HTMLMediaElement&, |
| 73 const WebMediaPlayerSource&, | 73 const WebMediaPlayerSource&, |
| 74 WebMediaPlayerClient*) override { | 74 WebMediaPlayerClient*) override { |
| 75 return WTF::wrapUnique(new MockWebMediaPlayer); | 75 return WTF::wrapUnique(new MockWebMediaPlayer); |
| 76 } | 76 } |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace | 79 } // namespace |
| 80 | 80 |
| 81 class HTMLVideoElementTest : public ::testing::Test { | 81 class HTMLVideoElementTest : public ::testing::Test { |
| 82 protected: | 82 protected: |
| 83 HTMLVideoElementTest() | 83 HTMLVideoElementTest() |
| 84 : m_dummyPageHolder( | 84 : m_dummyPageHolder( |
| 85 DummyPageHolder::create(IntSize(640, 360), | 85 DummyPageHolder::create(IntSize(640, 360), |
| 86 nullptr, | 86 nullptr, |
| 87 StubFrameLoaderClient::create())) { | 87 StubLocalFrameClient::create())) { |
| 88 // TODO(sandersd): This should be done by a settings initializer. | 88 // TODO(sandersd): This should be done by a settings initializer. |
| 89 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0); | 89 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0); |
| 90 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); | 90 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void setSrc(const AtomicString& url) { | 93 void setSrc(const AtomicString& url) { |
| 94 m_video->setSrc(url); | 94 m_video->setSrc(url); |
| 95 testing::runPendingTasks(); | 95 testing::runPendingTasks(); |
| 96 } | 96 } |
| 97 | 97 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 ::testing::Mock::VerifyAndClearExpectations(player); | 147 ::testing::Mock::VerifyAndClearExpectations(player); |
| 148 | 148 |
| 149 // On play, the strategy is set to normal. | 149 // On play, the strategy is set to normal. |
| 150 EXPECT_CALL(*player, | 150 EXPECT_CALL(*player, |
| 151 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal)); | 151 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal)); |
| 152 m_video->play(); | 152 m_video->play(); |
| 153 ::testing::Mock::VerifyAndClearExpectations(player); | 153 ::testing::Mock::VerifyAndClearExpectations(player); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |