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

Side by Side Diff: content/renderer/media/webmediaplayer_ms_unittest.cc

Issue 2490783002: Refactor WebMediaPlayerDelegate interface. (Closed)
Patch Set: Update WMPA properly. Created 4 years 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "content/public/renderer/media_stream_renderer_factory.h" 9 #include "content/public/renderer/media_stream_renderer_factory.h"
10 #include "content/renderer/media/webmediaplayer_ms.h" 10 #include "content/renderer/media/webmediaplayer_ms.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 observer_ = observer; 46 observer_ = observer;
47 return delegate_id_; 47 return delegate_id_;
48 } 48 }
49 49
50 void RemoveObserver(int delegate_id) override { 50 void RemoveObserver(int delegate_id) override {
51 EXPECT_EQ(delegate_id_, delegate_id); 51 EXPECT_EQ(delegate_id_, delegate_id);
52 observer_ = nullptr; 52 observer_ = nullptr;
53 } 53 }
54 54
55 void DidPlay(int delegate_id, 55 void DidPlay(int delegate_id,
56 bool has_audio,
56 bool has_video, 57 bool has_video,
57 bool has_audio,
58 bool is_remote,
59 media::MediaContentType type) override { 58 media::MediaContentType type) override {
60 EXPECT_EQ(delegate_id_, delegate_id); 59 EXPECT_EQ(delegate_id_, delegate_id);
61 EXPECT_FALSE(playing_); 60 EXPECT_FALSE(playing_);
62 playing_ = true; 61 playing_ = true;
62 has_video_ = has_video;
63 is_gone_ = false; 63 is_gone_ = false;
64 } 64 }
65 65
66 void DidPause(int delegate_id, bool reached_end_of_stream) override { 66 void DidPause(int delegate_id) override {
67 EXPECT_EQ(delegate_id_, delegate_id); 67 EXPECT_EQ(delegate_id_, delegate_id);
68 EXPECT_TRUE(playing_); 68 EXPECT_TRUE(playing_);
69 EXPECT_FALSE(is_gone_); 69 EXPECT_FALSE(is_gone_);
70 playing_ = false; 70 playing_ = false;
71 } 71 }
72 72
73 void PlayerGone(int delegate_id) override { 73 void PlayerGone(int delegate_id) override {
74 EXPECT_EQ(delegate_id_, delegate_id); 74 EXPECT_EQ(delegate_id_, delegate_id);
75 is_gone_ = true; 75 is_gone_ = true;
76 } 76 }
77 77
78 bool IsHidden() override { return is_hidden_; } 78 void SetIdle(int delegate_id, bool is_idle) override {
79 EXPECT_EQ(delegate_id_, delegate_id);
80 is_idle_ = is_idle;
81 }
79 82
80 bool IsPlayingBackgroundVideo() override { return false; } 83 bool IsIdle(int delegate_id) override {
84 EXPECT_EQ(delegate_id_, delegate_id);
85 return is_idle_;
86 }
87
88 void ClearStaleFlag(int delegate_id) override {
89 EXPECT_EQ(delegate_id_, delegate_id);
90 }
91
92 bool IsStale(int delegate_id) override {
93 EXPECT_EQ(delegate_id_, delegate_id);
94 return false;
95 }
96
97 bool IsFrameHidden() override { return is_hidden_; }
98 bool IsFrameClosed() override { return false; }
99 bool IsBackgroundVideoPlaybackAllowed() override { return false; }
81 100
82 void set_hidden(bool is_hidden) { is_hidden_ = is_hidden; } 101 void set_hidden(bool is_hidden) { is_hidden_ = is_hidden; }
83 102
84 private: 103 private:
85 int delegate_id_ = 1234; 104 int delegate_id_ = 1234;
86 Observer* observer_ = nullptr; 105 Observer* observer_ = nullptr;
87 bool playing_ = false; 106 bool playing_ = false;
107 bool has_video_ = false;
88 bool is_hidden_ = false; 108 bool is_hidden_ = false;
89 bool is_gone_ = true; 109 bool is_gone_ = true;
110 bool is_idle_ = false;
90 111
91 DISALLOW_COPY_AND_ASSIGN(FakeWebMediaPlayerDelegate); 112 DISALLOW_COPY_AND_ASSIGN(FakeWebMediaPlayerDelegate);
92 }; 113 };
93 114
94 class ReusableMessageLoopEvent { 115 class ReusableMessageLoopEvent {
95 public: 116 public:
96 ReusableMessageLoopEvent() : event_(new media::WaitableMessageLoopEvent()) {} 117 ReusableMessageLoopEvent() : event_(new media::WaitableMessageLoopEvent()) {}
97 118
98 base::Closure GetClosure() const { return event_->GetClosure(); } 119 base::Closure GetClosure() const { return event_->GetClosure(); }
99 120
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // OnShown() should restart after a forced suspension. 956 // OnShown() should restart after a forced suspension.
936 player_->OnShown(); 957 player_->OnShown();
937 EXPECT_FALSE(player_->paused()); 958 EXPECT_FALSE(player_->paused());
938 EXPECT_CALL(*this, DoSetWebLayer(false)); 959 EXPECT_CALL(*this, DoSetWebLayer(false));
939 960
940 base::RunLoop().RunUntilIdle(); 961 base::RunLoop().RunUntilIdle();
941 } 962 }
942 #endif 963 #endif
943 964
944 } // namespace content 965 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698