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

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

Issue 11413217: Instant API: tell page whether the browser is capturing key strokes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@focus
Patch Set: Fix tests. Created 8 years 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
« no previous file with comments | « no previous file | chrome/browser/instant/instant_client.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/content_settings/host_content_settings_map.h" 5 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 #include "chrome/browser/history/history_service_factory.h" 6 #include "chrome/browser/history/history_service_factory.h"
7 #include "chrome/browser/instant/instant_loader.h" 7 #include "chrome/browser/instant/instant_loader.h"
8 #include "chrome/browser/instant/instant_model_observer.h" 8 #include "chrome/browser/instant/instant_model_observer.h"
9 #include "chrome/browser/prefs/pref_service.h" 9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 void KillInstantRenderView() { 96 void KillInstantRenderView() {
97 base::KillProcess( 97 base::KillProcess(
98 instant()->GetPreviewContents()->GetRenderProcessHost()->GetHandle(), 98 instant()->GetPreviewContents()->GetRenderProcessHost()->GetHandle(),
99 content::RESULT_CODE_KILLED, 99 content::RESULT_CODE_KILLED,
100 false); 100 false);
101 } 101 }
102 102
103 void FocusOmnibox() { 103 void FocusOmnibox() {
104 // If the omnibox already has focus, just notify Instant. 104 // If the omnibox already has focus, just notify Instant.
105 if (omnibox()->model()->has_focus()) 105 if (omnibox()->model()->has_focus()) {
106 instant()->OmniboxGotFocus(); 106 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE,
107 else 107 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL);
108 }
109 else {
108 browser()->window()->GetLocationBar()->FocusLocation(false); 110 browser()->window()->GetLocationBar()->FocusLocation(false);
111 }
109 } 112 }
110 113
111 void FocusOmniboxAndWaitForInstantSupport() { 114 void FocusOmniboxAndWaitForInstantSupport() {
112 content::WindowedNotificationObserver observer( 115 content::WindowedNotificationObserver observer(
113 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED, 116 chrome::NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
114 content::NotificationService::AllSources()); 117 content::NotificationService::AllSources());
115 FocusOmnibox(); 118 FocusOmnibox();
116 observer.Wait(); 119 observer.Wait();
117 } 120 }
118 121
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 content::WebContents* preview_tab = instant()->GetPreviewContents(); 674 content::WebContents* preview_tab = instant()->GetPreviewContents();
672 EXPECT_TRUE(preview_tab); 675 EXPECT_TRUE(preview_tab);
673 676
674 // Type a URL. This causes the preview to be hidden. 677 // Type a URL. This causes the preview to be hidden.
675 SetOmniboxText("http://hideous/zippleback"); 678 SetOmniboxText("http://hideous/zippleback");
676 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); 679 EXPECT_FALSE(instant()->IsPreviewingSearchResults());
677 EXPECT_TRUE(instant()->model()->mode().is_default()); 680 EXPECT_TRUE(instant()->model()->mode().is_default());
678 681
679 // Pretend the omnibox got focus. It already had focus, so we are just trying 682 // Pretend the omnibox got focus. It already had focus, so we are just trying
680 // to tickle a different code path. 683 // to tickle a different code path.
681 instant()->OmniboxGotFocus(); 684 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_VISIBLE,
685 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL);
682 686
683 // Commit the URL. As before, check that Instant wasn't committed. 687 // Commit the URL. As before, check that Instant wasn't committed.
684 browser()->window()->GetLocationBar()->AcceptInput(); 688 browser()->window()->GetLocationBar()->AcceptInput();
685 content::WebContents* active_tab = 689 content::WebContents* active_tab =
686 browser()->tab_strip_model()->GetActiveWebContents(); 690 browser()->tab_strip_model()->GetActiveWebContents();
687 EXPECT_NE(preview_tab, active_tab); 691 EXPECT_NE(preview_tab, active_tab);
688 EXPECT_EQ(ASCIIToUTF16("hideous/zippleback"), omnibox()->GetText()); 692 EXPECT_EQ(ASCIIToUTF16("hideous/zippleback"), omnibox()->GetText());
689 693
690 // As before, Instant shouldn't have done anything. 694 // As before, Instant shouldn't have done anything.
691 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); 695 EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 894 ASSERT_NO_FATAL_FAILURE(SetupInstant());
891 FocusOmniboxAndWaitForInstantSupport(); 895 FocusOmniboxAndWaitForInstantSupport();
892 896
893 // The preview is refreshed only after all three conditions above are met. 897 // The preview is refreshed only after all three conditions above are met.
894 SetOmniboxTextAndWaitForInstantToShow("query"); 898 SetOmniboxTextAndWaitForInstantToShow("query");
895 instant()->stale_loader_timer_.Stop(); 899 instant()->stale_loader_timer_.Stop();
896 instant()->OnStaleLoader(); 900 instant()->OnStaleLoader();
897 EXPECT_TRUE(instant()->loader_->supports_instant()); 901 EXPECT_TRUE(instant()->loader_->supports_instant());
898 instant()->HideLoader(); 902 instant()->HideLoader();
899 EXPECT_TRUE(instant()->loader_->supports_instant()); 903 EXPECT_TRUE(instant()->loader_->supports_instant());
900 instant()->OmniboxLostFocus(NULL); 904 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE,
905 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL);
901 EXPECT_FALSE(instant()->loader_->supports_instant()); 906 EXPECT_FALSE(instant()->loader_->supports_instant());
902 907
903 // Try with a different ordering. 908 // Try with a different ordering.
904 SetOmniboxTextAndWaitForInstantToShow("query"); 909 SetOmniboxTextAndWaitForInstantToShow("query");
905 instant()->stale_loader_timer_.Stop(); 910 instant()->stale_loader_timer_.Stop();
906 instant()->OnStaleLoader(); 911 instant()->OnStaleLoader();
907 EXPECT_TRUE(instant()->loader_->supports_instant()); 912 EXPECT_TRUE(instant()->loader_->supports_instant());
908 instant()->OmniboxLostFocus(NULL); 913 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE,
914 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL);
909 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideLoader(). When it 915 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideLoader(). When it
910 // stops hiding the preview eventually, uncomment these two lines: 916 // stops hiding the preview eventually, uncomment these two lines:
911 // EXPECT_TRUE(instant()->loader_->supports_instant()); 917 // EXPECT_TRUE(instant()->loader_->supports_instant());
912 // instant()->HideLoader(); 918 // instant()->HideLoader();
913 EXPECT_FALSE(instant()->loader_->supports_instant()); 919 EXPECT_FALSE(instant()->loader_->supports_instant());
914 } 920 }
915 921
916 // Test that suggestions are case insensitive. http://crbug.com/150728 922 // Test that suggestions are case insensitive. http://crbug.com/150728
917 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { 923 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) {
918 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 924 ASSERT_NO_FATAL_FAILURE(SetupInstant());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 SetOmniboxTextAndWaitForInstantToShow("q"); 1084 SetOmniboxTextAndWaitForInstantToShow("q");
1079 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); 1085 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText());
1080 1086
1081 // Kill the instant renderer and wait for instant support again. 1087 // Kill the instant renderer and wait for instant support again.
1082 KillInstantRenderView(); 1088 KillInstantRenderView();
1083 FocusOmniboxAndWaitForInstantSupport(); 1089 FocusOmniboxAndWaitForInstantSupport();
1084 1090
1085 SetOmniboxTextAndWaitForInstantToShow("qu"); 1091 SetOmniboxTextAndWaitForInstantToShow("qu");
1086 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); 1092 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText());
1087 } 1093 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698