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

Unified Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 2296483002: Fix some unit_tests under PlzNavigate (Closed)
Patch Set: not in public interface Created 4 years, 4 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 | « no previous file | content/browser/frame_host/navigation_controller_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/browser_with_test_window_test.cc
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 3ceadfb6f0339da8abe9814b1cea84bb5866b2ad..a6c8a13bb8366a988e094d3f4ab411348bf7275f 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -19,6 +19,8 @@
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/browser_side_navigation_policy.h"
+#include "content/public/test/browser_side_navigation_test_utils.h"
#include "content/public/test/test_renderer_host.h"
#include "ui/base/page_transition_types.h"
@@ -65,6 +67,9 @@ void BrowserWithTestWindowTest::SetUp() {
SetConstrainedWindowViewsClient(CreateChromeConstrainedWindowViewsClient());
#endif
+ if (content::IsBrowserSideNavigationEnabled())
+ content::BrowserSideNavigationSetUp();
+
// Subclasses can provide their own Profile.
profile_ = CreateProfile();
// Subclasses can provide their own test BrowserWindow. If they return NULL
@@ -85,6 +90,9 @@ void BrowserWithTestWindowTest::TearDown() {
// audio service) depend on test stubs that the helpers below will remove.
DestroyBrowserAndProfile();
+ if (content::IsBrowserSideNavigationEnabled())
+ content::BrowserSideNavigationTearDown();
+
#if defined(TOOLKIT_VIEWS)
constrained_window::SetConstrainedWindowViewsClient(nullptr);
#endif
@@ -127,44 +135,7 @@ void BrowserWithTestWindowTest::CommitPendingLoad(
if (!controller->GetPendingEntry())
return; // Nothing to commit.
- RenderFrameHost* old_rfh = controller->GetWebContents()->GetMainFrame();
-
- RenderFrameHost* pending_rfh = RenderFrameHostTester::GetPendingForController(
- controller);
- if (pending_rfh) {
- // Simulate the BeforeUnload_ACK that is received from the current renderer
- // for a cross-site navigation.
- DCHECK_NE(old_rfh, pending_rfh);
- RenderFrameHostTester::For(old_rfh)->SendBeforeUnloadACK(true);
- }
- // Commit on the pending_rfh, if one exists.
- RenderFrameHost* test_rfh = pending_rfh ? pending_rfh : old_rfh;
- RenderFrameHostTester* test_rfh_tester = RenderFrameHostTester::For(test_rfh);
-
- // Simulate a SwapOut_ACK before the navigation commits.
- if (pending_rfh)
- RenderFrameHostTester::For(old_rfh)->SimulateSwapOutACK();
-
- // For new navigations, we need to send a larger page ID. For renavigations,
- // we need to send the preexisting page ID. We can tell these apart because
- // renavigations will have a pending_entry_index while new ones won't (they'll
- // just have a standalong pending_entry that isn't in the list already).
- if (controller->GetPendingEntryIndex() >= 0) {
- test_rfh_tester->SendNavigateWithTransition(
- controller->GetPendingEntry()->GetPageID(),
- controller->GetPendingEntry()->GetUniqueID(),
- false,
- controller->GetPendingEntry()->GetURL(),
- controller->GetPendingEntry()->GetTransitionType());
- } else {
- test_rfh_tester->SendNavigateWithTransition(
- controller->GetWebContents()->GetMaxPageIDForSiteInstance(
- test_rfh->GetSiteInstance()) + 1,
- controller->GetPendingEntry()->GetUniqueID(),
- true,
- controller->GetPendingEntry()->GetURL(),
- controller->GetPendingEntry()->GetTransitionType());
- }
+ RenderFrameHostTester::CommitPendingLoad(controller);
}
void BrowserWithTestWindowTest::NavigateAndCommit(
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_controller_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698