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

Side by Side Diff: components/history/core/browser/visit_tracker_unittest.cc

Issue 823273003: Switch the history backend from using page ids to navigation entry unique ids. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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
« no previous file with comments | « components/history/core/browser/visit_tracker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "components/history/core/browser/visit_tracker.h" 5 #include "components/history/core/browser/visit_tracker.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using history::ContextID; 10 using history::ContextID;
11 using history::VisitTracker; 11 using history::VisitTracker;
12 12
13 namespace { 13 namespace {
14 14
15 struct VisitToTest { 15 struct VisitToTest {
16 // Identifies the context. 16 // Identifies the context.
17 int context_id_int; 17 int context_id_int;
18 int32 page_id; 18 int nav_entry_id;
19 19
20 // Used when adding this to the tracker 20 // Used when adding this to the tracker
21 const char* url; 21 const char* url;
22 const history::VisitID visit_id; 22 const history::VisitID visit_id;
23 23
24 // Used when finding the referrer 24 // Used when finding the referrer
25 const char* referrer; 25 const char* referrer;
26 26
27 // the correct referring visit ID to compare to the computed one 27 // the correct referring visit ID to compare to the computed one
28 history::VisitID referring_visit_id; 28 history::VisitID referring_visit_id;
29 }; 29 };
30 30
31 void RunTest(VisitTracker* tracker, VisitToTest* test, int test_count) { 31 void RunTest(VisitTracker* tracker, VisitToTest* test, int test_count) {
32 for (int i = 0; i < test_count; i++) { 32 for (int i = 0; i < test_count; i++) {
33 // Our host pointer is actually just an int, convert it (it will not get 33 // Our host pointer is actually just an int, convert it (it will not get
34 // dereferenced). 34 // dereferenced).
35 ContextID context_id = reinterpret_cast<ContextID>(test[i].context_id_int); 35 ContextID context_id = reinterpret_cast<ContextID>(test[i].context_id_int);
36 36
37 // Check the referrer for this visit. 37 // Check the referrer for this visit.
38 history::VisitID ref_visit = tracker->GetLastVisit( 38 history::VisitID ref_visit = tracker->GetLastVisit(
39 context_id, test[i].page_id, GURL(test[i].referrer)); 39 context_id, test[i].nav_entry_id, GURL(test[i].referrer));
40 EXPECT_EQ(test[i].referring_visit_id, ref_visit); 40 EXPECT_EQ(test[i].referring_visit_id, ref_visit);
41 41
42 // Now add this visit. 42 // Now add this visit.
43 tracker->AddVisit( 43 tracker->AddVisit(
44 context_id, test[i].page_id, GURL(test[i].url), test[i].visit_id); 44 context_id, test[i].nav_entry_id, GURL(test[i].url), test[i].visit_id);
45 } 45 }
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 // A simple test that makes sure we transition between main pages in the 50 // A simple test that makes sure we transition between main pages in the
51 // presence of back/forward. 51 // presence of back/forward.
52 TEST(VisitTracker, SimpleTransitions) { 52 TEST(VisitTracker, SimpleTransitions) {
53 VisitToTest test_simple[] = { 53 VisitToTest test_simple[] = {
54 // Started here: 54 // Started here:
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Say that context has been invalidated. 121 // Say that context has been invalidated.
122 tracker.ClearCachedDataForContextID(reinterpret_cast<ContextID>(1)); 122 tracker.ClearCachedDataForContextID(reinterpret_cast<ContextID>(1));
123 123
124 // Simple navigation from a new process with the same ID, it should not find 124 // Simple navigation from a new process with the same ID, it should not find
125 // a referrer. 125 // a referrer.
126 VisitToTest part2[] = { 126 VisitToTest part2[] = {
127 {1, 1, "http://images.google.com/", 2, "http://www.google.com/", 0}, 127 {1, 1, "http://images.google.com/", 2, "http://www.google.com/", 0},
128 }; 128 };
129 RunTest(&tracker, part2, arraysize(part2)); 129 RunTest(&tracker, part2, arraysize(part2));
130 } 130 }
OLDNEW
« no previous file with comments | « components/history/core/browser/visit_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698