Chromium Code Reviews| 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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); | 784 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 785 ASSERT_TRUE(edit_view->model()->keyword().empty()); | 785 ASSERT_TRUE(edit_view->model()->keyword().empty()); |
| 786 | 786 |
| 787 // Trigger keyword mode by space. | 787 // Trigger keyword mode by space. |
| 788 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); | 788 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, false, false, false)); |
| 789 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); | 789 ASSERT_FALSE(edit_view->model()->is_keyword_hint()); |
| 790 ASSERT_EQ(text, edit_view->model()->keyword()); | 790 ASSERT_EQ(text, edit_view->model()->keyword()); |
| 791 ASSERT_TRUE(edit_view->GetText().empty()); | 791 ASSERT_TRUE(edit_view->GetText().empty()); |
| 792 } | 792 } |
| 793 | 793 |
| 794 // http://crbug.com/70807 | |
|
Peter Kasting
2011/01/26 00:58:07
Nit: Probably no need for this comment, other test
| |
| 795 void NonSubstitutingKeywordTest() { | |
| 796 AutocompleteEditView* edit_view = NULL; | |
| 797 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | |
| 798 AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); | |
| 799 ASSERT_TRUE(popup_model); | |
| 800 | |
| 801 TemplateURLModel* template_url_model = | |
| 802 browser()->profile()->GetTemplateURLModel(); | |
| 803 | |
| 804 // Add a non-default substituting keyword. | |
| 805 TemplateURL* template_url = new TemplateURL(); | |
| 806 template_url->SetURL("http://abc.com/{searchTerms}", 0, 0); | |
| 807 template_url->set_keyword(UTF8ToUTF16(kSearchText)); | |
| 808 template_url->set_short_name(UTF8ToUTF16("Search abc")); | |
| 809 template_url_model->Add(template_url); | |
| 810 | |
| 811 edit_view->SetUserText(string16()); | |
| 812 | |
| 813 // non-default substituting keyword shouldn't be matched by default. | |
|
Peter Kasting
2011/01/26 00:58:07
Nit: non -> Non
| |
| 814 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | |
| 815 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
| 816 ASSERT_TRUE(popup_model->IsOpen()); | |
| 817 | |
| 818 // Check if the default match result is Search Primary Provider. | |
| 819 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, | |
| 820 popup_model->result().default_match()->type); | |
| 821 ASSERT_EQ(kSearchTextURL, | |
| 822 popup_model->result().default_match()->destination_url.spec()); | |
| 823 | |
| 824 edit_view->SetUserText(string16()); | |
| 825 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
| 826 ASSERT_FALSE(popup_model->IsOpen()); | |
| 827 | |
| 828 // Try a non-substituting keyword. | |
| 829 template_url_model->Remove(template_url); | |
| 830 template_url = new TemplateURL(); | |
| 831 template_url->SetURL("http://abc.com/", 0, 0); | |
| 832 template_url->set_keyword(UTF8ToUTF16(kSearchText)); | |
| 833 template_url->set_short_name(UTF8ToUTF16("abc")); | |
| 834 template_url_model->Add(template_url); | |
| 835 | |
| 836 // We always allow exact match non-substituting keywords. | |
|
Peter Kasting
2011/01/26 00:58:07
Nit: match -> matches for
| |
| 837 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); | |
| 838 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
| 839 ASSERT_TRUE(popup_model->IsOpen()); | |
| 840 ASSERT_EQ(AutocompleteMatch::HISTORY_KEYWORD, | |
| 841 popup_model->result().default_match()->type); | |
| 842 ASSERT_EQ("http://abc.com/", | |
| 843 popup_model->result().default_match()->destination_url.spec()); | |
| 844 } | |
| 794 }; | 845 }; |
| 795 | 846 |
| 796 // Test if ctrl-* accelerators are workable in omnibox. | 847 // Test if ctrl-* accelerators are workable in omnibox. |
| 797 // See http://crbug.com/19193: omnibox blocks ctrl-* commands | 848 // See http://crbug.com/19193: omnibox blocks ctrl-* commands |
| 798 // | 849 // |
| 799 // Flaky on interactive tests (dbg), http://crbug.com/69433 | 850 // Flaky on interactive tests (dbg), http://crbug.com/69433 |
| 800 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) { | 851 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, FLAKY_BrowserAccelerators) { |
| 801 BrowserAcceleratorsTest(); | 852 BrowserAcceleratorsTest(); |
| 802 } | 853 } |
| 803 | 854 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 } | 888 } |
| 838 | 889 |
| 839 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BasicTextOperations) { | 890 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, BasicTextOperations) { |
| 840 BasicTextOperationsTest(); | 891 BasicTextOperationsTest(); |
| 841 } | 892 } |
| 842 | 893 |
| 843 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AcceptKeywordBySpace) { | 894 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AcceptKeywordBySpace) { |
| 844 AcceptKeywordBySpaceTest(); | 895 AcceptKeywordBySpaceTest(); |
| 845 } | 896 } |
| 846 | 897 |
| 898 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) { | |
| 899 NonSubstitutingKeywordTest(); | |
| 900 } | |
| 901 | |
| 847 #if defined(OS_LINUX) | 902 #if defined(OS_LINUX) |
| 848 // TODO(oshima): enable these tests for views-implmentation when | 903 // TODO(oshima): enable these tests for views-implmentation when |
| 849 // these featuers are supported. | 904 // these featuers are supported. |
| 850 | 905 |
| 851 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) { | 906 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, UndoRedoLinux) { |
| 852 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); | 907 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kAboutBlankURL)); |
| 853 browser()->FocusLocationBar(); | 908 browser()->FocusLocationBar(); |
| 854 | 909 |
| 855 AutocompleteEditView* edit_view = NULL; | 910 AutocompleteEditView* edit_view = NULL; |
| 856 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); | 911 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1013 } | 1068 } |
| 1014 | 1069 |
| 1015 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, BasicTextOperations) { | 1070 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, BasicTextOperations) { |
| 1016 BasicTextOperationsTest(); | 1071 BasicTextOperationsTest(); |
| 1017 } | 1072 } |
| 1018 | 1073 |
| 1019 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, AcceptKeywordBySpace) { | 1074 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, AcceptKeywordBySpace) { |
| 1020 AcceptKeywordBySpaceTest(); | 1075 AcceptKeywordBySpaceTest(); |
| 1021 } | 1076 } |
| 1022 | 1077 |
| 1078 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, NonSubstitutingKeywordTest ) { | |
| 1079 NonSubstitutingKeywordTest(); | |
| 1080 } | |
| 1081 | |
| 1023 #endif | 1082 #endif |
| OLD | NEW |