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

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

Issue 242047: Try to fix AutocompleteEditViewTest failures on buildbot (issue 23213).... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/keyboard_codes.h" 8 #include "base/keyboard_codes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bookmark_model->SetURLStarred(url, std::wstring(), true); 236 bookmark_model->SetURLStarred(url, std::wstring(), true);
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 void SetupHostResolver() { 241 void SetupHostResolver() {
242 for (size_t i = 0; i < arraysize(kBlockedHostnames); ++i) 242 for (size_t i = 0; i < arraysize(kBlockedHostnames); ++i)
243 host_resolver()->AddSimulatedFailure(kBlockedHostnames[i]); 243 host_resolver()->AddSimulatedFailure(kBlockedHostnames[i]);
244 } 244 }
245 245
246 void SetupComponents() {
247 ASSERT_NO_FATAL_FAILURE(SetupHostResolver());
248 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
249 ASSERT_NO_FATAL_FAILURE(SetupHistory());
250 }
251
246 virtual void Observe(NotificationType type, 252 virtual void Observe(NotificationType type,
247 const NotificationSource& source, 253 const NotificationSource& source,
248 const NotificationDetails& details) { 254 const NotificationDetails& details) {
249 ASSERT_TRUE(MessageLoopForUI::current()->IsNested()); 255 ASSERT_TRUE(MessageLoopForUI::current()->IsNested());
250 switch (type.value) { 256 switch (type.value) {
251 case NotificationType::TAB_PARENTED: 257 case NotificationType::TAB_PARENTED:
252 case NotificationType::TAB_CLOSED: 258 case NotificationType::TAB_CLOSED:
253 case NotificationType::TEMPLATE_URL_MODEL_LOADED: 259 case NotificationType::TEMPLATE_URL_MODEL_LOADED:
254 case NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED: 260 case NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED:
255 case NotificationType::HISTORY_LOADED: 261 case NotificationType::HISTORY_LOADED:
(...skipping 15 matching lines...) Expand all
271 new MessageLoop::QuitTask(), 277 new MessageLoop::QuitTask(),
272 2000); 278 2000);
273 ui_test_utils::RunMessageLoop(); 279 ui_test_utils::RunMessageLoop();
274 } 280 }
275 #endif 281 #endif
276 }; 282 };
277 283
278 // Test if ctrl-* accelerators are workable in omnibox. 284 // Test if ctrl-* accelerators are workable in omnibox.
279 // See http://crbug.com/19193: omnibox blocks ctrl-* commands 285 // See http://crbug.com/19193: omnibox blocks ctrl-* commands
280 // This test is disabled. See bug 23213. 286 // This test is disabled. See bug 23213.
281 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DISABLED_BrowserAccelerators) { 287 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BrowserAccelerators) {
288 ASSERT_NO_FATAL_FAILURE(SetupComponents());
282 browser()->FocusLocationBar(); 289 browser()->FocusLocationBar();
283 AutocompleteEditView* edit_view = NULL; 290 AutocompleteEditView* edit_view = NULL;
284 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 291 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
285 292
286 int tab_count = browser()->tab_count(); 293 int tab_count = browser()->tab_count();
287 294
288 // Create a new Tab. 295 // Create a new Tab.
289 browser()->NewTab(); 296 browser()->NewTab();
290 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); 297 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1));
291 298
(...skipping 14 matching lines...) Expand all
306 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count)); 313 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count));
307 314
308 // Try ctrl-l to focus location bar. 315 // Try ctrl-l to focus location bar.
309 edit_view->SetUserText(L"Hello world"); 316 edit_view->SetUserText(L"Hello world");
310 EXPECT_FALSE(edit_view->IsSelectAll()); 317 EXPECT_FALSE(edit_view->IsSelectAll());
311 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_L, true, false, false)); 318 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_L, true, false, false));
312 EXPECT_TRUE(edit_view->IsSelectAll()); 319 EXPECT_TRUE(edit_view->IsSelectAll());
313 } 320 }
314 321
315 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BackspaceInKeywordMode) { 322 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BackspaceInKeywordMode) {
316 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 323 ASSERT_NO_FATAL_FAILURE(SetupComponents());
317 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
318 browser()->FocusLocationBar(); 324 browser()->FocusLocationBar();
319 325
320 AutocompleteEditView* edit_view = NULL; 326 AutocompleteEditView* edit_view = NULL;
321 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 327 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
322 328
323 // Trigger keyword hint mode. 329 // Trigger keyword hint mode.
324 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); 330 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
325 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); 331 ASSERT_TRUE(edit_view->model()->is_keyword_hint());
326 ASSERT_EQ(std::wstring(kSearchKeyword), edit_view->model()->keyword()); 332 ASSERT_EQ(std::wstring(kSearchKeyword), edit_view->model()->keyword());
327 333
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // Backspace at the beginning of the search text shall turn off 365 // Backspace at the beginning of the search text shall turn off
360 // the keyword mode. 366 // the keyword mode.
361 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false)); 367 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false));
362 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); 368 ASSERT_FALSE(edit_view->model()->is_keyword_hint());
363 ASSERT_EQ(std::wstring(), edit_view->model()->keyword()); 369 ASSERT_EQ(std::wstring(), edit_view->model()->keyword());
364 ASSERT_EQ(std::wstring(kSearchKeyword) + std::wstring(kSearchText), 370 ASSERT_EQ(std::wstring(kSearchKeyword) + std::wstring(kSearchText),
365 edit_view->GetText()); 371 edit_view->GetText());
366 } 372 }
367 373
368 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) { 374 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) {
375 ASSERT_NO_FATAL_FAILURE(SetupComponents());
369 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); 376 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL));
370 browser()->FocusLocationBar(); 377 browser()->FocusLocationBar();
371 378
372 AutocompleteEditView* edit_view = NULL; 379 AutocompleteEditView* edit_view = NULL;
373 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 380 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
374 381
375 std::wstring old_text = edit_view->GetText(); 382 std::wstring old_text = edit_view->GetText();
376 EXPECT_FALSE(old_text.empty()); 383 EXPECT_FALSE(old_text.empty());
377 EXPECT_TRUE(edit_view->IsSelectAll()); 384 EXPECT_TRUE(edit_view->IsSelectAll());
378 385
379 // Delete all text in omnibox. 386 // Delete all text in omnibox.
380 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false)); 387 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false));
381 EXPECT_TRUE(edit_view->GetText().empty()); 388 EXPECT_TRUE(edit_view->GetText().empty());
382 389
383 // Escape shall revert the text in omnibox. 390 // Escape shall revert the text in omnibox.
384 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false)); 391 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false));
385 EXPECT_EQ(old_text, edit_view->GetText()); 392 EXPECT_EQ(old_text, edit_view->GetText());
386 EXPECT_TRUE(edit_view->IsSelectAll()); 393 EXPECT_TRUE(edit_view->IsSelectAll());
387 } 394 }
388 395
389 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DesiredTLD) { 396 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DesiredTLD) {
390 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 397 ASSERT_NO_FATAL_FAILURE(SetupComponents());
391 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
392 browser()->FocusLocationBar(); 398 browser()->FocusLocationBar();
393 399
394 AutocompleteEditView* edit_view = NULL; 400 AutocompleteEditView* edit_view = NULL;
395 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 401 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
396 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); 402 AutocompletePopupModel* popup_model = edit_view->model()->popup_model();
397 ASSERT_TRUE(popup_model); 403 ASSERT_TRUE(popup_model);
398 404
399 // Test ctrl-Enter. 405 // Test ctrl-Enter.
400 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); 406 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys));
401 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 407 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
402 ASSERT_TRUE(popup_model->IsOpen()); 408 ASSERT_TRUE(popup_model->IsOpen());
403 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened. 409 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened.
404 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, true, false, false)); 410 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, true, false, false));
405 411
406 GURL url = browser()->GetSelectedTabContents()->GetURL(); 412 GURL url = browser()->GetSelectedTabContents()->GetURL();
407 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); 413 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str());
408 } 414 }
409 415
410 // This test is disabled. See bug 23213. 416 // This test is disabled. See bug 23213.
411 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DISABLED_AltEnter) { 417 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) {
412 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 418 ASSERT_NO_FATAL_FAILURE(SetupComponents());
413 browser()->FocusLocationBar(); 419 browser()->FocusLocationBar();
414 420
415 AutocompleteEditView* edit_view = NULL; 421 AutocompleteEditView* edit_view = NULL;
416 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 422 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
417 423
418 edit_view->SetUserText(ASCIIToWide(chrome::kChromeUIHistoryURL)); 424 edit_view->SetUserText(ASCIIToWide(chrome::kChromeUIHistoryURL));
419 int tab_count = browser()->tab_count(); 425 int tab_count = browser()->tab_count();
420 // alt-Enter opens a new tab. 426 // alt-Enter opens a new tab.
421 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true)); 427 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true));
422 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); 428 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 466
461 // Open the default match. 467 // Open the default match.
462 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false)); 468 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false));
463 url = browser()->GetSelectedTabContents()->GetURL(); 469 url = browser()->GetSelectedTabContents()->GetURL();
464 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); 470 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str());
465 } 471 }
466 472
467 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for 473 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for
468 // "See recent pages in history" 474 // "See recent pages in history"
469 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) { 475 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) {
470 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 476 ASSERT_NO_FATAL_FAILURE(SetupComponents());
471 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
472 ASSERT_NO_FATAL_FAILURE(SetupHistory());
473
474 browser()->FocusLocationBar(); 477 browser()->FocusLocationBar();
475 478
476 AutocompleteEditView* edit_view = NULL; 479 AutocompleteEditView* edit_view = NULL;
477 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 480 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
478 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); 481 AutocompletePopupModel* popup_model = edit_view->model()->popup_model();
479 ASSERT_TRUE(popup_model); 482 ASSERT_TRUE(popup_model);
480 483
481 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 484 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
482 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 485 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
483 ASSERT_TRUE(popup_model->IsOpen()); 486 ASSERT_TRUE(popup_model->IsOpen());
(...skipping 16 matching lines...) Expand all
500 ASSERT_EQ(AutocompleteMatch::OPEN_HISTORY_PAGE, 503 ASSERT_EQ(AutocompleteMatch::OPEN_HISTORY_PAGE,
501 popup_model->result().match_at(popup_model->selected_line()).type); 504 popup_model->result().match_at(popup_model->selected_line()).type);
502 505
503 // Open the history page item. 506 // Open the history page item.
504 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false)); 507 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false));
505 GURL url = browser()->GetSelectedTabContents()->GetURL(); 508 GURL url = browser()->GetSelectedTabContents()->GetURL();
506 EXPECT_STREQ(kHistoryPageURL, url.spec().c_str()); 509 EXPECT_STREQ(kHistoryPageURL, url.spec().c_str());
507 } 510 }
508 511
509 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EscapeToDefaultMatch) { 512 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EscapeToDefaultMatch) {
510 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 513 ASSERT_NO_FATAL_FAILURE(SetupComponents());
511 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
512 ASSERT_NO_FATAL_FAILURE(SetupHistory());
513 browser()->FocusLocationBar(); 514 browser()->FocusLocationBar();
514 515
515 AutocompleteEditView* edit_view = NULL; 516 AutocompleteEditView* edit_view = NULL;
516 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 517 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
517 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); 518 AutocompletePopupModel* popup_model = edit_view->model()->popup_model();
518 ASSERT_TRUE(popup_model); 519 ASSERT_TRUE(popup_model);
519 520
520 // Input something to trigger inline autocomplete. 521 // Input something to trigger inline autocomplete.
521 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 522 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
522 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 523 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
(...skipping 16 matching lines...) Expand all
539 break; 540 break;
540 } 541 }
541 542
542 EXPECT_NE(old_text, edit_view->GetText()); 543 EXPECT_NE(old_text, edit_view->GetText());
543 544
544 // Escape shall revert back to the default match item. 545 // Escape shall revert back to the default match item.
545 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false)); 546 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false));
546 EXPECT_EQ(old_text, edit_view->GetText()); 547 EXPECT_EQ(old_text, edit_view->GetText());
547 EXPECT_EQ(old_selected_line, popup_model->selected_line()); 548 EXPECT_EQ(old_selected_line, popup_model->selected_line());
548 } 549 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698