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

Side by Side Diff: chrome/browser/history/history_querying_unittest.cc

Issue 341087: Eliminate QueryOptions::most_recent_visit_only. All non-unittest consumers o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "chrome/browser/history/history.h" 9 #include "chrome/browser/history/history.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 DISALLOW_EVIL_CONSTRUCTORS(HistoryQueryTest); 143 DISALLOW_EVIL_CONSTRUCTORS(HistoryQueryTest);
144 }; 144 };
145 145
146 TEST_F(HistoryQueryTest, Basic) { 146 TEST_F(HistoryQueryTest, Basic) {
147 ASSERT_TRUE(history_.get()); 147 ASSERT_TRUE(history_.get());
148 148
149 QueryOptions options; 149 QueryOptions options;
150 QueryResults results; 150 QueryResults results;
151 151
152 // First query for all of them to make sure they are there and in 152 // Test duplicate collapsing.
153 // chronological order, most recent first.
154 QueryHistory(std::wstring(), options, &results); 153 QueryHistory(std::wstring(), options, &results);
155 ASSERT_EQ(5U, results.size()); 154 EXPECT_EQ(4U, results.size());
156 EXPECT_TRUE(NthResultIs(results, 0, 4)); 155 EXPECT_TRUE(NthResultIs(results, 0, 4));
157 EXPECT_TRUE(NthResultIs(results, 1, 2)); 156 EXPECT_TRUE(NthResultIs(results, 1, 2));
158 EXPECT_TRUE(NthResultIs(results, 2, 3)); 157 EXPECT_TRUE(NthResultIs(results, 2, 3));
159 EXPECT_TRUE(NthResultIs(results, 3, 1)); 158 EXPECT_TRUE(NthResultIs(results, 3, 1));
160 EXPECT_TRUE(NthResultIs(results, 4, 0));
161 159
162 // Next query a time range. The beginning should be inclusive, the ending 160 // Next query a time range. The beginning should be inclusive, the ending
163 // should be exclusive. 161 // should be exclusive.
164 options.begin_time = test_entries[3].time; 162 options.begin_time = test_entries[3].time;
165 options.end_time = test_entries[2].time; 163 options.end_time = test_entries[2].time;
166 QueryHistory(std::wstring(), options, &results); 164 QueryHistory(std::wstring(), options, &results);
167 EXPECT_EQ(1U, results.size()); 165 EXPECT_EQ(1U, results.size());
168 EXPECT_TRUE(NthResultIs(results, 0, 3)); 166 EXPECT_TRUE(NthResultIs(results, 0, 3));
169 } 167 }
170 168
171 // Tests max_count feature for basic (non-Full Text Search) queries. 169 // Tests max_count feature for basic (non-Full Text Search) queries.
172 TEST_F(HistoryQueryTest, BasicCount) { 170 TEST_F(HistoryQueryTest, BasicCount) {
173 ASSERT_TRUE(history_.get()); 171 ASSERT_TRUE(history_.get());
174 172
175 QueryOptions options; 173 QueryOptions options;
176 QueryResults results; 174 QueryResults results;
177 175
178 // Query all time but with a limit on the number of entries. We should 176 // Query all time but with a limit on the number of entries. We should
179 // get the N most recent entries. 177 // get the N most recent entries.
180 options.max_count = 2; 178 options.max_count = 2;
181 QueryHistory(std::wstring(), options, &results); 179 QueryHistory(std::wstring(), options, &results);
182 EXPECT_EQ(2U, results.size()); 180 EXPECT_EQ(2U, results.size());
183 EXPECT_TRUE(NthResultIs(results, 0, 4)); 181 EXPECT_TRUE(NthResultIs(results, 0, 4));
184 EXPECT_TRUE(NthResultIs(results, 1, 2)); 182 EXPECT_TRUE(NthResultIs(results, 1, 2));
185 } 183 }
186 184
187 // Tests duplicate collapsing and not in non-Full Text Search situations.
188 TEST_F(HistoryQueryTest, BasicDupes) {
189 ASSERT_TRUE(history_.get());
190
191 QueryOptions options;
192 QueryResults results;
193
194 // We did the query for no collapsing in the "Basic" test above, so here we
195 // only test collapsing.
196 options.most_recent_visit_only = true;
197 QueryHistory(std::wstring(), options, &results);
198 EXPECT_EQ(4U, results.size());
199 EXPECT_TRUE(NthResultIs(results, 0, 4));
200 EXPECT_TRUE(NthResultIs(results, 1, 2));
201 EXPECT_TRUE(NthResultIs(results, 2, 3));
202 EXPECT_TRUE(NthResultIs(results, 3, 1));
203 }
204
205 TEST_F(HistoryQueryTest, ReachedBeginning) { 185 TEST_F(HistoryQueryTest, ReachedBeginning) {
206 ASSERT_TRUE(history_.get()); 186 ASSERT_TRUE(history_.get());
207 187
208 QueryOptions options; 188 QueryOptions options;
209 QueryResults results; 189 QueryResults results;
210 190
211 QueryHistory(std::wstring(), options, &results); 191 QueryHistory(std::wstring(), options, &results);
212 EXPECT_TRUE(results.reached_beginning()); 192 EXPECT_TRUE(results.reached_beginning());
213 193
214 options.begin_time = test_entries[1].time; 194 options.begin_time = test_entries[1].time;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 won't get picked up by the deletor and it can happen again. When this is the 332 won't get picked up by the deletor and it can happen again. When this is the
353 case, we should fix this test to duplicate that situation. 333 case, we should fix this test to duplicate that situation.
354 334
355 // Tests duplicate collapsing and not in Full Text Search situations. 335 // Tests duplicate collapsing and not in Full Text Search situations.
356 TEST_F(HistoryQueryTest, FTSDupes) { 336 TEST_F(HistoryQueryTest, FTSDupes) {
357 ASSERT_TRUE(history_.get()); 337 ASSERT_TRUE(history_.get());
358 338
359 QueryOptions options; 339 QueryOptions options;
360 QueryResults results; 340 QueryResults results;
361 341
362 // First do the search with collapsing.
363 QueryHistory(std::wstring(L"Other"), options, &results);
364 EXPECT_EQ(2, results.urls().size());
365 EXPECT_TRUE(NthResultIs(results, 0, 4));
366 EXPECT_TRUE(NthResultIs(results, 1, 0));
367
368 // Now with collapsing.
369 options.most_recent_visit_only = true;
370 QueryHistory(std::wstring(L"Other"), options, &results); 342 QueryHistory(std::wstring(L"Other"), options, &results);
371 EXPECT_EQ(1, results.urls().size()); 343 EXPECT_EQ(1, results.urls().size());
372 EXPECT_TRUE(NthResultIs(results, 0, 4)); 344 EXPECT_TRUE(NthResultIs(results, 0, 4));
373 } 345 }
374 */ 346 */
375 347
376 } // namespace history 348 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend_unittest.cc ('k') | chrome/browser/history/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698