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

Side by Side Diff: chrome/browser/instant/instant_browsertest.cc

Issue 10949016: Fix case handling in Instant suggestions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebaseline Created 8 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/instant/instant_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "chrome/browser/content_settings/host_content_settings_map.h" 6 #include "chrome/browser/content_settings/host_content_settings_map.h"
7 #include "chrome/browser/history/history_service_factory.h" 7 #include "chrome/browser/history/history_service_factory.h"
8 #include "chrome/browser/instant/instant_controller.h" 8 #include "chrome/browser/instant/instant_controller.h"
9 #include "chrome/browser/instant/instant_loader.h" 9 #include "chrome/browser/instant/instant_loader.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 void FocusOmniboxAndWaitForInstantSupport() { 72 void FocusOmniboxAndWaitForInstantSupport() {
73 content::WindowedNotificationObserver observer( 73 content::WindowedNotificationObserver observer(
74 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 74 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
75 content::NotificationService::AllSources()); 75 content::NotificationService::AllSources());
76 FocusOmnibox(); 76 FocusOmnibox();
77 observer.Wait(); 77 observer.Wait();
78 } 78 }
79 79
80 void SetOmniboxText(const std::string& text) { 80 void SetOmniboxText(const std::string& text) {
81 FocusOmnibox(); 81 FocusOmnibox();
82 omnibox()->SetUserText(ASCIIToUTF16(text)); 82 omnibox()->SetUserText(UTF8ToUTF16(text));
83 } 83 }
84 84
85 void SetOmniboxTextAndWaitForInstantToShow(const std::string& text) { 85 void SetOmniboxTextAndWaitForInstantToShow(const std::string& text) {
86 content::WindowedNotificationObserver observer( 86 content::WindowedNotificationObserver observer(
87 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN, 87 chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
88 content::NotificationService::AllSources()); 88 content::NotificationService::AllSources());
89 SetOmniboxText(text); 89 SetOmniboxText(text);
90 observer.Wait(); 90 observer.Wait();
91 } 91 }
92 92
(...skipping 29 matching lines...) Expand all
122 GetIntFromJS(rvh, "oncancelcalls", &oncancelcalls_) && 122 GetIntFromJS(rvh, "oncancelcalls", &oncancelcalls_) &&
123 GetIntFromJS(rvh, "onresizecalls", &onresizecalls_) && 123 GetIntFromJS(rvh, "onresizecalls", &onresizecalls_) &&
124 GetStringFromJS(rvh, "value", &value_) && 124 GetStringFromJS(rvh, "value", &value_) &&
125 GetBoolFromJS(rvh, "verbatim", &verbatim_) && 125 GetBoolFromJS(rvh, "verbatim", &verbatim_) &&
126 GetIntFromJS(rvh, "height", &height_); 126 GetIntFromJS(rvh, "height", &height_);
127 } 127 }
128 128
129 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT { 129 bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT {
130 return content::ExecuteJavaScript( 130 return content::ExecuteJavaScript(
131 instant()->GetPreviewContents()->web_contents()->GetRenderViewHost(), 131 instant()->GetPreviewContents()->web_contents()->GetRenderViewHost(),
132 std::wstring(), ASCIIToWide(script)); 132 std::wstring(), UTF8ToWide(script));
133 } 133 }
134 134
135 bool CheckVisibilityIs(TabContents* tab, bool expected) WARN_UNUSED_RESULT { 135 bool CheckVisibilityIs(TabContents* tab, bool expected) WARN_UNUSED_RESULT {
136 bool actual = !expected; // Purposely start with a mis-match. 136 bool actual = !expected; // Purposely start with a mis-match.
137 // We can only use ASSERT_*() in a method that returns void, hence this 137 // We can only use ASSERT_*() in a method that returns void, hence this
138 // convoluted check. 138 // convoluted check.
139 return GetBoolFromJS(tab->web_contents()->GetRenderViewHost(), 139 return GetBoolFromJS(tab->web_contents()->GetRenderViewHost(),
140 "!document.webkitHidden", &actual) && 140 "!document.webkitHidden", &actual) &&
141 actual == expected; 141 actual == expected;
142 } 142 }
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // Instant is showing, so OnStaleLoader() shouldn't kill the preview. 860 // Instant is showing, so OnStaleLoader() shouldn't kill the preview.
861 instant()->stale_loader_timer_.Stop(); 861 instant()->stale_loader_timer_.Stop();
862 instant()->OnStaleLoader(); 862 instant()->OnStaleLoader();
863 EXPECT_TRUE(instant()->is_showing()); 863 EXPECT_TRUE(instant()->is_showing());
864 864
865 // The preview should be recreated once the omnibox loses focus. 865 // The preview should be recreated once the omnibox loses focus.
866 EXPECT_TRUE(instant()->loader()->supports_instant()); 866 EXPECT_TRUE(instant()->loader()->supports_instant());
867 instant()->OnAutocompleteLostFocus(NULL); 867 instant()->OnAutocompleteLostFocus(NULL);
868 EXPECT_FALSE(instant()->loader()->supports_instant()); 868 EXPECT_FALSE(instant()->loader()->supports_instant());
869 } 869 }
870
871 // Test that suggestions are case insensitive. http://crbug.com/150728
872 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) {
873 ASSERT_NO_FATAL_FAILURE(SetupInstant("instant.html"));
874 FocusOmniboxAndWaitForInstantSupport();
875
876 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]"));
877
878 SetOmniboxTextAndWaitForInstantToShow("in");
879 EXPECT_EQ(ASCIIToUTF16("instant"), omnibox()->GetText());
880
881 instant()->Hide();
882 SetOmniboxTextAndWaitForInstantToShow("IN");
883 EXPECT_EQ(ASCIIToUTF16("INSTANT"), omnibox()->GetText());
884
885 // U+0130 == LATIN CAPITAL LETTER I WITH DOT ABOVE
886 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: '\\u0130NSTANT' } ]"));
887
888 instant()->Hide();
889 SetOmniboxTextAndWaitForInstantToShow("i");
890 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText());
891
892 instant()->Hide();
893 SetOmniboxTextAndWaitForInstantToShow("I");
894 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText());
895
896 instant()->Hide();
897 SetOmniboxTextAndWaitForInstantToShow(WideToUTF8(L"i\u0307"));
898 EXPECT_EQ(WideToUTF16(L"i\u0307nstant"), omnibox()->GetText());
899
900 instant()->Hide();
901 SetOmniboxTextAndWaitForInstantToShow(WideToUTF8(L"I\u0307"));
902 EXPECT_EQ(WideToUTF16(L"I\u0307nstant"), omnibox()->GetText());
903
904 instant()->Hide();
905 SetOmniboxTextAndWaitForInstantToShow(WideToUTF8(L"\u0130"));
906 EXPECT_EQ(WideToUTF16(L"\u0130NSTANT"), omnibox()->GetText());
907
908 instant()->Hide();
909 SetOmniboxTextAndWaitForInstantToShow("in");
910 EXPECT_EQ(ASCIIToUTF16("in"), omnibox()->GetText());
911
912 instant()->Hide();
913 SetOmniboxTextAndWaitForInstantToShow("IN");
914 EXPECT_EQ(ASCIIToUTF16("IN"), omnibox()->GetText());
915 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698