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

Unified Diff: chrome/browser/history/history_unittest.cc

Issue 8286011: When users navigate to an intranet host that has not been previously typed, treat it as a typed n... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/url_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_unittest.cc
===================================================================
--- chrome/browser/history/history_unittest.cc (revision 105368)
+++ chrome/browser/history/history_unittest.cc (working copy)
@@ -469,8 +469,8 @@
ASSERT_TRUE(history->Init(history_dir_, NULL));
const char* first_sequence[] = {
- "http://first.page/",
- "http://second.page/"};
+ "http://first.page.com/",
+ "http://second.page.com/"};
int first_count = arraysize(first_sequence);
history::RedirectList first_redirects;
for (int i = 0; i < first_count; i++)
@@ -515,7 +515,7 @@
// so we pass in a CLIENT_REDIRECT qualifier to mock that behavior.
history::RedirectList second_redirects;
second_redirects.push_back(first_redirects[1]);
- second_redirects.push_back(GURL("http://last.page/"));
+ second_redirects.push_back(GURL("http://last.page.com/"));
history->AddPage(second_redirects[1], MakeFakeHost(1), 1,
second_redirects[0],
static_cast<content::PageTransition>(
@@ -534,10 +534,87 @@
EXPECT_EQ(1, query_url_row_.visit_count());
ASSERT_EQ(1U, query_url_visits_.size());
EXPECT_EQ(content::PAGE_TRANSITION_CLIENT_REDIRECT |
- content::PAGE_TRANSITION_CHAIN_END, query_url_visits_[0].transition);
+ content::PAGE_TRANSITION_CHAIN_END,
+ query_url_visits_[0].transition);
EXPECT_EQ(second_visit, query_url_visits_[0].referring_visit);
}
+TEST_F(HistoryTest, MakeIntranetURLsTyped) {
+ scoped_refptr<HistoryService> history(new HistoryService);
+ history_service_ = history;
+ ASSERT_TRUE(history->Init(history_dir_, NULL));
+
+ // Add a non-typed visit to an intranet URL on an unvisited host. This should
+ // get promoted to a typed visit.
+ const GURL test_url("http://intranet_host/path");
+ history->AddPage(test_url, NULL, 0, GURL(), content::PAGE_TRANSITION_LINK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url));
+ EXPECT_EQ(1, query_url_row_.visit_count());
+ EXPECT_EQ(1, query_url_row_.typed_count());
+ ASSERT_EQ(1U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_TYPED,
+ content::PageTransitionStripQualifier(query_url_visits_[0].transition));
+
+ // Add more visits on the same host. None of these should be promoted since
+ // there is already a typed visit.
+
+ // Different path.
+ const GURL test_url2("http://intranet_host/different_path");
+ history->AddPage(test_url2, NULL, 0, GURL(), content::PAGE_TRANSITION_LINK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url2));
+ EXPECT_EQ(1, query_url_row_.visit_count());
+ EXPECT_EQ(0, query_url_row_.typed_count());
+ ASSERT_EQ(1U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_LINK,
+ content::PageTransitionStripQualifier(query_url_visits_[0].transition));
+
+ // No path.
+ const GURL test_url3("http://intranet_host/");
+ history->AddPage(test_url3, NULL, 0, GURL(), content::PAGE_TRANSITION_LINK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url3));
+ EXPECT_EQ(1, query_url_row_.visit_count());
+ EXPECT_EQ(0, query_url_row_.typed_count());
+ ASSERT_EQ(1U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_LINK,
+ content::PageTransitionStripQualifier(query_url_visits_[0].transition));
+
+ // Different scheme.
+ const GURL test_url4("https://intranet_host/");
+ history->AddPage(test_url4, NULL, 0, GURL(), content::PAGE_TRANSITION_LINK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url4));
+ EXPECT_EQ(1, query_url_row_.visit_count());
+ EXPECT_EQ(0, query_url_row_.typed_count());
+ ASSERT_EQ(1U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_LINK,
+ content::PageTransitionStripQualifier(query_url_visits_[0].transition));
+
+ // Different transition.
+ const GURL test_url5("http://intranet_host/another_path");
+ history->AddPage(test_url5, NULL, 0, GURL(),
+ content::PAGE_TRANSITION_AUTO_BOOKMARK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url5));
+ EXPECT_EQ(1, query_url_row_.visit_count());
+ EXPECT_EQ(0, query_url_row_.typed_count());
+ ASSERT_EQ(1U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_AUTO_BOOKMARK,
+ content::PageTransitionStripQualifier(query_url_visits_[0].transition));
+
+ // Original URL.
+ history->AddPage(test_url, NULL, 0, GURL(), content::PAGE_TRANSITION_LINK,
+ history::RedirectList(), history::SOURCE_BROWSED, false);
+ EXPECT_TRUE(QueryURL(history, test_url));
+ EXPECT_EQ(2, query_url_row_.visit_count());
+ EXPECT_EQ(1, query_url_row_.typed_count());
+ ASSERT_EQ(2U, query_url_visits_.size());
+ EXPECT_EQ(content::PAGE_TRANSITION_LINK,
+ content::PageTransitionStripQualifier(query_url_visits_[1].transition));
+}
+
TEST_F(HistoryTest, Typed) {
scoped_refptr<HistoryService> history(new HistoryService);
history_service_ = history;
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/url_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698