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

Side by Side Diff: chrome/browser/webdata/keyword_table_unittest.cc

Issue 10386222: Use ScopedTempDir instead of DIR_TEST_DATA for creating test data. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_temp_dir.h"
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
15 #include "chrome/browser/search_engines/template_url.h" 16 #include "chrome/browser/search_engines/template_url.h"
16 #include "chrome/browser/webdata/keyword_table.h" 17 #include "chrome/browser/webdata/keyword_table.h"
17 #include "chrome/browser/webdata/web_database.h" 18 #include "chrome/browser/webdata/web_database.h"
18 #include "sql/statement.h" 19 #include "sql/statement.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 using base::Time; 22 using base::Time;
22 using base::TimeDelta; 23 using base::TimeDelta;
23 24
24 class KeywordTableTest : public testing::Test { 25 class KeywordTableTest : public testing::Test {
25 public: 26 public:
26 KeywordTableTest() {} 27 KeywordTableTest() {}
27 virtual ~KeywordTableTest() {} 28 virtual ~KeywordTableTest() {}
28 29
29 protected: 30 protected:
30 virtual void SetUp() { 31 virtual void SetUp() {
31 PathService::Get(chrome::DIR_TEST_DATA, &file_); 32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
32 const std::string test_db = "TestWebDatabase" + 33 file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
33 base::Int64ToString(Time::Now().ToTimeT()) +
34 ".db";
35 file_ = file_.AppendASCII(test_db);
36 file_util::Delete(file_, false);
37 }
38
39 virtual void TearDown() {
40 file_util::Delete(file_, false);
41 } 34 }
42 35
43 FilePath file_; 36 FilePath file_;
37 ScopedTempDir temp_dir_;
44 38
45 private: 39 private:
46 DISALLOW_COPY_AND_ASSIGN(KeywordTableTest); 40 DISALLOW_COPY_AND_ASSIGN(KeywordTableTest);
47 }; 41 };
48 42
49 43
50 TEST_F(KeywordTableTest, Keywords) { 44 TEST_F(KeywordTableTest, Keywords) {
51 WebDatabase db; 45 WebDatabase db;
52 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 46 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
53 KeywordTable* keyword_table = db.GetKeywordTable(); 47 KeywordTable* keyword_table = db.GetKeywordTable();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 s.BindString16(0, string16()); 426 s.BindString16(0, string16());
433 s.BindInt64(1, 2000); 427 s.BindInt64(1, 2000);
434 EXPECT_TRUE(s.Run()); 428 EXPECT_TRUE(s.Run());
435 EXPECT_TRUE(keyword_table->UpdateBackupSignature( 429 EXPECT_TRUE(keyword_table->UpdateBackupSignature(
436 WebDatabase::kCurrentVersionNumber)); 430 WebDatabase::kCurrentVersionNumber));
437 431
438 // GetKeywords() should erase the entry with the empty URL field. 432 // GetKeywords() should erase the entry with the empty URL field.
439 EXPECT_TRUE(keyword_table->GetKeywords(&keywords)); 433 EXPECT_TRUE(keyword_table->GetKeywords(&keywords));
440 EXPECT_EQ(1U, keywords.size()); 434 EXPECT_EQ(1U, keywords.size());
441 } 435 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_table_unittest.cc ('k') | chrome/browser/webdata/token_service_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698