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

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

Issue 325443002: Move about://-related constants from //content to //url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android ifx Created 6 years, 6 months 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 | Annotate | Revision Log
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 "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/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_input.h" 10 #include "chrome/browser/autocomplete/autocomplete_input.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 71 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
72 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 72 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
73 return; 73 return;
74 #endif 74 #endif
75 75
76 WaitForTemplateURLServiceToLoad(); 76 WaitForTemplateURLServiceToLoad();
77 LocationBar* location_bar = GetLocationBar(); 77 LocationBar* location_bar = GetLocationBar();
78 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 78 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
79 79
80 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 80 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
81 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 81 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
82 omnibox_view->GetText());
83 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across 82 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across
84 // platforms. 83 // platforms.
85 84
86 location_bar->FocusLocation(true); 85 location_bar->FocusLocation(true);
87 86
88 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 87 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
89 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 88 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
90 omnibox_view->GetText());
91 EXPECT_TRUE(omnibox_view->IsSelectAll()); 89 EXPECT_TRUE(omnibox_view->IsSelectAll());
92 90
93 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); 91 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome"));
94 92
95 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 93 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
96 EXPECT_EQ(base::ASCIIToUTF16("chrome"), omnibox_view->GetText()); 94 EXPECT_EQ(base::ASCIIToUTF16("chrome"), omnibox_view->GetText());
97 EXPECT_FALSE(omnibox_view->IsSelectAll()); 95 EXPECT_FALSE(omnibox_view->IsSelectAll());
98 96
99 omnibox_view->RevertAll(); 97 omnibox_view->RevertAll();
100 98
101 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 99 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
102 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 100 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
103 omnibox_view->GetText());
104 EXPECT_FALSE(omnibox_view->IsSelectAll()); 101 EXPECT_FALSE(omnibox_view->IsSelectAll());
105 102
106 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); 103 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome"));
107 location_bar->Revert(); 104 location_bar->Revert();
108 105
109 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 106 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
110 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 107 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
111 omnibox_view->GetText());
112 EXPECT_FALSE(omnibox_view->IsSelectAll()); 108 EXPECT_FALSE(omnibox_view->IsSelectAll());
113 } 109 }
114 110
115 // Autocomplete test is flaky on ChromeOS. 111 // Autocomplete test is flaky on ChromeOS.
116 // http://crbug.com/52928 112 // http://crbug.com/52928
117 #if defined(OS_CHROMEOS) 113 #if defined(OS_CHROMEOS)
118 #define MAYBE_Autocomplete DISABLED_Autocomplete 114 #define MAYBE_Autocomplete DISABLED_Autocomplete
119 #else 115 #else
120 #define MAYBE_Autocomplete Autocomplete 116 #define MAYBE_Autocomplete Autocomplete
121 #endif 117 #endif
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // about the other match existing. 150 // about the other match existing.
155 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); 151 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result);
156 AutocompleteMatch match = result.match_at(0); 152 AutocompleteMatch match = result.match_at(0);
157 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type); 153 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type);
158 EXPECT_FALSE(match.deletable); 154 EXPECT_FALSE(match.deletable);
159 } 155 }
160 156
161 { 157 {
162 location_bar->Revert(); 158 location_bar->Revert();
163 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 159 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
164 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 160 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
165 omnibox_view->GetText());
166 EXPECT_FALSE(omnibox_view->IsSelectAll()); 161 EXPECT_FALSE(omnibox_view->IsSelectAll());
167 const AutocompleteResult& result = autocomplete_controller->result(); 162 const AutocompleteResult& result = autocomplete_controller->result();
168 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); 163 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result);
169 } 164 }
170 } 165 }
171 166
172 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { 167 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
173 #if defined(OS_WIN) && defined(USE_ASH) 168 #if defined(OS_WIN) && defined(USE_ASH)
174 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 169 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
175 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 170 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
176 return; 171 return;
177 #endif 172 #endif
178 173
179 WaitForTemplateURLServiceToLoad(); 174 WaitForTemplateURLServiceToLoad();
180 // http://code.google.com/p/chromium/issues/detail?id=38385 175 // http://code.google.com/p/chromium/issues/detail?id=38385
181 // Make sure that tabbing away from an empty omnibox causes a revert 176 // Make sure that tabbing away from an empty omnibox causes a revert
182 // and select all. 177 // and select all.
183 LocationBar* location_bar = GetLocationBar(); 178 LocationBar* location_bar = GetLocationBar();
184 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 179 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
185 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 180 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
186 omnibox_view->GetText());
187 omnibox_view->SetUserText(base::string16()); 181 omnibox_view->SetUserText(base::string16());
188 content::WindowedNotificationObserver observer( 182 content::WindowedNotificationObserver observer(
189 content::NOTIFICATION_LOAD_STOP, 183 content::NOTIFICATION_LOAD_STOP,
190 content::NotificationService::AllSources()); 184 content::NotificationService::AllSources());
191 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), 185 chrome::AddSelectedTabWithURL(browser(),
186 GURL(url::kAboutBlankURL),
192 content::PAGE_TRANSITION_AUTO_TOPLEVEL); 187 content::PAGE_TRANSITION_AUTO_TOPLEVEL);
193 observer.Wait(); 188 observer.Wait();
194 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 189 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
195 omnibox_view->GetText());
196 chrome::CloseTab(browser()); 190 chrome::CloseTab(browser());
197 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 191 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
198 omnibox_view->GetText());
199 EXPECT_TRUE(omnibox_view->IsSelectAll()); 192 EXPECT_TRUE(omnibox_view->IsSelectAll());
200 } 193 }
201 194
202 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { 195 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) {
203 #if defined(OS_WIN) && defined(USE_ASH) 196 #if defined(OS_WIN) && defined(USE_ASH)
204 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 197 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
205 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 198 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
206 return; 199 return;
207 #endif 200 #endif
208 201
209 WaitForTemplateURLServiceToLoad(); 202 WaitForTemplateURLServiceToLoad();
210 LocationBar* location_bar = GetLocationBar(); 203 LocationBar* location_bar = GetLocationBar();
211 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 204 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
212 205
213 // Focus search when omnibox is blank 206 // Focus search when omnibox is blank
214 { 207 {
215 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 208 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
216 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 209 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL), omnibox_view->GetText());
217 omnibox_view->GetText());
218 210
219 location_bar->FocusSearch(); 211 location_bar->FocusSearch();
220 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 212 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
221 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); 213 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText());
222 214
223 size_t selection_start, selection_end; 215 size_t selection_start, selection_end;
224 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); 216 omnibox_view->GetSelectionBounds(&selection_start, &selection_end);
225 EXPECT_EQ(1U, selection_start); 217 EXPECT_EQ(1U, selection_start);
226 EXPECT_EQ(1U, selection_end); 218 EXPECT_EQ(1U, selection_end);
227 } 219 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 location_bar->FocusSearch(); 277 location_bar->FocusSearch();
286 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 278 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
287 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); 279 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText());
288 280
289 size_t selection_start, selection_end; 281 size_t selection_start, selection_end;
290 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); 282 omnibox_view->GetSelectionBounds(&selection_start, &selection_end);
291 EXPECT_EQ(4U, std::min(selection_start, selection_end)); 283 EXPECT_EQ(4U, std::min(selection_start, selection_end));
292 EXPECT_EQ(7U, std::max(selection_start, selection_end)); 284 EXPECT_EQ(7U, std::max(selection_start, selection_end));
293 } 285 }
294 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/android/omnibox/autocomplete_controller_android.cc ('k') | chrome/browser/autocomplete/builtin_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698