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_overlay.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" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | 105 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
106 | 106 |
107 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 107 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
108 | 108 |
109 // Doing a search should also use the same preloaded page. | 109 // Doing a search should also use the same preloaded page. |
110 SetOmniboxTextAndWaitForInstantToShow("query"); | 110 SetOmniboxTextAndWaitForInstantToShow("query"); |
111 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 111 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
112 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 112 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
113 } | 113 } |
114 | 114 |
115 // Test that Instant works when the URL is set via a TemplateURL (as opposed to | |
116 // --instant-url). | |
117 IN_PROC_BROWSER_TEST_F(InstantTest, SetWithTemplateURL) { | |
118 ASSERT_NO_FATAL_FAILURE(SetupInstantUsingTemplateURL()); | |
119 | |
120 // Explicitly unfocus the omnibox. | |
121 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
122 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | |
123 | |
124 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
125 EXPECT_FALSE(omnibox()->model()->has_focus()); | |
126 | |
127 // Delete any existing preview. | |
128 instant()->overlay_.reset(); | |
129 EXPECT_FALSE(instant()->GetPreviewContents()); | |
130 | |
131 // Refocus the omnibox. The InstantController should've preloaded Instant. | |
132 FocusOmniboxAndWaitForInstantSupport(); | |
133 | |
134 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
135 EXPECT_TRUE(omnibox()->model()->has_focus()); | |
136 | |
137 content::WebContents* preview_tab = instant()->GetPreviewContents(); | |
138 EXPECT_TRUE(preview_tab); | |
139 | |
140 // Check that the page supports Instant, but it isn't showing. | |
141 EXPECT_TRUE(instant()->overlay_->supports_instant()); | |
142 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | |
143 EXPECT_TRUE(instant()->model()->mode().is_default()); | |
144 } | |
145 | |
146 // Flakes on Windows and Mac: http://crbug.com/170677 | 115 // Flakes on Windows and Mac: http://crbug.com/170677 |
147 #if defined(OS_WIN) || defined(OS_MACOSX) | 116 #if defined(OS_WIN) || defined(OS_MACOSX) |
148 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent | 117 #define MAYBE_OnChangeEvent DISABLED_OnChangeEvent |
149 #else | 118 #else |
150 #define MAYBE_OnChangeEvent OnChangeEvent | 119 #define MAYBE_OnChangeEvent OnChangeEvent |
151 #endif | 120 #endif |
152 // Test that the onchange event is dispatched upon typing in the omnibox. | 121 // Test that the onchange event is dispatched upon typing in the omnibox. |
153 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { | 122 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE_OnChangeEvent) { |
154 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 123 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
155 FocusOmniboxAndWaitForInstantSupport(); | 124 FocusOmniboxAndWaitForInstantSupport(); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 content::WebContents* active_tab = | 995 content::WebContents* active_tab = |
1027 browser()->tab_strip_model()->GetActiveWebContents(); | 996 browser()->tab_strip_model()->GetActiveWebContents(); |
1028 EXPECT_TRUE(instant_service->IsInstantProcess( | 997 EXPECT_TRUE(instant_service->IsInstantProcess( |
1029 active_tab->GetRenderProcessHost()->GetID())); | 998 active_tab->GetRenderProcessHost()->GetID())); |
1030 | 999 |
1031 // Navigating away should change the process. | 1000 // Navigating away should change the process. |
1032 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1001 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
1033 EXPECT_FALSE(instant_service->IsInstantProcess( | 1002 EXPECT_FALSE(instant_service->IsInstantProcess( |
1034 active_tab->GetRenderProcessHost()->GetID())); | 1003 active_tab->GetRenderProcessHost()->GetID())); |
1035 } | 1004 } |
OLD | NEW |