| 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 "components/omnibox/browser/shortcuts_backend.h" | 5 #include "components/omnibox/browser/shortcuts_backend.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 data.SetKeyword(base::UTF8ToUTF16("foo")); | 105 data.SetKeyword(base::UTF8ToUTF16("foo")); |
| 106 | 106 |
| 107 TemplateURL* template_url = | 107 TemplateURL* template_url = |
| 108 template_url_service_->Add(base::MakeUnique<TemplateURL>(data)); | 108 template_url_service_->Add(base::MakeUnique<TemplateURL>(data)); |
| 109 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); | 109 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void ShortcutsBackendTest::SetUp() { | 112 void ShortcutsBackendTest::SetUp() { |
| 113 template_url_service_.reset(new TemplateURLService(nullptr, 0)); | 113 template_url_service_.reset(new TemplateURLService(nullptr, 0)); |
| 114 if (profile_dir_.CreateUniqueTempDir()) | 114 if (profile_dir_.CreateUniqueTempDir()) |
| 115 history_service_ = history::CreateHistoryService(profile_dir_.path(), true); | 115 history_service_ = |
| 116 history::CreateHistoryService(profile_dir_.GetPath(), true); |
| 116 ASSERT_TRUE(history_service_); | 117 ASSERT_TRUE(history_service_); |
| 117 | 118 |
| 118 db_thread_.Start(); | 119 db_thread_.Start(); |
| 119 base::FilePath shortcuts_database_path = | 120 base::FilePath shortcuts_database_path = |
| 120 profile_dir_.path().Append(kShortcutsDatabaseName); | 121 profile_dir_.GetPath().Append(kShortcutsDatabaseName); |
| 121 backend_ = new ShortcutsBackend( | 122 backend_ = new ShortcutsBackend( |
| 122 template_url_service_.get(), base::MakeUnique<SearchTermsData>(), | 123 template_url_service_.get(), base::MakeUnique<SearchTermsData>(), |
| 123 history_service_.get(), db_thread_.task_runner(), shortcuts_database_path, | 124 history_service_.get(), db_thread_.task_runner(), shortcuts_database_path, |
| 124 false); | 125 false); |
| 125 ASSERT_TRUE(backend_.get()); | 126 ASSERT_TRUE(backend_.get()); |
| 126 backend_->AddObserver(this); | 127 backend_->AddObserver(this); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void ShortcutsBackendTest::TearDown() { | 130 void ShortcutsBackendTest::TearDown() { |
| 130 backend_->RemoveObserver(this); | 131 backend_->RemoveObserver(this); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 ASSERT_TRUE(shortcut4_iter != shortcuts_map().end()); | 316 ASSERT_TRUE(shortcut4_iter != shortcuts_map().end()); |
| 316 EXPECT_EQ(shortcut4.id, shortcut4_iter->second.id); | 317 EXPECT_EQ(shortcut4.id, shortcut4_iter->second.id); |
| 317 | 318 |
| 318 ShortcutsDatabase::ShortcutIDs deleted_ids; | 319 ShortcutsDatabase::ShortcutIDs deleted_ids; |
| 319 deleted_ids.push_back(shortcut3.id); | 320 deleted_ids.push_back(shortcut3.id); |
| 320 deleted_ids.push_back(shortcut4.id); | 321 deleted_ids.push_back(shortcut4.id); |
| 321 EXPECT_TRUE(DeleteShortcutsWithIDs(deleted_ids)); | 322 EXPECT_TRUE(DeleteShortcutsWithIDs(deleted_ids)); |
| 322 | 323 |
| 323 ASSERT_EQ(0U, shortcuts_map().size()); | 324 ASSERT_EQ(0U, shortcuts_map().size()); |
| 324 } | 325 } |
| OLD | NEW |