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

Side by Side Diff: content/browser/media/session/media_session_visibility_browsertest.cc

Issue 2108783003: Re-enabling MediaSessionVisibilityBrowserTests for debugging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-enabling MediaSessionVisibilityBrowserTests for debugging Created 4 years, 5 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 | « no previous file | 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/logging.h"
7 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
8 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
9 #include "content/browser/media/session/media_session.h" 10 #include "content/browser/media/session/media_session.h"
10 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
11 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
12 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 14 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 15 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_navigation_observer.h" 16 #include "content/public/test/test_navigation_observer.h"
16 #include "content/shell/browser/shell.h" 17 #include "content/shell/browser/shell.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 103
103 void WaitForMediaSessionState(MediaSession::State state) { 104 void WaitForMediaSessionState(MediaSession::State state) {
104 ASSERT_TRUE(media_session_state_loop_runners_.count(state)); 105 ASSERT_TRUE(media_session_state_loop_runners_.count(state));
105 media_session_state_loop_runners_[state]->Run(); 106 media_session_state_loop_runners_[state]->Run();
106 } 107 }
107 108
108 protected: 109 protected:
109 void TestSessionInactiveWhenHiddenAfterContentPause() { 110 void TestSessionInactiveWhenHiddenAfterContentPause() {
110 LoadTestPage(); 111 LoadTestPage();
111 112
113 LOG(INFO) << "Starting player";
112 ClearMediaSessionStateLoopRunners(); 114 ClearMediaSessionStateLoopRunners();
113 RunScript(kStartPlayerScript); 115 RunScript(kStartPlayerScript);
116 LOG(INFO) << "Waiting for Session to be active";
114 WaitForMediaSessionState(MediaSession::State::ACTIVE); 117 WaitForMediaSessionState(MediaSession::State::ACTIVE);
115 118
119 LOG(INFO) << "Pausing player";
116 ClearMediaSessionStateLoopRunners(); 120 ClearMediaSessionStateLoopRunners();
117 RunScript(kPausePlayerScript); 121 RunScript(kPausePlayerScript);
122 LOG(INFO) << "Waiting for Session to be suspended";
118 WaitForMediaSessionState(MediaSession::State::SUSPENDED); 123 WaitForMediaSessionState(MediaSession::State::SUSPENDED);
119 124
125 LOG(INFO) << "Hiding the tab";
120 ClearMediaSessionStateLoopRunners(); 126 ClearMediaSessionStateLoopRunners();
121 web_contents_->WasHidden(); 127 web_contents_->WasHidden();
128 LOG(INFO) << "Waiting for Session to be inactive";
122 WaitForMediaSessionState(MediaSession::State::INACTIVE); 129 WaitForMediaSessionState(MediaSession::State::INACTIVE);
130
131 LOG(INFO) << "Test succeeded";
123 } 132 }
124 133
125 void TestSessionInactiveWhenHiddenWhilePlaying() { 134 void TestSessionInactiveWhenHiddenWhilePlaying() {
126 LoadTestPage(); 135 LoadTestPage();
127 136
137 LOG(INFO) << "Starting player";
128 ClearMediaSessionStateLoopRunners(); 138 ClearMediaSessionStateLoopRunners();
129 RunScript(kStartPlayerScript); 139 RunScript(kStartPlayerScript);
140 LOG(INFO) << "Waiting for Session to be active";
130 WaitForMediaSessionState(MediaSession::State::ACTIVE); 141 WaitForMediaSessionState(MediaSession::State::ACTIVE);
131 142
143 LOG(INFO) << "Hiding the tab";
132 ClearMediaSessionStateLoopRunners(); 144 ClearMediaSessionStateLoopRunners();
133 web_contents_->WasHidden(); 145 web_contents_->WasHidden();
146 LOG(INFO) << "Waiting for Session to be inactive";
134 WaitForMediaSessionState(MediaSession::State::INACTIVE); 147 WaitForMediaSessionState(MediaSession::State::INACTIVE);
148
149 LOG(INFO) << "Test succeeded";
135 } 150 }
136 151
137 void TestSessionSuspendedWhenHiddenAfterContentPause() { 152 void TestSessionSuspendedWhenHiddenAfterContentPause() {
138 LoadTestPage(); 153 LoadTestPage();
139 154
155 LOG(INFO) << "Starting player";
140 ClearMediaSessionStateLoopRunners(); 156 ClearMediaSessionStateLoopRunners();
141 RunScript(kStartPlayerScript); 157 RunScript(kStartPlayerScript);
158 LOG(INFO) << "Waiting for Session to be active";
142 WaitForMediaSessionState(MediaSession::State::ACTIVE); 159 WaitForMediaSessionState(MediaSession::State::ACTIVE);
143 160
161 LOG(INFO) << "Pausing player";
144 ClearMediaSessionStateLoopRunners(); 162 ClearMediaSessionStateLoopRunners();
145 RunScript(kPausePlayerScript); 163 RunScript(kPausePlayerScript);
164 LOG(INFO) << "Waiting for Session to be suspended";
146 WaitForMediaSessionState(MediaSession::State::SUSPENDED); 165 WaitForMediaSessionState(MediaSession::State::SUSPENDED);
147 166
167 LOG(INFO) << "Hiding the tab";
148 // Wait for 1 second and check the MediaSession state. 168 // Wait for 1 second and check the MediaSession state.
149 // No better solution till now. 169 // No better solution till now.
150 web_contents_->WasHidden(); 170 web_contents_->WasHidden();
151 Wait(base::TimeDelta::FromSeconds(1)); 171 Wait(base::TimeDelta::FromSeconds(1));
152 ASSERT_EQ(media_session_->audio_focus_state_, 172 ASSERT_EQ(media_session_->audio_focus_state_,
153 MediaSession::State::SUSPENDED); 173 MediaSession::State::SUSPENDED);
174
175 LOG(INFO) << "Test succeeded";
154 } 176 }
155 177
156 void TestSessionActiveWhenHiddenWhilePlaying() { 178 void TestSessionActiveWhenHiddenWhilePlaying() {
157 LoadTestPage(); 179 LoadTestPage();
158 180
181 LOG(INFO) << "Starting player";
159 ClearMediaSessionStateLoopRunners(); 182 ClearMediaSessionStateLoopRunners();
160 RunScript(kStartPlayerScript); 183 RunScript(kStartPlayerScript);
184 LOG(INFO) << "Waiting for Session to be active";
161 WaitForMediaSessionState(MediaSession::State::ACTIVE); 185 WaitForMediaSessionState(MediaSession::State::ACTIVE);
162 186
187 LOG(INFO) << "Hiding the tab";
163 // Wait for 1 second and check the MediaSession state. 188 // Wait for 1 second and check the MediaSession state.
164 // No better solution till now. 189 // No better solution till now.
165 web_contents_->WasHidden(); 190 web_contents_->WasHidden();
166 Wait(base::TimeDelta::FromSeconds(1)); 191 Wait(base::TimeDelta::FromSeconds(1));
167 ASSERT_EQ(media_session_->audio_focus_state_, 192 ASSERT_EQ(media_session_->audio_focus_state_,
168 MediaSession::State::ACTIVE); 193 MediaSession::State::ACTIVE);
194
195 LOG(INFO) << "Test succeeded";
169 } 196 }
170 197
171 WebContents* web_contents_; 198 WebContents* web_contents_;
172 MediaSession* media_session_; 199 MediaSession* media_session_;
173 // MessageLoopRunners for waiting MediaSession state to change. Note that the 200 // MessageLoopRunners for waiting MediaSession state to change. Note that the
174 // MessageLoopRunners can accept Quit() before calling Run(), thus the state 201 // MessageLoopRunners can accept Quit() before calling Run(), thus the state
175 // change can still be captured before waiting. For example, the MediaSession 202 // change can still be captured before waiting. For example, the MediaSession
176 // might go active immediately after calling HTMLMediaElement.play(). A test 203 // might go active immediately after calling HTMLMediaElement.play(). A test
177 // can listen to the state change before calling play(), and then wait for the 204 // can listen to the state change before calling play(), and then wait for the
178 // state change after play(). 205 // state change after play().
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 #if defined(OS_ANDROID) 260 #if defined(OS_ANDROID)
234 // AndroidPipeline + SuspendOnHide 261 // AndroidPipeline + SuspendOnHide
235 class MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide : 262 class MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide :
236 public MediaSessionVisibilityBrowserTest { 263 public MediaSessionVisibilityBrowserTest {
237 void SetUpCommandLine(base::CommandLine* command_line) override { 264 void SetUpCommandLine(base::CommandLine* command_line) override {
238 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); 265 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line);
239 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline); 266 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline);
240 } 267 }
241 }; 268 };
242 269
243 // Disabled pending crbug.com/619096. 270 // The following tests are flaky. Re-enabling with logging to see what's
244 // INCLUDE_TEST_FROM_BASE_CLASS( 271 // happening on the bots. See crbug.com/619096.
245 // MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide, 272 INCLUDE_TEST_FROM_BASE_CLASS(
246 // TestSessionInactiveWhenHiddenAfterContentPause) 273 MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
247 // INCLUDE_TEST_FROM_BASE_CLASS( 274 TestSessionInactiveWhenHiddenAfterContentPause)
248 // MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide, 275 INCLUDE_TEST_FROM_BASE_CLASS(
249 // TestSessionInactiveWhenHiddenWhilePlaying) 276 MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
277 TestSessionInactiveWhenHiddenWhilePlaying)
250 278
251 // AndroidPipeline + NosuspendOnHide 279 // AndroidPipeline + NosuspendOnHide
252 class MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide : 280 class MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide :
253 public MediaSessionVisibilityBrowserTest { 281 public MediaSessionVisibilityBrowserTest {
254 void SetUpCommandLine(base::CommandLine* command_line) override { 282 void SetUpCommandLine(base::CommandLine* command_line) override {
255 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); 283 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line);
256 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline); 284 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline);
257 command_line->AppendSwitch(switches::kDisableMediaSuspend); 285 command_line->AppendSwitch(switches::kDisableMediaSuspend);
258 } 286 }
259 }; 287 };
260 288
261 // Disabled pending crbug.com/619096. 289 // The following tests are flaky. Re-enabling with logging to see what's
262 // INCLUDE_TEST_FROM_BASE_CLASS( 290 // happening on the bots. See crbug.com/619096.
263 // MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide, 291 INCLUDE_TEST_FROM_BASE_CLASS(
264 // TestSessionSuspendedWhenHiddenAfterContentPause) 292 MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
265 //INCLUDE_TEST_FROM_BASE_CLASS( 293 TestSessionSuspendedWhenHiddenAfterContentPause)
266 // MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide, 294 INCLUDE_TEST_FROM_BASE_CLASS(
267 // TestSessionActiveWhenHiddenWhilePlaying) 295 MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
296 TestSessionActiveWhenHiddenWhilePlaying)
268 297
269 #endif // defined(OS_ANDROID) 298 #endif // defined(OS_ANDROID)
270 299
271 } // namespace content 300 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698