OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "chrome/browser/browser.h" | 22 #include "chrome/browser/browser.h" |
23 #include "chrome/browser/browser_window.h" | 23 #include "chrome/browser/browser_window.h" |
24 #include "chrome/browser/history/history.h" | 24 #include "chrome/browser/history/history.h" |
25 #include "chrome/browser/location_bar.h" | 25 #include "chrome/browser/location_bar.h" |
26 #include "chrome/browser/profile.h" | 26 #include "chrome/browser/profile.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
28 #include "chrome/browser/search_engines/template_url_model.h" | 28 #include "chrome/browser/search_engines/template_url_model.h" |
29 #include "chrome/browser/tab_contents/tab_contents.h" | 29 #include "chrome/browser/tab_contents/tab_contents.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/notification_service.h" | 31 #include "chrome/common/notification_service.h" |
| 32 #include "chrome/common/url_constants.h" |
32 #include "chrome/test/in_process_browser_test.h" | 33 #include "chrome/test/in_process_browser_test.h" |
33 #include "chrome/test/ui_test_utils.h" | 34 #include "chrome/test/ui_test_utils.h" |
34 #include "net/base/mock_host_resolver.h" | 35 #include "net/base/mock_host_resolver.h" |
35 #include "views/event.h" | 36 #include "views/event.h" |
36 | 37 |
37 using base::Time; | 38 using base::Time; |
38 using base::TimeDelta; | 39 using base::TimeDelta; |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // Backspace at the beginning of the search text shall turn off | 357 // Backspace at the beginning of the search text shall turn off |
357 // the keyword mode. | 358 // the keyword mode. |
358 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false)); | 359 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_BACK, false, false, false)); |
359 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); | 360 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
360 ASSERT_EQ(std::wstring(), edit_view->model()->keyword()); | 361 ASSERT_EQ(std::wstring(), edit_view->model()->keyword()); |
361 ASSERT_EQ(std::wstring(kSearchKeyword) + std::wstring(kSearchText), | 362 ASSERT_EQ(std::wstring(kSearchKeyword) + std::wstring(kSearchText), |
362 edit_view->GetText()); | 363 edit_view->GetText()); |
363 } | 364 } |
364 | 365 |
365 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) { | 366 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, Escape) { |
366 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history/")); | 367 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); |
367 browser()->FocusLocationBar(); | 368 browser()->FocusLocationBar(); |
368 | 369 |
369 AutocompleteEditView* edit_view = NULL; | 370 AutocompleteEditView* edit_view = NULL; |
370 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 371 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
371 | 372 |
372 std::wstring old_text = edit_view->GetText(); | 373 std::wstring old_text = edit_view->GetText(); |
373 EXPECT_FALSE(old_text.empty()); | 374 EXPECT_FALSE(old_text.empty()); |
374 EXPECT_TRUE(edit_view->IsSelectAll()); | 375 EXPECT_TRUE(edit_view->IsSelectAll()); |
375 | 376 |
376 // Delete all text in omnibox. | 377 // Delete all text in omnibox. |
(...skipping 27 matching lines...) Expand all Loading... |
404 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); | 405 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); |
405 } | 406 } |
406 | 407 |
407 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) { | 408 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) { |
408 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); | 409 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); |
409 browser()->FocusLocationBar(); | 410 browser()->FocusLocationBar(); |
410 | 411 |
411 AutocompleteEditView* edit_view = NULL; | 412 AutocompleteEditView* edit_view = NULL; |
412 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 413 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
413 | 414 |
414 edit_view->SetUserText(L"chrome://history/"); | 415 edit_view->SetUserText(ASCIIToWide(chrome::kChromeUIHistoryURL)); |
415 int tab_count = browser()->tab_count(); | 416 int tab_count = browser()->tab_count(); |
416 // alt-Enter opens a new tab. | 417 // alt-Enter opens a new tab. |
417 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true)); | 418 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true)); |
418 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); | 419 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); |
419 } | 420 } |
420 | 421 |
421 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToSearch) { | 422 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToSearch) { |
422 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); | 423 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); |
423 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); | 424 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); |
424 browser()->FocusLocationBar(); | 425 browser()->FocusLocationBar(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 break; | 536 break; |
536 } | 537 } |
537 | 538 |
538 EXPECT_NE(old_text, edit_view->GetText()); | 539 EXPECT_NE(old_text, edit_view->GetText()); |
539 | 540 |
540 // Escape shall revert back to the default match item. | 541 // Escape shall revert back to the default match item. |
541 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false)); | 542 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false)); |
542 EXPECT_EQ(old_text, edit_view->GetText()); | 543 EXPECT_EQ(old_text, edit_view->GetText()); |
543 EXPECT_EQ(old_selected_line, popup_model->selected_line()); | 544 EXPECT_EQ(old_selected_line, popup_model->selected_line()); |
544 } | 545 } |
OLD | NEW |