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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
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/loader/EmptyClients.h" 8 #include "core/loader/EmptyClients.h"
9 #include "core/page/NetworkStateNotifier.h" 9 #include "core/page/NetworkStateNotifier.h"
10 #include "core/testing/DummyPageHolder.h" 10 #include "core/testing/DummyPageHolder.h"
11 #include "platform/UserGestureIndicator.h" 11 #include "platform/UserGestureIndicator.h"
12 #include "platform/testing/UnitTestHelpers.h" 12 #include "platform/testing/UnitTestHelpers.h"
13 #include "public/platform/WebMediaPlayer.h" 13 #include "public/platform/WebMediaPlayer.h"
14 #include "public/platform/WebSize.h" 14 #include "public/platform/WebSize.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "wtf/PtrUtil.h"
18 #include <memory>
19 17
20 namespace blink { 18 namespace blink {
21 19
22 namespace { 20 namespace {
23 21
24 class EmptyWebMediaPlayer : public WebMediaPlayer { 22 class EmptyWebMediaPlayer : public WebMediaPlayer {
25 public: 23 public:
26 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override { }; 24 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override { };
27 void play() override { }; 25 void play() override { };
28 void pause() override { }; 26 void pause() override { };
(...skipping 30 matching lines...) Expand all
59 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy)); 57 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy));
60 }; 58 };
61 59
62 class StubFrameLoaderClient : public EmptyFrameLoaderClient { 60 class StubFrameLoaderClient : public EmptyFrameLoaderClient {
63 public: 61 public:
64 static StubFrameLoaderClient* create() 62 static StubFrameLoaderClient* create()
65 { 63 {
66 return new StubFrameLoaderClient; 64 return new StubFrameLoaderClient;
67 } 65 }
68 66
69 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, cons t WebMediaPlayerSource&, WebMediaPlayerClient*) override 67 PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const Web MediaPlayerSource&, WebMediaPlayerClient*) override
70 { 68 {
71 return wrapUnique(new MockWebMediaPlayer); 69 return adoptPtr(new MockWebMediaPlayer);
72 } 70 }
73 }; 71 };
74 72
75 } // namespace 73 } // namespace
76 74
77 class HTMLVideoElementTest : public ::testing::Test { 75 class HTMLVideoElementTest : public ::testing::Test {
78 protected: 76 protected:
79 HTMLVideoElementTest() 77 HTMLVideoElementTest()
80 : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, StubFrameLoaderClient::create())) 78 : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, StubFrameLoaderClient::create()))
81 { 79 {
82 // TODO(sandersd): This should be done by a settings initializer. 80 // TODO(sandersd): This should be done by a settings initializer.
83 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0); 81 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0);
84 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); 82 m_video = HTMLVideoElement::create(m_dummyPageHolder->document());
85 } 83 }
86 84
87 void setSrc(const AtomicString& url) 85 void setSrc(const AtomicString& url)
88 { 86 {
89 m_video->setSrc(url); 87 m_video->setSrc(url);
90 testing::runPendingTasks(); 88 testing::runPendingTasks();
91 } 89 }
92 90
93 MockWebMediaPlayer* webMediaPlayer() 91 MockWebMediaPlayer* webMediaPlayer()
94 { 92 {
95 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer()); 93 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer());
96 } 94 }
97 95
98 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 96 OwnPtr<DummyPageHolder> m_dummyPageHolder;
99 Persistent<HTMLVideoElement> m_video; 97 Persistent<HTMLVideoElement> m_video;
100 }; 98 };
101 99
102 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause) 100 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause)
103 { 101 {
104 setSrc("http://foo.bar/"); 102 setSrc("http://foo.bar/");
105 MockWebMediaPlayer* player = webMediaPlayer(); 103 MockWebMediaPlayer* player = webMediaPlayer();
106 ASSERT_TRUE(player); 104 ASSERT_TRUE(player);
107 105
108 // On play, the strategy is set to normal. 106 // On play, the strategy is set to normal.
(...skipping 30 matching lines...) Expand all
139 } 137 }
140 ::testing::Mock::VerifyAndClearExpectations(player); 138 ::testing::Mock::VerifyAndClearExpectations(player);
141 139
142 // On play, the strategy is set to normal. 140 // On play, the strategy is set to normal.
143 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal)); 141 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal));
144 m_video->play(); 142 m_video->play();
145 ::testing::Mock::VerifyAndClearExpectations(player); 143 ::testing::Mock::VerifyAndClearExpectations(player);
146 } 144 }
147 145
148 } // namespace blink 146 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLVideoElement.cpp ('k') | third_party/WebKit/Source/core/html/LinkManifest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698