| OLD | NEW |
| 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 <tuple> |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/location.h" | 8 #include "base/location.h" |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "content/browser/media/session/media_session.h" | 12 #include "content/browser/media/session/media_session.h" |
| 11 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
| 15 #include "content/public/test/content_browser_test_utils.h" | 17 #include "content/public/test/content_browser_test_utils.h" |
| 16 #include "content/public/test/test_navigation_observer.h" | 18 #include "content/public/test/test_navigation_observer.h" |
| 17 #include "content/shell/browser/shell.h" | 19 #include "content/shell/browser/shell.h" |
| 18 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 namespace { | 24 namespace { |
| 23 static const char kStartPlayerScript[] = | 25 static const char kStartPlayerScript[] = |
| 24 "document.getElementById('long-video').play()"; | 26 "document.getElementById('long-video').play()"; |
| 25 static const char kPausePlayerScript[] = | 27 static const char kPausePlayerScript[] = |
| 26 "document.getElementById('long-video').pause()"; | 28 "document.getElementById('long-video').pause()"; |
| 29 |
| 30 enum class MediaSuspend { |
| 31 ENABLED, |
| 32 DISABLED, |
| 33 }; |
| 34 |
| 35 enum class Pipeline { |
| 36 WMPI, |
| 37 WMPA, |
| 38 }; |
| 39 |
| 40 enum class BackgroundResuming { |
| 41 ENABLED, |
| 42 DISABLED, |
| 43 }; |
| 44 |
| 45 enum class SessionState { |
| 46 ACTIVE, |
| 47 SUSPENDED, |
| 48 INACTIVE, |
| 49 }; |
| 50 |
| 51 struct VisibilityTestData { |
| 52 MediaSuspend media_suspend; |
| 53 BackgroundResuming background_resuming; |
| 54 SessionState session_state_before_hide; |
| 55 SessionState session_state_after_hide; |
| 56 }; |
| 57 |
| 27 } | 58 } |
| 28 | 59 |
| 29 | 60 |
| 30 // Base class of MediaSession visibility tests. The class is intended | 61 // Base class of MediaSession visibility tests. The class is intended |
| 31 // to be used to run tests under different configurations. Tests | 62 // to be used to run tests under different configurations. Tests |
| 32 // should inheret from this class, set up their own command line per | 63 // should inheret from this class, set up their own command line per |
| 33 // their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to | 64 // their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to |
| 34 // include required tests. See | 65 // include required tests. See |
| 35 // media_session_visibility_browsertest_instances.cc for examples. | 66 // media_session_visibility_browsertest_instances.cc for examples. |
| 36 class MediaSessionVisibilityBrowserTest | 67 class MediaSessionVisibilityBrowserTest |
| 37 : public ContentBrowserTest { | 68 : public ContentBrowserTest, |
| 69 public ::testing::WithParamInterface< |
| 70 std::tr1::tuple<VisibilityTestData, Pipeline>> { |
| 38 public: | 71 public: |
| 39 MediaSessionVisibilityBrowserTest() = default; | 72 MediaSessionVisibilityBrowserTest() = default; |
| 40 ~MediaSessionVisibilityBrowserTest() override = default; | 73 ~MediaSessionVisibilityBrowserTest() override = default; |
| 41 | 74 |
| 42 void SetUpOnMainThread() override { | 75 void SetUpOnMainThread() override { |
| 43 ContentBrowserTest::SetUpOnMainThread(); | 76 ContentBrowserTest::SetUpOnMainThread(); |
| 44 web_contents_ = shell()->web_contents(); | 77 web_contents_ = shell()->web_contents(); |
| 45 media_session_ = MediaSession::Get(web_contents_); | 78 media_session_ = MediaSession::Get(web_contents_); |
| 46 | 79 |
| 47 media_session_state_loop_runners_[MediaSession::State::ACTIVE] = | 80 media_session_state_loop_runners_[MediaSession::State::ACTIVE] = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 72 disabled_features = media::kResumeBackgroundVideo.name; | 105 disabled_features = media::kResumeBackgroundVideo.name; |
| 73 | 106 |
| 74 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); | 107 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 75 feature_list->InitializeFromCommandLine( | 108 feature_list->InitializeFromCommandLine( |
| 76 enabled_features, disabled_features); | 109 enabled_features, disabled_features); |
| 77 base::FeatureList::ClearInstanceForTesting(); | 110 base::FeatureList::ClearInstanceForTesting(); |
| 78 base::FeatureList::SetInstance(std::move(feature_list)); | 111 base::FeatureList::SetInstance(std::move(feature_list)); |
| 79 } | 112 } |
| 80 | 113 |
| 81 void SetUpCommandLine(base::CommandLine* command_line) override { | 114 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 82 EnableDisableResumingBackgroundVideos(false); | |
| 83 | |
| 84 command_line->AppendSwitch( | 115 command_line->AppendSwitch( |
| 85 switches::kDisableGestureRequirementForMediaPlayback); | 116 switches::kDisableGestureRequirementForMediaPlayback); |
| 86 #if !defined(OS_ANDROID) | 117 #if !defined(OS_ANDROID) |
| 87 command_line->AppendSwitch( | 118 command_line->AppendSwitch( |
| 88 switches::kEnableDefaultMediaSession); | 119 switches::kEnableDefaultMediaSession); |
| 89 #endif // !defined(OS_ANDROID) | 120 #endif // !defined(OS_ANDROID) |
| 121 |
| 122 VisibilityTestData params = GetVisibilityTestData(); |
| 123 |
| 124 if (params.media_suspend == MediaSuspend::ENABLED) |
| 125 command_line->AppendSwitch(switches::kEnableMediaSuspend); |
| 126 else |
| 127 command_line->AppendSwitch(switches::kDisableMediaSuspend); |
| 128 |
| 129 #if defined(OS_ANDROID) |
| 130 Pipeline pipeline = std::tr1::get<1>(GetParam()); |
| 131 if (pipeline == Pipeline::WMPA) |
| 132 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline); |
| 133 #endif // defined(OS_ANDROID) |
| 134 |
| 135 if (params.background_resuming == BackgroundResuming::ENABLED) { |
| 136 command_line->AppendSwitchASCII(switches::kEnableFeatures, |
| 137 media::kResumeBackgroundVideo.name); |
| 138 } else { |
| 139 command_line->AppendSwitchASCII(switches::kDisableFeatures, |
| 140 media::kResumeBackgroundVideo.name); |
| 141 } |
| 90 } | 142 } |
| 91 | 143 |
| 144 const VisibilityTestData& GetVisibilityTestData() { |
| 145 return std::tr1::get<0>(GetParam()); |
| 146 } |
| 147 |
| 148 void StartPlayer() { |
| 149 LoadTestPage(); |
| 150 |
| 151 LOG(INFO) << "Starting player"; |
| 152 ClearMediaSessionStateLoopRunners(); |
| 153 RunScript(kStartPlayerScript); |
| 154 LOG(INFO) << "Waiting for session to be active"; |
| 155 WaitForMediaSessionState(MediaSession::State::ACTIVE); |
| 156 } |
| 157 |
| 158 // Maybe pause the player depending on whether the session state before hide |
| 159 // is SUSPENDED. |
| 160 void MaybePausePlayer() { |
| 161 ASSERT_TRUE(GetVisibilityTestData().session_state_before_hide |
| 162 != SessionState::INACTIVE); |
| 163 if (GetVisibilityTestData().session_state_before_hide |
| 164 == SessionState::ACTIVE) |
| 165 return; |
| 166 |
| 167 LOG(INFO) << "Pausing player"; |
| 168 ClearMediaSessionStateLoopRunners(); |
| 169 RunScript(kPausePlayerScript); |
| 170 LOG(INFO) << "Waiting for session to be suspended"; |
| 171 WaitForMediaSessionState(MediaSession::State::SUSPENDED); |
| 172 } |
| 173 |
| 174 void HideTab() { |
| 175 LOG(INFO) << "Hiding the tab"; |
| 176 ClearMediaSessionStateLoopRunners(); |
| 177 web_contents_->WasHidden(); |
| 178 } |
| 179 |
| 180 void CheckSessionStateAfterHide() { |
| 181 MediaSession::State state_before_hide = |
| 182 ToMediaSessionState(GetVisibilityTestData().session_state_before_hide); |
| 183 MediaSession::State state_after_hide = |
| 184 ToMediaSessionState(GetVisibilityTestData().session_state_after_hide); |
| 185 |
| 186 if (state_before_hide == state_after_hide) { |
| 187 LOG(INFO) << "Waiting for 1 second and check session state is unchanged"; |
| 188 Wait(base::TimeDelta::FromSeconds(1)); |
| 189 ASSERT_EQ(media_session_->audio_focus_state_, state_after_hide); |
| 190 } else { |
| 191 LOG(INFO) << "Waiting for Session to change"; |
| 192 WaitForMediaSessionState(state_after_hide); |
| 193 } |
| 194 |
| 195 LOG(INFO) << "Test succeeded"; |
| 196 } |
| 197 |
| 198 private: |
| 92 void LoadTestPage() { | 199 void LoadTestPage() { |
| 93 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); | 200 TestNavigationObserver navigation_observer(shell()->web_contents(), 1); |
| 94 shell()->LoadURL(GetTestUrl("media/session", "media-session.html")); | 201 shell()->LoadURL(GetTestUrl("media/session", "media-session.html")); |
| 95 navigation_observer.Wait(); | 202 navigation_observer.Wait(); |
| 96 } | 203 } |
| 97 | 204 |
| 98 void RunScript(const std::string& script) { | 205 void RunScript(const std::string& script) { |
| 99 ASSERT_TRUE(ExecuteScript(web_contents_->GetMainFrame(), script)); | 206 ASSERT_TRUE(ExecuteScript(web_contents_->GetMainFrame(), script)); |
| 100 } | 207 } |
| 101 | 208 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 116 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 223 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 117 FROM_HERE, run_loop.QuitClosure(), timeout); | 224 FROM_HERE, run_loop.QuitClosure(), timeout); |
| 118 run_loop.Run(); | 225 run_loop.Run(); |
| 119 } | 226 } |
| 120 | 227 |
| 121 void WaitForMediaSessionState(MediaSession::State state) { | 228 void WaitForMediaSessionState(MediaSession::State state) { |
| 122 ASSERT_TRUE(media_session_state_loop_runners_.count(state)); | 229 ASSERT_TRUE(media_session_state_loop_runners_.count(state)); |
| 123 media_session_state_loop_runners_[state]->Run(); | 230 media_session_state_loop_runners_[state]->Run(); |
| 124 } | 231 } |
| 125 | 232 |
| 126 protected: | 233 MediaSession::State ToMediaSessionState(SessionState state) { |
| 127 void TestSessionInactiveWhenHiddenAfterContentPause() { | 234 switch (state) { |
| 128 LoadTestPage(); | 235 case SessionState::ACTIVE: |
| 129 | 236 return MediaSession::State::ACTIVE; |
| 130 LOG(INFO) << "Starting player"; | 237 break; |
| 131 ClearMediaSessionStateLoopRunners(); | 238 case SessionState::SUSPENDED: |
| 132 RunScript(kStartPlayerScript); | 239 return MediaSession::State::SUSPENDED; |
| 133 LOG(INFO) << "Waiting for Session to be active"; | 240 break; |
| 134 WaitForMediaSessionState(MediaSession::State::ACTIVE); | 241 case SessionState::INACTIVE: |
| 135 | 242 return MediaSession::State::INACTIVE; |
| 136 LOG(INFO) << "Pausing player"; | 243 break; |
| 137 ClearMediaSessionStateLoopRunners(); | 244 default: |
| 138 RunScript(kPausePlayerScript); | 245 ADD_FAILURE() << "invalid SessionState to convert"; |
| 139 LOG(INFO) << "Waiting for Session to be suspended"; | 246 return MediaSession::State::INACTIVE; |
| 140 WaitForMediaSessionState(MediaSession::State::SUSPENDED); | 247 } |
| 141 | |
| 142 LOG(INFO) << "Hiding the tab"; | |
| 143 ClearMediaSessionStateLoopRunners(); | |
| 144 web_contents_->WasHidden(); | |
| 145 LOG(INFO) << "Waiting for Session to be inactive"; | |
| 146 WaitForMediaSessionState(MediaSession::State::INACTIVE); | |
| 147 | |
| 148 LOG(INFO) << "Test succeeded"; | |
| 149 } | |
| 150 | |
| 151 void TestSessionInactiveWhenHiddenWhilePlaying() { | |
| 152 LoadTestPage(); | |
| 153 | |
| 154 LOG(INFO) << "Starting player"; | |
| 155 ClearMediaSessionStateLoopRunners(); | |
| 156 RunScript(kStartPlayerScript); | |
| 157 LOG(INFO) << "Waiting for Session to be active"; | |
| 158 WaitForMediaSessionState(MediaSession::State::ACTIVE); | |
| 159 | |
| 160 LOG(INFO) << "Hiding the tab"; | |
| 161 ClearMediaSessionStateLoopRunners(); | |
| 162 web_contents_->WasHidden(); | |
| 163 LOG(INFO) << "Waiting for Session to be inactive"; | |
| 164 WaitForMediaSessionState(MediaSession::State::INACTIVE); | |
| 165 | |
| 166 LOG(INFO) << "Test succeeded"; | |
| 167 } | |
| 168 | |
| 169 void TestSessionSuspendedWhenHiddenWhilePlaying() { | |
| 170 LoadTestPage(); | |
| 171 | |
| 172 LOG(INFO) << "Starting player"; | |
| 173 ClearMediaSessionStateLoopRunners(); | |
| 174 RunScript(kStartPlayerScript); | |
| 175 LOG(INFO) << "Waiting for Session to be active"; | |
| 176 WaitForMediaSessionState(MediaSession::State::ACTIVE); | |
| 177 | |
| 178 LOG(INFO) << "Hiding the tab"; | |
| 179 ClearMediaSessionStateLoopRunners(); | |
| 180 web_contents_->WasHidden(); | |
| 181 LOG(INFO) << "Waiting for Session to be suspended"; | |
| 182 WaitForMediaSessionState(MediaSession::State::SUSPENDED); | |
| 183 | |
| 184 LOG(INFO) << "Test succeeded"; | |
| 185 } | |
| 186 | |
| 187 void TestSessionSuspendedWhenHiddenAfterContentPause() { | |
| 188 LoadTestPage(); | |
| 189 | |
| 190 LOG(INFO) << "Starting player"; | |
| 191 ClearMediaSessionStateLoopRunners(); | |
| 192 RunScript(kStartPlayerScript); | |
| 193 LOG(INFO) << "Waiting for Session to be active"; | |
| 194 WaitForMediaSessionState(MediaSession::State::ACTIVE); | |
| 195 | |
| 196 LOG(INFO) << "Pausing player"; | |
| 197 ClearMediaSessionStateLoopRunners(); | |
| 198 RunScript(kPausePlayerScript); | |
| 199 LOG(INFO) << "Waiting for Session to be suspended"; | |
| 200 WaitForMediaSessionState(MediaSession::State::SUSPENDED); | |
| 201 | |
| 202 LOG(INFO) << "Hiding the tab"; | |
| 203 // Wait for 1 second and check the MediaSession state. | |
| 204 // No better solution till now. | |
| 205 web_contents_->WasHidden(); | |
| 206 Wait(base::TimeDelta::FromSeconds(1)); | |
| 207 ASSERT_EQ(media_session_->audio_focus_state_, | |
| 208 MediaSession::State::SUSPENDED); | |
| 209 | |
| 210 LOG(INFO) << "Test succeeded"; | |
| 211 } | |
| 212 | |
| 213 void TestSessionActiveWhenHiddenWhilePlaying() { | |
| 214 LoadTestPage(); | |
| 215 | |
| 216 LOG(INFO) << "Starting player"; | |
| 217 ClearMediaSessionStateLoopRunners(); | |
| 218 RunScript(kStartPlayerScript); | |
| 219 LOG(INFO) << "Waiting for Session to be active"; | |
| 220 WaitForMediaSessionState(MediaSession::State::ACTIVE); | |
| 221 | |
| 222 LOG(INFO) << "Hiding the tab"; | |
| 223 // Wait for 1 second and check the MediaSession state. | |
| 224 // No better solution till now. | |
| 225 web_contents_->WasHidden(); | |
| 226 Wait(base::TimeDelta::FromSeconds(1)); | |
| 227 ASSERT_EQ(media_session_->audio_focus_state_, | |
| 228 MediaSession::State::ACTIVE); | |
| 229 | |
| 230 LOG(INFO) << "Test succeeded"; | |
| 231 } | 248 } |
| 232 | 249 |
| 233 WebContents* web_contents_; | 250 WebContents* web_contents_; |
| 234 MediaSession* media_session_; | 251 MediaSession* media_session_; |
| 235 // MessageLoopRunners for waiting MediaSession state to change. Note that the | 252 // MessageLoopRunners for waiting MediaSession state to change. Note that the |
| 236 // MessageLoopRunners can accept Quit() before calling Run(), thus the state | 253 // MessageLoopRunners can accept Quit() before calling Run(), thus the state |
| 237 // change can still be captured before waiting. For example, the MediaSession | 254 // change can still be captured before waiting. For example, the MediaSession |
| 238 // might go active immediately after calling HTMLMediaElement.play(). A test | 255 // might go active immediately after calling HTMLMediaElement.play(). A test |
| 239 // can listen to the state change before calling play(), and then wait for the | 256 // can listen to the state change before calling play(), and then wait for the |
| 240 // state change after play(). | 257 // state change after play(). |
| 241 std::map<MediaSession::State, scoped_refptr<MessageLoopRunner> > | 258 std::map<MediaSession::State, scoped_refptr<MessageLoopRunner> > |
| 242 media_session_state_loop_runners_; | 259 media_session_state_loop_runners_; |
| 243 std::unique_ptr<base::CallbackList<void(MediaSession::State)>::Subscription> | 260 std::unique_ptr<base::CallbackList<void(MediaSession::State)>::Subscription> |
| 244 media_session_state_callback_subscription_; | 261 media_session_state_callback_subscription_; |
| 245 | 262 |
| 246 private: | |
| 247 DISALLOW_COPY_AND_ASSIGN(MediaSessionVisibilityBrowserTest); | 263 DISALLOW_COPY_AND_ASSIGN(MediaSessionVisibilityBrowserTest); |
| 248 }; | 264 }; |
| 249 | 265 |
| 250 // Helper macro to include tests from the base class. | 266 namespace { |
| 251 #define INCLUDE_TEST_FROM_BASE_CLASS(test_fixture, test_name) \ | |
| 252 IN_PROC_BROWSER_TEST_F(test_fixture, test_name) { \ | |
| 253 test_name(); \ | |
| 254 } | |
| 255 | 267 |
| 256 /////////////////////////////////////////////////////////////////////////////// | 268 VisibilityTestData kTestParams[] = { |
| 257 // Configuration instances. | 269 { MediaSuspend::ENABLED, BackgroundResuming::DISABLED, |
| 258 | 270 SessionState::SUSPENDED, SessionState::INACTIVE }, |
| 259 // UnifiedPipeline + SuspendOnHide | 271 { MediaSuspend::ENABLED, BackgroundResuming::DISABLED, |
| 260 class MediaSessionVisibilityBrowserTest_UnifiedPipeline_SuspendOnHide : | 272 SessionState::ACTIVE, SessionState::INACTIVE }, |
| 261 public MediaSessionVisibilityBrowserTest { | 273 { MediaSuspend::ENABLED, BackgroundResuming::ENABLED, |
| 262 void SetUpCommandLine(base::CommandLine* command_line) override { | 274 SessionState::ACTIVE, SessionState::SUSPENDED }, |
| 263 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); | 275 { MediaSuspend::ENABLED, BackgroundResuming::ENABLED, |
| 264 #if !defined(OS_ANDROID) | 276 SessionState::SUSPENDED, SessionState::SUSPENDED }, |
| 265 command_line->AppendSwitch(switches::kEnableMediaSuspend); | 277 { MediaSuspend::DISABLED, BackgroundResuming::DISABLED, |
| 266 #endif // defined(OS_ANDROID) | 278 SessionState::SUSPENDED, SessionState::SUSPENDED }, |
| 267 } | 279 { MediaSuspend::DISABLED, BackgroundResuming::DISABLED, |
| 280 SessionState::ACTIVE, SessionState::ACTIVE }, |
| 281 { MediaSuspend::DISABLED, BackgroundResuming::ENABLED, |
| 282 SessionState::ACTIVE, SessionState::ACTIVE }, |
| 283 { MediaSuspend::DISABLED, BackgroundResuming::ENABLED, |
| 284 SessionState::SUSPENDED, SessionState::SUSPENDED }, |
| 268 }; | 285 }; |
| 269 | 286 |
| 270 INCLUDE_TEST_FROM_BASE_CLASS( | 287 Pipeline kPipelines[] = { |
| 271 MediaSessionVisibilityBrowserTest_UnifiedPipeline_SuspendOnHide, | 288 Pipeline::WMPI, |
| 272 TestSessionInactiveWhenHiddenAfterContentPause) | 289 #if defined(OS_ANDROID) |
| 273 INCLUDE_TEST_FROM_BASE_CLASS( | 290 Pipeline::WMPA, |
| 274 MediaSessionVisibilityBrowserTest_UnifiedPipeline_SuspendOnHide, | 291 #endif // defined(OS_ANDROID) |
| 275 TestSessionInactiveWhenHiddenWhilePlaying) | 292 }; |
| 276 | 293 |
| 277 IN_PROC_BROWSER_TEST_F( | 294 } // anonymous namespace |
| 278 MediaSessionVisibilityBrowserTest_UnifiedPipeline_SuspendOnHide, | 295 |
| 279 TestSessionSuspendedWhenHiddenWhilePlaying) { | 296 IN_PROC_BROWSER_TEST_P(MediaSessionVisibilityBrowserTest, |
| 280 EnableDisableResumingBackgroundVideos(true); | 297 TestEntryPoint) { |
| 281 TestSessionSuspendedWhenHiddenWhilePlaying(); | 298 StartPlayer(); |
| 299 MaybePausePlayer(); |
| 300 HideTab(); |
| 301 CheckSessionStateAfterHide(); |
| 282 } | 302 } |
| 283 | 303 |
| 284 IN_PROC_BROWSER_TEST_F( | 304 INSTANTIATE_TEST_CASE_P(MediaSessionVisibilityBrowserTestInstances, |
| 285 MediaSessionVisibilityBrowserTest_UnifiedPipeline_SuspendOnHide, | 305 MediaSessionVisibilityBrowserTest, |
| 286 TestSessionSuspendedWhenHiddenAfterContentPause) { | 306 ::testing::Combine(::testing::ValuesIn(kTestParams), |
| 287 EnableDisableResumingBackgroundVideos(true); | 307 ::testing::ValuesIn(kPipelines))); |
| 288 TestSessionSuspendedWhenHiddenAfterContentPause(); | |
| 289 } | |
| 290 | |
| 291 // UnifiedPipeline + NosuspendOnHide | |
| 292 class MediaSessionVisibilityBrowserTest_UnifiedPipeline_NosuspendOnHide : | |
| 293 public MediaSessionVisibilityBrowserTest { | |
| 294 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 295 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); | |
| 296 #if defined(OS_ANDROID) | |
| 297 command_line->AppendSwitch(switches::kDisableMediaSuspend); | |
| 298 #endif // defined(OS_ANDROID) | |
| 299 } | |
| 300 }; | |
| 301 | |
| 302 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 303 MediaSessionVisibilityBrowserTest_UnifiedPipeline_NosuspendOnHide, | |
| 304 TestSessionSuspendedWhenHiddenAfterContentPause) | |
| 305 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 306 MediaSessionVisibilityBrowserTest_UnifiedPipeline_NosuspendOnHide, | |
| 307 TestSessionActiveWhenHiddenWhilePlaying) | |
| 308 | |
| 309 IN_PROC_BROWSER_TEST_F( | |
| 310 MediaSessionVisibilityBrowserTest_UnifiedPipeline_NosuspendOnHide, | |
| 311 TestSessionActiveWhenHiddenWhilePlayingWithResume) { | |
| 312 EnableDisableResumingBackgroundVideos(true); | |
| 313 TestSessionActiveWhenHiddenWhilePlaying(); | |
| 314 } | |
| 315 | |
| 316 #if defined(OS_ANDROID) | |
| 317 // AndroidPipeline + SuspendOnHide | |
| 318 class MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide : | |
| 319 public MediaSessionVisibilityBrowserTest { | |
| 320 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 321 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); | |
| 322 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline); | |
| 323 } | |
| 324 }; | |
| 325 | |
| 326 // The following tests are flaky. Re-enabling with logging to see what's | |
| 327 // happening on the bots. See crbug.com/619096. | |
| 328 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 329 MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide, | |
| 330 TestSessionInactiveWhenHiddenAfterContentPause) | |
| 331 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 332 MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide, | |
| 333 TestSessionInactiveWhenHiddenWhilePlaying) | |
| 334 | |
| 335 // AndroidPipeline + NosuspendOnHide | |
| 336 class MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide : | |
| 337 public MediaSessionVisibilityBrowserTest { | |
| 338 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 339 MediaSessionVisibilityBrowserTest::SetUpCommandLine(command_line); | |
| 340 command_line->AppendSwitch(switches::kDisableUnifiedMediaPipeline); | |
| 341 command_line->AppendSwitch(switches::kDisableMediaSuspend); | |
| 342 } | |
| 343 }; | |
| 344 | |
| 345 // The following tests are flaky. Re-enabling with logging to see what's | |
| 346 // happening on the bots. See crbug.com/619096. | |
| 347 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 348 MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide, | |
| 349 TestSessionSuspendedWhenHiddenAfterContentPause) | |
| 350 INCLUDE_TEST_FROM_BASE_CLASS( | |
| 351 MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide, | |
| 352 TestSessionActiveWhenHiddenWhilePlaying) | |
| 353 | |
| 354 #endif // defined(OS_ANDROID) | |
| 355 | 308 |
| 356 } // namespace content | 309 } // namespace content |
| OLD | NEW |