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

Side by Side Diff: third_party/WebKit/Source/core/paint/VideoPainterTest.cpp

Issue 2746103002: Let MockWebMediaPlayers in blink unit tests inherit from EmptyWebMediaPlayer (Closed)
Patch Set: rebased Created 3 years, 9 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/core/html/shadow/MediaControlsTest.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/paint/VideoPainter.h" 5 #include "core/paint/VideoPainter.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/Settings.h" 8 #include "core/frame/Settings.h"
9 #include "core/html/HTMLMediaElement.h" 9 #include "core/html/HTMLMediaElement.h"
10 #include "core/loader/EmptyClients.h" 10 #include "core/loader/EmptyClients.h"
11 #include "core/paint/StubChromeClientForSPv2.h" 11 #include "core/paint/StubChromeClientForSPv2.h"
12 #include "core/testing/DummyPageHolder.h" 12 #include "core/testing/DummyPageHolder.h"
13 #include "platform/testing/EmptyWebMediaPlayer.h"
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
14 #include "platform/testing/UnitTestHelpers.h" 15 #include "platform/testing/UnitTestHelpers.h"
15 #include "public/platform/Platform.h" 16 #include "public/platform/Platform.h"
16 #include "public/platform/WebCompositorSupport.h" 17 #include "public/platform/WebCompositorSupport.h"
17 #include "public/platform/WebLayer.h" 18 #include "public/platform/WebLayer.h"
18 #include "public/platform/WebMediaPlayer.h"
19 #include "public/platform/WebSize.h" 19 #include "public/platform/WebSize.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 // Integration tests of video painting code (in SPv2 mode). 22 // Integration tests of video painting code (in SPv2 mode).
23 23
24 namespace blink { 24 namespace blink {
25 namespace { 25 namespace {
26 26
27 class StubWebMediaPlayer : public WebMediaPlayer { 27 class StubWebMediaPlayer : public EmptyWebMediaPlayer {
28 public: 28 public:
29 StubWebMediaPlayer(WebMediaPlayerClient* client) : m_client(client) {} 29 StubWebMediaPlayer(WebMediaPlayerClient* client) : m_client(client) {}
30 30
31 const WebLayer* getWebLayer() { return m_webLayer.get(); } 31 const WebLayer* getWebLayer() { return m_webLayer.get(); }
32 32
33 // WebMediaPlayer 33 // WebMediaPlayer
34 void load(LoadType, const WebMediaPlayerSource&, CORSMode) { 34 void load(LoadType, const WebMediaPlayerSource&, CORSMode) {
35 m_networkState = NetworkStateLoaded; 35 m_networkState = NetworkStateLoaded;
36 m_client->networkStateChanged(); 36 m_client->networkStateChanged();
37 m_readyState = ReadyStateHaveEnoughData; 37 m_readyState = ReadyStateHaveEnoughData;
38 m_client->readyStateChanged(); 38 m_client->readyStateChanged();
39 m_webLayer = Platform::current()->compositorSupport()->createLayer(); 39 m_webLayer = Platform::current()->compositorSupport()->createLayer();
40 m_client->setWebLayer(m_webLayer.get()); 40 m_client->setWebLayer(m_webLayer.get());
41 } 41 }
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 false; }
54 bool hasAudio() const override { return false; }
55 WebSize naturalSize() const override { return WebSize(0, 0); }
56 bool paused() const override { return false; }
57 bool seeking() const override { return false; }
58 double duration() const override { return 0.0; }
59 double currentTime() const override { return 0.0; }
60 NetworkState getNetworkState() const override { return m_networkState; } 42 NetworkState getNetworkState() const override { return m_networkState; }
61 ReadyState getReadyState() const override { return m_readyState; } 43 ReadyState getReadyState() const override { return m_readyState; }
62 WebString getErrorMessage() override { return WebString(); }
63 bool didLoadingProgress() override { return false; }
64 bool hasSingleSecurityOrigin() const override { return true; }
65 bool didPassCORSAccessCheck() const override { return true; }
66 double mediaTimeForTimeValue(double timeValue) const override {
67 return timeValue;
68 }
69 unsigned decodedFrameCount() const override { return 0; }
70 unsigned droppedFrameCount() const override { return 0; }
71 size_t audioDecodedByteCount() const override { return 0; }
72 size_t videoDecodedByteCount() const override { return 0; }
73 void paint(WebCanvas*, const WebRect&, PaintFlags&) override {}
74 44
75 private: 45 private:
76 WebMediaPlayerClient* m_client; 46 WebMediaPlayerClient* m_client;
77 std::unique_ptr<WebLayer> m_webLayer; 47 std::unique_ptr<WebLayer> m_webLayer;
78 NetworkState m_networkState = NetworkStateEmpty; 48 NetworkState m_networkState = NetworkStateEmpty;
79 ReadyState m_readyState = ReadyStateHaveNothing; 49 ReadyState m_readyState = ReadyStateHaveNothing;
80 }; 50 };
81 51
82 class StubLocalFrameClient : public EmptyLocalFrameClient { 52 class StubLocalFrameClient : public EmptyLocalFrameClient {
83 public: 53 public:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 StubWebMediaPlayer* player = 108 StubWebMediaPlayer* player =
139 static_cast<StubWebMediaPlayer*>(element->webMediaPlayer()); 109 static_cast<StubWebMediaPlayer*>(element->webMediaPlayer());
140 const WebLayer* layer = player->getWebLayer(); 110 const WebLayer* layer = player->getWebLayer();
141 ASSERT_TRUE(layer); 111 ASSERT_TRUE(layer);
142 EXPECT_TRUE(hasLayerAttached(*layer)); 112 EXPECT_TRUE(hasLayerAttached(*layer));
143 EXPECT_EQ(WebSize(300, 200), layer->bounds()); 113 EXPECT_EQ(WebSize(300, 200), layer->bounds());
144 } 114 }
145 115
146 } // namespace 116 } // namespace
147 } // namespace blink 117 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698