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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 2846813002: Convert MediaWebContentsObsever to be the client of WakeLock mojo interface. (Closed)
Patch Set: remove dependency, code rebase Created 3 years, 7 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
« no previous file with comments | « content/browser/media/media_web_contents_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index 36ce1924d1dbcfd1388a83d87c375011be32f515..1eda27565a29aaec4708c4c0bdbb119436eff283 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -257,16 +257,16 @@ class WebContentsImplTest : public RenderViewHostImplTestHarness {
RenderViewHostImplTestHarness::TearDown();
}
- bool has_audio_power_save_blocker() {
+ bool has_audio_wake_lock() {
return contents()
->media_web_contents_observer()
- ->has_audio_power_save_blocker_for_testing();
+ ->has_audio_wake_lock_for_testing();
}
- bool has_video_power_save_blocker() {
+ bool has_video_wake_lock() {
return contents()
->media_web_contents_observer()
- ->has_video_power_save_blocker_for_testing();
+ ->has_video_wake_lock_for_testing();
}
};
@@ -3214,15 +3214,15 @@ TEST_F(WebContentsImplTest, NoEarlyStop) {
EXPECT_FALSE(contents()->IsLoading());
}
-TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) {
+TEST_F(WebContentsImplTest, MediaWakeLock) {
// Verify that both negative and positive player ids don't blow up.
const int kPlayerAudioVideoId = 15;
const int kPlayerAudioOnlyId = -15;
const int kPlayerVideoOnlyId = 30;
const int kPlayerRemoteId = -30;
- EXPECT_FALSE(has_audio_power_save_blocker());
- EXPECT_FALSE(has_video_power_save_blocker());
+ EXPECT_FALSE(has_audio_wake_lock());
+ EXPECT_FALSE(has_video_wake_lock());
TestRenderFrameHost* rfh = main_test_rfh();
AudioStreamMonitor* monitor = contents()->audio_stream_monitor();
@@ -3230,100 +3230,100 @@ TEST_F(WebContentsImplTest, MediaPowerSaveBlocking) {
// Ensure RenderFrame is initialized before simulating events coming from it.
main_test_rfh()->InitializeRenderFrameIfNeeded();
- // Send a fake audio stream monitor notification. The audio power save
- // blocker should be created.
+ // Send a fake audio stream monitor notification. The audio wake lock
+ // should be created.
monitor->set_was_recently_audible_for_testing(true);
contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
- EXPECT_TRUE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_audio_wake_lock());
// Send another fake notification, this time when WasRecentlyAudible() will
- // be false. The power save blocker should be released.
+ // be false. The wake lock should be released.
monitor->set_was_recently_audible_for_testing(false);
contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Start a player with both audio and video. A video power save blocker
+ // Start a player with both audio and video. A video wake lock
// should be created. If audio stream monitoring is available, an audio power
// save blocker should be created too.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying(
0, kPlayerAudioVideoId, true, true, false,
media::MediaContentType::Persistent));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Upon hiding the video power save blocker should be released.
+ // Upon hiding the video wake lock should be released.
contents()->WasHidden();
- EXPECT_FALSE(has_video_power_save_blocker());
+ EXPECT_FALSE(has_video_wake_lock());
// Start another player that only has video. There should be no change in
- // the power save blockers. The notification should take into account the
+ // the wake locks. The notification should take into account the
// visibility state of the WebContents.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying(
0, kPlayerVideoOnlyId, true, false, false,
media::MediaContentType::Persistent));
- EXPECT_FALSE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_FALSE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
// Showing the WebContents should result in the creation of the blocker.
contents()->WasShown();
- EXPECT_TRUE(has_video_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
// Start another player that only has audio. There should be no change in
- // the power save blockers.
+ // the wake locks.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying(
0, kPlayerAudioOnlyId, false, true, false,
media::MediaContentType::Persistent));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
// Start a remote player. There should be no change in the power save
// blockers.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying(
0, kPlayerRemoteId, true, true, true,
media::MediaContentType::Persistent));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Destroy the original audio video player. Both power save blockers should
+ // Destroy the original audio video player. Both wake locks should
// remain.
rfh->OnMessageReceived(
MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerAudioVideoId, false));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Destroy the audio only player. The video power save blocker should remain.
+ // Destroy the audio only player. The video wake lock should remain.
rfh->OnMessageReceived(
MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerAudioOnlyId, false));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Destroy the video only player. No power save blockers should remain.
+ // Destroy the video only player. No wake locks should remain.
rfh->OnMessageReceived(
MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerVideoOnlyId, false));
- EXPECT_FALSE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_FALSE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Destroy the remote player. No power save blockers should remain.
+ // Destroy the remote player. No wake locks should remain.
rfh->OnMessageReceived(
MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerRemoteId, false));
- EXPECT_FALSE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_FALSE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
- // Start a player with both audio and video. A video power save blocker
+ // Start a player with both audio and video. A video wake lock
// should be created. If audio stream monitoring is available, an audio power
// save blocker should be created too.
rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying(
0, kPlayerAudioVideoId, true, true, false,
media::MediaContentType::Persistent));
- EXPECT_TRUE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ EXPECT_TRUE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
// Crash the renderer.
main_test_rfh()->GetProcess()->SimulateCrash();
- // Verify that all the power save blockers have been released.
- EXPECT_FALSE(has_video_power_save_blocker());
- EXPECT_FALSE(has_audio_power_save_blocker());
+ // Verify that all the wake locks have been released.
+ EXPECT_FALSE(has_video_wake_lock());
+ EXPECT_FALSE(has_audio_wake_lock());
}
TEST_F(WebContentsImplTest, ThemeColorChangeDependingOnFirstVisiblePaint) {
« no previous file with comments | « content/browser/media/media_web_contents_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698