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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 // New temporary text is shown. 937 // New temporary text is shown.
938 ASSERT_EQ(selected_text, edit_view->GetText()); 938 ASSERT_EQ(selected_text, edit_view->GetText());
939 939
940 // As the current selected item is the new default item, pressing Escape key 940 // As the current selected item is the new default item, pressing Escape key
941 // should revert all directly. 941 // should revert all directly.
942 ASSERT_TRUE(edit_view->model()->OnEscapeKeyPressed()); 942 ASSERT_TRUE(edit_view->model()->OnEscapeKeyPressed());
943 ASSERT_EQ(old_text, edit_view->GetText()); 943 ASSERT_EQ(old_text, edit_view->GetText());
944 ASSERT_TRUE(edit_view->IsSelectAll()); 944 ASSERT_TRUE(edit_view->IsSelectAll());
945 } 945 }
946 946
947 void TabMoveCursorToEndTest() {
948 AutocompleteEditView* edit_view = NULL;
949 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
950
951 edit_view->SetUserText(ASCIIToUTF16("Hello world"));
952
953 // Move cursor to the beginning.
954 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, false, false, false));
955
956 string16::size_type start, end;
957 edit_view->GetSelectionBounds(&start, &end);
958 EXPECT_EQ(0U, start);
959 EXPECT_EQ(0U, end);
960
961 // Pressing tab should move cursor to the end.
962 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
963
964 edit_view->GetSelectionBounds(&start, &end);
965 EXPECT_EQ(edit_view->GetText().size(), start);
966 EXPECT_EQ(edit_view->GetText().size(), end);
967
968 // The location bar should still have focus.
969 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
970
971 // Select all text.
972 edit_view->SelectAll(true);
973 EXPECT_TRUE(edit_view->IsSelectAll());
974 edit_view->GetSelectionBounds(&start, &end);
975 EXPECT_EQ(0U, start);
976 EXPECT_EQ(edit_view->GetText().size(), end);
977
978 // Pressing tab should move cursor to the end.
979 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
980
981 edit_view->GetSelectionBounds(&start, &end);
982 EXPECT_EQ(edit_view->GetText().size(), start);
983 EXPECT_EQ(edit_view->GetText().size(), end);
984
985 // The location bar should still have focus.
986 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
987
988 // Pressing tab when cursor is at the end should change focus.
989 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, false, false, false));
990
991 ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
992 }
947 }; 993 };
948 994
949 // Test if ctrl-* accelerators are workable in omnibox. 995 // Test if ctrl-* accelerators are workable in omnibox.
950 // See http://crbug.com/19193: omnibox blocks ctrl-* commands 996 // See http://crbug.com/19193: omnibox blocks ctrl-* commands
951 // 997 //
952 // Flaky on interactive tests (dbg), http://crbug.com/69433 998 // Flaky on interactive tests (dbg), http://crbug.com/69433
953 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) { 999 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) {
954 BrowserAcceleratorsTest(); 1000 BrowserAcceleratorsTest();
955 } 1001 }
956 1002
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 1044 }
999 1045
1000 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) { 1046 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) {
1001 NonSubstitutingKeywordTest(); 1047 NonSubstitutingKeywordTest();
1002 } 1048 }
1003 1049
1004 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DeleteItem) { 1050 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DeleteItem) {
1005 DeleteItemTest(); 1051 DeleteItemTest();
1006 } 1052 }
1007 1053
1054 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabMoveCursorToEnd) {
1055 TabMoveCursorToEndTest();
1056 }
1057
1008 #if defined(OS_LINUX) 1058 #if defined(OS_LINUX)
1009 // TODO(oshima): enable these tests for views-implmentation when 1059 // TODO(oshima): enable these tests for views-implmentation when
1010 // these featuers are supported. 1060 // these featuers are supported.
1011 1061
1012 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) { 1062 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) {
1013 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); 1063 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL));
1014 browser()->FocusLocationBar(); 1064 browser()->FocusLocationBar();
1015 1065
1016 AutocompleteEditView* edit_view = NULL; 1066 AutocompleteEditView* edit_view = NULL;
1017 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 1067 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1233
1184 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, 1234 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
1185 NonSubstitutingKeywordTest) { 1235 NonSubstitutingKeywordTest) {
1186 NonSubstitutingKeywordTest(); 1236 NonSubstitutingKeywordTest();
1187 } 1237 }
1188 1238
1189 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, DeleteItem) { 1239 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, DeleteItem) {
1190 DeleteItemTest(); 1240 DeleteItemTest();
1191 } 1241 }
1192 1242
1243 // TODO(suzhe): This test is broken because of broken ViewID support when
1244 // enabling AutocompleteEditViewViews.
1245 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
1246 DISABLED_TabMoveCursorToEnd) {
1247 TabMoveCursorToEndTest();
1248 }
1249
1193 #endif 1250 #endif
OLDNEW
« 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