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

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

Issue 1156023006: Bring RFH/RVH unit tests closer to reality of how RF/RV are initialized (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move InitializeRenderFrameIfNeeded to RenderFrameHostTester and fix RlzLibTest code. Created 5 years, 6 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 "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 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 // The interstitial should show until the new navigation commits. 1682 // The interstitial should show until the new navigation commits.
1683 RunAllPendingInMessageLoop(); 1683 RunAllPendingInMessageLoop();
1684 ASSERT_FALSE(deleted); 1684 ASSERT_FALSE(deleted);
1685 EXPECT_EQ(TestInterstitialPage::OKED, state); 1685 EXPECT_EQ(TestInterstitialPage::OKED, state);
1686 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1686 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1687 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1687 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1688 1688
1689 // Simulate the navigation to the page, that's when the interstitial gets 1689 // Simulate the navigation to the page, that's when the interstitial gets
1690 // hidden. 1690 // hidden.
1691 GURL url3("http://www.thepage.com"); 1691 GURL url3("http://www.thepage.com");
1692 contents()->GetMainFrame()->PrepareForCommit();
1692 contents()->GetMainFrame()->SendNavigate(2, 0, true, url3); 1693 contents()->GetMainFrame()->SendNavigate(2, 0, true, url3);
1693 1694
1694 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1695 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1695 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1696 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1696 entry = controller().GetVisibleEntry(); 1697 entry = controller().GetVisibleEntry();
1697 ASSERT_NE(nullptr, entry); 1698 ASSERT_NE(nullptr, entry);
1698 EXPECT_TRUE(entry->GetURL() == url3); 1699 EXPECT_TRUE(entry->GetURL() == url3);
1699 1700
1700 EXPECT_EQ(2, controller().GetEntryCount()); 1701 EXPECT_EQ(2, controller().GetEntryCount());
1701 1702
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 const int kPlayerAudioOnlyId = -15; 3017 const int kPlayerAudioOnlyId = -15;
3017 const int kPlayerVideoOnlyId = 30; 3018 const int kPlayerVideoOnlyId = 30;
3018 const int kPlayerRemoteId = -30; 3019 const int kPlayerRemoteId = -30;
3019 3020
3020 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 3021 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
3021 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 3022 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
3022 3023
3023 TestRenderFrameHost* rfh = contents()->GetMainFrame(); 3024 TestRenderFrameHost* rfh = contents()->GetMainFrame();
3024 AudioStateProvider* audio_state = contents()->audio_state_provider(); 3025 AudioStateProvider* audio_state = contents()->audio_state_provider();
3025 3026
3027 // Ensure RenderFrame is initialized before simulating events coming from it.
3028 main_test_rfh()->InitializeRenderFrameIfNeeded();
3029
3026 // The audio power save blocker should not be based on having a media player 3030 // The audio power save blocker should not be based on having a media player
3027 // when audio stream monitoring is available. 3031 // when audio stream monitoring is available.
3028 if (audio_state->IsAudioStateAvailable()) { 3032 if (audio_state->IsAudioStateAvailable()) {
3029 // Send a fake audio stream monitor notification. The audio power save 3033 // Send a fake audio stream monitor notification. The audio power save
3030 // blocker should be created. 3034 // blocker should be created.
3031 audio_state->set_was_recently_audible_for_testing(true); 3035 audio_state->set_was_recently_audible_for_testing(true);
3032 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); 3036 contents()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB);
3033 EXPECT_TRUE(contents()->has_audio_power_save_blocker_for_testing()); 3037 EXPECT_TRUE(contents()->has_audio_power_save_blocker_for_testing());
3034 3038
3035 // Send another fake notification, this time when WasRecentlyAudible() will 3039 // Send another fake notification, this time when WasRecentlyAudible() will
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 // Additional changes made by the web contents should propagate as well. 3158 // Additional changes made by the web contents should propagate as well.
3155 RenderViewHostTester::TestOnMessageReceived( 3159 RenderViewHostTester::TestOnMessageReceived(
3156 test_rvh(), 3160 test_rvh(),
3157 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN)); 3161 FrameHostMsg_DidChangeThemeColor(rfh->GetRoutingID(), SK_ColorGREEN));
3158 3162
3159 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor()); 3163 EXPECT_EQ(SK_ColorGREEN, contents()->GetThemeColor());
3160 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color()); 3164 EXPECT_EQ(SK_ColorGREEN, observer.last_theme_color());
3161 } 3165 }
3162 3166
3163 } // namespace content 3167 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698