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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 232023004: Ensures the autocomplete_controller input is saved and restored when changing tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken browser test. Created 6 years, 7 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
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 ASSERT_TRUE(popup_model); 1453 ASSERT_TRUE(popup_model);
1454 1454
1455 // Input something to trigger inline autocomplete. 1455 // Input something to trigger inline autocomplete.
1456 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys)); 1456 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kInlineAutocompleteTextKeys));
1457 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1457 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1458 ASSERT_TRUE(popup_model->IsOpen()); 1458 ASSERT_TRUE(popup_model->IsOpen());
1459 size_t start, end; 1459 size_t start, end;
1460 omnibox_view->GetSelectionBounds(&start, &end); 1460 omnibox_view->GetSelectionBounds(&start, &end);
1461 EXPECT_TRUE(start != end); 1461 EXPECT_TRUE(start != end);
1462 base::string16 old_autocomplete_text = 1462 base::string16 old_autocomplete_text =
1463 omnibox_view->model()->autocomplete_controller()->input().text(); 1463 omnibox_view->model()->autocomplete_controller()->input_.text();
1464 1464
1465 // Unfocus the omnibox. This should clear the text field selection and 1465 // Unfocus the omnibox. This should clear the text field selection and
1466 // close the popup, but should not run autocomplete. 1466 // close the popup, but should not run autocomplete.
1467 // Note: GTK preserves the selection when the omnibox is unfocused. 1467 // Note: GTK preserves the selection when the omnibox is unfocused.
1468 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); 1468 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
1469 ASSERT_FALSE(popup_model->IsOpen()); 1469 ASSERT_FALSE(popup_model->IsOpen());
1470 omnibox_view->GetSelectionBounds(&start, &end); 1470 omnibox_view->GetSelectionBounds(&start, &end);
1471 EXPECT_TRUE(start == end); 1471 EXPECT_TRUE(start == end);
1472 1472
1473 EXPECT_EQ(old_autocomplete_text, 1473 EXPECT_EQ(old_autocomplete_text,
1474 omnibox_view->model()->autocomplete_controller()->input().text()); 1474 omnibox_view->model()->autocomplete_controller()->input_.text());
1475 } 1475 }
1476 1476
1477 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, Paste) { 1477 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, Paste) {
1478 OmniboxView* omnibox_view = NULL; 1478 OmniboxView* omnibox_view = NULL;
1479 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 1479 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
1480 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); 1480 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model();
1481 ASSERT_TRUE(popup_model); 1481 ASSERT_TRUE(popup_model);
1482 EXPECT_FALSE(popup_model->IsOpen()); 1482 EXPECT_FALSE(popup_model->IsOpen());
1483 1483
1484 // Paste should yield the expected text and open the popup. 1484 // Paste should yield the expected text and open the popup.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 omnibox_view->Update(); 1782 omnibox_view->Update();
1783 EXPECT_EQ(url_c, omnibox_view->GetText()); 1783 EXPECT_EQ(url_c, omnibox_view->GetText());
1784 } 1784 }
1785 1785
1786 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { 1786 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) {
1787 browser()->toolbar_model()->set_url_replacement_enabled(true); 1787 browser()->toolbar_model()->set_url_replacement_enabled(true);
1788 chrome::FocusLocationBar(browser()); 1788 chrome::FocusLocationBar(browser());
1789 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); 1789 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0));
1790 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); 1790 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled());
1791 } 1791 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.cc ('k') | chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698