| 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_commands.h" | 16 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 215 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
| 206 omnibox()->model()->PermanentURL().spec()); | 216 omnibox()->model()->PermanentURL().spec()); |
| 207 | 217 |
| 208 // Commit the search by pressing Enter. | 218 // Commit the search by pressing Enter. |
| 209 browser()->window()->GetLocationBar()->AcceptInput(); | 219 browser()->window()->GetLocationBar()->AcceptInput(); |
| 210 | 220 |
| 211 // After the commit, Instant should not be showing. | 221 // After the commit, Instant should not be showing. |
| 212 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 222 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| 213 EXPECT_TRUE(instant()->model()->mode().is_default()); | 223 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 214 | 224 |
| 215 // The old loader is deleted and a new one is created. | 225 // The old overlay is deleted and a new one is created. |
| 216 EXPECT_TRUE(instant()->GetPreviewContents()); | 226 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 217 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 227 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
| 218 | 228 |
| 219 // Check that the current active tab is indeed what was once the preview. | 229 // Check that the current active tab is indeed what was once the preview. |
| 220 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 230 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
| 221 | 231 |
| 222 // We should have two navigation entries, one for the NTP, and one for the | 232 // We should have two navigation entries, one for the NTP, and one for the |
| 223 // Instant search that was committed. | 233 // Instant search that was committed. |
| 224 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); | 234 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); |
| 225 | 235 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 EXPECT_EQ(std::string(chrome::kAboutBlankURL), | 275 EXPECT_EQ(std::string(chrome::kAboutBlankURL), |
| 266 omnibox()->model()->PermanentURL().spec()); | 276 omnibox()->model()->PermanentURL().spec()); |
| 267 | 277 |
| 268 // Commit the search by clicking on the preview. | 278 // Commit the search by clicking on the preview. |
| 269 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 279 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 270 | 280 |
| 271 // After the commit, Instant should not be showing. | 281 // After the commit, Instant should not be showing. |
| 272 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 282 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| 273 EXPECT_TRUE(instant()->model()->mode().is_default()); | 283 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 274 | 284 |
| 275 // The old loader is deleted and a new one is created. | 285 // The old overlay is deleted and a new one is created. |
| 276 EXPECT_TRUE(instant()->GetPreviewContents()); | 286 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 277 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 287 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
| 278 | 288 |
| 279 // Check that the current active tab is indeed what was once the preview. | 289 // Check that the current active tab is indeed what was once the preview. |
| 280 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 290 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
| 281 | 291 |
| 282 // We should have two navigation entries, one for the NTP, and one for the | 292 // We should have two navigation entries, one for the NTP, and one for the |
| 283 // Instant search that was committed. | 293 // Instant search that was committed. |
| 284 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); | 294 EXPECT_EQ(2, preview_tab->GetController().GetEntryCount()); |
| 285 | 295 |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 chrome::NewEmptyWindow(browser()->profile()); | 779 chrome::NewEmptyWindow(browser()->profile()); |
| 770 observer.WaitUntilDesiredPreviewState(); | 780 observer.WaitUntilDesiredPreviewState(); |
| 771 | 781 |
| 772 // Even though we just created a new Browser object (for the new window), the | 782 // Even though we just created a new Browser object (for the new window), the |
| 773 // browser() accessor should still give us the first window's Browser object. | 783 // browser() accessor should still give us the first window's Browser object. |
| 774 EXPECT_EQ(previous_window, browser()); | 784 EXPECT_EQ(previous_window, browser()); |
| 775 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 785 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| 776 EXPECT_TRUE(instant()->model()->mode().is_default()); | 786 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 777 } | 787 } |
| 778 | 788 |
| 779 // Test that the Instant loader is recreated when all these conditions are met: | 789 // Test that the Instant overlay is recreated when all these conditions are met: |
| 780 // - The stale loader timer has fired. | 790 // - The stale overlay timer has fired. |
| 781 // - The preview is not showing. | 791 // - The preview is not showing. |
| 782 // - The omnibox doesn't have focus. | 792 // - The omnibox doesn't have focus. |
| 783 IN_PROC_BROWSER_TEST_F(InstantTest, InstantLoaderRefresh) { | 793 IN_PROC_BROWSER_TEST_F(InstantTest, InstantOverlayRefresh) { |
| 784 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 794 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 785 FocusOmniboxAndWaitForInstantSupport(); | 795 FocusOmniboxAndWaitForInstantSupport(); |
| 786 | 796 |
| 787 // The preview is refreshed only after all three conditions above are met. | 797 // The preview is refreshed only after all three conditions above are met. |
| 788 SetOmniboxTextAndWaitForInstantToShow("query"); | 798 SetOmniboxTextAndWaitForInstantToShow("query"); |
| 789 instant()->stale_loader_timer_.Stop(); | 799 instant()->overlay_->is_stale_ = true; |
| 790 instant()->OnStaleLoader(); | 800 instant()->ReloadOverlayIfStale(); |
| 791 EXPECT_TRUE(instant()->loader_->supports_instant()); | 801 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 792 instant()->HideLoader(); | 802 instant()->HideOverlay(); |
| 793 EXPECT_TRUE(instant()->loader_->supports_instant()); | 803 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 794 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 804 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
| 795 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 805 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
| 796 EXPECT_FALSE(instant()->loader_->supports_instant()); | 806 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
| 797 | 807 |
| 798 // Try with a different ordering. | 808 // Try with a different ordering. |
| 799 SetOmniboxTextAndWaitForInstantToShow("query"); | 809 SetOmniboxTextAndWaitForInstantToShow("query"); |
| 800 instant()->stale_loader_timer_.Stop(); | 810 instant()->overlay_->is_stale_ = true; |
| 801 instant()->OnStaleLoader(); | 811 instant()->ReloadOverlayIfStale(); |
| 802 EXPECT_TRUE(instant()->loader_->supports_instant()); | 812 EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 803 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, | 813 instant()->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, |
| 804 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); | 814 OMNIBOX_FOCUS_CHANGE_EXPLICIT, NULL); |
| 805 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideLoader(). When it | 815 // TODO(sreeram): Currently, OmniboxLostFocus() calls HideOverlay(). When it |
| 806 // stops hiding the preview eventually, uncomment these two lines: | 816 // stops hiding the preview eventually, uncomment these two lines: |
| 807 // EXPECT_TRUE(instant()->loader_->supports_instant()); | 817 // EXPECT_TRUE(instant()->overlay_->supports_instant()); |
| 808 // instant()->HideLoader(); | 818 // instant()->HideOverlay(); |
| 809 EXPECT_FALSE(instant()->loader_->supports_instant()); | 819 EXPECT_FALSE(instant()->overlay_->supports_instant()); |
| 810 } | 820 } |
| 811 | 821 |
| 812 // Test that suggestions are case insensitive. http://crbug.com/150728 | 822 // Test that suggestions are case insensitive. http://crbug.com/150728 |
| 813 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { | 823 IN_PROC_BROWSER_TEST_F(InstantTest, SuggestionsAreCaseInsensitive) { |
| 814 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 824 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 815 FocusOmniboxAndWaitForInstantSupport(); | 825 FocusOmniboxAndWaitForInstantSupport(); |
| 816 | 826 |
| 817 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); | 827 EXPECT_TRUE(ExecuteScript("suggestion = [ { value: 'INSTANT' } ]")); |
| 818 | 828 |
| 819 SetOmniboxTextAndWaitForInstantToShow("in"); | 829 SetOmniboxTextAndWaitForInstantToShow("in"); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 &active_tab_onvisibilitycalls)); | 919 &active_tab_onvisibilitycalls)); |
| 910 EXPECT_EQ(0, active_tab_onvisibilitycalls); | 920 EXPECT_EQ(0, active_tab_onvisibilitycalls); |
| 911 | 921 |
| 912 // Commit the search by pressing Alt-Enter. | 922 // Commit the search by pressing Alt-Enter. |
| 913 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); | 923 omnibox()->model()->AcceptInput(NEW_FOREGROUND_TAB, false); |
| 914 | 924 |
| 915 // After the commit, Instant should not be showing. | 925 // After the commit, Instant should not be showing. |
| 916 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 926 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| 917 EXPECT_TRUE(instant()->model()->mode().is_default()); | 927 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 918 | 928 |
| 919 // The old loader is deleted and a new one is created. | 929 // The old overlay is deleted and a new one is created. |
| 920 EXPECT_TRUE(instant()->GetPreviewContents()); | 930 EXPECT_TRUE(instant()->GetPreviewContents()); |
| 921 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); | 931 EXPECT_NE(instant()->GetPreviewContents(), preview_tab); |
| 922 | 932 |
| 923 // Check that we have two tabs and that the new active tab is indeed what was | 933 // Check that we have two tabs and that the new active tab is indeed what was |
| 924 // once the preview. The preview tab should have just one navigation entry, | 934 // once the preview. The preview tab should have just one navigation entry, |
| 925 // for the Instant search that was committed. | 935 // for the Instant search that was committed. |
| 926 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 936 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 927 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); | 937 EXPECT_EQ(preview_tab, browser()->tab_strip_model()->GetActiveWebContents()); |
| 928 EXPECT_EQ(1, preview_tab->GetController().GetEntryCount()); | 938 EXPECT_EQ(1, preview_tab->GetController().GetEntryCount()); |
| 929 | 939 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 SetOmniboxText("ins"); | 973 SetOmniboxText("ins"); |
| 964 EXPECT_EQ(ASCIIToUTF16("tant"), omnibox()->GetInstantSuggestion()); | 974 EXPECT_EQ(ASCIIToUTF16("tant"), omnibox()->GetInstantSuggestion()); |
| 965 | 975 |
| 966 SetOmniboxText("in"); | 976 SetOmniboxText("in"); |
| 967 EXPECT_EQ(ASCIIToUTF16("stant"), omnibox()->GetInstantSuggestion()); | 977 EXPECT_EQ(ASCIIToUTF16("stant"), omnibox()->GetInstantSuggestion()); |
| 968 | 978 |
| 969 SetOmniboxText("insane"); | 979 SetOmniboxText("insane"); |
| 970 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 980 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
| 971 } | 981 } |
| 972 | 982 |
| 973 // Test that instant loader is recreated if it gets destroyed. | 983 // Test that instant overlay is recreated if it gets destroyed. |
| 974 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { | 984 IN_PROC_BROWSER_TEST_F(InstantTest, InstantRenderViewGone) { |
| 975 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 985 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 976 FocusOmniboxAndWaitForInstantSupport(); | 986 FocusOmniboxAndWaitForInstantSupport(); |
| 977 | 987 |
| 978 // Type partial query, get suggestion to show. | 988 // Type partial query, get suggestion to show. |
| 979 SetOmniboxTextAndWaitForInstantToShow("q"); | 989 SetOmniboxTextAndWaitForInstantToShow("q"); |
| 980 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); | 990 EXPECT_EQ(ASCIIToUTF16("query suggestion"), omnibox()->GetText()); |
| 981 | 991 |
| 982 // Kill the instant renderer and wait for instant support again. | 992 // Kill the instant renderer and wait for instant support again. |
| 983 KillInstantRenderView(); | 993 KillInstantRenderView(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 content::WebContents* active_tab = | 1025 content::WebContents* active_tab = |
| 1016 browser()->tab_strip_model()->GetActiveWebContents(); | 1026 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1017 EXPECT_TRUE(instant_service->IsInstantProcess( | 1027 EXPECT_TRUE(instant_service->IsInstantProcess( |
| 1018 active_tab->GetRenderProcessHost()->GetID())); | 1028 active_tab->GetRenderProcessHost()->GetID())); |
| 1019 | 1029 |
| 1020 // Navigating away should change the process. | 1030 // Navigating away should change the process. |
| 1021 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1031 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 1022 EXPECT_FALSE(instant_service->IsInstantProcess( | 1032 EXPECT_FALSE(instant_service->IsInstantProcess( |
| 1023 active_tab->GetRenderProcessHost()->GetID())); | 1033 active_tab->GetRenderProcessHost()->GetID())); |
| 1024 } | 1034 } |
| OLD | NEW |