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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 8 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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 // New temporary text is shown. 997 // New temporary text is shown.
998 ASSERT_EQ(selected_text, edit_view->GetText()); 998 ASSERT_EQ(selected_text, edit_view->GetText());
999 999
1000 // As the current selected item is the new default item, pressing Escape key 1000 // As the current selected item is the new default item, pressing Escape key
1001 // should revert all directly. 1001 // should revert all directly.
1002 ASSERT_TRUE(edit_view->model()->OnEscapeKeyPressed()); 1002 ASSERT_TRUE(edit_view->model()->OnEscapeKeyPressed());
1003 ASSERT_EQ(old_text, edit_view->GetText()); 1003 ASSERT_EQ(old_text, edit_view->GetText());
1004 ASSERT_TRUE(edit_view->IsSelectAll()); 1004 ASSERT_TRUE(edit_view->IsSelectAll());
1005 } 1005 }
1006 1006
1007 void TabMoveCursorToEndTest() { 1007 void TabAcceptKeyword() {
1008 AutocompleteEditView* edit_view = NULL; 1008 AutocompleteEditView* edit_view = NULL;
1009 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 1009 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
1010 1010
1011 edit_view->SetUserText(ASCIIToUTF16("Hello world")); 1011 string16 text = UTF8ToUTF16(kSearchKeyword);
1012 1012
1013 // Move cursor to the beginning. 1013 // Trigger keyword hint mode.
1014 #if defined(OS_MACOSX) 1014 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
1015 // Home doesn't work on Mac trybot. 1015 ASSERT_TRUE(edit_view->model()->is_keyword_hint());
1016 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, ui::EF_CONTROL_DOWN)); 1016 ASSERT_EQ(text, edit_view->model()->keyword());
1017 #else 1017 ASSERT_EQ(text, edit_view->GetText());
1018 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_HOME, 0));
1019 #endif
1020 1018
1021 string16::size_type start, end; 1019 // Trigger keyword mode by tab.
1022 edit_view->GetSelectionBounds(&start, &end); 1020 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1023 EXPECT_EQ(0U, start); 1021 ASSERT_FALSE(edit_view->model()->is_keyword_hint());
1024 EXPECT_EQ(0U, end); 1022 ASSERT_EQ(text, edit_view->model()->keyword());
1023 ASSERT_TRUE(edit_view->GetText().empty());
1025 1024
1026 // Pressing tab should move cursor to the end. 1025 // Revert to keyword hint mode.
1027 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0)); 1026 edit_view->model()->ClearKeyword(string16());
1028 1027 ASSERT_TRUE(edit_view->model()->is_keyword_hint());
1029 edit_view->GetSelectionBounds(&start, &end); 1028 ASSERT_EQ(text, edit_view->model()->keyword());
1030 EXPECT_EQ(edit_view->GetText().size(), start); 1029 ASSERT_EQ(text, edit_view->GetText());
1031 EXPECT_EQ(edit_view->GetText().size(), end);
1032
1033 // The location bar should still have focus.
1034 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
1035
1036 // Select all text.
1037 edit_view->SelectAll(true);
1038 EXPECT_TRUE(edit_view->IsSelectAll());
1039 edit_view->GetSelectionBounds(&start, &end);
1040 EXPECT_EQ(0U, start);
1041 EXPECT_EQ(edit_view->GetText().size(), end);
1042
1043 // Pressing tab should move cursor to the end.
1044 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1045
1046 edit_view->GetSelectionBounds(&start, &end);
1047 EXPECT_EQ(edit_view->GetText().size(), start);
1048 EXPECT_EQ(edit_view->GetText().size(), end);
1049
1050 // The location bar should still have focus.
1051 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
1052
1053 // Pressing tab when cursor is at the end should change focus.
1054 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_TAB, 0));
1055
1056 ASSERT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR));
1057 } 1030 }
1058 1031
1059 void PersistKeywordModeOnTabSwitch() { 1032 void PersistKeywordModeOnTabSwitch() {
1060 AutocompleteEditView* edit_view = NULL; 1033 AutocompleteEditView* edit_view = NULL;
1061 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 1034 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
1062 1035
1063 // Trigger keyword hint mode. 1036 // Trigger keyword hint mode.
1064 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); 1037 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
1065 ASSERT_TRUE(edit_view->model()->is_keyword_hint()); 1038 ASSERT_TRUE(edit_view->model()->is_keyword_hint());
1066 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(edit_view->model()->keyword())); 1039 ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(edit_view->model()->keyword()));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 } 1133 }
1161 1134
1162 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) { 1135 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) {
1163 NonSubstitutingKeywordTest(); 1136 NonSubstitutingKeywordTest();
1164 } 1137 }
1165 1138
1166 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DeleteItem) { 1139 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, DeleteItem) {
1167 DeleteItemTest(); 1140 DeleteItemTest();
1168 } 1141 }
1169 1142
1170 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabMoveCursorToEnd) { 1143 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, TabAcceptKeyword) {
1171 TabMoveCursorToEndTest(); 1144 TabAcceptKeyword();
1172 } 1145 }
1173 1146
1174 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, 1147 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest,
1175 PersistKeywordModeOnTabSwitch) { 1148 PersistKeywordModeOnTabSwitch) {
1176 PersistKeywordModeOnTabSwitch(); 1149 PersistKeywordModeOnTabSwitch();
1177 } 1150 }
1178 1151
1179 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, 1152 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest,
1180 CtrlKeyPressedWithInlineAutocompleteTest) { 1153 CtrlKeyPressedWithInlineAutocompleteTest) {
1181 CtrlKeyPressedWithInlineAutocompleteTest(); 1154 CtrlKeyPressedWithInlineAutocompleteTest();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 } 1338 }
1366 1339
1367 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, DeleteItem) { 1340 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, DeleteItem) {
1368 DeleteItemTest(); 1341 DeleteItemTest();
1369 } 1342 }
1370 1343
1371 // TODO(suzhe): This test is broken because of broken ViewID support when 1344 // TODO(suzhe): This test is broken because of broken ViewID support when
1372 // enabling AutocompleteEditViewViews. 1345 // enabling AutocompleteEditViewViews.
1373 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, 1346 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
1374 DISABLED_TabMoveCursorToEnd) { 1347 DISABLED_TabMoveCursorToEnd) {
1375 TabMoveCursorToEndTest(); 1348 TabAcceptKeyword();
1376 } 1349 }
1377 1350
1378 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, 1351 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
1379 PersistKeywordModeOnTabSwitch) { 1352 PersistKeywordModeOnTabSwitch) {
1380 PersistKeywordModeOnTabSwitch(); 1353 PersistKeywordModeOnTabSwitch();
1381 } 1354 }
1382 1355
1383 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, 1356 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest,
1384 CtrlKeyPressedWithInlineAutocompleteTest) { 1357 CtrlKeyPressedWithInlineAutocompleteTest) {
1385 CtrlKeyPressedWithInlineAutocompleteTest(); 1358 CtrlKeyPressedWithInlineAutocompleteTest();
1386 } 1359 }
1387 1360
1388 #endif 1361 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698