Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/autocomplete/shortcuts_provider_extension_unittest.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/run_loop.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" 16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" 18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "components/history/core/browser/history_service.h" 20 #include "components/history/core/browser/history_service.h"
21 #include "components/omnibox/browser/autocomplete_input.h" 21 #include "components/omnibox/browser/autocomplete_input.h"
22 #include "components/omnibox/browser/autocomplete_match.h" 22 #include "components/omnibox/browser/autocomplete_match.h"
23 #include "components/omnibox/browser/autocomplete_result.h" 23 #include "components/omnibox/browser/autocomplete_result.h"
24 #include "components/omnibox/browser/shortcuts_backend.h" 24 #include "components/omnibox/browser/shortcuts_backend.h"
25 #include "components/omnibox/browser/shortcuts_provider_test_util.h" 25 #include "components/omnibox/browser/shortcuts_provider_test_util.h"
26 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
27 #include "content/public/test/test_browser_thread.h" 27 #include "content/public/test/test_browser_thread.h"
28 #include "extensions/features/features.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 #if defined(ENABLE_EXTENSIONS) 31 #if BUILDFLAG(ENABLE_EXTENSIONS)
31 #include "extensions/browser/notification_types.h" 32 #include "extensions/browser/notification_types.h"
32 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
33 #include "extensions/common/extension_builder.h" 34 #include "extensions/common/extension_builder.h"
34 #endif 35 #endif
35 36
36 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>; 37 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>;
37 38
38 namespace { 39 namespace {
39 40
40 struct TestShortcutData shortcut_test_db[] = { 41 struct TestShortcutData shortcut_test_db[] = {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 void ShortcutsProviderExtensionTest::TearDown() { 86 void ShortcutsProviderExtensionTest::TearDown() {
86 // Run all pending tasks or else some threads hold on to the message loop 87 // Run all pending tasks or else some threads hold on to the message loop
87 // and prevent it from being deleted. 88 // and prevent it from being deleted.
88 base::RunLoop().RunUntilIdle(); 89 base::RunLoop().RunUntilIdle();
89 profile_.DestroyHistoryService(); 90 profile_.DestroyHistoryService();
90 provider_ = NULL; 91 provider_ = NULL;
91 } 92 }
92 93
93 // Actual tests --------------------------------------------------------------- 94 // Actual tests ---------------------------------------------------------------
94 95
95 #if defined(ENABLE_EXTENSIONS) 96 #if BUILDFLAG(ENABLE_EXTENSIONS)
96 TEST_F(ShortcutsProviderExtensionTest, Extension) { 97 TEST_F(ShortcutsProviderExtensionTest, Extension) {
97 // Try an input string that matches an extension URL. 98 // Try an input string that matches an extension URL.
98 base::string16 text(base::ASCIIToUTF16("echo")); 99 base::string16 text(base::ASCIIToUTF16("echo"));
99 std::string expected_url( 100 std::string expected_url(
100 "chrome-extension://cedabbhfglmiikkmdgcpjdkocfcmbkee/?q=echo"); 101 "chrome-extension://cedabbhfglmiikkmdgcpjdkocfcmbkee/?q=echo");
101 ExpectedURLs expected_urls; 102 ExpectedURLs expected_urls;
102 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(expected_url, true)); 103 expected_urls.push_back(ExpectedURLAndAllowedToBeDefault(expected_url, true));
103 RunShortcutsProviderTest(provider_, text, false, expected_urls, expected_url, 104 RunShortcutsProviderTest(provider_, text, false, expected_urls, expected_url,
104 base::ASCIIToUTF16(" echo")); 105 base::ASCIIToUTF16(" echo"));
105 106
(...skipping 11 matching lines...) Expand all
117 content::NotificationService::current()->Notify( 118 content::NotificationService::current()->Notify(
118 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 119 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
119 content::Source<Profile>(&profile_), 120 content::Source<Profile>(&profile_),
120 content::Details<extensions::UnloadedExtensionInfo>(&details)); 121 content::Details<extensions::UnloadedExtensionInfo>(&details));
121 122
122 // Now the URL should have disappeared. 123 // Now the URL should have disappeared.
123 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), 124 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(),
124 std::string(), base::string16()); 125 std::string(), base::string16());
125 } 126 }
126 #endif 127 #endif
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_extensions_manager.cc ('k') | chrome/browser/browser_about_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698