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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 data.SetKeyword(base::UTF8ToUTF16("foo")); | 103 data.SetKeyword(base::UTF8ToUTF16("foo")); |
104 | 104 |
105 TemplateURL* template_url = new TemplateURL(data); | 105 TemplateURL* template_url = new TemplateURL(data); |
106 // Takes ownership of |template_url|. | 106 // Takes ownership of |template_url|. |
107 template_url_service_->Add(template_url); | 107 template_url_service_->Add(template_url); |
108 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); | 108 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); |
109 } | 109 } |
110 | 110 |
111 void ShortcutsBackendTest::SetUp() { | 111 void ShortcutsBackendTest::SetUp() { |
112 template_url_service_.reset(new TemplateURLService(nullptr, 0)); | 112 template_url_service_.reset(new TemplateURLService(nullptr, 0)); |
113 if (profile_dir_.CreateUniqueTempDir()) { | 113 if (profile_dir_.CreateUniqueTempDir()) |
114 history_service_ = | 114 history_service_ = history::CreateHistoryService(profile_dir_.path(), true); |
115 history::CreateHistoryService(profile_dir_.path(), std::string(), true); | |
116 } | |
117 ASSERT_TRUE(history_service_); | 115 ASSERT_TRUE(history_service_); |
118 | 116 |
119 db_thread_.Start(); | 117 db_thread_.Start(); |
120 base::FilePath shortcuts_database_path = | 118 base::FilePath shortcuts_database_path = |
121 profile_dir_.path().Append(kShortcutsDatabaseName); | 119 profile_dir_.path().Append(kShortcutsDatabaseName); |
122 backend_ = new ShortcutsBackend( | 120 backend_ = new ShortcutsBackend( |
123 template_url_service_.get(), make_scoped_ptr(new SearchTermsData()), | 121 template_url_service_.get(), make_scoped_ptr(new SearchTermsData()), |
124 history_service_.get(), db_thread_.task_runner(), shortcuts_database_path, | 122 history_service_.get(), db_thread_.task_runner(), shortcuts_database_path, |
125 false); | 123 false); |
126 ASSERT_TRUE(backend_.get()); | 124 ASSERT_TRUE(backend_.get()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 ASSERT_TRUE(shortcut4_iter != shortcuts_map().end()); | 314 ASSERT_TRUE(shortcut4_iter != shortcuts_map().end()); |
317 EXPECT_EQ(shortcut4.id, shortcut4_iter->second.id); | 315 EXPECT_EQ(shortcut4.id, shortcut4_iter->second.id); |
318 | 316 |
319 ShortcutsDatabase::ShortcutIDs deleted_ids; | 317 ShortcutsDatabase::ShortcutIDs deleted_ids; |
320 deleted_ids.push_back(shortcut3.id); | 318 deleted_ids.push_back(shortcut3.id); |
321 deleted_ids.push_back(shortcut4.id); | 319 deleted_ids.push_back(shortcut4.id); |
322 EXPECT_TRUE(DeleteShortcutsWithIDs(deleted_ids)); | 320 EXPECT_TRUE(DeleteShortcutsWithIDs(deleted_ids)); |
323 | 321 |
324 ASSERT_EQ(0U, shortcuts_map().size()); | 322 ASSERT_EQ(0U, shortcuts_map().size()); |
325 } | 323 } |
OLD | NEW |