| 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/history/shortcuts_database.h" | 10 #include "chrome/browser/history/shortcuts_database.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "sql/statement.h" | 13 #include "sql/statement.h" |
| 13 | 14 |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace history { | 17 namespace history { |
| 17 | 18 |
| 18 struct ShortcutsDatabaseTestInfo { | 19 struct ShortcutsDatabaseTestInfo { |
| 19 std::string guid; | 20 std::string guid; |
| 20 std::string url; | 21 std::string url; |
| 21 std::string title; // The text that orginally was searched for. | 22 std::string title; // The text that orginally was searched for. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 45 virtual void TearDown(); | 46 virtual void TearDown(); |
| 46 | 47 |
| 47 void ClearDB(); | 48 void ClearDB(); |
| 48 size_t CountRecords() const; | 49 size_t CountRecords() const; |
| 49 | 50 |
| 50 ShortcutsBackend::Shortcut ShortcutFromTestInfo( | 51 ShortcutsBackend::Shortcut ShortcutFromTestInfo( |
| 51 const ShortcutsDatabaseTestInfo& info); | 52 const ShortcutsDatabaseTestInfo& info); |
| 52 | 53 |
| 53 void AddAll(); | 54 void AddAll(); |
| 54 | 55 |
| 56 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; |
| 55 scoped_ptr<TestingProfile> profile_; | 57 scoped_ptr<TestingProfile> profile_; |
| 56 scoped_refptr<ShortcutsDatabase> db_; | 58 scoped_refptr<ShortcutsDatabase> db_; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 void ShortcutsDatabaseTest::SetUp() { | 61 void ShortcutsDatabaseTest::SetUp() { |
| 62 thread_bundle_.reset(new content::TestBrowserThreadBundle()); |
| 60 profile_.reset(new TestingProfile()); | 63 profile_.reset(new TestingProfile()); |
| 61 db_ = new ShortcutsDatabase(profile_.get()); | 64 db_ = new ShortcutsDatabase(profile_.get()); |
| 62 ASSERT_TRUE(db_->Init()); | 65 ASSERT_TRUE(db_->Init()); |
| 63 ClearDB(); | 66 ClearDB(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 void ShortcutsDatabaseTest::TearDown() { | 69 void ShortcutsDatabaseTest::TearDown() { |
| 67 db_ = NULL; | 70 db_ = NULL; |
| 68 } | 71 } |
| 69 | 72 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 AddAll(); | 185 AddAll(); |
| 183 ShortcutsDatabase::GuidToShortcutMap shortcuts; | 186 ShortcutsDatabase::GuidToShortcutMap shortcuts; |
| 184 EXPECT_TRUE(db_->LoadShortcuts(&shortcuts)); | 187 EXPECT_TRUE(db_->LoadShortcuts(&shortcuts)); |
| 185 EXPECT_EQ(arraysize(shortcut_test_db), shortcuts.size()); | 188 EXPECT_EQ(arraysize(shortcut_test_db), shortcuts.size()); |
| 186 EXPECT_TRUE(db_->DeleteAllShortcuts()); | 189 EXPECT_TRUE(db_->DeleteAllShortcuts()); |
| 187 EXPECT_TRUE(db_->LoadShortcuts(&shortcuts)); | 190 EXPECT_TRUE(db_->LoadShortcuts(&shortcuts)); |
| 188 EXPECT_EQ(0U, shortcuts.size()); | 191 EXPECT_EQ(0U, shortcuts.size()); |
| 189 } | 192 } |
| 190 | 193 |
| 191 } // namespace history | 194 } // namespace history |
| OLD | NEW |