| OLD | NEW |
| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 {"http://www.bar.com/3", "Page 3", kSearchText, 8, 8, false }, | 102 {"http://www.bar.com/3", "Page 3", kSearchText, 8, 8, false }, |
| 103 {"http://www.bar.com/4", "Page 4", kSearchText, 7, 7, false }, | 103 {"http://www.bar.com/4", "Page 4", kSearchText, 7, 7, false }, |
| 104 {"http://www.bar.com/5", "Page 5", kSearchText, 6, 6, false }, | 104 {"http://www.bar.com/5", "Page 5", kSearchText, 6, 6, false }, |
| 105 {"http://www.bar.com/6", "Page 6", kSearchText, 5, 5, false }, | 105 {"http://www.bar.com/6", "Page 6", kSearchText, 5, 5, false }, |
| 106 {"http://www.bar.com/7", "Page 7", kSearchText, 4, 4, false }, | 106 {"http://www.bar.com/7", "Page 7", kSearchText, 4, 4, false }, |
| 107 {"http://www.bar.com/8", "Page 8", kSearchText, 3, 3, false }, | 107 {"http://www.bar.com/8", "Page 8", kSearchText, 3, 3, false }, |
| 108 {"http://www.bar.com/9", "Page 9", kSearchText, 2, 2, false }, | 108 {"http://www.bar.com/9", "Page 9", kSearchText, 2, 2, false }, |
| 109 | 109 |
| 110 // To trigger inline autocomplete. | 110 // To trigger inline autocomplete. |
| 111 {"http://www.def.com", "Page def", kSearchText, 10000, 10000, true }, | 111 {"http://www.def.com", "Page def", kSearchText, 10000, 10000, true }, |
| 112 {"http://bar/", "Bar", kSearchText, 1, 0, false }, |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 #if defined(OS_LINUX) | 115 #if defined(OS_LINUX) |
| 115 // Returns the text stored in the PRIMARY clipboard. | 116 // Returns the text stored in the PRIMARY clipboard. |
| 116 std::string GetPrimarySelectionText() { | 117 std::string GetPrimarySelectionText() { |
| 117 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 118 GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
| 118 DCHECK(clipboard); | 119 DCHECK(clipboard); |
| 119 | 120 |
| 120 gchar* selection_text = gtk_clipboard_wait_for_text(clipboard); | 121 gchar* selection_text = gtk_clipboard_wait_for_text(clipboard); |
| 121 std::string result(selection_text ? selection_text : ""); | 122 std::string result(selection_text ? selection_text : ""); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); | 922 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); |
| 922 ASSERT_TRUE(popup_model); | 923 ASSERT_TRUE(popup_model); |
| 923 | 924 |
| 924 string16 old_text = omnibox_view->GetText(); | 925 string16 old_text = omnibox_view->GetText(); |
| 925 | 926 |
| 926 // Input something that can match history items. | 927 // Input something that can match history items. |
| 927 omnibox_view->SetUserText(ASCIIToUTF16("bar")); | 928 omnibox_view->SetUserText(ASCIIToUTF16("bar")); |
| 928 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 929 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 929 ASSERT_TRUE(popup_model->IsOpen()); | 930 ASSERT_TRUE(popup_model->IsOpen()); |
| 930 | 931 |
| 932 // Verify that we got something more than just what we 'typed'. |
| 933 EXPECT_EQ(ASCIIToUTF16("bar.com/1"), omnibox_view->GetText()); |
| 934 |
| 931 // Delete the inline autocomplete part. | 935 // Delete the inline autocomplete part. |
| 932 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); | 936 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_DELETE, 0)); |
| 933 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 937 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 934 ASSERT_TRUE(popup_model->IsOpen()); | 938 ASSERT_TRUE(popup_model->IsOpen()); |
| 935 ASSERT_GE(popup_model->result().size(), 3U); | 939 ASSERT_GE(popup_model->result().size(), 3U); |
| 936 | 940 |
| 937 string16 user_text = omnibox_view->GetText(); | 941 string16 user_text = omnibox_view->GetText(); |
| 938 ASSERT_EQ(ASCIIToUTF16("bar"), user_text); | 942 ASSERT_EQ(ASCIIToUTF16("bar"), user_text); |
| 939 omnibox_view->SelectAll(true); | 943 omnibox_view->SelectAll(true); |
| 940 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 944 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 omnibox_view->model()->OnUpOrDownKeyPressed(1); | 981 omnibox_view->model()->OnUpOrDownKeyPressed(1); |
| 978 ASSERT_EQ(default_line + 1, popup_model->selected_line()); | 982 ASSERT_EQ(default_line + 1, popup_model->selected_line()); |
| 979 omnibox_view->model()->OnUpOrDownKeyPressed(-1); | 983 omnibox_view->model()->OnUpOrDownKeyPressed(-1); |
| 980 ASSERT_EQ(default_line, popup_model->selected_line()); | 984 ASSERT_EQ(default_line, popup_model->selected_line()); |
| 981 | 985 |
| 982 selected_text = popup_model->result().match_at(default_line).fill_into_edit; | 986 selected_text = popup_model->result().match_at(default_line).fill_into_edit; |
| 983 // New temporary text is shown. | 987 // New temporary text is shown. |
| 984 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 988 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 985 ASSERT_FALSE(omnibox_view->IsSelectAll()); | 989 ASSERT_FALSE(omnibox_view->IsSelectAll()); |
| 986 | 990 |
| 991 #if 0 |
| 992 // TODO(mrossetti): http://crbug.com/82335 |
| 987 // Delete the default item. | 993 // Delete the default item. |
| 988 popup_model->TryDeletingCurrentItem(); | 994 popup_model->TryDeletingCurrentItem(); |
| 989 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 995 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| 990 // The selected line shouldn't be changed, but the default item should have | 996 // The selected line shouldn't be changed, but the default item should have |
| 991 // been changed. | 997 // been changed. |
| 992 ASSERT_EQ(default_line, popup_model->selected_line()); | 998 ASSERT_EQ(default_line, popup_model->selected_line()); |
| 993 // Make sure the item is really deleted. | 999 // Make sure the item is really deleted. |
| 994 ASSERT_NE(selected_text, | 1000 EXPECT_NE(selected_text, |
| 995 popup_model->result().match_at(default_line).fill_into_edit); | 1001 popup_model->result().match_at(default_line).fill_into_edit); |
| 996 selected_text = | 1002 selected_text = |
| 997 popup_model->result().match_at(default_line).fill_into_edit; | 1003 popup_model->result().match_at(default_line).fill_into_edit; |
| 998 // New temporary text is shown. | 1004 // New temporary text is shown. |
| 999 ASSERT_EQ(selected_text, omnibox_view->GetText()); | 1005 ASSERT_EQ(selected_text, omnibox_view->GetText()); |
| 1006 #endif |
| 1000 | 1007 |
| 1001 // As the current selected item is the new default item, pressing Escape key | 1008 // As the current selected item is the new default item, pressing Escape key |
| 1002 // should revert all directly. | 1009 // should revert all directly. |
| 1003 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); | 1010 ASSERT_TRUE(omnibox_view->model()->OnEscapeKeyPressed()); |
| 1004 ASSERT_EQ(old_text, omnibox_view->GetText()); | 1011 ASSERT_EQ(old_text, omnibox_view->GetText()); |
| 1005 ASSERT_TRUE(omnibox_view->IsSelectAll()); | 1012 ASSERT_TRUE(omnibox_view->IsSelectAll()); |
| 1006 } | 1013 } |
| 1007 | 1014 |
| 1008 void TabMoveCursorToEndTest() { | 1015 void TabMoveCursorToEndTest() { |
| 1009 OmniboxView* omnibox_view = NULL; | 1016 OmniboxView* omnibox_view = NULL; |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 PersistKeywordModeOnTabSwitch) { | 1393 PersistKeywordModeOnTabSwitch) { |
| 1387 PersistKeywordModeOnTabSwitch(); | 1394 PersistKeywordModeOnTabSwitch(); |
| 1388 } | 1395 } |
| 1389 | 1396 |
| 1390 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, | 1397 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, |
| 1391 CtrlKeyPressedWithInlineAutocompleteTest) { | 1398 CtrlKeyPressedWithInlineAutocompleteTest) { |
| 1392 CtrlKeyPressedWithInlineAutocompleteTest(); | 1399 CtrlKeyPressedWithInlineAutocompleteTest(); |
| 1393 } | 1400 } |
| 1394 | 1401 |
| 1395 #endif | 1402 #endif |
| OLD | NEW |