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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. 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>
17 19
18 namespace blink { 20 namespace blink {
19 21
20 namespace { 22 namespace {
21 23
22 class EmptyWebMediaPlayer : public WebMediaPlayer { 24 class EmptyWebMediaPlayer : public WebMediaPlayer {
23 public: 25 public:
24 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override { }; 26 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override { };
25 void play() override { }; 27 void play() override { };
26 void pause() override { }; 28 void pause() override { };
(...skipping 30 matching lines...) Expand all
57 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy)); 59 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy));
58 }; 60 };
59 61
60 class StubFrameLoaderClient : public EmptyFrameLoaderClient { 62 class StubFrameLoaderClient : public EmptyFrameLoaderClient {
61 public: 63 public:
62 static StubFrameLoaderClient* create() 64 static StubFrameLoaderClient* create()
63 { 65 {
64 return new StubFrameLoaderClient; 66 return new StubFrameLoaderClient;
65 } 67 }
66 68
67 PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, const Web MediaPlayerSource&, WebMediaPlayerClient*) override 69 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(HTMLMediaElement&, cons t WebMediaPlayerSource&, WebMediaPlayerClient*) override
68 { 70 {
69 return adoptPtr(new MockWebMediaPlayer); 71 return wrapUnique(new MockWebMediaPlayer);
70 } 72 }
71 }; 73 };
72 74
73 } // namespace 75 } // namespace
74 76
75 class HTMLVideoElementTest : public ::testing::Test { 77 class HTMLVideoElementTest : public ::testing::Test {
76 protected: 78 protected:
77 HTMLVideoElementTest() 79 HTMLVideoElementTest()
78 : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, StubFrameLoaderClient::create())) 80 : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, StubFrameLoaderClient::create()))
79 { 81 {
80 // TODO(sandersd): This should be done by a settings initializer. 82 // TODO(sandersd): This should be done by a settings initializer.
81 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0); 83 networkStateNotifier().setWebConnection(WebConnectionTypeWifi, 54.0);
82 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); 84 m_video = HTMLVideoElement::create(m_dummyPageHolder->document());
83 } 85 }
84 86
85 void setSrc(const AtomicString& url) 87 void setSrc(const AtomicString& url)
86 { 88 {
87 m_video->setSrc(url); 89 m_video->setSrc(url);
88 testing::runPendingTasks(); 90 testing::runPendingTasks();
89 } 91 }
90 92
91 MockWebMediaPlayer* webMediaPlayer() 93 MockWebMediaPlayer* webMediaPlayer()
92 { 94 {
93 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer()); 95 return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer());
94 } 96 }
95 97
96 OwnPtr<DummyPageHolder> m_dummyPageHolder; 98 std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
97 Persistent<HTMLVideoElement> m_video; 99 Persistent<HTMLVideoElement> m_video;
98 }; 100 };
99 101
100 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause) 102 TEST_F(HTMLVideoElementTest, setBufferingStrategy_NonUserPause)
101 { 103 {
102 setSrc("http://foo.bar/"); 104 setSrc("http://foo.bar/");
103 MockWebMediaPlayer* player = webMediaPlayer(); 105 MockWebMediaPlayer* player = webMediaPlayer();
104 ASSERT_TRUE(player); 106 ASSERT_TRUE(player);
105 107
106 // On play, the strategy is set to normal. 108 // On play, the strategy is set to normal.
(...skipping 30 matching lines...) Expand all
137 } 139 }
138 ::testing::Mock::VerifyAndClearExpectations(player); 140 ::testing::Mock::VerifyAndClearExpectations(player);
139 141
140 // On play, the strategy is set to normal. 142 // On play, the strategy is set to normal.
141 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal)); 143 EXPECT_CALL(*player, setBufferingStrategy(WebMediaPlayer::BufferingStrategy: :Normal));
142 m_video->play(); 144 m_video->play();
143 ::testing::Mock::VerifyAndClearExpectations(player); 145 ::testing::Mock::VerifyAndClearExpectations(player);
144 } 146 }
145 147
146 } // namespace blink 148 } // 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