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

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

Issue 849323002: Componentize HistoryDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android compilation 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
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 "chrome/browser/history/history_database.h" 5 #include "components/history/core/browser/history_database.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "components/history/core/test/test_history_database.h"
12 #include "sql/init_status.h" 13 #include "sql/init_status.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace history { 16 namespace history {
16 17
17 TEST(HistoryDatabaseTest, DropBookmarks) { 18 TEST(HistoryDatabaseTest, DropBookmarks) {
18 base::ScopedTempDir temp_dir; 19 base::ScopedTempDir temp_dir;
19 base::FilePath db_file; 20 base::FilePath db_file;
20 21
21 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 22 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
22 db_file = temp_dir.path().AppendASCII("DropBookmarks.db"); 23 db_file = temp_dir.path().AppendASCII("DropBookmarks.db");
23 sql::Connection::Delete(db_file); 24 sql::Connection::Delete(db_file);
24 25
25 // Copy db file over that contains starred URLs. 26 // Copy db file over that contains starred URLs.
26 base::FilePath old_history_path; 27 base::FilePath old_history_path;
27 PathService::Get(chrome::DIR_TEST_DATA, &old_history_path); 28 PathService::Get(chrome::DIR_TEST_DATA, &old_history_path);
28 old_history_path = old_history_path.AppendASCII("bookmarks"); 29 old_history_path = old_history_path.AppendASCII("bookmarks");
29 old_history_path = old_history_path.Append( 30 old_history_path = old_history_path.Append(
30 FILE_PATH_LITERAL("History_with_starred")); 31 FILE_PATH_LITERAL("History_with_starred"));
31 base::CopyFile(old_history_path, db_file); 32 base::CopyFile(old_history_path, db_file);
32 33
33 // Load the DB twice. The first time it should migrate. Make sure that the 34 // Load the DB twice. The first time it should migrate. Make sure that the
34 // migration leaves it in a state fit to load again later. 35 // migration leaves it in a state fit to load again later.
35 for (int i = 0; i < 2; ++i) { 36 for (int i = 0; i < 2; ++i) {
36 HistoryDatabase history_db; 37 TestHistoryDatabase history_db;
37 ASSERT_EQ(sql::INIT_OK, history_db.Init(db_file)); 38 ASSERT_EQ(sql::INIT_OK, history_db.Init(db_file));
38 HistoryDatabase::URLEnumerator url_enumerator; 39 HistoryDatabase::URLEnumerator url_enumerator;
39 ASSERT_TRUE(history_db.InitURLEnumeratorForEverything(&url_enumerator)); 40 ASSERT_TRUE(history_db.InitURLEnumeratorForEverything(&url_enumerator));
40 int num_urls = 0; 41 int num_urls = 0;
41 URLRow url_row; 42 URLRow url_row;
42 while (url_enumerator.GetNextURL(&url_row)) { 43 while (url_enumerator.GetNextURL(&url_row)) {
43 ++num_urls; 44 ++num_urls;
44 } 45 }
45 ASSERT_EQ(5, num_urls); 46 ASSERT_EQ(5, num_urls);
46 } 47 }
47 } 48 }
48 49
49 } // namespace history 50 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_database.cc ('k') | chrome/browser/history/history_querying_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698