| 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> | 5 #include <tuple> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // Base class of MediaSession visibility tests. The class is intended | 55 // Base class of MediaSession visibility tests. The class is intended |
| 56 // to be used to run tests under different configurations. Tests | 56 // to be used to run tests under different configurations. Tests |
| 57 // should inheret from this class, set up their own command line per | 57 // should inheret from this class, set up their own command line per |
| 58 // their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to | 58 // their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to |
| 59 // include required tests. See | 59 // include required tests. See |
| 60 // media_session_visibility_browsertest_instances.cc for examples. | 60 // media_session_visibility_browsertest_instances.cc for examples. |
| 61 class MediaSessionImplVisibilityBrowserTest | 61 class MediaSessionImplVisibilityBrowserTest |
| 62 : public ContentBrowserTest, | 62 : public ContentBrowserTest, |
| 63 public ::testing::WithParamInterface<VisibilityTestData> { | 63 public ::testing::WithParamInterface<VisibilityTestData> { |
| 64 public: | 64 public: |
| 65 MediaSessionImplVisibilityBrowserTest() = default; | 65 MediaSessionImplVisibilityBrowserTest() { |
| 66 VisibilityTestData params = GetVisibilityTestData(); |
| 67 EnableDisableResumingBackgroundVideos(params.background_resuming == |
| 68 BackgroundResuming::ENABLED); |
| 69 } |
| 70 |
| 66 ~MediaSessionImplVisibilityBrowserTest() override = default; | 71 ~MediaSessionImplVisibilityBrowserTest() override = default; |
| 67 | 72 |
| 68 void SetUpOnMainThread() override { | 73 void SetUpOnMainThread() override { |
| 69 ContentBrowserTest::SetUpOnMainThread(); | 74 ContentBrowserTest::SetUpOnMainThread(); |
| 70 web_contents_ = shell()->web_contents(); | 75 web_contents_ = shell()->web_contents(); |
| 71 media_session_ = MediaSessionImpl::Get(web_contents_); | 76 media_session_ = MediaSessionImpl::Get(web_contents_); |
| 72 | 77 |
| 73 media_session_state_loop_runners_[MediaSessionImpl::State::ACTIVE] = | 78 media_session_state_loop_runners_[MediaSessionImpl::State::ACTIVE] = |
| 74 new MessageLoopRunner(); | 79 new MessageLoopRunner(); |
| 75 media_session_state_loop_runners_[MediaSessionImpl::State::SUSPENDED] = | 80 media_session_state_loop_runners_[MediaSessionImpl::State::SUSPENDED] = |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 #if !defined(OS_ANDROID) | 106 #if !defined(OS_ANDROID) |
| 102 command_line->AppendSwitch(switches::kEnableAudioFocus); | 107 command_line->AppendSwitch(switches::kEnableAudioFocus); |
| 103 #endif // !defined(OS_ANDROID) | 108 #endif // !defined(OS_ANDROID) |
| 104 | 109 |
| 105 VisibilityTestData params = GetVisibilityTestData(); | 110 VisibilityTestData params = GetVisibilityTestData(); |
| 106 | 111 |
| 107 if (params.media_suspend == MediaSuspend::ENABLED) | 112 if (params.media_suspend == MediaSuspend::ENABLED) |
| 108 command_line->AppendSwitch(switches::kEnableMediaSuspend); | 113 command_line->AppendSwitch(switches::kEnableMediaSuspend); |
| 109 else | 114 else |
| 110 command_line->AppendSwitch(switches::kDisableMediaSuspend); | 115 command_line->AppendSwitch(switches::kDisableMediaSuspend); |
| 111 | |
| 112 if (params.background_resuming == BackgroundResuming::ENABLED) { | |
| 113 command_line->AppendSwitchASCII(switches::kEnableFeatures, | |
| 114 media::kResumeBackgroundVideo.name); | |
| 115 } else { | |
| 116 command_line->AppendSwitchASCII(switches::kDisableFeatures, | |
| 117 media::kResumeBackgroundVideo.name); | |
| 118 } | |
| 119 } | 116 } |
| 120 | 117 |
| 121 const VisibilityTestData& GetVisibilityTestData() { | 118 const VisibilityTestData& GetVisibilityTestData() { |
| 122 return GetParam(); | 119 return GetParam(); |
| 123 } | 120 } |
| 124 | 121 |
| 125 void StartPlayer() { | 122 void StartPlayer() { |
| 126 LoadTestPage(); | 123 LoadTestPage(); |
| 127 | 124 |
| 128 LOG(INFO) << "Starting player"; | 125 LOG(INFO) << "Starting player"; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 MaybePausePlayer(); | 267 MaybePausePlayer(); |
| 271 HideTab(); | 268 HideTab(); |
| 272 CheckSessionStateAfterHide(); | 269 CheckSessionStateAfterHide(); |
| 273 } | 270 } |
| 274 | 271 |
| 275 INSTANTIATE_TEST_CASE_P(MediaSessionImplVisibilityBrowserTestInstances, | 272 INSTANTIATE_TEST_CASE_P(MediaSessionImplVisibilityBrowserTestInstances, |
| 276 MediaSessionImplVisibilityBrowserTest, | 273 MediaSessionImplVisibilityBrowserTest, |
| 277 ::testing::ValuesIn(kTestParams)); | 274 ::testing::ValuesIn(kTestParams)); |
| 278 | 275 |
| 279 } // namespace content | 276 } // namespace content |
| OLD | NEW |