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

Side by Side Diff: chrome/browser/autocomplete/in_memory_url_index_unittest.cc

Issue 1542413002: Switch to standard integer types in chrome/browser/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stddef.h>
6 #include <stdint.h>
7
5 #include <algorithm> 8 #include <algorithm>
6 #include <fstream> 9 #include <fstream>
7 10
8 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
9 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
12 #include "base/i18n/case_conversion.h" 15 #include "base/i18n/case_conversion.h"
16 #include "base/macros.h"
13 #include "base/path_service.h" 17 #include "base/path_service.h"
14 #include "base/run_loop.h" 18 #include "base/run_loop.h"
15 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
16 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
17 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
20 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 24 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
21 #include "chrome/browser/history/history_service_factory.h" 25 #include "chrome/browser/history/history_service_factory.h"
22 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ASSERT_TRUE(statement.is_valid()); 275 ASSERT_TRUE(statement.is_valid());
272 base::Time time_right_now = base::Time::NowFromSystemTime(); 276 base::Time time_right_now = base::Time::NowFromSystemTime();
273 base::TimeDelta day_delta = base::TimeDelta::FromDays(1); 277 base::TimeDelta day_delta = base::TimeDelta::FromDays(1);
274 { 278 {
275 sql::Transaction transaction(&db); 279 sql::Transaction transaction(&db);
276 transaction.Begin(); 280 transaction.Begin();
277 while (statement.Step()) { 281 while (statement.Step()) {
278 history::URLRow row; 282 history::URLRow row;
279 history_database_->FillURLRow(statement, &row); 283 history_database_->FillURLRow(statement, &row);
280 base::Time last_visit = time_right_now; 284 base::Time last_visit = time_right_now;
281 for (int64 i = row.last_visit().ToInternalValue(); i > 0; --i) 285 for (int64_t i = row.last_visit().ToInternalValue(); i > 0; --i)
282 last_visit -= day_delta; 286 last_visit -= day_delta;
283 row.set_last_visit(last_visit); 287 row.set_last_visit(last_visit);
284 history_database_->UpdateURLRow(row.id(), row); 288 history_database_->UpdateURLRow(row.id(), row);
285 } 289 }
286 transaction.Commit(); 290 transaction.Commit();
287 } 291 }
288 292
289 // Update the visit_time table column in the "visits" table 293 // Update the visit_time table column in the "visits" table
290 // such that it represents a time relative to 'now'. 294 // such that it represents a time relative to 'now'.
291 statement.Assign(db.GetUniqueStatement( 295 statement.Assign(db.GetUniqueStatement(
292 "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits;")); 296 "SELECT" HISTORY_VISIT_ROW_FIELDS "FROM visits;"));
293 ASSERT_TRUE(statement.is_valid()); 297 ASSERT_TRUE(statement.is_valid());
294 { 298 {
295 sql::Transaction transaction(&db); 299 sql::Transaction transaction(&db);
296 transaction.Begin(); 300 transaction.Begin();
297 while (statement.Step()) { 301 while (statement.Step()) {
298 history::VisitRow row; 302 history::VisitRow row;
299 history_database_->FillVisitRow(statement, &row); 303 history_database_->FillVisitRow(statement, &row);
300 base::Time last_visit = time_right_now; 304 base::Time last_visit = time_right_now;
301 for (int64 i = row.visit_time.ToInternalValue(); i > 0; --i) 305 for (int64_t i = row.visit_time.ToInternalValue(); i > 0; --i)
302 last_visit -= day_delta; 306 last_visit -= day_delta;
303 row.visit_time = last_visit; 307 row.visit_time = last_visit;
304 history_database_->UpdateVisitRow(row); 308 history_database_->UpdateVisitRow(row);
305 } 309 }
306 transaction.Commit(); 310 transaction.Commit();
307 } 311 }
308 312
309 if (InitializeInMemoryURLIndexInSetUp()) 313 if (InitializeInMemoryURLIndexInSetUp())
310 InitializeInMemoryURLIndex(); 314 InitializeInMemoryURLIndex();
311 } 315 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 485
482 bool LimitedInMemoryURLIndexTest::InitializeInMemoryURLIndexInSetUp() const { 486 bool LimitedInMemoryURLIndexTest::InitializeInMemoryURLIndexInSetUp() const {
483 return false; 487 return false;
484 } 488 }
485 489
486 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { 490 TEST_F(LimitedInMemoryURLIndexTest, Initialization) {
487 // Verify that the database contains the expected number of items, which 491 // Verify that the database contains the expected number of items, which
488 // is the pre-filtered count, i.e. all of the items. 492 // is the pre-filtered count, i.e. all of the items.
489 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); 493 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;"));
490 ASSERT_TRUE(statement.is_valid()); 494 ASSERT_TRUE(statement.is_valid());
491 uint64 row_count = 0; 495 uint64_t row_count = 0;
492 while (statement.Step()) ++row_count; 496 while (statement.Step()) ++row_count;
493 EXPECT_EQ(1U, row_count); 497 EXPECT_EQ(1U, row_count);
494 498
495 InitializeInMemoryURLIndex(); 499 InitializeInMemoryURLIndex();
496 URLIndexPrivateData& private_data(*GetPrivateData()); 500 URLIndexPrivateData& private_data(*GetPrivateData());
497 501
498 // history_info_map_ should have the same number of items as were filtered. 502 // history_info_map_ should have the same number of items as were filtered.
499 EXPECT_EQ(1U, private_data.history_info_map_.size()); 503 EXPECT_EQ(1U, private_data.history_info_map_.size());
500 EXPECT_EQ(35U, private_data.char_word_map_.size()); 504 EXPECT_EQ(35U, private_data.char_word_map_.size());
501 EXPECT_EQ(17U, private_data.word_map_.size()); 505 EXPECT_EQ(17U, private_data.word_map_.size());
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 ASSERT_TRUE(GetCacheFilePath(&full_file_path)); 1316 ASSERT_TRUE(GetCacheFilePath(&full_file_path));
1313 std::vector<base::FilePath::StringType> actual_parts; 1317 std::vector<base::FilePath::StringType> actual_parts;
1314 full_file_path.GetComponents(&actual_parts); 1318 full_file_path.GetComponents(&actual_parts);
1315 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1319 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1316 size_t count = expected_parts.size(); 1320 size_t count = expected_parts.size();
1317 for (size_t i = 0; i < count; ++i) 1321 for (size_t i = 0; i < count; ++i)
1318 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1322 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1319 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1323 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1320 set_history_dir(base::FilePath()); 1324 set_history_dir(base::FilePath());
1321 } 1325 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698