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

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

Issue 14585015: Recommit the generate profile patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Load the browser dll manually on Windows. Created 7 years, 7 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 | « chrome/browser/history/history_types.h ('k') | chrome/browser/history/top_sites.h » ('j') | 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) 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 // History unit tests come in two flavors: 5 // History unit tests come in two flavors:
6 // 6 //
7 // 1. The more complicated style is that the unit test creates a full history 7 // 1. The more complicated style is that the unit test creates a full history
8 // service. This spawns a background thread for the history backend, and 8 // service. This spawns a background thread for the history backend, and
9 // all communication is asynchronous. This is useful for testing more 9 // all communication is asynchronous. This is useful for testing more
10 // complicated things or end-to-end behavior. 10 // complicated things or end-to-end behavior.
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 MessageLoop::current()->Run(); 1254 MessageLoop::current()->Run();
1255 1255
1256 EXPECT_EQ(4U, most_visited_urls_.size()); 1256 EXPECT_EQ(4U, most_visited_urls_.size());
1257 EXPECT_EQ(url1, most_visited_urls_[0].url); 1257 EXPECT_EQ(url1, most_visited_urls_[0].url);
1258 EXPECT_EQ(url2, most_visited_urls_[1].url); 1258 EXPECT_EQ(url2, most_visited_urls_[1].url);
1259 EXPECT_EQ(url0, most_visited_urls_[2].url); 1259 EXPECT_EQ(url0, most_visited_urls_[2].url);
1260 EXPECT_EQ(url3, most_visited_urls_[3].url); 1260 EXPECT_EQ(url3, most_visited_urls_[3].url);
1261 EXPECT_EQ(2U, most_visited_urls_[3].redirects.size()); 1261 EXPECT_EQ(2U, most_visited_urls_[3].redirects.size());
1262 } 1262 }
1263 1263
1264 // The version of the history database should be current in the "typical
1265 // history" example file or it will be imported on startup, throwing off timing
1266 // measurements.
1267 //
1268 // See test/data/profiles/profile_with_default_theme/README.txt for
1269 // instructions on how to up the version.
1270 TEST(HistoryProfileTest, TypicalProfileVersion) {
1271 base::FilePath file;
1272 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &file));
1273 file = file.AppendASCII("profiles");
1274 file = file.AppendASCII("profile_with_default_theme");
1275 file = file.AppendASCII("Default");
1276 file = file.AppendASCII("History");
1277
1278 int cur_version = HistoryDatabase::GetCurrentVersion();
1279
1280 sql::Connection db;
1281 ASSERT_TRUE(db.Open(file));
1282
1283 {
1284 sql::Statement s(db.GetUniqueStatement(
1285 "SELECT value FROM meta WHERE key = 'version'"));
1286 EXPECT_TRUE(s.Step());
1287 int file_version = s.ColumnInt(0);
1288 EXPECT_EQ(cur_version, file_version);
1289 }
1290 }
1291
1292 namespace { 1264 namespace {
1293 1265
1294 // A HistoryDBTask implementation. Each time RunOnDBThread is invoked 1266 // A HistoryDBTask implementation. Each time RunOnDBThread is invoked
1295 // invoke_count is increment. When invoked kWantInvokeCount times, true is 1267 // invoke_count is increment. When invoked kWantInvokeCount times, true is
1296 // returned from RunOnDBThread which should stop RunOnDBThread from being 1268 // returned from RunOnDBThread which should stop RunOnDBThread from being
1297 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to 1269 // invoked again. When DoneRunOnMainThread is invoked, done_invoked is set to
1298 // true. 1270 // true.
1299 class HistoryDBTaskImpl : public HistoryDBTask { 1271 class HistoryDBTaskImpl : public HistoryDBTask {
1300 public: 1272 public:
1301 static const int kWantInvokeCount; 1273 static const int kWantInvokeCount;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 std::vector<PageUsageData*> results; 1656 std::vector<PageUsageData*> results;
1685 db_->QuerySegmentUsage(segment_time, 10, &results); 1657 db_->QuerySegmentUsage(segment_time, 10, &results);
1686 ASSERT_EQ(1u, results.size()); 1658 ASSERT_EQ(1u, results.size());
1687 EXPECT_EQ(url, results[0]->GetURL()); 1659 EXPECT_EQ(url, results[0]->GetURL());
1688 EXPECT_EQ(segment_id, results[0]->GetID()); 1660 EXPECT_EQ(segment_id, results[0]->GetID());
1689 EXPECT_EQ(title, results[0]->GetTitle()); 1661 EXPECT_EQ(title, results[0]->GetTitle());
1690 STLDeleteElements(&results); 1662 STLDeleteElements(&results);
1691 } 1663 }
1692 1664
1693 } // namespace history 1665 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_types.h ('k') | chrome/browser/history/top_sites.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698