| 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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/search_engines/keyword_table.h" | 14 #include "components/search_engines/keyword_table.h" |
| 15 #include "components/search_engines/template_url_data.h" | 15 #include "components/search_engines/template_url_data.h" |
| 16 #include "components/webdata/common/web_database.h" | 16 #include "components/webdata/common/web_database.h" |
| 17 #include "sql/statement.h" | 17 #include "sql/statement.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 using base::ASCIIToUTF16; | 20 using base::ASCIIToUTF16; |
| 21 using base::Time; | 21 using base::Time; |
| 22 using base::TimeDelta; | 22 using base::TimeDelta; |
| 23 | 23 |
| 24 class KeywordTableTest : public testing::Test { | 24 class KeywordTableTest : public testing::Test { |
| 25 public: | 25 public: |
| 26 KeywordTableTest() {} | 26 KeywordTableTest() {} |
| 27 virtual ~KeywordTableTest() {} | 27 ~KeywordTableTest() override {} |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 virtual void SetUp() { | 30 void SetUp() override { |
| 31 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 31 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 32 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); | 32 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); |
| 33 | 33 |
| 34 table_.reset(new KeywordTable); | 34 table_.reset(new KeywordTable); |
| 35 db_.reset(new WebDatabase); | 35 db_.reset(new WebDatabase); |
| 36 db_->AddTable(table_.get()); | 36 db_->AddTable(table_.get()); |
| 37 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); | 37 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void AddKeyword(const TemplateURLData& keyword) const { | 40 void AddKeyword(const TemplateURLData& keyword) const { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // previously saved into the database. | 218 // previously saved into the database. |
| 219 sql::Statement s; | 219 sql::Statement s; |
| 220 GetStatement("UPDATE keywords SET url=? WHERE id=?", &s); | 220 GetStatement("UPDATE keywords SET url=? WHERE id=?", &s); |
| 221 s.BindString16(0, base::string16()); | 221 s.BindString16(0, base::string16()); |
| 222 s.BindInt64(1, 2000); | 222 s.BindInt64(1, 2000); |
| 223 EXPECT_TRUE(s.Run()); | 223 EXPECT_TRUE(s.Run()); |
| 224 | 224 |
| 225 // GetKeywords() should erase the entry with the empty URL field. | 225 // GetKeywords() should erase the entry with the empty URL field. |
| 226 EXPECT_EQ(1U, GetKeywords().size()); | 226 EXPECT_EQ(1U, GetKeywords().size()); |
| 227 } | 227 } |
| OLD | NEW |