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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 1570043002: Implement MediaSession on top of the WebMediaPlayerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session
Patch Set: Rebase yet again. Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 3218 matching lines...) Expand 10 before | Expand all | Expand 10 after
3229 // be false. The power save blocker should be released. 3229 // be false. The power save blocker should be released.
3230 monitor->set_was_recently_audible_for_testing(false); 3230 monitor->set_was_recently_audible_for_testing(false);
3231 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); 3231 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
3232 EXPECT_FALSE(has_audio_power_save_blocker()); 3232 EXPECT_FALSE(has_audio_power_save_blocker());
3233 } 3233 }
3234 3234
3235 // Start a player with both audio and video. A video power save blocker 3235 // Start a player with both audio and video. A video power save blocker
3236 // should be created. If audio stream monitoring is available, an audio power 3236 // should be created. If audio stream monitoring is available, an audio power
3237 // save blocker should be created too. 3237 // save blocker should be created too.
3238 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 3238 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
3239 0, kPlayerAudioVideoId, true, true, false)); 3239 0, kPlayerAudioVideoId, true, true, false, base::TimeDelta()));
3240 EXPECT_TRUE(has_video_power_save_blocker()); 3240 EXPECT_TRUE(has_video_power_save_blocker());
3241 EXPECT_EQ(has_audio_power_save_blocker(), 3241 EXPECT_EQ(has_audio_power_save_blocker(),
3242 !AudioStreamMonitor::monitoring_available()); 3242 !AudioStreamMonitor::monitoring_available());
3243 3243
3244 // Upon hiding the video power save blocker should be released. 3244 // Upon hiding the video power save blocker should be released.
3245 contents()->WasHidden(); 3245 contents()->WasHidden();
3246 EXPECT_FALSE(has_video_power_save_blocker()); 3246 EXPECT_FALSE(has_video_power_save_blocker());
3247 3247
3248 // Start another player that only has video. There should be no change in 3248 // Start another player that only has video. There should be no change in
3249 // the power save blockers. The notification should take into account the 3249 // the power save blockers. The notification should take into account the
3250 // visibility state of the WebContents. 3250 // visibility state of the WebContents.
3251 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 3251 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
3252 0, kPlayerVideoOnlyId, true, false, false)); 3252 0, kPlayerVideoOnlyId, true, false, false, base::TimeDelta()));
3253 EXPECT_FALSE(has_video_power_save_blocker()); 3253 EXPECT_FALSE(has_video_power_save_blocker());
3254 EXPECT_EQ(has_audio_power_save_blocker(), 3254 EXPECT_EQ(has_audio_power_save_blocker(),
3255 !AudioStreamMonitor::monitoring_available()); 3255 !AudioStreamMonitor::monitoring_available());
3256 3256
3257 // Showing the WebContents should result in the creation of the blocker. 3257 // Showing the WebContents should result in the creation of the blocker.
3258 contents()->WasShown(); 3258 contents()->WasShown();
3259 EXPECT_TRUE(has_video_power_save_blocker()); 3259 EXPECT_TRUE(has_video_power_save_blocker());
3260 3260
3261 // Start another player that only has audio. There should be no change in 3261 // Start another player that only has audio. There should be no change in
3262 // the power save blockers. 3262 // the power save blockers.
3263 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 3263 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
3264 0, kPlayerAudioOnlyId, false, true, false)); 3264 0, kPlayerAudioOnlyId, false, true, false, base::TimeDelta()));
3265 EXPECT_TRUE(has_video_power_save_blocker()); 3265 EXPECT_TRUE(has_video_power_save_blocker());
3266 EXPECT_EQ(has_audio_power_save_blocker(), 3266 EXPECT_EQ(has_audio_power_save_blocker(),
3267 !AudioStreamMonitor::monitoring_available()); 3267 !AudioStreamMonitor::monitoring_available());
3268 3268
3269 // Start a remote player. There should be no change in the power save 3269 // Start a remote player. There should be no change in the power save
3270 // blockers. 3270 // blockers.
3271 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 3271 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
3272 0, kPlayerRemoteId, true, true, true)); 3272 0, kPlayerRemoteId, true, true, true, base::TimeDelta()));
3273 EXPECT_TRUE(has_video_power_save_blocker()); 3273 EXPECT_TRUE(has_video_power_save_blocker());
3274 EXPECT_EQ(has_audio_power_save_blocker(), 3274 EXPECT_EQ(has_audio_power_save_blocker(),
3275 !AudioStreamMonitor::monitoring_available()); 3275 !AudioStreamMonitor::monitoring_available());
3276 3276
3277 // Destroy the original audio video player. Both power save blockers should 3277 // Destroy the original audio video player. Both power save blockers should
3278 // remain. 3278 // remain.
3279 rfh->OnMessageReceived( 3279 rfh->OnMessageReceived(
3280 FrameHostMsg_MediaPausedNotification(0, kPlayerAudioVideoId)); 3280 FrameHostMsg_MediaPausedNotification(0, kPlayerAudioVideoId, false));
3281 EXPECT_TRUE(has_video_power_save_blocker()); 3281 EXPECT_TRUE(has_video_power_save_blocker());
3282 EXPECT_EQ(has_audio_power_save_blocker(), 3282 EXPECT_EQ(has_audio_power_save_blocker(),
3283 !AudioStreamMonitor::monitoring_available()); 3283 !AudioStreamMonitor::monitoring_available());
3284 3284
3285 // Destroy the audio only player. The video power save blocker should remain. 3285 // Destroy the audio only player. The video power save blocker should remain.
3286 rfh->OnMessageReceived( 3286 rfh->OnMessageReceived(
3287 FrameHostMsg_MediaPausedNotification(0, kPlayerAudioOnlyId)); 3287 FrameHostMsg_MediaPausedNotification(0, kPlayerAudioOnlyId, false));
3288 EXPECT_TRUE(has_video_power_save_blocker()); 3288 EXPECT_TRUE(has_video_power_save_blocker());
3289 EXPECT_FALSE(has_audio_power_save_blocker()); 3289 EXPECT_FALSE(has_audio_power_save_blocker());
3290 3290
3291 // Destroy the video only player. No power save blockers should remain. 3291 // Destroy the video only player. No power save blockers should remain.
3292 rfh->OnMessageReceived( 3292 rfh->OnMessageReceived(
3293 FrameHostMsg_MediaPausedNotification(0, kPlayerVideoOnlyId)); 3293 FrameHostMsg_MediaPausedNotification(0, kPlayerVideoOnlyId, false));
3294 EXPECT_FALSE(has_video_power_save_blocker()); 3294 EXPECT_FALSE(has_video_power_save_blocker());
3295 EXPECT_FALSE(has_audio_power_save_blocker()); 3295 EXPECT_FALSE(has_audio_power_save_blocker());
3296 3296
3297 // Destroy the remote player. No power save blockers should remain. 3297 // Destroy the remote player. No power save blockers should remain.
3298 rfh->OnMessageReceived( 3298 rfh->OnMessageReceived(
3299 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 3299 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId, false));
3300 EXPECT_FALSE(has_video_power_save_blocker()); 3300 EXPECT_FALSE(has_video_power_save_blocker());
3301 EXPECT_FALSE(has_audio_power_save_blocker()); 3301 EXPECT_FALSE(has_audio_power_save_blocker());
3302 3302
3303 // Start a player with both audio and video. A video power save blocker 3303 // Start a player with both audio and video. A video power save blocker
3304 // should be created. If audio stream monitoring is available, an audio power 3304 // should be created. If audio stream monitoring is available, an audio power
3305 // save blocker should be created too. 3305 // save blocker should be created too.
3306 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification( 3306 rfh->OnMessageReceived(FrameHostMsg_MediaPlayingNotification(
3307 0, kPlayerAudioVideoId, true, true, false)); 3307 0, kPlayerAudioVideoId, true, true, false, base::TimeDelta()));
3308 EXPECT_TRUE(has_video_power_save_blocker()); 3308 EXPECT_TRUE(has_video_power_save_blocker());
3309 EXPECT_EQ(has_audio_power_save_blocker(), 3309 EXPECT_EQ(has_audio_power_save_blocker(),
3310 !AudioStreamMonitor::monitoring_available()); 3310 !AudioStreamMonitor::monitoring_available());
3311 3311
3312 // Crash the renderer. 3312 // Crash the renderer.
3313 contents()->GetMainFrame()->GetProcess()->SimulateCrash(); 3313 contents()->GetMainFrame()->GetProcess()->SimulateCrash();
3314 3314
3315 // Verify that all the power save blockers have been released. 3315 // Verify that all the power save blockers have been released.
3316 EXPECT_FALSE(has_video_power_save_blocker()); 3316 EXPECT_FALSE(has_video_power_save_blocker());
3317 EXPECT_FALSE(has_audio_power_save_blocker()); 3317 EXPECT_FALSE(has_audio_power_save_blocker());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3378 backend->AllowCertForHost(*cert, test_url.host(), 1); 3378 backend->AllowCertForHost(*cert, test_url.host(), 1);
3379 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3379 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3380 3380
3381 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type", 3381 contents()->OnDidLoadResourceFromMemoryCache(test_url, "", "GET", "mime type",
3382 RESOURCE_TYPE_MAIN_FRAME); 3382 RESOURCE_TYPE_MAIN_FRAME);
3383 3383
3384 EXPECT_TRUE(backend->HasAllowException(test_url.host())); 3384 EXPECT_TRUE(backend->HasAllowException(test_url.host()));
3385 } 3385 }
3386 3386
3387 } // namespace content 3387 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698