OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/autocomplete/autocomplete.h" | 7 #include "chrome/browser/autocomplete/autocomplete.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
12 #include "chrome/browser/browser_window.h" | 12 #include "chrome/browser/browser_window.h" |
13 #include "chrome/browser/extensions/extension_apitest.h" | 13 #include "chrome/browser/extensions/extension_apitest.h" |
14 #include "chrome/browser/location_bar.h" | 14 #include "chrome/browser/location_bar.h" |
15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/search_engines/template_url_model.h" | 16 #include "chrome/browser/search_engines/template_url_model.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/notification_type.h" | 18 #include "chrome/common/notification_type.h" |
19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
20 #include "chrome/test/ui_test_utils.h" | 20 #include "chrome/test/ui_test_utils.h" |
21 | 21 |
| 22 // Basic test is flaky on ChromeOS. |
| 23 // http://crbug.com/52929 |
| 24 #if defined(OS_CHROMEOS) |
| 25 #define MAYBE_Basic FLAKY_Basic |
| 26 #else |
| 27 #define MAYBE_Basic Basic |
| 28 #endif |
| 29 |
22 namespace { | 30 namespace { |
23 | 31 |
24 std::wstring AutocompleteResultAsString(const AutocompleteResult& result) { | 32 std::wstring AutocompleteResultAsString(const AutocompleteResult& result) { |
25 std::wstring output(StringPrintf(L"{%d} ", result.size())); | 33 std::wstring output(StringPrintf(L"{%d} ", result.size())); |
26 for (size_t i = 0; i < result.size(); ++i) { | 34 for (size_t i = 0; i < result.size(); ++i) { |
27 AutocompleteMatch match = result.match_at(i); | 35 AutocompleteMatch match = result.match_at(i); |
28 std::wstring provider_name(ASCIIToWide(match.provider->name())); | 36 std::wstring provider_name(ASCIIToWide(match.provider->name())); |
29 output.append(StringPrintf(L"[\"%ls\" by \"%ls\"] ", | 37 output.append(StringPrintf(L"[\"%ls\" by \"%ls\"] ", |
30 match.contents.c_str(), | 38 match.contents.c_str(), |
31 provider_name.c_str())); | 39 provider_name.c_str())); |
(...skipping 25 matching lines...) Expand all Loading... |
57 } | 65 } |
58 | 66 |
59 void WaitForAutocompleteDone(AutocompleteController* controller) { | 67 void WaitForAutocompleteDone(AutocompleteController* controller) { |
60 while (!controller->done()) { | 68 while (!controller->done()) { |
61 ui_test_utils::WaitForNotification( | 69 ui_test_utils::WaitForNotification( |
62 NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED); | 70 NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED); |
63 } | 71 } |
64 } | 72 } |
65 }; | 73 }; |
66 | 74 |
67 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, Basic) { | 75 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) { |
68 CommandLine::ForCurrentProcess()->AppendSwitch( | 76 CommandLine::ForCurrentProcess()->AppendSwitch( |
69 switches::kEnableExperimentalExtensionApis); | 77 switches::kEnableExperimentalExtensionApis); |
70 | 78 |
71 ASSERT_TRUE(test_server()->Start()); | 79 ASSERT_TRUE(test_server()->Start()); |
72 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_; | 80 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_; |
73 | 81 |
74 // The results depend on the TemplateURLModel being loaded. Make sure it is | 82 // The results depend on the TemplateURLModel being loaded. Make sure it is |
75 // loaded so that the autocomplete results are consistent. | 83 // loaded so that the autocomplete results are consistent. |
76 WaitForTemplateURLModelToLoad(); | 84 WaitForTemplateURLModelToLoad(); |
77 | 85 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 162 } |
155 | 163 |
156 { | 164 { |
157 ResultCatcher catcher; | 165 ResultCatcher catcher; |
158 autocomplete_controller->Start(L"keyword command", std::wstring(), | 166 autocomplete_controller->Start(L"keyword command", std::wstring(), |
159 true, false, false); | 167 true, false, false); |
160 location_bar->AcceptInput(); | 168 location_bar->AcceptInput(); |
161 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 169 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
162 } | 170 } |
163 } | 171 } |
OLD | NEW |