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

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

Issue 9071014: Database usage adjustment for .../history (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify SQL Created 8 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 | Annotate | Revision Log
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 <fstream> 5 #include <fstream>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 95 }
96 } 96 }
97 transaction.Commit(); 97 transaction.Commit();
98 } 98 }
99 proto_file.close(); 99 proto_file.close();
100 100
101 // Update the last_visit_time table column 101 // Update the last_visit_time table column
102 // such that it represents a time relative to 'now'. 102 // such that it represents a time relative to 'now'.
103 sql::Statement statement(db.GetUniqueStatement( 103 sql::Statement statement(db.GetUniqueStatement(
104 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls;")); 104 "SELECT" HISTORY_URL_ROW_FIELDS "FROM urls;"));
105 EXPECT_TRUE(statement); 105 ASSERT_TRUE(statement.is_valid());
106 base::Time time_right_now = base::Time::NowFromSystemTime(); 106 base::Time time_right_now = base::Time::NowFromSystemTime();
107 base::TimeDelta day_delta = base::TimeDelta::FromDays(1); 107 base::TimeDelta day_delta = base::TimeDelta::FromDays(1);
108 { 108 {
109 sql::Transaction transaction(&db); 109 sql::Transaction transaction(&db);
110 transaction.Begin(); 110 transaction.Begin();
111 while (statement.Step()) { 111 while (statement.Step()) {
112 URLRow row; 112 URLRow row;
113 FillURLRow(statement, &row); 113 FillURLRow(statement, &row);
114 base::Time last_visit = time_right_now; 114 base::Time last_visit = time_right_now;
115 for (int64 i = row.last_visit().ToInternalValue(); i > 0; --i) 115 for (int64 i = row.last_visit().ToInternalValue(); i > 0; --i)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 TEST_F(InMemoryURLIndexTest, Construction) { 198 TEST_F(InMemoryURLIndexTest, Construction) {
199 url_index_.reset(new InMemoryURLIndex(FilePath())); 199 url_index_.reset(new InMemoryURLIndex(FilePath()));
200 EXPECT_TRUE(url_index_.get()); 200 EXPECT_TRUE(url_index_.get());
201 } 201 }
202 202
203 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { 203 TEST_F(LimitedInMemoryURLIndexTest, Initialization) {
204 // Verify that the database contains the expected number of items, which 204 // Verify that the database contains the expected number of items, which
205 // is the pre-filtered count, i.e. all of the items. 205 // is the pre-filtered count, i.e. all of the items.
206 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); 206 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;"));
207 EXPECT_TRUE(statement); 207 ASSERT_TRUE(statement.is_valid());
208 uint64 row_count = 0; 208 uint64 row_count = 0;
209 while (statement.Step()) ++row_count; 209 while (statement.Step()) ++row_count;
210 EXPECT_EQ(1U, row_count); 210 EXPECT_EQ(1U, row_count);
211 url_index_.reset(new InMemoryURLIndex(FilePath())); 211 url_index_.reset(new InMemoryURLIndex(FilePath()));
212 url_index_->Init(this, "en,ja,hi,zh"); 212 url_index_->Init(this, "en,ja,hi,zh");
213 URLIndexPrivateData& private_data(*(url_index_->private_data_)); 213 URLIndexPrivateData& private_data(*(url_index_->private_data_));
214 214
215 // history_info_map_ should have the same number of items as were filtered. 215 // history_info_map_ should have the same number of items as were filtered.
216 EXPECT_EQ(1U, private_data.history_info_map_.size()); 216 EXPECT_EQ(1U, private_data.history_info_map_.size());
217 EXPECT_EQ(35U, private_data.char_word_map_.size()); 217 EXPECT_EQ(35U, private_data.char_word_map_.size());
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 const URLRow& expected_row(expected->second); 698 const URLRow& expected_row(expected->second);
699 const URLRow& actual_row(actual->second); 699 const URLRow& actual_row(actual->second);
700 EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count()); 700 EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count());
701 EXPECT_EQ(expected_row.typed_count(), actual_row.typed_count()); 701 EXPECT_EQ(expected_row.typed_count(), actual_row.typed_count());
702 EXPECT_EQ(expected_row.last_visit(), actual_row.last_visit()); 702 EXPECT_EQ(expected_row.last_visit(), actual_row.last_visit());
703 EXPECT_EQ(expected_row.url(), actual_row.url()); 703 EXPECT_EQ(expected_row.url(), actual_row.url());
704 } 704 }
705 } 705 }
706 706
707 } // namespace history 707 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_database.cc ('k') | chrome/browser/history/shortcuts_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698