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

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

Issue 1011943003: Don't treat back/forwards as typed transitions in history. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests Created 5 years, 9 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 | components/history/core/browser/expire_history_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_backend_unittest.cc
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 9442ae0a8ba61f80a3b5231236b10655deeb4af0..58c061262c67898420b3b6ec6fb05a50e47fcc7e 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -888,6 +888,17 @@ TEST_F(HistoryBackendTest, KeywordGenerated) {
backend_->db()->GetVisibleVisitsInRange(query_options, &visits);
EXPECT_TRUE(visits.empty());
+ // Going back to the same entry should not increment the typed count.
+ ui::PageTransition back_transition = ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FORWARD_BACK);
+ HistoryAddPageArgs back_request(url, visit_time, NULL, 0, GURL(),
+ history::RedirectList(), back_transition,
+ history::SOURCE_BROWSED, false);
+ backend_->AddPage(back_request);
+ url_id = backend_->db()->GetRowForURL(url, &row);
+ ASSERT_NE(0, url_id);
+ ASSERT_EQ(1, row.typed_count());
+
// Expire the visits.
std::set<GURL> restrict_urls;
backend_->expire_backend()->ExpireHistoryBetween(restrict_urls,
@@ -1202,6 +1213,81 @@ TEST_F(HistoryBackendTest, StripUsernamePasswordTest) {
ASSERT_EQ(1U, visits.size());
}
+TEST_F(HistoryBackendTest, AddPageVisitBackForward) {
+ ASSERT_TRUE(backend_.get());
+
+ GURL url("http://www.google.com");
+
+ // Clear all history.
+ backend_->DeleteAllHistory();
+
+ // Visit the url after typing it.
+ backend_->AddPageVisit(url, base::Time::Now(), 0,
+ ui::PAGE_TRANSITION_TYPED,
+ history::SOURCE_BROWSED);
+
+ // Ensure both the typed count and visit count are 1.
+ VisitVector visits;
+ URLRow row;
+ URLID id = backend_->db()->GetRowForURL(url, &row);
+ ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits));
+ EXPECT_EQ(1, row.typed_count());
+ EXPECT_EQ(1, row.visit_count());
+
+ // Visit the url again via back/forward.
+ backend_->AddPageVisit(url, base::Time::Now(), 0,
+ ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FORWARD_BACK),
+ history::SOURCE_BROWSED);
+
+ // Ensure the typed count is still 1 but the visit count is 2.
+ id = backend_->db()->GetRowForURL(url, &row);
+ ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits));
+ EXPECT_EQ(1, row.typed_count());
+ EXPECT_EQ(2, row.visit_count());
+}
+
+TEST_F(HistoryBackendTest, AddPageVisitRedirectBackForward) {
+ ASSERT_TRUE(backend_.get());
+
+ GURL url1("http://www.google.com");
+ GURL url2("http://www.chromium.org");
+
+ // Clear all history.
+ backend_->DeleteAllHistory();
+
+ // Visit a typed URL with a redirect.
+ backend_->AddPageVisit(url1, base::Time::Now(), 0,
+ ui::PAGE_TRANSITION_TYPED,
+ history::SOURCE_BROWSED);
+ backend_->AddPageVisit(url2, base::Time::Now(), 0,
+ ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_CLIENT_REDIRECT),
+ history::SOURCE_BROWSED);
+
+ // Ensure the redirected URL does not count as typed.
+ VisitVector visits;
+ URLRow row;
+ URLID id = backend_->db()->GetRowForURL(url2, &row);
+ ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits));
+ EXPECT_EQ(0, row.typed_count());
+ EXPECT_EQ(1, row.visit_count());
+
+ // Visit the redirected url again via back/forward.
+ backend_->AddPageVisit(url2, base::Time::Now(), 0,
+ ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED |
+ ui::PAGE_TRANSITION_FORWARD_BACK |
+ ui::PAGE_TRANSITION_CLIENT_REDIRECT),
+ history::SOURCE_BROWSED);
+
+ // Ensure the typed count is still 1 but the visit count is 2.
+ id = backend_->db()->GetRowForURL(url2, &row);
+ ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits));
+ EXPECT_EQ(0, row.typed_count());
+ EXPECT_EQ(2, row.visit_count());
+}
+
TEST_F(HistoryBackendTest, AddPageVisitSource) {
ASSERT_TRUE(backend_.get());
« no previous file with comments | « no previous file | components/history/core/browser/expire_history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698