OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/instant/instant_commit_type.h" | 5 #include "chrome/browser/instant/instant_commit_type.h" |
6 #include "chrome/browser/instant/instant_ntp.h" | 6 #include "chrome/browser/instant/instant_ntp.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_TRUE(preview_tab); | 119 EXPECT_TRUE(preview_tab); |
120 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 120 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
121 EXPECT_TRUE(instant()->model()->mode().is_default()); | 121 EXPECT_TRUE(instant()->model()->mode().is_default()); |
122 | 122 |
123 // Typing in the omnibox should show the overlay. | 123 // Typing in the omnibox should show the overlay. |
124 SetOmniboxTextAndWaitForInstantToShow("query"); | 124 SetOmniboxTextAndWaitForInstantToShow("query"); |
125 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 125 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
126 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 126 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
127 } | 127 } |
128 | 128 |
| 129 // Test that middle clicking on a suggestion opens the result in a new tab. |
| 130 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 131 MiddleClickOnSuggestionOpensInNewTab) { |
| 132 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 133 FocusOmniboxAndWaitForInstantSupport(); |
| 134 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 135 |
| 136 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 137 |
| 138 // Typing in the omnibox should show the overlay. |
| 139 SetOmniboxTextAndWaitForInstantToShow("santa"); |
| 140 EXPECT_TRUE(instant()->IsPreviewingSearchResults()); |
| 141 |
| 142 // Create an event listener that opens the top suggestion in a new tab. |
| 143 EXPECT_TRUE(ExecuteScript( |
| 144 "var rid = getApiHandle().nativeSuggestions[0].rid;" |
| 145 "document.body.addEventListener('click', function() {" |
| 146 "chrome.embeddedSearch.navigateContentWindow(rid, 2);" |
| 147 "});" |
| 148 )); |
| 149 |
| 150 content::WindowedNotificationObserver observer( |
| 151 chrome::NOTIFICATION_TAB_ADDED, |
| 152 content::NotificationService::AllSources()); |
| 153 |
| 154 // Click to trigger the event listener. |
| 155 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 156 |
| 157 // Wait for the new tab to be added. |
| 158 observer.Wait(); |
| 159 |
| 160 // Check that the new tab URL is as expected. |
| 161 content::WebContents* new_tab_contents = |
| 162 browser()->tab_strip_model()->GetWebContentsAt(1); |
| 163 EXPECT_EQ(new_tab_contents->GetURL().spec(), instant_url_.spec()+"q=santa"); |
| 164 |
| 165 // Check that there are now two tabs. |
| 166 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 167 } |
| 168 |
129 // TODO(sreeram): Enable this test once @mathp's CL lands: | 169 // TODO(sreeram): Enable this test once @mathp's CL lands: |
130 // https://codereview.chromium.org/12179025/ | 170 // https://codereview.chromium.org/12179025/ |
131 // | 171 // |
132 // Test that omnibox text is correctly set when overlay is committed with Enter. | 172 // Test that omnibox text is correctly set when overlay is committed with Enter. |
133 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 173 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
134 DISABLED_OmniboxTextUponEnterCommit) { | 174 DISABLED_OmniboxTextUponEnterCommit) { |
135 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 175 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
136 FocusOmniboxAndWaitForInstantSupport(); | 176 FocusOmniboxAndWaitForInstantSupport(); |
137 | 177 |
138 // The page will autocomplete once we set the omnibox value. | 178 // The page will autocomplete once we set the omnibox value. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 content::WebContents* active_tab = | 443 content::WebContents* active_tab = |
404 browser()->tab_strip_model()->GetActiveWebContents(); | 444 browser()->tab_strip_model()->GetActiveWebContents(); |
405 EXPECT_TRUE(instant_service->IsInstantProcess( | 445 EXPECT_TRUE(instant_service->IsInstantProcess( |
406 active_tab->GetRenderProcessHost()->GetID())); | 446 active_tab->GetRenderProcessHost()->GetID())); |
407 | 447 |
408 // Navigating elsewhere should not use the Instant render process. | 448 // Navigating elsewhere should not use the Instant render process. |
409 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); | 449 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); |
410 EXPECT_FALSE(instant_service->IsInstantProcess( | 450 EXPECT_FALSE(instant_service->IsInstantProcess( |
411 active_tab->GetRenderProcessHost()->GetID())); | 451 active_tab->GetRenderProcessHost()->GetID())); |
412 } | 452 } |
OLD | NEW |