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

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

Issue 12893: Get rid of kPathSeparator on windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <vector> 5 #include <vector>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 bool EnsureStarredIntegrity() { 61 bool EnsureStarredIntegrity() {
62 return StarredURLDatabase::EnsureStarredIntegrity(); 62 return StarredURLDatabase::EnsureStarredIntegrity();
63 } 63 }
64 64
65 private: 65 private:
66 // Test setup. 66 // Test setup.
67 void SetUp() { 67 void SetUp() {
68 PathService::Get(base::DIR_TEMP, &db_file_); 68 PathService::Get(base::DIR_TEMP, &db_file_);
69 db_file_.push_back(file_util::kPathSeparator); 69 db_file_ = db_file_.Append(FILE_PATH_LITERAL("VisitTest.db"));
70 db_file_.append(L"VisitTest.db");
71 file_util::Delete(db_file_, false); 70 file_util::Delete(db_file_, false);
72 71
73 // Copy db file over that contains starred table. 72 // Copy db file over that contains starred table.
74 std::wstring old_history_path; 73 FilePath old_history_path;
75 PathService::Get(chrome::DIR_TEST_DATA, &old_history_path); 74 PathService::Get(chrome::DIR_TEST_DATA, &old_history_path);
76 file_util::AppendToPath(&old_history_path, L"bookmarks"); 75 old_history_path = old_history_path.Append(FILE_PATH_LITERAL("bookmarks"));
77 file_util::AppendToPath(&old_history_path, L"History_with_empty_starred"); 76 old_history_path = old_history_path.Append(
77 FILE_PATH_LITERAL("History_with_empty_starred"));
78 file_util::CopyFile(old_history_path, db_file_); 78 file_util::CopyFile(old_history_path, db_file_);
79 79
80 EXPECT_EQ(SQLITE_OK, sqlite3_open(WideToUTF8(db_file_).c_str(), &db_)); 80 EXPECT_EQ(SQLITE_OK,
81 sqlite3_open(WideToUTF8(db_file_.ToWStringHack()).c_str(), &db_));
81 statement_cache_ = new SqliteStatementCache(db_); 82 statement_cache_ = new SqliteStatementCache(db_);
82 83
83 // Initialize the tables for this test. 84 // Initialize the tables for this test.
84 CreateURLTable(false); 85 CreateURLTable(false);
85 CreateMainURLIndex(); 86 CreateMainURLIndex();
86 EnsureStarredIntegrity(); 87 EnsureStarredIntegrity();
87 } 88 }
88 void TearDown() { 89 void TearDown() {
89 delete statement_cache_; 90 delete statement_cache_;
90 sqlite3_close(db_); 91 sqlite3_close(db_);
91 file_util::Delete(db_file_, false); 92 file_util::Delete(db_file_, false);
92 } 93 }
93 94
94 // Provided for URL/StarredURLDatabase. 95 // Provided for URL/StarredURLDatabase.
95 virtual sqlite3* GetDB() { 96 virtual sqlite3* GetDB() {
96 return db_; 97 return db_;
97 } 98 }
98 virtual SqliteStatementCache& GetStatementCache() { 99 virtual SqliteStatementCache& GetStatementCache() {
99 return *statement_cache_; 100 return *statement_cache_;
100 } 101 }
101 102
102 std::wstring db_file_; 103 FilePath db_file_;
103 sqlite3* db_; 104 sqlite3* db_;
104 SqliteStatementCache* statement_cache_; 105 SqliteStatementCache* statement_cache_;
105 }; 106 };
106 107
107 //----------------------------------------------------------------------------- 108 //-----------------------------------------------------------------------------
108 109
109 TEST_F(StarredURLDatabaseTest, FixOrphanedGroup) { 110 TEST_F(StarredURLDatabaseTest, FixOrphanedGroup) {
110 const size_t initial_count = GetStarredEntryCount(); 111 const size_t initial_count = GetStarredEntryCount();
111 112
112 // Create a group that isn't parented to the other/bookmark folders. 113 // Create a group that isn't parented to the other/bookmark folders.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 284
284 // Fix up the table. 285 // Fix up the table.
285 ASSERT_TRUE(EnsureStarredIntegrity()); 286 ASSERT_TRUE(EnsureStarredIntegrity());
286 287
287 // The entry we just created should have been nuked. 288 // The entry we just created should have been nuked.
288 ASSERT_EQ(initial_count, GetStarredEntryCount()); 289 ASSERT_EQ(initial_count, GetStarredEntryCount());
289 } 290 }
290 291
291 } // namespace history 292 } // namespace history
292 293
OLDNEW
« no previous file with comments | « chrome/browser/download/save_page_uitest.cc ('k') | chrome/browser/history/url_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698