Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/file_path.h" | |
| 6 #include "base/file_util.h" | |
| 7 #include "base/path_service.h" | |
| 8 #include "base/scoped_temp_dir.h" | |
| 9 #include "chrome/common/chrome_paths.h" | |
| 10 #include "chrome/browser/history/history_database.h" | |
|
sky
2012/08/23 16:04:17
Tests should follow the order of .cc files, histor
| |
| 11 #include "sql/init_status.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 | |
| 14 namespace history { | |
| 15 | |
| 16 TEST(HistoryDatabaseTest, DropBookmarks) { | |
| 17 ScopedTempDir temp_dir; | |
| 18 FilePath db_file; | |
| 19 | |
| 20 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
| 21 db_file = temp_dir.path().AppendASCII("DropBookmarks.db"); | |
| 22 file_util::Delete(db_file, false); | |
| 23 | |
| 24 // Copy db file over that contains starred URLs. | |
| 25 FilePath old_history_path; | |
| 26 PathService::Get(chrome::DIR_TEST_DATA, &old_history_path); | |
| 27 old_history_path = old_history_path.AppendASCII("bookmarks"); | |
| 28 old_history_path = old_history_path.Append( | |
| 29 FILE_PATH_LITERAL("History_with_starred")); | |
| 30 file_util::CopyFile(old_history_path, db_file); | |
| 31 | |
| 32 // Load the DB twice. The first time it should migrate. Make sure that the | |
| 33 // migration leaves it in a state fit to load again later. | |
| 34 for (int i = 0; i < 2; ++i) { | |
| 35 HistoryDatabase history_db; | |
| 36 ASSERT_EQ(sql::INIT_OK, history_db.Init(db_file)); | |
| 37 HistoryDatabase::URLEnumerator url_enumerator; | |
| 38 ASSERT_TRUE(history_db.InitURLEnumeratorForEverything(&url_enumerator)); | |
| 39 int nUrls = 0; | |
|
sky
2012/08/23 16:04:17
n_urls
| |
| 40 URLRow url_row; | |
| 41 while (url_enumerator.GetNextURL(&url_row)) { | |
| 42 ++nUrls; | |
| 43 } | |
| 44 ASSERT_EQ(5, nUrls); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 } // namespace history | |
| OLD | NEW |