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

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

Issue 2957783002: Fix wrong ui::PAGE_TRANSITION_FORWARD_BACK in tests. (Closed)
Patch Set: Created 3 years, 5 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 std::vector<std::unique_ptr<NavigationEntry>> entries; 853 std::vector<std::unique_ptr<NavigationEntry>> entries;
854 std::unique_ptr<NavigationEntry> new_entry = 854 std::unique_ptr<NavigationEntry> new_entry =
855 NavigationControllerImpl::CreateNavigationEntry( 855 NavigationControllerImpl::CreateNavigationEntry(
856 native_url, Referrer(), ui::PAGE_TRANSITION_LINK, false, 856 native_url, Referrer(), ui::PAGE_TRANSITION_LINK, false,
857 std::string(), browser_context()); 857 std::string(), browser_context());
858 entries.push_back(std::move(new_entry)); 858 entries.push_back(std::move(new_entry));
859 controller().Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); 859 controller().Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries);
860 ASSERT_EQ(0u, entries.size()); 860 ASSERT_EQ(0u, entries.size());
861 ASSERT_EQ(1, controller().GetEntryCount()); 861 ASSERT_EQ(1, controller().GetEntryCount());
862 862
863 controller().GoToIndex(0); 863 EXPECT_TRUE(controller().NeedsReload());
864 controller().LoadIfNecessary();
864 NavigationEntry* entry = controller().GetPendingEntry(); 865 NavigationEntry* entry = controller().GetPendingEntry();
865 orig_rfh->PrepareForCommit(); 866 orig_rfh->PrepareForCommit();
866 contents()->TestDidNavigate(orig_rfh, entry->GetUniqueID(), false, 867 contents()->TestDidNavigate(orig_rfh, entry->GetUniqueID(), false,
867 native_url, ui::PAGE_TRANSITION_RELOAD); 868 native_url, ui::PAGE_TRANSITION_RELOAD);
868 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); 869 EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
869 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); 870 EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL());
870 EXPECT_FALSE(orig_instance->HasSite()); 871 EXPECT_FALSE(orig_instance->HasSite());
871 872
872 // Navigate to a regular site and verify that the SiteInstance was kept. 873 // Navigate to a regular site and verify that the SiteInstance was kept.
873 browser_client.set_assign_site_for_url(true); 874 browser_client.set_assign_site_for_url(true);
(...skipping 28 matching lines...) Expand all
902 std::vector<std::unique_ptr<NavigationEntry>> entries; 903 std::vector<std::unique_ptr<NavigationEntry>> entries;
903 std::unique_ptr<NavigationEntry> new_entry = 904 std::unique_ptr<NavigationEntry> new_entry =
904 NavigationControllerImpl::CreateNavigationEntry( 905 NavigationControllerImpl::CreateNavigationEntry(
905 regular_url, Referrer(), ui::PAGE_TRANSITION_LINK, false, 906 regular_url, Referrer(), ui::PAGE_TRANSITION_LINK, false,
906 std::string(), browser_context()); 907 std::string(), browser_context());
907 entries.push_back(std::move(new_entry)); 908 entries.push_back(std::move(new_entry));
908 controller().Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries); 909 controller().Restore(0, RestoreType::LAST_SESSION_EXITED_CLEANLY, &entries);
909 ASSERT_EQ(0u, entries.size()); 910 ASSERT_EQ(0u, entries.size());
910 911
911 ASSERT_EQ(1, controller().GetEntryCount()); 912 ASSERT_EQ(1, controller().GetEntryCount());
912 controller().GoToIndex(0); 913 EXPECT_TRUE(controller().NeedsReload());
914 controller().LoadIfNecessary();
913 NavigationEntry* entry = controller().GetPendingEntry(); 915 NavigationEntry* entry = controller().GetPendingEntry();
914 orig_rfh->PrepareForCommit(); 916 orig_rfh->PrepareForCommit();
915 contents()->TestDidNavigate(orig_rfh, entry->GetUniqueID(), false, 917 contents()->TestDidNavigate(orig_rfh, entry->GetUniqueID(), false,
916 regular_url, ui::PAGE_TRANSITION_RELOAD); 918 regular_url, ui::PAGE_TRANSITION_RELOAD);
917 EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); 919 EXPECT_EQ(orig_instance, contents()->GetSiteInstance());
918 EXPECT_TRUE(orig_instance->HasSite()); 920 EXPECT_TRUE(orig_instance->HasSite());
919 921
920 // Navigate to another site and verify that a new SiteInstance was created. 922 // Navigate to another site and verify that a new SiteInstance was created.
921 const GURL url("http://www.google.com"); 923 const GURL url("http://www.google.com");
922 controller().LoadURL( 924 controller().LoadURL(
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 orig_rfh->PrepareForCommit(); 1462 orig_rfh->PrepareForCommit();
1461 contents()->TestDidNavigate(orig_rfh, entry_id, true, url2, 1463 contents()->TestDidNavigate(orig_rfh, entry_id, true, url2,
1462 ui::PAGE_TRANSITION_TYPED); 1464 ui::PAGE_TRANSITION_TYPED);
1463 entry = controller().GetLastCommittedEntry(); 1465 entry = controller().GetLastCommittedEntry();
1464 EXPECT_TRUE(entry->GetPageState().IsValid()); 1466 EXPECT_TRUE(entry->GetPageState().IsValid());
1465 1467
1466 // Now go back. Committed entry should still have page state. 1468 // Now go back. Committed entry should still have page state.
1467 controller().GoBack(); 1469 controller().GoBack();
1468 entry_id = controller().GetPendingEntry()->GetUniqueID(); 1470 entry_id = controller().GetPendingEntry()->GetUniqueID();
1469 orig_rfh->PrepareForCommit(); 1471 orig_rfh->PrepareForCommit();
1470 contents()->TestDidNavigate(orig_rfh, entry_id, false, url, 1472 contents()->TestDidNavigate(
1471 ui::PAGE_TRANSITION_TYPED); 1473 orig_rfh, entry_id, false, url,
1474 controller().GetPendingEntry()->GetTransitionType());
1472 entry = controller().GetLastCommittedEntry(); 1475 entry = controller().GetLastCommittedEntry();
1473 EXPECT_TRUE(entry->GetPageState().IsValid()); 1476 EXPECT_TRUE(entry->GetPageState().IsValid());
1474 } 1477 }
1475 1478
1476 // Test that NavigationEntries have the correct page state and SiteInstance 1479 // Test that NavigationEntries have the correct page state and SiteInstance
1477 // state after opening a new window to about:blank. Prevents regression for 1480 // state after opening a new window to about:blank. Prevents regression for
1478 // bugs b/1116137 and http://crbug.com/111975. 1481 // bugs b/1116137 and http://crbug.com/111975.
1479 TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { 1482 TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) {
1480 TestRenderFrameHost* orig_rfh = main_test_rfh(); 1483 TestRenderFrameHost* orig_rfh = main_test_rfh();
1481 1484
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after
3535 // An automatic navigation. 3538 // An automatic navigation.
3536 main_test_rfh()->SendNavigateWithModificationCallback( 3539 main_test_rfh()->SendNavigateWithModificationCallback(
3537 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3540 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3538 3541
3539 EXPECT_EQ(1u, dialog_manager.reset_count()); 3542 EXPECT_EQ(1u, dialog_manager.reset_count());
3540 3543
3541 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3544 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3542 } 3545 }
3543 3546
3544 } // namespace content 3547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698