| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 16 #include "components/history/core/browser/history_service.h" | 17 #include "components/history/core/browser/history_service.h" |
| 17 #include "components/history/core/test/history_service_test_util.h" | 18 #include "components/history/core/test/history_service_test_util.h" |
| 18 #include "components/omnibox/browser/shortcuts_constants.h" | 19 #include "components/omnibox/browser/shortcuts_constants.h" |
| 19 #include "components/omnibox/browser/shortcuts_database.h" | 20 #include "components/omnibox/browser/shortcuts_database.h" |
| 20 #include "components/search_engines/search_terms_data.h" | 21 #include "components/search_engines/search_terms_data.h" |
| 21 #include "components/search_engines/template_url_service.h" | 22 #include "components/search_engines/template_url_service.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 139 |
| 139 void ShortcutsBackendTest::OnShortcutsChanged() { | 140 void ShortcutsBackendTest::OnShortcutsChanged() { |
| 140 changed_notified_ = true; | 141 changed_notified_ = true; |
| 141 } | 142 } |
| 142 | 143 |
| 143 void ShortcutsBackendTest::InitBackend() { | 144 void ShortcutsBackendTest::InitBackend() { |
| 144 ASSERT_TRUE(backend_); | 145 ASSERT_TRUE(backend_); |
| 145 ASSERT_FALSE(load_notified_); | 146 ASSERT_FALSE(load_notified_); |
| 146 ASSERT_FALSE(backend_->initialized()); | 147 ASSERT_FALSE(backend_->initialized()); |
| 147 backend_->Init(); | 148 backend_->Init(); |
| 148 base::MessageLoop::current()->Run(); | 149 base::RunLoop().Run(); |
| 149 EXPECT_TRUE(load_notified_); | 150 EXPECT_TRUE(load_notified_); |
| 150 EXPECT_TRUE(backend_->initialized()); | 151 EXPECT_TRUE(backend_->initialized()); |
| 151 } | 152 } |
| 152 | 153 |
| 153 bool ShortcutsBackendTest::AddShortcut( | 154 bool ShortcutsBackendTest::AddShortcut( |
| 154 const ShortcutsDatabase::Shortcut& shortcut) { | 155 const ShortcutsDatabase::Shortcut& shortcut) { |
| 155 return backend_->AddShortcut(shortcut); | 156 return backend_->AddShortcut(shortcut); |
| 156 } | 157 } |
| 157 | 158 |
| 158 bool ShortcutsBackendTest::UpdateShortcut( | 159 bool ShortcutsBackendTest::UpdateShortcut( |
| (...skipping 156 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 |