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" | |
14 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 15 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 16 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 17 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
19 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
20 #include "components/history/core/browser/history_service.h" | 19 #include "components/history/core/browser/history_service.h" |
21 #include "components/omnibox/browser/autocomplete_input.h" | 20 #include "components/omnibox/browser/autocomplete_input.h" |
22 #include "components/omnibox/browser/autocomplete_match.h" | 21 #include "components/omnibox/browser/autocomplete_match.h" |
23 #include "components/omnibox/browser/autocomplete_result.h" | 22 #include "components/omnibox/browser/autocomplete_result.h" |
24 #include "components/omnibox/browser/shortcuts_backend.h" | 23 #include "components/omnibox/browser/shortcuts_backend.h" |
25 #include "components/omnibox/browser/shortcuts_provider_test_util.h" | 24 #include "components/omnibox/browser/shortcuts_provider_test_util.h" |
26 #include "content/public/test/test_browser_thread.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
27 #include "extensions/features/features.h" | 26 #include "extensions/features/features.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
29 | 28 |
30 #if BUILDFLAG(ENABLE_EXTENSIONS) | 29 #if BUILDFLAG(ENABLE_EXTENSIONS) |
31 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
32 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
33 #include "extensions/common/extension_builder.h" | 32 #include "extensions/common/extension_builder.h" |
34 #endif | 33 #endif |
35 | 34 |
36 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>; | 35 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>; |
(...skipping 12 matching lines...) Expand all Loading... |
49 // ShortcutsProviderExtensionTest --------------------------------------------- | 48 // ShortcutsProviderExtensionTest --------------------------------------------- |
50 | 49 |
51 class ShortcutsProviderExtensionTest : public testing::Test { | 50 class ShortcutsProviderExtensionTest : public testing::Test { |
52 public: | 51 public: |
53 ShortcutsProviderExtensionTest(); | 52 ShortcutsProviderExtensionTest(); |
54 | 53 |
55 protected: | 54 protected: |
56 void SetUp() override; | 55 void SetUp() override; |
57 void TearDown() override; | 56 void TearDown() override; |
58 | 57 |
59 base::MessageLoopForUI message_loop_; | 58 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
60 content::TestBrowserThread ui_thread_; | |
61 content::TestBrowserThread file_thread_; | |
62 TestingProfile profile_; | 59 TestingProfile profile_; |
63 ChromeAutocompleteProviderClient client_; | 60 ChromeAutocompleteProviderClient client_; |
64 scoped_refptr<ShortcutsBackend> backend_; | 61 scoped_refptr<ShortcutsBackend> backend_; |
65 scoped_refptr<ShortcutsProvider> provider_; | 62 scoped_refptr<ShortcutsProvider> provider_; |
66 }; | 63 }; |
67 | 64 |
68 ShortcutsProviderExtensionTest::ShortcutsProviderExtensionTest() | 65 ShortcutsProviderExtensionTest::ShortcutsProviderExtensionTest() |
69 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 66 : client_(&profile_) {} |
70 file_thread_(content::BrowserThread::FILE, &message_loop_), | |
71 client_(&profile_) {} | |
72 | 67 |
73 void ShortcutsProviderExtensionTest::SetUp() { | 68 void ShortcutsProviderExtensionTest::SetUp() { |
74 ShortcutsBackendFactory::GetInstance()->SetTestingFactoryAndUse( | 69 ShortcutsBackendFactory::GetInstance()->SetTestingFactoryAndUse( |
75 &profile_, &ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting); | 70 &profile_, &ShortcutsBackendFactory::BuildProfileNoDatabaseForTesting); |
76 backend_ = ShortcutsBackendFactory::GetForProfile(&profile_); | 71 backend_ = ShortcutsBackendFactory::GetForProfile(&profile_); |
77 ASSERT_TRUE(backend_.get()); | 72 ASSERT_TRUE(backend_.get()); |
78 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); | 73 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); |
79 provider_ = new ShortcutsProvider(&client_); | 74 provider_ = new ShortcutsProvider(&client_); |
80 PopulateShortcutsBackendWithTestData(client_.GetShortcutsBackend(), | 75 PopulateShortcutsBackendWithTestData(client_.GetShortcutsBackend(), |
81 shortcut_test_db, | 76 shortcut_test_db, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 .SetID("cedabbhfglmiikkmdgcpjdkocfcmbkee") | 108 .SetID("cedabbhfglmiikkmdgcpjdkocfcmbkee") |
114 .Build(); | 109 .Build(); |
115 extensions::ExtensionRegistry::Get(&profile_)->TriggerOnUnloaded( | 110 extensions::ExtensionRegistry::Get(&profile_)->TriggerOnUnloaded( |
116 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); | 111 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); |
117 | 112 |
118 // Now the URL should have disappeared. | 113 // Now the URL should have disappeared. |
119 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), | 114 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), |
120 std::string(), base::string16()); | 115 std::string(), base::string16()); |
121 } | 116 } |
122 #endif | 117 #endif |
OLD | NEW |