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

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

Issue 6793008: Replacing base::DIR_TEMP with ScopedTempDir when appropriate. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Needed to rebase; patch didn't apply cleanly to save_package_unittest. Created 9 years, 8 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "app/sql/connection.h" 5 #include "app/sql/connection.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_temp_dir.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/history/url_database.h" 12 #include "chrome/browser/history/url_database.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 using base::Time; 15 using base::Time;
15 using base::TimeDelta; 16 using base::TimeDelta;
16 17
17 namespace history { 18 namespace history {
(...skipping 22 matching lines...) Expand all
40 41
41 protected: 42 protected:
42 // Provided for URL/VisitDatabase. 43 // Provided for URL/VisitDatabase.
43 virtual sql::Connection& GetDB() { 44 virtual sql::Connection& GetDB() {
44 return db_; 45 return db_;
45 } 46 }
46 47
47 private: 48 private:
48 // Test setup. 49 // Test setup.
49 void SetUp() { 50 void SetUp() {
50 FilePath temp_dir; 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
51 PathService::Get(base::DIR_TEMP, &temp_dir); 52 FilePath db_file = temp_dir_.path().AppendASCII("URLTest.db");
52 db_file_ = temp_dir.AppendASCII("URLTest.db");
53 53
54 EXPECT_TRUE(db_.Open(db_file_)); 54 EXPECT_TRUE(db_.Open(db_file));
55 55
56 // Initialize the tables for this test. 56 // Initialize the tables for this test.
57 CreateURLTable(false); 57 CreateURLTable(false);
58 CreateMainURLIndex(); 58 CreateMainURLIndex();
59 InitKeywordSearchTermsTable(); 59 InitKeywordSearchTermsTable();
60 CreateKeywordSearchTermsIndices(); 60 CreateKeywordSearchTermsIndices();
61 } 61 }
62 void TearDown() { 62 void TearDown() {
63 db_.Close(); 63 db_.Close();
64 file_util::Delete(db_file_, false);
65 } 64 }
66 65
67 FilePath db_file_; 66 ScopedTempDir temp_dir_;
68 sql::Connection db_; 67 sql::Connection db_;
69 }; 68 };
70 69
71 // Test add and query for the URL table in the HistoryDatabase. 70 // Test add and query for the URL table in the HistoryDatabase.
72 TEST_F(URLDatabaseTest, AddURL) { 71 TEST_F(URLDatabaseTest, AddURL) {
73 // First, add two URLs. 72 // First, add two URLs.
74 const GURL url1("http://www.google.com/"); 73 const GURL url1("http://www.google.com/");
75 URLRow url_info1(url1); 74 URLRow url_info1(url1);
76 url_info1.set_title(UTF8ToUTF16("Google")); 75 url_info1.set_title(UTF8ToUTF16("Google"));
77 url_info1.set_visit_count(4); 76 url_info1.set_visit_count(4);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 IconMappingEnumerator e; 261 IconMappingEnumerator e;
263 InitIconMappingEnumeratorForEverything(&e); 262 InitIconMappingEnumeratorForEverything(&e);
264 IconMapping icon_mapping; 263 IconMapping icon_mapping;
265 ASSERT_TRUE(e.GetNextIconMapping(&icon_mapping)); 264 ASSERT_TRUE(e.GetNextIconMapping(&icon_mapping));
266 ASSERT_EQ(url1, icon_mapping.page_url); 265 ASSERT_EQ(url1, icon_mapping.page_url);
267 ASSERT_EQ(icon_id, icon_mapping.icon_id); 266 ASSERT_EQ(icon_id, icon_mapping.icon_id);
268 ASSERT_FALSE(e.GetNextIconMapping(&icon_mapping)); 267 ASSERT_FALSE(e.GetNextIconMapping(&icon_mapping));
269 } 268 }
270 269
271 } // namespace history 270 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/text_database_unittest.cc ('k') | chrome/browser/history/visit_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698