OLD | NEW |
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_overlay.h" |
8 #include "chrome/browser/instant/instant_service.h" | 8 #include "chrome/browser/instant/instant_service.h" |
9 #include "chrome/browser/instant/instant_service_factory.h" | 9 #include "chrome/browser/instant/instant_service_factory.h" |
10 #include "chrome/browser/instant/instant_test_utils.h" | 10 #include "chrome/browser/instant/instant_test_utils.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
14 #include "chrome/browser/task_manager/task_manager.h" | 14 #include "chrome/browser/task_manager/task_manager.h" |
15 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" | 15 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_commands.h" | 17 #include "chrome/browser/ui/browser_commands.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
20 #include "chrome/test/base/interactive_test_utils.h" | 21 #include "chrome/test/base/interactive_test_utils.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
24 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
25 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
26 | 28 |
27 class InstantTest : public InstantTestBase { | 29 class InstantTest : public InstantTestBase { |
28 protected: | 30 protected: |
29 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 31 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
30 ASSERT_TRUE(test_server()->Start()); | 32 ASSERT_TRUE(test_server()->Start()); |
31 instant_url_ = test_server()->GetURL("files/instant.html"); | 33 instant_url_ = test_server()->GetURL("files/instant.html"); |
32 } | 34 } |
33 | 35 |
| 36 void FocusOmniboxAndWaitForInstantSupport() { |
| 37 content::WindowedNotificationObserver observer( |
| 38 chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED, |
| 39 content::NotificationService::AllSources()); |
| 40 FocusOmnibox(); |
| 41 observer.Wait(); |
| 42 } |
| 43 |
34 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { | 44 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { |
35 return GetIntFromJS(contents, "onvisibilitycalls", &onvisibilitycalls_) && | 45 return GetIntFromJS(contents, "onvisibilitycalls", &onvisibilitycalls_) && |
36 GetIntFromJS(contents, "onchangecalls", &onchangecalls_) && | 46 GetIntFromJS(contents, "onchangecalls", &onchangecalls_) && |
37 GetIntFromJS(contents, "onsubmitcalls", &onsubmitcalls_) && | 47 GetIntFromJS(contents, "onsubmitcalls", &onsubmitcalls_) && |
38 GetIntFromJS(contents, "oncancelcalls", &oncancelcalls_) && | 48 GetIntFromJS(contents, "oncancelcalls", &oncancelcalls_) && |
39 GetIntFromJS(contents, "onresizecalls", &onresizecalls_) && | 49 GetIntFromJS(contents, "onresizecalls", &onresizecalls_) && |
40 GetStringFromJS(contents, "value", &value_) && | 50 GetStringFromJS(contents, "value", &value_) && |
41 GetBoolFromJS(contents, "verbatim", &verbatim_) && | 51 GetBoolFromJS(contents, "verbatim", &verbatim_) && |
42 GetIntFromJS(contents, "height", &height_); | 52 GetIntFromJS(contents, "height", &height_); |
43 } | 53 } |
(...skipping 14 matching lines...) Expand all Loading... |
58 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 68 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
59 | 69 |
60 // Explicitly unfocus the omnibox. | 70 // Explicitly unfocus the omnibox. |
61 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 71 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
62 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 72 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
63 | 73 |
64 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 74 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
65 EXPECT_FALSE(omnibox()->model()->has_focus()); | 75 EXPECT_FALSE(omnibox()->model()->has_focus()); |
66 | 76 |
67 // Delete any existing preview. | 77 // Delete any existing preview. |
68 instant()->loader_.reset(); | 78 instant()->overlay_.reset(); |
69 EXPECT_FALSE(instant()->GetPreviewContents()); | 79 EXPECT_FALSE(instant()->GetPreviewContents()); |
70 | 80 |
71 // Refocus the omnibox. The InstantController should've preloaded Instant. | 81 // Refocus the omnibox. The InstantController should've preloaded Instant. |
72 FocusOmniboxAndWaitForInstantSupport(); | 82 FocusOmniboxAndWaitForInstantSupport(); |
73 | 83 |
74 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 84 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
75 EXPECT_TRUE(omnibox()->model()->has_focus()); | 85 EXPECT_TRUE(omnibox()->model()->has_focus()); |
76 | 86 |
77 content::WebContents* preview_tab = instant()->GetPreviewContents(); | 87 content::WebContents* preview_tab = instant()->GetPreviewContents(); |
78 EXPECT_TRUE(preview_tab); | 88 EXPECT_TRUE(preview_tab); |
79 | 89 |
80 // Check that the page supports Instant, but it isn't showing. | 90 // Check that the page supports Instant, but it isn't showing. |
81 EXPECT_TRUE(instant()->loader_->supports_instant()); | 91 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
82 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 92 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
83 EXPECT_TRUE(instant()->model()->mode().is_default()); | 93 EXPECT_TRUE(instant()->model()->mode().is_default()); |
84 | 94 |
85 // Adding a new tab shouldn't delete or recreate the preview; otherwise, | 95 // Adding a new tab shouldn't delete or recreate the preview; otherwise, |
86 // what's the point of preloading? | 96 // what's the point of preloading? |
87 AddBlankTabAndShow(browser()); | 97 AddBlankTabAndShow(browser()); |
88 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 98 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
89 | 99 |
90 // Unfocusing and refocusing the omnibox should also preserve the preview. | 100 // Unfocusing and refocusing the omnibox should also preserve the preview. |
91 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 101 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
(...skipping 16 matching lines...) Expand all Loading... |
108 ASSERT_NO_FATAL_FAILURE(SetupInstantUsingTemplateURL()); | 118 ASSERT_NO_FATAL_FAILURE(SetupInstantUsingTemplateURL()); |
109 | 119 |
110 // Explicitly unfocus the omnibox. | 120 // Explicitly unfocus the omnibox. |
111 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 121 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
112 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 122 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
113 | 123 |
114 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 124 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
115 EXPECT_FALSE(omnibox()->model()->has_focus()); | 125 EXPECT_FALSE(omnibox()->model()->has_focus()); |
116 | 126 |
117 // Delete any existing preview. | 127 // Delete any existing preview. |
118 instant()->loader_.reset(); | 128 instant()->overlay_.reset(); |
119 EXPECT_FALSE(instant()->GetPreviewContents()); | 129 EXPECT_FALSE(instant()->GetPreviewContents()); |
120 | 130 |
121 // Refocus the omnibox. The InstantController should've preloaded Instant. | 131 // Refocus the omnibox. The InstantController should've preloaded Instant. |
122 FocusOmniboxAndWaitForInstantSupport(); | 132 FocusOmniboxAndWaitForInstantSupport(); |
123 | 133 |
124 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 134 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
125 EXPECT_TRUE(omnibox()->model()->has_focus()); | 135 EXPECT_TRUE(omnibox()->model()->has_focus()); |
126 | 136 |
127 content::WebContents* preview_tab = instant()->GetPreviewContents(); | 137 content::WebContents* preview_tab = instant()->GetPreviewContents(); |
128 EXPECT_TRUE(preview_tab); | 138 EXPECT_TRUE(preview_tab); |
129 | 139 |
130 // Check that the page supports Instant, but it isn't showing. | 140 // Check that the page supports Instant, but it isn't showing. |
131 EXPECT_TRUE(instant()->loader_->supports_instant()); | 141 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
132 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 142 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
133 EXPECT_TRUE(instant()->model()->mode().is_default()); | 143 EXPECT_TRUE(instant()->model()->mode().is_default()); |
134 } | 144 } |
135 | 145 |
136 // Flakes on Windows and Mac: http://crbug.com/170677 | 146 // Flakes on Windows and Mac: http://crbug.com/170677 |
137 #if defined(OS_WIN) || defined(OS_MACOSX) | 147 #if defined(OS_WIN) || defined(OS_MACOSX) |
138 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent | 148 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent |
139 #else | 149 #else |
140 #define MAYBE_OnChangeEvent OnChangeEvent | 150 #define MAYBE_OnChangeEvent OnChangeEvent |
141 #endif | 151 #endif |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 216 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
207 omnibox()->model()->PermanentURL().spec()); | 217 omnibox()->model()->PermanentURL().spec()); |
208 | 218 |
209 // Commit the search by pressing Enter. | 219 // Commit the search by pressing Enter. |
210 browser()->window()->GetLocationBar()->AcceptInput(); | 220 browser()->window()->GetLocationBar()->AcceptInput(); |
211 | 221 |
212 // After the commit, Instant should not be showing. | 222 // After the commit, Instant should not be showing. |
213 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 223 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
214 EXPECT_TRUE(instant()->model()->mode().is_default()); | 224 EXPECT_TRUE(instant()->model()->mode().is_default()); |
215 | 225 |
216 // The old loader is deleted and a new one is created. | 226 // The old overlay is deleted and a new one is created. |
217 EXPECT_TRUE(instant()->GetPreviewContents()); | 227 EXPECT_TRUE(instant()->GetPreviewContents()); |
218 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 228 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
219 | 229 |
220 // Check that the current active tab is indeed what was once the preview. | 230 // Check that the current active tab is indeed what was once the preview. |
221 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 231 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
222 | 232 |
223 // We should have two navigation entries, one for the NTP, and one for the | 233 // We should have two navigation entries, one for the NTP, and one for the |
224 // Instant search that was committed. | 234 // Instant search that was committed. |
225 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); | 235 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); |
226 | 236 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 276 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
267 omnibox()->model()->PermanentURL().spec()); | 277 omnibox()->model()->PermanentURL().spec()); |
268 | 278 |
269 // Commit the search by clicking on the preview. | 279 // Commit the search by clicking on the preview. |
270 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 280 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
271 | 281 |
272 // After the commit, Instant should not be showing. | 282 // After the commit, Instant should not be showing. |
273 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 283 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
274 EXPECT_TRUE(instant()->model()->mode().is_default()); | 284 EXPECT_TRUE(instant()->model()->mode().is_default()); |
275 | 285 |
276 // The old loader is deleted and a new one is created. | 286 // The old overlay is deleted and a new one is created. |
277 EXPECT_TRUE(instant()->GetPreviewContents()); | 287 EXPECT_TRUE(instant()->GetPreviewContents()); |
278 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 288 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
279 | 289 |
280 // Check that the current active tab is indeed what was once the preview. | 290 // Check that the current active tab is indeed what was once the preview. |
281 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 291 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
282 | 292 |
283 // We should have two navigation entries, one for the NTP, and one for the | 293 // We should have two navigation entries, one for the NTP, and one for the |
284 // Instant search that was committed. | 294 // Instant search that was committed. |
285 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); | 295 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); |
286 | 296 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 chrome::NewEmptyWindow(browser()->profile()); | 780 chrome::NewEmptyWindow(browser()->profile()); |
771 observer.WaitUntilDesiredPreviewState(); | 781 observer.WaitUntilDesiredPreviewState(); |
772 | 782 |
773 // Even though we just created a new Browser object (for the new window), the | 783 // Even though we just created a new Browser object (for the new window), the |
774 // browser() accessor should still give us the first window's Browser object. | 784 // browser() accessor should still give us the first window's Browser object. |
775 EXPECT_EQ(previous_window, browser()); | 785 EXPECT_EQ(previous_window, browser()); |
776 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 786 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
777 EXPECT_TRUE(instant()->model()->mode().is_default()); | 787 EXPECT_TRUE(instant()->model()->mode().is_default()); |
778 } | 788 } |
779 | 789 |
780 // Test that the Instant loader is recreated when all these conditions are met: | 790 // Test that the Instant overlay is recreated when all these conditions are met: |
781 // - The stale loader timer has fired. | 791 // - The stale overlay timer has fired. |
782 // - The preview is not showing. | 792 // - The preview is not showing. |
783 // - The omnibox doesn't have focus. | 793 // - The omnibox doesn't have focus. |
784 IN_PROC_BROWSER_TEST_F(InstantTest, InstantLoaderRefresh) { | 794 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { |
785 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 795 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
786 FocusOmniboxAndWaitForInstantSupport(); | 796 FocusOmniboxAndWaitForInstantSupport(); |
787 | 797 |
788 // The preview is refreshed only after all three conditions above are met. | 798 // The preview is refreshed only after all three conditions above are met. |
789 SetOmniboxTextAndWaitForInstantToShow("query"); | 799 SetOmniboxTextAndWaitForInstantToShow("query"); |
790 instant()->stale_loader_timer_.Stop(); | 800 instant()->overlay_->is_stale_ = true; |
791 instant()->OnStaleLoader(); | 801 instant()->ReloadOverlayIfStale(); |
792 EXPECT_TRUE(instant()->loader_->supports_instant()); | 802 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
793 instant()->HideLoader(); | 803 instant()->HideOverlay(); |
794 EXPECT_TRUE(instant()->loader_->supports_instant()); | 804 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
795 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 805 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
796 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 806 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
797 EXPECT_FALSE(instant()->loader_->supports_instant()); | 807 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
798 | 808 |
799 // Try with a different ordering. | 809 // Try with a different ordering. |
800 SetOmniboxTextAndWaitForInstantToShow("query"); | 810 SetOmniboxTextAndWaitForInstantToShow("query"); |
801 instant()->stale_loader_timer_.Stop(); | 811 instant()->overlay_->is_stale_ = true; |
802 instant()->OnStaleLoader(); | 812 instant()->ReloadOverlayIfStale(); |
803 EXPECT_TRUE(instant()->loader_->supports_instant()); | 813 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
804 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 814 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
805 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 815 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
806 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideLoader(). When it | 816 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it |
807 // stops hiding the preview eventually, uncomment these two lines: | 817 // stops hiding the preview eventually, uncomment these two lines: |
808 // EXPECT_TRUE(instant()->loader_->supports_instant()); | 818 // EXPECT_TRUE(instant()->overlay_->supports_instant()); |
809 // instant()->HideLoader(); | 819 // instant()->HideOverlay(); |
810 EXPECT_FALSE(instant()->loader_->supports_instant()); | 820 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
811 } | 821 } |
812 | 822 |
813 // Test that suggestions are case insensitive. http://crbug.com/150728 | 823 // Test that suggestions are case insensitive. http://crbug.com/150728 |
814 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { | 824 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { |
815 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 825 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
816 FocusOmniboxAndWaitForInstantSupport(); | 826 FocusOmniboxAndWaitForInstantSupport(); |
817 | 827 |
818 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); | 828 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); |
819 | 829 |
820 SetOmniboxTextAndWaitForInstantToShow("in"); | 830 SetOmniboxTextAndWaitForInstantToShow("in"); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 &active_tab_onvisibilitycalls)); | 920 &active_tab_onvisibilitycalls)); |
911 EXPECT_EQ(0, active_tab_onvisibilitycalls); | 921 EXPECT_EQ(0, active_tab_onvisibilitycalls); |
912 | 922 |
913 // Commit the search by pressing Alt-Enter. | 923 // Commit the search by pressing Alt-Enter. |
914 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); | 924 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); |
915 | 925 |
916 // After the commit, Instant should not be showing. | 926 // After the commit, Instant should not be showing. |
917 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 927 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
918 EXPECT_TRUE(instant()->model()->mode().is_default()); | 928 EXPECT_TRUE(instant()->model()->mode().is_default()); |
919 | 929 |
920 // The old loader is deleted and a new one is created. | 930 // The old overlay is deleted and a new one is created. |
921 EXPECT_TRUE(instant()->GetPreviewContents()); | 931 EXPECT_TRUE(instant()->GetPreviewContents()); |
922 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 932 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
923 | 933 |
924 // Check that we have two tabs and that the new active tab is indeed what was | 934 // Check that we have two tabs and that the new active tab is indeed what was |
925 // once the preview. The preview tab should have just one navigation entry, | 935 // once the preview. The preview tab should have just one navigation entry, |
926 // for the Instant search that was committed. | 936 // for the Instant search that was committed. |
927 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 937 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
928 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 938 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
929 EXPECT_EQ(1, preview_tab->GetController().GetEntryCount()); | 939 EXPECT_EQ(1, preview_tab->GetController().GetEntryCount()); |
930 | 940 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 SetOmniboxText("ins"); | 974 SetOmniboxText("ins"); |
965 EXPECT_EQ(ASCIIToUTF16("tant"), omnibox()->GetInstantSuggestion()); | 975 EXPECT_EQ(ASCIIToUTF16("tant"), omnibox()->GetInstantSuggestion()); |
966 | 976 |
967 SetOmniboxText("in"); | 977 SetOmniboxText("in"); |
968 EXPECT_EQ(ASCIIToUTF16("stant"), omnibox()->GetInstantSuggestion()); | 978 EXPECT_EQ(ASCIIToUTF16("stant"), omnibox()->GetInstantSuggestion()); |
969 | 979 |
970 SetOmniboxText("insane"); | 980 SetOmniboxText("insane"); |
971 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 981 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
972 } | 982 } |
973 | 983 |
974 // Test that instant loader is recreated if it gets destroyed. | 984 // Test that instant overlay is recreated if it gets destroyed. |
975 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { | 985 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { |
976 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 986 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
977 FocusOmniboxAndWaitForInstantSupport(); | 987 FocusOmniboxAndWaitForInstantSupport(); |
978 | 988 |
979 // Type partial query, get suggestion to show. | 989 // Type partial query, get suggestion to show. |
980 SetOmniboxTextAndWaitForInstantToShow("q"); | 990 SetOmniboxTextAndWaitForInstantToShow("q"); |
981 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 991 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
982 | 992 |
983 // Kill the instant renderer and wait for instant support again. | 993 // Kill the instant renderer and wait for instant support again. |
984 KillInstantRenderView(); | 994 KillInstantRenderView(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 content::WebContents* active_tab = | 1026 content::WebContents* active_tab = |
1017 browser()->tab_strip_model()->GetActiveWebContents(); | 1027 browser()->tab_strip_model()->GetActiveWebContents(); |
1018 EXPECT_TRUE(instant_service->IsInstantProcess( | 1028 EXPECT_TRUE(instant_service->IsInstantProcess( |
1019 active_tab->GetRenderProcessHost()->GetID())); | 1029 active_tab->GetRenderProcessHost()->GetID())); |
1020 | 1030 |
1021 // Navigating away should change the process. | 1031 // Navigating away should change the process. |
1022 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1032 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
1023 EXPECT_FALSE(instant_service->IsInstantProcess( | 1033 EXPECT_FALSE(instant_service->IsInstantProcess( |
1024 active_tab->GetRenderProcessHost()->GetID())); | 1034 active_tab->GetRenderProcessHost()->GetID())); |
1025 } | 1035 } |
OLD | NEW |