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

Unified Diff: content/browser/media/session/media_session_browsertest.cc

Issue 2439483003: Link MediaSessionTabHelper with native MediaSession [CL is going to be split] (Closed)
Patch Set: addressed comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/session/media_session_browsertest.cc
diff --git a/content/browser/media/session/media_session_browsertest.cc b/content/browser/media/session/media_session_browsertest.cc
index 5f79eeb2862e0ff58f59de8340865ac4200b620a..06171b04380583f8da8e7e2221e35f30fbd25ccf 100644
--- a/content/browser/media/session/media_session_browsertest.cc
+++ b/content/browser/media/session/media_session_browsertest.cc
@@ -14,16 +14,15 @@
#include "base/test/histogram_tester.h"
#include "base/test/simple_test_tick_clock.h"
#include "content/browser/media/session/audio_focus_delegate.h"
+#include "content/browser/media/session/media_session_observer.h"
#include "content/browser/media/session/mock_media_session_player_observer.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/content_browser_test.h"
#include "content/shell/browser/shell.h"
#include "media/base/media_content_type.h"
#include "testing/gmock/include/gmock/gmock.h"
using content::WebContents;
-using content::WebContentsObserver;
using content::MediaSession;
using content::AudioFocusDelegate;
using content::MediaSessionPlayerObserver;
@@ -47,10 +46,10 @@ class MockAudioFocusDelegate : public AudioFocusDelegate {
}
};
-class MockWebContentsObserver : public WebContentsObserver {
+class MockMediaSessionObserver : public content::MediaSessionObserver {
public:
- MockWebContentsObserver(WebContents* web_contents)
- : WebContentsObserver(web_contents) {}
+ MockMediaSessionObserver(MediaSession* session)
+ : MediaSessionObserver(session) {}
MOCK_METHOD2(MediaSessionStateChanged,
void(bool is_controllable, bool is_suspended));
@@ -65,8 +64,8 @@ class MediaSessionBrowserTest : public content::ContentBrowserTest {
void SetUpOnMainThread() override {
ContentBrowserTest::SetUpOnMainThread();
- mock_web_contents_observer_.reset(
- new MockWebContentsObserver(shell()->web_contents()));
+ mock_media_session_observer_.reset(new MockMediaSessionObserver(
+ MediaSession::Get(shell()->web_contents())));
media_session_ = MediaSession::Get(shell()->web_contents());
media_session_->SetDelegateForTests(
std::unique_ptr<AudioFocusDelegate>(new MockAudioFocusDelegate()));
@@ -74,7 +73,7 @@ class MediaSessionBrowserTest : public content::ContentBrowserTest {
}
void TearDownOnMainThread() override {
- mock_web_contents_observer_.reset();
+ mock_media_session_observer_.reset();
media_session_->RemoveAllPlayersForTest();
media_session_ = nullptr;
@@ -152,8 +151,8 @@ class MediaSessionBrowserTest : public content::ContentBrowserTest {
media_session_->StopDucking();
}
- MockWebContentsObserver* mock_web_contents_observer() {
- return mock_web_contents_observer_.get();
+ MockMediaSessionObserver* mock_media_session_observer() {
+ return mock_media_session_observer_.get();
}
std::unique_ptr<MediaSession> CreateDummyMediaSession() {
@@ -166,7 +165,7 @@ class MediaSessionBrowserTest : public content::ContentBrowserTest {
protected:
MediaSession* media_session_;
- std::unique_ptr<MockWebContentsObserver> mock_web_contents_observer_;
+ std::unique_ptr<MockMediaSessionObserver> mock_media_session_observer_;
DISALLOW_COPY_AND_ASSIGN(MediaSessionBrowserTest);
};
@@ -590,7 +589,7 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, AudioFocusType) {
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsShowForContent) {
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
@@ -605,7 +604,7 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsShowForContent) {
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsNoShowForTransient) {
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, false));
std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
@@ -620,9 +619,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsNoShowForTransient) {
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsHideWhenStopped) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, true))
.After(showControls);
@@ -639,7 +638,7 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsHideWhenStopped) {
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsShownAcceptTransient) {
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
@@ -659,8 +658,8 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsShownAcceptTransient) {
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsShownAfterContentAdded) {
Expectation dontShowControls = EXPECT_CALL(
- *mock_web_contents_observer(), MediaSessionStateChanged(false, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ *mock_media_session_observer(), MediaSessionStateChanged(false, false));
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false))
.After(dontShowControls);
@@ -680,7 +679,7 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsStayIfOnlyOnePlayerHasBeenPaused) {
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
@@ -701,9 +700,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsHideWhenTheLastPlayerIsRemoved) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, true))
.After(showControls);
std::unique_ptr<MockMediaSessionPlayerObserver> player_observer(
@@ -727,9 +726,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsHideWhenAllThePlayersAreRemoved) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, true))
.After(showControls);
@@ -749,9 +748,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsNotHideWhenTheLastPlayerIsPaused) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
@@ -776,9 +775,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
SuspendTemporaryUpdatesControls) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
@@ -795,12 +794,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsUpdatedWhenResumed) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false))
.After(pauseControls);
@@ -818,9 +817,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ControlsUpdatedWhenResumed) {
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsHideWhenSessionSuspendedPermanently) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, true))
.After(showControls);
@@ -838,12 +837,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ConstrolsHideWhenSessionStops) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, true))
.After(pauseControls);
@@ -861,12 +860,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsHideWhenSessionChangesFromContentToTransient) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(false, false))
.After(pauseControls);
@@ -888,12 +887,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsUpdatedWhenNewPlayerResetsSession) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false))
.After(pauseControls);
@@ -914,12 +913,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsResumedWhenPlayerIsResumed) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false))
.After(pauseControls);
@@ -940,9 +939,9 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsUpdatedDueToResumeSessionAction) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
@@ -959,12 +958,12 @@ IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
ControlsUpdatedDueToSuspendSessionAction) {
- Expectation showControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation showControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false));
- Expectation pauseControls = EXPECT_CALL(*mock_web_contents_observer(),
+ Expectation pauseControls = EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, true))
.After(showControls);
- EXPECT_CALL(*mock_web_contents_observer(),
+ EXPECT_CALL(*mock_media_session_observer(),
MediaSessionStateChanged(true, false))
.After(pauseControls);

Powered by Google App Engine
This is Rietveld 408576698