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_provider.h" | 5 #include "components/omnibox/browser/shortcuts_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
16 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
17 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
19 #include "components/history/core/browser/history_service.h" | 20 #include "components/history/core/browser/history_service.h" |
20 #include "components/omnibox/browser/autocomplete_input.h" | 21 #include "components/omnibox/browser/autocomplete_input.h" |
21 #include "components/omnibox/browser/autocomplete_match.h" | 22 #include "components/omnibox/browser/autocomplete_match.h" |
22 #include "components/omnibox/browser/autocomplete_result.h" | 23 #include "components/omnibox/browser/autocomplete_result.h" |
23 #include "components/omnibox/browser/shortcuts_backend.h" | 24 #include "components/omnibox/browser/shortcuts_backend.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); | 78 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); |
78 provider_ = new ShortcutsProvider(&client_); | 79 provider_ = new ShortcutsProvider(&client_); |
79 PopulateShortcutsBackendWithTestData(client_.GetShortcutsBackend(), | 80 PopulateShortcutsBackendWithTestData(client_.GetShortcutsBackend(), |
80 shortcut_test_db, | 81 shortcut_test_db, |
81 arraysize(shortcut_test_db)); | 82 arraysize(shortcut_test_db)); |
82 } | 83 } |
83 | 84 |
84 void ShortcutsProviderExtensionTest::TearDown() { | 85 void ShortcutsProviderExtensionTest::TearDown() { |
85 // Run all pending tasks or else some threads hold on to the message loop | 86 // Run all pending tasks or else some threads hold on to the message loop |
86 // and prevent it from being deleted. | 87 // and prevent it from being deleted. |
87 message_loop_.RunUntilIdle(); | 88 base::RunLoop().RunUntilIdle(); |
88 profile_.DestroyHistoryService(); | 89 profile_.DestroyHistoryService(); |
89 provider_ = NULL; | 90 provider_ = NULL; |
90 } | 91 } |
91 | 92 |
92 // Actual tests --------------------------------------------------------------- | 93 // Actual tests --------------------------------------------------------------- |
93 | 94 |
94 #if defined(ENABLE_EXTENSIONS) | 95 #if defined(ENABLE_EXTENSIONS) |
95 TEST_F(ShortcutsProviderExtensionTest, Extension) { | 96 TEST_F(ShortcutsProviderExtensionTest, Extension) { |
96 // Try an input string that matches an extension URL. | 97 // Try an input string that matches an extension URL. |
97 base::string16 text(base::ASCIIToUTF16("echo")); | 98 base::string16 text(base::ASCIIToUTF16("echo")); |
(...skipping 18 matching lines...) Expand all Loading... |
116 content::NotificationService::current()->Notify( | 117 content::NotificationService::current()->Notify( |
117 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 118 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
118 content::Source<Profile>(&profile_), | 119 content::Source<Profile>(&profile_), |
119 content::Details<extensions::UnloadedExtensionInfo>(&details)); | 120 content::Details<extensions::UnloadedExtensionInfo>(&details)); |
120 | 121 |
121 // Now the URL should have disappeared. | 122 // Now the URL should have disappeared. |
122 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), | 123 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), |
123 std::string(), base::string16()); | 124 std::string(), base::string16()); |
124 } | 125 } |
125 #endif | 126 #endif |
OLD | NEW |