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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/frame_host/cross_site_transferring_request.h" | 8 #include "content/browser/frame_host/cross_site_transferring_request.h" |
9 #include "content/browser/frame_host/interstitial_page_impl.h" | 9 #include "content/browser/frame_host/interstitial_page_impl.h" |
10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 // The interstitial should show until the new navigation commits. | 1674 // The interstitial should show until the new navigation commits. |
1675 RunAllPendingInMessageLoop(); | 1675 RunAllPendingInMessageLoop(); |
1676 ASSERT_FALSE(deleted); | 1676 ASSERT_FALSE(deleted); |
1677 EXPECT_EQ(TestInterstitialPage::OKED, state); | 1677 EXPECT_EQ(TestInterstitialPage::OKED, state); |
1678 EXPECT_TRUE(contents()->ShowingInterstitialPage()); | 1678 EXPECT_TRUE(contents()->ShowingInterstitialPage()); |
1679 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); | 1679 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); |
1680 | 1680 |
1681 // Simulate the navigation to the page, that's when the interstitial gets | 1681 // Simulate the navigation to the page, that's when the interstitial gets |
1682 // hidden. | 1682 // hidden. |
1683 GURL url3("http://www.thepage.com"); | 1683 GURL url3("http://www.thepage.com"); |
| 1684 contents()->GetMainFrame()->PrepareForCommit(); |
1684 contents()->GetMainFrame()->SendNavigate(2, 0, true, url3); | 1685 contents()->GetMainFrame()->SendNavigate(2, 0, true, url3); |
1685 | 1686 |
1686 EXPECT_FALSE(contents()->ShowingInterstitialPage()); | 1687 EXPECT_FALSE(contents()->ShowingInterstitialPage()); |
1687 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); | 1688 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); |
1688 entry = controller().GetVisibleEntry(); | 1689 entry = controller().GetVisibleEntry(); |
1689 ASSERT_NE(nullptr, entry); | 1690 ASSERT_NE(nullptr, entry); |
1690 EXPECT_TRUE(entry->GetURL() == url3); | 1691 EXPECT_TRUE(entry->GetURL() == url3); |
1691 | 1692 |
1692 EXPECT_EQ(2, controller().GetEntryCount()); | 1693 EXPECT_EQ(2, controller().GetEntryCount()); |
1693 | 1694 |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 const int kPlayerAudioOnlyId = -15; | 3009 const int kPlayerAudioOnlyId = -15; |
3009 const int kPlayerVideoOnlyId = 30; | 3010 const int kPlayerVideoOnlyId = 30; |
3010 const int kPlayerRemoteId = -30; | 3011 const int kPlayerRemoteId = -30; |
3011 | 3012 |
3012 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3013 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3013 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3014 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3014 | 3015 |
3015 TestRenderFrameHost* rfh = contents()->GetMainFrame(); | 3016 TestRenderFrameHost* rfh = contents()->GetMainFrame(); |
3016 AudioStateProvider* audio_state = contents()->audio_state_provider(); | 3017 AudioStateProvider* audio_state = contents()->audio_state_provider(); |
3017 | 3018 |
| 3019 // Ensure RenderFrame is initialized before simulating events coming from it. |
| 3020 main_test_rfh()->InitializeRenderFrameIfNeeded(); |
| 3021 |
3018 // The audio power save blocker should not be based on having a media player | 3022 // The audio power save blocker should not be based on having a media player |
3019 // when audio stream monitoring is available. | 3023 // when audio stream monitoring is available. |
3020 if (audio_state->IsAudioStateAvailable()) { | 3024 if (audio_state->IsAudioStateAvailable()) { |
3021 // Send a fake audio stream monitor notification. The audio power save | 3025 // Send a fake audio stream monitor notification. The audio power save |
3022 // blocker should be created. | 3026 // blocker should be created. |
3023 audio_state->set_was_recently_audible_for_testing(true); | 3027 audio_state->set_was_recently_audible_for_testing(true); |
3024 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | 3028 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
3025 EXPECT_TRUE(contents()->has_audio_power_save_blocker_for_testing()); | 3029 EXPECT_TRUE(contents()->has_audio_power_save_blocker_for_testing()); |
3026 | 3030 |
3027 // Send another fake notification, this time when WasRecentlyAudible() will | 3031 // Send another fake notification, this time when WasRecentlyAudible() will |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 | 3114 |
3111 // Crash the renderer. | 3115 // Crash the renderer. |
3112 contents()->GetMainFrame()->GetProcess()->SimulateCrash(); | 3116 contents()->GetMainFrame()->GetProcess()->SimulateCrash(); |
3113 | 3117 |
3114 // Verify that all the power save blockers have been released. | 3118 // Verify that all the power save blockers have been released. |
3115 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 3119 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
3116 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 3120 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
3117 } | 3121 } |
3118 | 3122 |
3119 } // namespace content | 3123 } // namespace content |
OLD | NEW |