OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
10 #include "chrome/browser/browser_window.h" | 10 #include "chrome/browser/browser_window.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 GetSearchStateAsString(preview_)); | 104 GetSearchStateAsString(preview_)); |
105 } | 105 } |
106 | 106 |
107 void SetLocationBarText(const std::wstring& text) { | 107 void SetLocationBarText(const std::wstring& text) { |
108 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); | 108 ASSERT_NO_FATAL_FAILURE(FindLocationBar()); |
109 location_bar_->location_entry()->SetUserText(text); | 109 location_bar_->location_entry()->SetUserText(text); |
110 ui_test_utils::WaitForNotification( | 110 ui_test_utils::WaitForNotification( |
111 NotificationType::INSTANT_CONTROLLER_SHOWN); | 111 NotificationType::INSTANT_CONTROLLER_SHOWN); |
112 } | 112 } |
113 | 113 |
114 void SendKey(app::KeyboardCode key) { | 114 void SendKey(ui::KeyboardCode key) { |
115 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 115 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
116 browser(), key, false, false, false, false)); | 116 browser(), key, false, false, false, false)); |
117 } | 117 } |
118 | 118 |
119 bool GetStringFromJavascript(TabContents* tab_contents, | 119 bool GetStringFromJavascript(TabContents* tab_contents, |
120 const std::string& function, | 120 const std::string& function, |
121 std::string* result) { | 121 std::string* result) { |
122 std::string script = StringPrintf( | 122 std::string script = StringPrintf( |
123 "window.domAutomationController.send(%s)", function.c_str()); | 123 "window.domAutomationController.send(%s)", function.c_str()); |
124 return ui_test_utils::ExecuteJavaScriptAndExtractString( | 124 return ui_test_utils::ExecuteJavaScriptAndExtractString( |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 // Verify that the onsubmit event is dispatched upon pressing enter. | 473 // Verify that the onsubmit event is dispatched upon pressing enter. |
474 IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) { | 474 IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) { |
475 ASSERT_TRUE(test_server()->Start()); | 475 ASSERT_TRUE(test_server()->Start()); |
476 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 476 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
477 | 477 |
478 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 478 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
479 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 479 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
480 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 480 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
481 | 481 |
482 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); | 482 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); |
483 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_RETURN)); | 483 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN)); |
484 | 484 |
485 // Check that the preview contents have been committed. | 485 // Check that the preview contents have been committed. |
486 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); | 486 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); |
487 ASSERT_FALSE(browser()->instant()->is_active()); | 487 ASSERT_FALSE(browser()->instant()->is_active()); |
488 TabContents* contents = browser()->GetSelectedTabContents(); | 488 TabContents* contents = browser()->GetSelectedTabContents(); |
489 ASSERT_TRUE(contents); | 489 ASSERT_TRUE(contents); |
490 | 490 |
491 // Check that the value is reflected and onsubmit is called. | 491 // Check that the value is reflected and onsubmit is called. |
492 EXPECT_EQ("true 1 0 1 1 a false abc true", | 492 EXPECT_EQ("true 1 0 1 1 a false abc true", |
493 GetSearchStateAsString(preview_)); | 493 GetSearchStateAsString(preview_)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 ASSERT_TRUE(test_server()->Start()); | 527 ASSERT_TRUE(test_server()->Start()); |
528 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); | 528 ASSERT_NO_FATAL_FAILURE(SetupInstantProvider("search.html")); |
529 | 529 |
530 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 530 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
531 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); | 531 ASSERT_NO_FATAL_FAILURE(SetupLocationBar()); |
532 ASSERT_NO_FATAL_FAILURE(SetupPreview()); | 532 ASSERT_NO_FATAL_FAILURE(SetupPreview()); |
533 | 533 |
534 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); | 534 ASSERT_NO_FATAL_FAILURE(SetLocationBarText(L"abc")); |
535 | 535 |
536 // Pressing tab to convert instant suggest into inline autocomplete. | 536 // Pressing tab to convert instant suggest into inline autocomplete. |
537 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_TAB)); | 537 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB)); |
538 | 538 |
539 ASSERT_EQ(L"abcdef", location_bar_->location_entry()->GetText()); | 539 ASSERT_EQ(L"abcdef", location_bar_->location_entry()->GetText()); |
540 | 540 |
541 EXPECT_EQ("true 0 0 2 2 a false abcdef false", | 541 EXPECT_EQ("true 0 0 2 2 a false abcdef false", |
542 GetSearchStateAsString(preview_)); | 542 GetSearchStateAsString(preview_)); |
543 | 543 |
544 // Pressing tab again to accept the current instant preview. | 544 // Pressing tab again to accept the current instant preview. |
545 ASSERT_NO_FATAL_FAILURE(SendKey(app::VKEY_TAB)); | 545 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB)); |
546 | 546 |
547 // Check that the preview contents have been committed. | 547 // Check that the preview contents have been committed. |
548 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); | 548 ASSERT_FALSE(browser()->instant()->GetPreviewContents()); |
549 ASSERT_FALSE(browser()->instant()->is_active()); | 549 ASSERT_FALSE(browser()->instant()->is_active()); |
550 TabContents* contents = browser()->GetSelectedTabContents(); | 550 TabContents* contents = browser()->GetSelectedTabContents(); |
551 ASSERT_TRUE(contents); | 551 ASSERT_TRUE(contents); |
552 | 552 |
553 // Check that the value is reflected and onsubmit is called. | 553 // Check that the value is reflected and onsubmit is called. |
554 EXPECT_EQ("true 1 0 2 2 a false abcdef true", | 554 EXPECT_EQ("true 1 0 2 2 a false abcdef true", |
555 GetSearchStateAsString(preview_)); | 555 GetSearchStateAsString(preview_)); |
556 } | 556 } |
OLD | NEW |