| OLD | NEW |
| 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 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3247 // be false. The power save blocker should be released. | 3247 // be false. The power save blocker should be released. |
| 3248 monitor->set_was_recently_audible_for_testing(false); | 3248 monitor->set_was_recently_audible_for_testing(false); |
| 3249 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | 3249 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
| 3250 EXPECT_FALSE(has_audio_power_save_blocker()); | 3250 EXPECT_FALSE(has_audio_power_save_blocker()); |
| 3251 } | 3251 } |
| 3252 | 3252 |
| 3253 // Start a player with both audio and video. A video power save blocker | 3253 // Start a player with both audio and video. A video power save blocker |
| 3254 // should be created. If audio stream monitoring is available, an audio power | 3254 // should be created. If audio stream monitoring is available, an audio power |
| 3255 // save blocker should be created too. | 3255 // save blocker should be created too. |
| 3256 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( | 3256 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( |
| 3257 0, kPlayerAudioVideoId, true, true, false, base::TimeDelta())); | 3257 0, kPlayerAudioVideoId, true, true, false, |
| 3258 media::MediaContentType::Persistent)); |
| 3258 EXPECT_TRUE(has_video_power_save_blocker()); | 3259 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3259 EXPECT_EQ(has_audio_power_save_blocker(), | 3260 EXPECT_EQ(has_audio_power_save_blocker(), |
| 3260 !AudioStreamMonitor::monitoring_available()); | 3261 !AudioStreamMonitor::monitoring_available()); |
| 3261 | 3262 |
| 3262 // Upon hiding the video power save blocker should be released. | 3263 // Upon hiding the video power save blocker should be released. |
| 3263 contents()->WasHidden(); | 3264 contents()->WasHidden(); |
| 3264 EXPECT_FALSE(has_video_power_save_blocker()); | 3265 EXPECT_FALSE(has_video_power_save_blocker()); |
| 3265 | 3266 |
| 3266 // Start another player that only has video. There should be no change in | 3267 // Start another player that only has video. There should be no change in |
| 3267 // the power save blockers. The notification should take into account the | 3268 // the power save blockers. The notification should take into account the |
| 3268 // visibility state of the WebContents. | 3269 // visibility state of the WebContents. |
| 3269 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( | 3270 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( |
| 3270 0, kPlayerVideoOnlyId, true, false, false, base::TimeDelta())); | 3271 0, kPlayerVideoOnlyId, true, false, false, |
| 3272 media::MediaContentType::Persistent)); |
| 3271 EXPECT_FALSE(has_video_power_save_blocker()); | 3273 EXPECT_FALSE(has_video_power_save_blocker()); |
| 3272 EXPECT_EQ(has_audio_power_save_blocker(), | 3274 EXPECT_EQ(has_audio_power_save_blocker(), |
| 3273 !AudioStreamMonitor::monitoring_available()); | 3275 !AudioStreamMonitor::monitoring_available()); |
| 3274 | 3276 |
| 3275 // Showing the WebContents should result in the creation of the blocker. | 3277 // Showing the WebContents should result in the creation of the blocker. |
| 3276 contents()->WasShown(); | 3278 contents()->WasShown(); |
| 3277 EXPECT_TRUE(has_video_power_save_blocker()); | 3279 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3278 | 3280 |
| 3279 // Start another player that only has audio. There should be no change in | 3281 // Start another player that only has audio. There should be no change in |
| 3280 // the power save blockers. | 3282 // the power save blockers. |
| 3281 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( | 3283 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( |
| 3282 0, kPlayerAudioOnlyId, false, true, false, base::TimeDelta())); | 3284 0, kPlayerAudioOnlyId, false, true, false, |
| 3285 media::MediaContentType::Persistent)); |
| 3283 EXPECT_TRUE(has_video_power_save_blocker()); | 3286 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3284 EXPECT_EQ(has_audio_power_save_blocker(), | 3287 EXPECT_EQ(has_audio_power_save_blocker(), |
| 3285 !AudioStreamMonitor::monitoring_available()); | 3288 !AudioStreamMonitor::monitoring_available()); |
| 3286 | 3289 |
| 3287 // Start a remote player. There should be no change in the power save | 3290 // Start a remote player. There should be no change in the power save |
| 3288 // blockers. | 3291 // blockers. |
| 3289 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( | 3292 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( |
| 3290 0, kPlayerRemoteId, true, true, true, base::TimeDelta())); | 3293 0, kPlayerRemoteId, true, true, true, |
| 3294 media::MediaContentType::Persistent)); |
| 3291 EXPECT_TRUE(has_video_power_save_blocker()); | 3295 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3292 EXPECT_EQ(has_audio_power_save_blocker(), | 3296 EXPECT_EQ(has_audio_power_save_blocker(), |
| 3293 !AudioStreamMonitor::monitoring_available()); | 3297 !AudioStreamMonitor::monitoring_available()); |
| 3294 | 3298 |
| 3295 // Destroy the original audio video player. Both power save blockers should | 3299 // Destroy the original audio video player. Both power save blockers should |
| 3296 // remain. | 3300 // remain. |
| 3297 rfh->OnMessageReceived( | 3301 rfh->OnMessageReceived( |
| 3298 MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerAudioVideoId, false)); | 3302 MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerAudioVideoId, false)); |
| 3299 EXPECT_TRUE(has_video_power_save_blocker()); | 3303 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3300 EXPECT_EQ(has_audio_power_save_blocker(), | 3304 EXPECT_EQ(has_audio_power_save_blocker(), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3315 // Destroy the remote player. No power save blockers should remain. | 3319 // Destroy the remote player. No power save blockers should remain. |
| 3316 rfh->OnMessageReceived( | 3320 rfh->OnMessageReceived( |
| 3317 MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerRemoteId, false)); | 3321 MediaPlayerDelegateHostMsg_OnMediaPaused(0, kPlayerRemoteId, false)); |
| 3318 EXPECT_FALSE(has_video_power_save_blocker()); | 3322 EXPECT_FALSE(has_video_power_save_blocker()); |
| 3319 EXPECT_FALSE(has_audio_power_save_blocker()); | 3323 EXPECT_FALSE(has_audio_power_save_blocker()); |
| 3320 | 3324 |
| 3321 // Start a player with both audio and video. A video power save blocker | 3325 // Start a player with both audio and video. A video power save blocker |
| 3322 // should be created. If audio stream monitoring is available, an audio power | 3326 // should be created. If audio stream monitoring is available, an audio power |
| 3323 // save blocker should be created too. | 3327 // save blocker should be created too. |
| 3324 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( | 3328 rfh->OnMessageReceived(MediaPlayerDelegateHostMsg_OnMediaPlaying( |
| 3325 0, kPlayerAudioVideoId, true, true, false, base::TimeDelta())); | 3329 0, kPlayerAudioVideoId, true, true, false, |
| 3330 media::MediaContentType::Persistent)); |
| 3326 EXPECT_TRUE(has_video_power_save_blocker()); | 3331 EXPECT_TRUE(has_video_power_save_blocker()); |
| 3327 EXPECT_EQ(has_audio_power_save_blocker(), | 3332 EXPECT_EQ(has_audio_power_save_blocker(), |
| 3328 !AudioStreamMonitor::monitoring_available()); | 3333 !AudioStreamMonitor::monitoring_available()); |
| 3329 | 3334 |
| 3330 // Crash the renderer. | 3335 // Crash the renderer. |
| 3331 contents()->GetMainFrame()->GetProcess()->SimulateCrash(); | 3336 contents()->GetMainFrame()->GetProcess()->SimulateCrash(); |
| 3332 | 3337 |
| 3333 // Verify that all the power save blockers have been released. | 3338 // Verify that all the power save blockers have been released. |
| 3334 EXPECT_FALSE(has_video_power_save_blocker()); | 3339 EXPECT_FALSE(has_video_power_save_blocker()); |
| 3335 EXPECT_FALSE(has_audio_power_save_blocker()); | 3340 EXPECT_FALSE(has_audio_power_save_blocker()); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3451 // An automatic navigation. | 3456 // An automatic navigation. |
| 3452 contents()->GetMainFrame()->SendNavigateWithModificationCallback( | 3457 contents()->GetMainFrame()->SendNavigateWithModificationCallback( |
| 3453 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 3458 2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); |
| 3454 | 3459 |
| 3455 EXPECT_EQ(1u, dialog_manager.reset_count()); | 3460 EXPECT_EQ(1u, dialog_manager.reset_count()); |
| 3456 | 3461 |
| 3457 contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 3462 contents()->SetJavaScriptDialogManagerForTesting(nullptr); |
| 3458 } | 3463 } |
| 3459 | 3464 |
| 3460 } // namespace content | 3465 } // namespace content |
| OLD | NEW |