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

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: 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),
82 omnibox_view->GetText()); 82 omnibox_view->GetText());
83 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across 83 // TODO(phajdan.jr): check state of IsSelectAll when it's consistent across
84 // platforms. 84 // platforms.
85 85
86 location_bar->FocusLocation(true); 86 location_bar->FocusLocation(true);
87 87
88 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 88 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
89 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 89 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
90 omnibox_view->GetText()); 90 omnibox_view->GetText());
91 EXPECT_TRUE(omnibox_view->IsSelectAll()); 91 EXPECT_TRUE(omnibox_view->IsSelectAll());
92 92
93 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); 93 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome"));
94 94
95 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 95 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
96 EXPECT_EQ(base::ASCIIToUTF16("chrome"), omnibox_view->GetText()); 96 EXPECT_EQ(base::ASCIIToUTF16("chrome"), omnibox_view->GetText());
97 EXPECT_FALSE(omnibox_view->IsSelectAll()); 97 EXPECT_FALSE(omnibox_view->IsSelectAll());
98 98
99 omnibox_view->RevertAll(); 99 omnibox_view->RevertAll();
100 100
101 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 101 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
102 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 102 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
103 omnibox_view->GetText()); 103 omnibox_view->GetText());
104 EXPECT_FALSE(omnibox_view->IsSelectAll()); 104 EXPECT_FALSE(omnibox_view->IsSelectAll());
105 105
106 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome")); 106 omnibox_view->SetUserText(base::ASCIIToUTF16("chrome"));
107 location_bar->Revert(); 107 location_bar->Revert();
108 108
109 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 109 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
110 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 110 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
111 omnibox_view->GetText()); 111 omnibox_view->GetText());
112 EXPECT_FALSE(omnibox_view->IsSelectAll()); 112 EXPECT_FALSE(omnibox_view->IsSelectAll());
113 } 113 }
114 114
115 // Autocomplete test is flaky on ChromeOS. 115 // Autocomplete test is flaky on ChromeOS.
116 // http://crbug.com/52928 116 // http://crbug.com/52928
117 #if defined(OS_CHROMEOS) 117 #if defined(OS_CHROMEOS)
118 #define MAYBE_Autocomplete DISABLED_Autocomplete 118 #define MAYBE_Autocomplete DISABLED_Autocomplete
119 #else 119 #else
120 #define MAYBE_Autocomplete Autocomplete 120 #define MAYBE_Autocomplete Autocomplete
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // about the other match existing. 154 // about the other match existing.
155 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result); 155 ASSERT_GE(result.size(), 1U) << AutocompleteResultAsString(result);
156 AutocompleteMatch match = result.match_at(0); 156 AutocompleteMatch match = result.match_at(0);
157 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type); 157 EXPECT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, match.type);
158 EXPECT_FALSE(match.deletable); 158 EXPECT_FALSE(match.deletable);
159 } 159 }
160 160
161 { 161 {
162 location_bar->Revert(); 162 location_bar->Revert();
163 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 163 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
164 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 164 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
165 omnibox_view->GetText()); 165 omnibox_view->GetText());
166 EXPECT_FALSE(omnibox_view->IsSelectAll()); 166 EXPECT_FALSE(omnibox_view->IsSelectAll());
167 const AutocompleteResult& result = autocomplete_controller->result(); 167 const AutocompleteResult& result = autocomplete_controller->result();
168 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result); 168 EXPECT_TRUE(result.empty()) << AutocompleteResultAsString(result);
169 } 169 }
170 } 170 }
171 171
172 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) { 172 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, TabAwayRevertSelect) {
173 #if defined(OS_WIN) && defined(USE_ASH) 173 #if defined(OS_WIN) && defined(USE_ASH)
174 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 174 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
175 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 175 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
176 return; 176 return;
177 #endif 177 #endif
178 178
179 WaitForTemplateURLServiceToLoad(); 179 WaitForTemplateURLServiceToLoad();
180 // http://code.google.com/p/chromium/issues/detail?id=38385 180 // http://code.google.com/p/chromium/issues/detail?id=38385
181 // Make sure that tabbing away from an empty omnibox causes a revert 181 // Make sure that tabbing away from an empty omnibox causes a revert
182 // and select all. 182 // and select all.
183 LocationBar* location_bar = GetLocationBar(); 183 LocationBar* location_bar = GetLocationBar();
184 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 184 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
185 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 185 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
186 omnibox_view->GetText()); 186 omnibox_view->GetText());
187 omnibox_view->SetUserText(base::string16()); 187 omnibox_view->SetUserText(base::string16());
188 content::WindowedNotificationObserver observer( 188 content::WindowedNotificationObserver observer(
189 content::NOTIFICATION_LOAD_STOP, 189 content::NOTIFICATION_LOAD_STOP,
190 content::NotificationService::AllSources()); 190 content::NotificationService::AllSources());
191 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), 191 chrome::AddSelectedTabWithURL(browser(), GURL(url::kAboutBlankURL),
192 content::PAGE_TRANSITION_AUTO_TOPLEVEL); 192 content::PAGE_TRANSITION_AUTO_TOPLEVEL);
193 observer.Wait(); 193 observer.Wait();
194 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 194 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
195 omnibox_view->GetText()); 195 omnibox_view->GetText());
196 chrome::CloseTab(browser()); 196 chrome::CloseTab(browser());
197 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 197 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
198 omnibox_view->GetText()); 198 omnibox_view->GetText());
199 EXPECT_TRUE(omnibox_view->IsSelectAll()); 199 EXPECT_TRUE(omnibox_view->IsSelectAll());
200 } 200 }
201 201
202 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { 202 IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) {
203 #if defined(OS_WIN) && defined(USE_ASH) 203 #if defined(OS_WIN) && defined(USE_ASH)
204 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 204 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
205 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 205 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
206 return; 206 return;
207 #endif 207 #endif
208 208
209 WaitForTemplateURLServiceToLoad(); 209 WaitForTemplateURLServiceToLoad();
210 LocationBar* location_bar = GetLocationBar(); 210 LocationBar* location_bar = GetLocationBar();
211 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 211 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
212 212
213 // Focus search when omnibox is blank 213 // Focus search when omnibox is blank
214 { 214 {
215 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 215 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
216 EXPECT_EQ(base::UTF8ToUTF16(content::kAboutBlankURL), 216 EXPECT_EQ(base::UTF8ToUTF16(url::kAboutBlankURL),
217 omnibox_view->GetText()); 217 omnibox_view->GetText());
218 218
219 location_bar->FocusSearch(); 219 location_bar->FocusSearch();
220 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 220 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
221 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); 221 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText());
222 222
223 size_t selection_start, selection_end; 223 size_t selection_start, selection_end;
224 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); 224 omnibox_view->GetSelectionBounds(&selection_start, &selection_end);
225 EXPECT_EQ(1U, selection_start); 225 EXPECT_EQ(1U, selection_start);
226 EXPECT_EQ(1U, selection_end); 226 EXPECT_EQ(1U, selection_end);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 location_bar->FocusSearch(); 285 location_bar->FocusSearch();
286 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 286 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
287 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); 287 EXPECT_EQ(base::ASCIIToUTF16(" ?foo"), omnibox_view->GetText());
288 288
289 size_t selection_start, selection_end; 289 size_t selection_start, selection_end;
290 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); 290 omnibox_view->GetSelectionBounds(&selection_start, &selection_end);
291 EXPECT_EQ(4U, std::min(selection_start, selection_end)); 291 EXPECT_EQ(4U, std::min(selection_start, selection_end));
292 EXPECT_EQ(7U, std::max(selection_start, selection_end)); 292 EXPECT_EQ(7U, std::max(selection_start, selection_end));
293 } 293 }
294 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698