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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/format_macros.h" | 6 #include "base/format_macros.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 AutocompleteController* GetAutocompleteController() const { | 64 AutocompleteController* GetAutocompleteController() const { |
65 return GetLocationBar()->GetOmniboxView()->model()->popup_model()-> | 65 return GetLocationBar()->GetOmniboxView()->model()->popup_model()-> |
66 autocomplete_controller(); | 66 autocomplete_controller(); |
67 } | 67 } |
68 }; | 68 }; |
69 | 69 |
70 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Basic) { | 70 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Basic) { |
71 #if defined(OS_WIN) && defined(USE_ASH) | 71 #if defined(OS_WIN) && defined(USE_ASH) |
72 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 72 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
73 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 73 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 74 switches::kAshBrowserTests)) |
74 return; | 75 return; |
75 #endif | 76 #endif |
76 | 77 |
77 WaitForTemplateURLServiceToLoad(); | 78 WaitForTemplateURLServiceToLoad(); |
78 LocationBar* location_bar = GetLocationBar(); | 79 LocationBar* location_bar = GetLocationBar(); |
79 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 80 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
80 | 81 |
81 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 82 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
82 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); | 83 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); |
83 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across | 84 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across |
(...skipping 29 matching lines...) Expand all Loading... |
113 // http://crbug.com/52928 | 114 // http://crbug.com/52928 |
114 #if defined(OS_CHROMEOS) | 115 #if defined(OS_CHROMEOS) |
115 #define MAYBE_Autocomplete DISABLED_Autocomplete | 116 #define MAYBE_Autocomplete DISABLED_Autocomplete |
116 #else | 117 #else |
117 #define MAYBE_Autocomplete Autocomplete | 118 #define MAYBE_Autocomplete Autocomplete |
118 #endif | 119 #endif |
119 | 120 |
120 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) { | 121 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) { |
121 #if defined(OS_WIN) && defined(USE_ASH) | 122 #if defined(OS_WIN) && defined(USE_ASH) |
122 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 123 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
123 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 124 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 125 switches::kAshBrowserTests)) |
124 return; | 126 return; |
125 #endif | 127 #endif |
126 | 128 |
127 WaitForTemplateURLServiceToLoad(); | 129 WaitForTemplateURLServiceToLoad(); |
128 // The results depend on the history backend being loaded. Make sure it is | 130 // The results depend on the history backend being loaded. Make sure it is |
129 // loaded so that the autocomplete results are consistent. | 131 // loaded so that the autocomplete results are consistent. |
130 ui_test_utils::WaitForHistoryToLoad( | 132 ui_test_utils::WaitForHistoryToLoad( |
131 HistoryServiceFactory::GetForProfile(browser()->profile(), | 133 HistoryServiceFactory::GetForProfile(browser()->profile(), |
132 Profile::EXPLICIT_ACCESS)); | 134 Profile::EXPLICIT_ACCESS)); |
133 | 135 |
(...skipping 25 matching lines...) Expand all Loading... |
159 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); | 161 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); |
160 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 162 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
161 const AutocompleteResult& result = autocomplete_controller->result(); | 163 const AutocompleteResult& result = autocomplete_controller->result(); |
162 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); | 164 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { | 168 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { |
167 #if defined(OS_WIN) && defined(USE_ASH) | 169 #if defined(OS_WIN) && defined(USE_ASH) |
168 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 170 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
169 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 171 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 172 switches::kAshBrowserTests)) |
170 return; | 173 return; |
171 #endif | 174 #endif |
172 | 175 |
173 WaitForTemplateURLServiceToLoad(); | 176 WaitForTemplateURLServiceToLoad(); |
174 // http://code.google.com/p/chromium/issues/detail?id=38385 | 177 // http://code.google.com/p/chromium/issues/detail?id=38385 |
175 // Make sure that tabbing away from an empty omnibox causes a revert | 178 // Make sure that tabbing away from an empty omnibox causes a revert |
176 // and select all. | 179 // and select all. |
177 LocationBar* location_bar = GetLocationBar(); | 180 LocationBar* location_bar = GetLocationBar(); |
178 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 181 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
179 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); | 182 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); |
180 omnibox_view->SetUserText(base::string16()); | 183 omnibox_view->SetUserText(base::string16()); |
181 content::WindowedNotificationObserver observer( | 184 content::WindowedNotificationObserver observer( |
182 content::NOTIFICATION_LOAD_STOP, | 185 content::NOTIFICATION_LOAD_STOP, |
183 content::NotificationService::AllSources()); | 186 content::NotificationService::AllSources()); |
184 chrome::AddSelectedTabWithURL(browser(), | 187 chrome::AddSelectedTabWithURL(browser(), |
185 GURL(url::kAboutBlankURL), | 188 GURL(url::kAboutBlankURL), |
186 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 189 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
187 observer.Wait(); | 190 observer.Wait(); |
188 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); | 191 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); |
189 chrome::CloseTab(browser()); | 192 chrome::CloseTab(browser()); |
190 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); | 193 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText()); |
191 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 194 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
192 } | 195 } |
193 | 196 |
194 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { | 197 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { |
195 #if defined(OS_WIN) && defined(USE_ASH) | 198 #if defined(OS_WIN) && defined(USE_ASH) |
196 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 199 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
197 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 201 switches::kAshBrowserTests)) |
198 return; | 202 return; |
199 #endif | 203 #endif |
200 | 204 |
201 WaitForTemplateURLServiceToLoad(); | 205 WaitForTemplateURLServiceToLoad(); |
202 LocationBar* location_bar = GetLocationBar(); | 206 LocationBar* location_bar = GetLocationBar(); |
203 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); | 207 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); |
204 | 208 |
205 // Focus search when omnibox is blank | 209 // Focus search when omnibox is blank |
206 { | 210 { |
207 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 211 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 location_bar->FocusSearch(); | 280 location_bar->FocusSearch(); |
277 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); | 281 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); |
278 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); | 282 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); |
279 | 283 |
280 size_t selection_start, selection_end; | 284 size_t selection_start, selection_end; |
281 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); | 285 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); |
282 EXPECT_EQ(4U, std::min(selection_start, selection_end)); | 286 EXPECT_EQ(4U, std::min(selection_start, selection_end)); |
283 EXPECT_EQ(7U, std::max(selection_start, selection_end)); | 287 EXPECT_EQ(7U, std::max(selection_start, selection_end)); |
284 } | 288 } |
285 } | 289 } |
OLD | NEW |