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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc

Issue 5966006: Hitting Tab should always move cursor to end of omnibox text. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build. Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index 1e796857aa3d675e6664e70bbd93cb7e0cc65640..f452757552ed799960fb5d7dba08a987a4474c06 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
@@ -944,6 +944,52 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
ASSERT_TRUE(edit_view->IsSelectAll());
}
+ void TabMoveCursorToEndTest() {
+ AutocompleteEditView* edit_view = NULL;
+ ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
+
+ edit_view->SetUserText(ASCIIToUTF16("Hello world"));
+
+ // Move cursor to the beginning.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, false, false, false));
+
+ string16::size_type start, end;
+ edit_view->GetSelectionBounds(&start, &end);
+ EXPECT_EQ(0U, start);
+ EXPECT_EQ(0U, end);
+
+ // Pressing tab should move cursor to the end.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
+
+ edit_view->GetSelectionBounds(&start, &end);
+ EXPECT_EQ(edit_view->GetText().size(), start);
+ EXPECT_EQ(edit_view->GetText().size(), end);
+
+ // The location bar should still have focus.
+ ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
+
+ // Select all text.
+ edit_view->SelectAll(true);
+ EXPECT_TRUE(edit_view->IsSelectAll());
+ edit_view->GetSelectionBounds(&start, &end);
+ EXPECT_EQ(0U, start);
+ EXPECT_EQ(edit_view->GetText().size(), end);
+
+ // Pressing tab should move cursor to the end.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
+
+ edit_view->GetSelectionBounds(&start, &end);
+ EXPECT_EQ(edit_view->GetText().size(), start);
+ EXPECT_EQ(edit_view->GetText().size(), end);
+
+ // The location bar should still have focus.
+ ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
+
+ // Pressing tab when cursor is at the end should change focus.
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
+
+ ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
+ }
};
// Test if ctrl-* accelerators are workable in omnibox.
@@ -1005,6 +1051,10 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DeleteItem) {
DeleteItemTest();
}
+IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabMoveCursorToEnd) {
+ TabMoveCursorToEndTest();
+}
+
#if defined(OS_LINUX)
// TODO(oshima): enable these tests for views-implmentation when
// these featuers are supported.
@@ -1190,4 +1240,11 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, DeleteItem) {
DeleteItemTest();
}
+// TODO(suzhe): This test is broken because of broken ViewID support when
+// enabling AutocompleteEditViewViews.
+IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
+ DISABLED_TabMoveCursorToEnd) {
+ TabMoveCursorToEndTest();
+}
+
#endif
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view.h ('k') | chrome/browser/autocomplete/autocomplete_edit_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698