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

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

Issue 2729613007: Fixing a crash in MediaCustomControlsFullscreenDetector when the page is destroyed (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
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 <memory> 7 #include <memory>
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/DocumentUserGestureToken.h" 9 #include "core/dom/DocumentUserGestureToken.h"
10 #include "core/loader/EmptyClients.h" 10 #include "core/loader/EmptyClients.h"
11 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
12 #include "platform/UserGestureIndicator.h" 12 #include "platform/UserGestureIndicator.h"
13 #include "platform/network/NetworkStateNotifier.h" 13 #include "platform/network/NetworkStateNotifier.h"
14 #include "platform/testing/EmptyWebMediaPlayer.h"
14 #include "platform/testing/UnitTestHelpers.h" 15 #include "platform/testing/UnitTestHelpers.h"
15 #include "public/platform/WebMediaPlayer.h"
16 #include "public/platform/WebSize.h" 16 #include "public/platform/WebSize.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "wtf/PtrUtil.h" 19 #include "wtf/PtrUtil.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 namespace { 23 namespace {
24 24
25 class EmptyWebMediaPlayer : public WebMediaPlayer {
26 public:
27 void load(LoadType, const WebMediaPlayerSource&, CORSMode) override{};
28 void play() override{};
29 void pause() override{};
30 bool supportsSave() const override { return false; };
31 void seek(double seconds) override{};
32 void setRate(double) override{};
33 void setVolume(double) override{};
34 WebTimeRanges buffered() const override { return WebTimeRanges(); };
35 WebTimeRanges seekable() const override { return WebTimeRanges(); };
36 void setSinkId(const WebString& sinkId,
37 const WebSecurityOrigin&,
38 WebSetSinkIdCallbacks*) override{};
39 bool hasVideo() const override { return false; };
40 bool hasAudio() const override { return false; };
41 WebSize naturalSize() const override { return WebSize(0, 0); };
42 bool paused() const override { return false; };
43 bool seeking() const override { return false; };
44 double duration() const override { return 0.0; };
45 double currentTime() const override { return 0.0; };
46 NetworkState getNetworkState() const override { return NetworkStateEmpty; };
47 ReadyState getReadyState() const override { return ReadyStateHaveNothing; };
48 WebString getErrorMessage() override { return WebString(); };
49 bool didLoadingProgress() override { return false; };
50 bool hasSingleSecurityOrigin() const override { return true; };
51 bool didPassCORSAccessCheck() const override { return true; };
52 double mediaTimeForTimeValue(double timeValue) const override {
53 return timeValue;
54 };
55 unsigned decodedFrameCount() const override { return 0; };
56 unsigned droppedFrameCount() const override { return 0; };
57 size_t audioDecodedByteCount() const override { return 0; };
58 size_t videoDecodedByteCount() const override { return 0; };
59 void paint(WebCanvas*, const WebRect&, PaintFlags&) override{};
60 };
61
62 class MockWebMediaPlayer : public EmptyWebMediaPlayer { 25 class MockWebMediaPlayer : public EmptyWebMediaPlayer {
63 public: 26 public:
64 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy)); 27 MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy));
65 }; 28 };
66 29
67 class StubLocalFrameClient : public EmptyLocalFrameClient { 30 class StubLocalFrameClient : public EmptyLocalFrameClient {
68 public: 31 public:
69 static StubLocalFrameClient* create() { return new StubLocalFrameClient; } 32 static StubLocalFrameClient* create() { return new StubLocalFrameClient; }
70 33
71 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( 34 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ::testing::Mock::VerifyAndClearExpectations(player); 110 ::testing::Mock::VerifyAndClearExpectations(player);
148 111
149 // On play, the strategy is set to normal. 112 // On play, the strategy is set to normal.
150 EXPECT_CALL(*player, 113 EXPECT_CALL(*player,
151 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal)); 114 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal));
152 m_video->play(); 115 m_video->play();
153 ::testing::Mock::VerifyAndClearExpectations(player); 116 ::testing::Mock::VerifyAndClearExpectations(player);
154 } 117 }
155 118
156 } // namespace blink 119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698