OLD | NEW |
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/files/scoped_temp_dir.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/common/chrome_paths.h" | |
16 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
17 #include "chrome/browser/webdata/keyword_table.h" | 16 #include "chrome/browser/webdata/keyword_table.h" |
18 #include "chrome/browser/webdata/web_database.h" | 17 #include "chrome/browser/webdata/web_database.h" |
| 18 #include "chrome/common/chrome_paths.h" |
19 #include "sql/statement.h" | 19 #include "sql/statement.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 using base::Time; | 22 using base::Time; |
23 using base::TimeDelta; | 23 using base::TimeDelta; |
24 | 24 |
25 class KeywordTableTest : public testing::Test { | 25 class KeywordTableTest : public testing::Test { |
26 public: | 26 public: |
27 KeywordTableTest() {} | 27 KeywordTableTest() {} |
28 virtual ~KeywordTableTest() {} | 28 virtual ~KeywordTableTest() {} |
29 | 29 |
30 protected: | 30 protected: |
31 virtual void SetUp() { | 31 virtual void SetUp() { |
32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
33 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); | 33 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); |
34 } | 34 } |
35 | 35 |
36 FilePath file_; | 36 FilePath file_; |
37 ScopedTempDir temp_dir_; | 37 base::ScopedTempDir temp_dir_; |
38 | 38 |
39 private: | 39 private: |
40 DISALLOW_COPY_AND_ASSIGN(KeywordTableTest); | 40 DISALLOW_COPY_AND_ASSIGN(KeywordTableTest); |
41 }; | 41 }; |
42 | 42 |
43 | 43 |
44 TEST_F(KeywordTableTest, Keywords) { | 44 TEST_F(KeywordTableTest, Keywords) { |
45 WebDatabase db; | 45 WebDatabase db; |
46 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 46 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
47 KeywordTable* keyword_table = db.GetKeywordTable(); | 47 KeywordTable* keyword_table = db.GetKeywordTable(); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 s.BindString16(0, string16()); | 433 s.BindString16(0, string16()); |
434 s.BindInt64(1, 2000); | 434 s.BindInt64(1, 2000); |
435 EXPECT_TRUE(s.Run()); | 435 EXPECT_TRUE(s.Run()); |
436 EXPECT_TRUE(keyword_table->UpdateBackupSignature( | 436 EXPECT_TRUE(keyword_table->UpdateBackupSignature( |
437 WebDatabase::kCurrentVersionNumber)); | 437 WebDatabase::kCurrentVersionNumber)); |
438 | 438 |
439 // GetKeywords() should erase the entry with the empty URL field. | 439 // GetKeywords() should erase the entry with the empty URL field. |
440 EXPECT_TRUE(keyword_table->GetKeywords(&keywords)); | 440 EXPECT_TRUE(keyword_table->GetKeywords(&keywords)); |
441 EXPECT_EQ(1U, keywords.size()); | 441 EXPECT_EQ(1U, keywords.size()); |
442 } | 442 } |
OLD | NEW |