| Index: content/browser/media/session/media_session_visibility_browsertest.cc
|
| diff --git a/content/browser/media/session/media_session_visibility_browsertest.cc b/content/browser/media/session/media_session_visibility_browsertest.cc
|
| index 74d4eb99f335b480a395661fe9868745b1b8026e..659b3c1a4d8b1a6a4c06e2bcb299c916762e6cae 100644
|
| --- a/content/browser/media/session/media_session_visibility_browsertest.cc
|
| +++ b/content/browser/media/session/media_session_visibility_browsertest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "base/command_line.h"
|
| #include "base/location.h"
|
| +#include "base/logging.h"
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "content/browser/media/session/media_session.h"
|
| @@ -109,63 +110,89 @@ class MediaSessionVisibilityBrowserTest
|
| void TestSessionInactiveWhenHiddenAfterContentPause() {
|
| LoadTestPage();
|
|
|
| + LOG(INFO) << "Starting player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kStartPlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be active";
|
| WaitForMediaSessionState(MediaSession::State::ACTIVE);
|
|
|
| + LOG(INFO) << "Pausing player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kPausePlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be suspended";
|
| WaitForMediaSessionState(MediaSession::State::SUSPENDED);
|
|
|
| + LOG(INFO) << "Hiding the tab";
|
| ClearMediaSessionStateLoopRunners();
|
| web_contents_->WasHidden();
|
| + LOG(INFO) << "Waiting for Session to be inactive";
|
| WaitForMediaSessionState(MediaSession::State::INACTIVE);
|
| +
|
| + LOG(INFO) << "Test succeeded";
|
| }
|
|
|
| void TestSessionInactiveWhenHiddenWhilePlaying() {
|
| LoadTestPage();
|
|
|
| + LOG(INFO) << "Starting player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kStartPlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be active";
|
| WaitForMediaSessionState(MediaSession::State::ACTIVE);
|
|
|
| + LOG(INFO) << "Hiding the tab";
|
| ClearMediaSessionStateLoopRunners();
|
| web_contents_->WasHidden();
|
| + LOG(INFO) << "Waiting for Session to be inactive";
|
| WaitForMediaSessionState(MediaSession::State::INACTIVE);
|
| +
|
| + LOG(INFO) << "Test succeeded";
|
| }
|
|
|
| void TestSessionSuspendedWhenHiddenAfterContentPause() {
|
| LoadTestPage();
|
|
|
| + LOG(INFO) << "Starting player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kStartPlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be active";
|
| WaitForMediaSessionState(MediaSession::State::ACTIVE);
|
|
|
| + LOG(INFO) << "Pausing player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kPausePlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be suspended";
|
| WaitForMediaSessionState(MediaSession::State::SUSPENDED);
|
|
|
| + LOG(INFO) << "Hiding the tab";
|
| // Wait for 1 second and check the MediaSession state.
|
| // No better solution till now.
|
| web_contents_->WasHidden();
|
| Wait(base::TimeDelta::FromSeconds(1));
|
| ASSERT_EQ(media_session_->audio_focus_state_,
|
| MediaSession::State::SUSPENDED);
|
| +
|
| + LOG(INFO) << "Test succeeded";
|
| }
|
|
|
| void TestSessionActiveWhenHiddenWhilePlaying() {
|
| LoadTestPage();
|
|
|
| + LOG(INFO) << "Starting player";
|
| ClearMediaSessionStateLoopRunners();
|
| RunScript(kStartPlayerScript);
|
| + LOG(INFO) << "Waiting for Session to be active";
|
| WaitForMediaSessionState(MediaSession::State::ACTIVE);
|
|
|
| + LOG(INFO) << "Hiding the tab";
|
| // Wait for 1 second and check the MediaSession state.
|
| // No better solution till now.
|
| web_contents_->WasHidden();
|
| Wait(base::TimeDelta::FromSeconds(1));
|
| ASSERT_EQ(media_session_->audio_focus_state_,
|
| MediaSession::State::ACTIVE);
|
| +
|
| + LOG(INFO) << "Test succeeded";
|
| }
|
|
|
| WebContents* web_contents_;
|
| @@ -240,13 +267,14 @@ class MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide :
|
| }
|
| };
|
|
|
| -// Disabled pending crbug.com/619096.
|
| -// INCLUDE_TEST_FROM_BASE_CLASS(
|
| -// MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
|
| -// TestSessionInactiveWhenHiddenAfterContentPause)
|
| -// INCLUDE_TEST_FROM_BASE_CLASS(
|
| -// MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
|
| -// TestSessionInactiveWhenHiddenWhilePlaying)
|
| +// The following tests are flaky. Re-enabling with logging to see what's
|
| +// happening on the bots. See crbug.com/619096.
|
| +INCLUDE_TEST_FROM_BASE_CLASS(
|
| + MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
|
| + TestSessionInactiveWhenHiddenAfterContentPause)
|
| +INCLUDE_TEST_FROM_BASE_CLASS(
|
| + MediaSessionVisibilityBrowserTest_AndroidPipeline_SuspendOnHide,
|
| + TestSessionInactiveWhenHiddenWhilePlaying)
|
|
|
| // AndroidPipeline + NosuspendOnHide
|
| class MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide :
|
| @@ -258,13 +286,14 @@ class MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide :
|
| }
|
| };
|
|
|
| -// Disabled pending crbug.com/619096.
|
| -// INCLUDE_TEST_FROM_BASE_CLASS(
|
| -// MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
|
| -// TestSessionSuspendedWhenHiddenAfterContentPause)
|
| -//INCLUDE_TEST_FROM_BASE_CLASS(
|
| -// MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
|
| -// TestSessionActiveWhenHiddenWhilePlaying)
|
| +// The following tests are flaky. Re-enabling with logging to see what's
|
| +// happening on the bots. See crbug.com/619096.
|
| +INCLUDE_TEST_FROM_BASE_CLASS(
|
| + MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
|
| + TestSessionSuspendedWhenHiddenAfterContentPause)
|
| +INCLUDE_TEST_FROM_BASE_CLASS(
|
| + MediaSessionVisibilityBrowserTest_AndroidPipeline_NosuspendOnHide,
|
| + TestSessionActiveWhenHiddenWhilePlaying)
|
|
|
| #endif // defined(OS_ANDROID)
|
|
|
|
|