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

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

Issue 11644009: Added support for passing WindowOpenDisposition into BrowserInstantController::OpenURL() from the o… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/ui/search/search.h" 11 #include "chrome/browser/ui/search/search.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "chrome/test/base/interactive_test_utils.h" 15 #include "chrome/test/base/interactive_test_utils.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 #include "content/public/browser/web_contents.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
sreeram 2013/02/20 22:53:32 Delete lines 20 and 21 (unnecessary blank line and
dougw 2013/02/20 23:35:11 Done.
23
21 class InstantExtendedTest : public InstantTestBase { 24 class InstantExtendedTest : public InstantTestBase {
22 protected: 25 protected:
23 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 26 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
24 chrome::search::EnableInstantExtendedAPIForTesting(); 27 chrome::search::EnableInstantExtendedAPIForTesting();
25 ASSERT_TRUE(https_test_server_.Start()); 28 ASSERT_TRUE(https_test_server_.Start());
26 instant_url_ = https_test_server_. 29 instant_url_ = https_test_server_.
27 GetURL("files/instant_extended.html?strk=1&"); 30 GetURL("files/instant_extended.html?strk=1&");
28 } 31 }
29 32
30 void FocusOmniboxAndWaitForInstantSupport() { 33 void FocusOmniboxAndWaitForInstantSupport() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 69 ASSERT_NO_FATAL_FAILURE(SetupInstant());
67 EXPECT_TRUE(instant()->extended_enabled_); 70 EXPECT_TRUE(instant()->extended_enabled_);
68 } 71 }
69 72
70 // Test that Instant is preloaded when the omnibox is focused. 73 // Test that Instant is preloaded when the omnibox is focused.
71 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { 74 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
72 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 75 ASSERT_NO_FATAL_FAILURE(SetupInstant());
73 76
74 // Explicitly unfocus the omnibox. 77 // Explicitly unfocus the omnibox.
75 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 78 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
76 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); 79 ui_test_utils::ClickOnView(browser(),
80 VIEW_ID_TAB_CONTAINER);
sreeram 2013/02/20 22:53:32 Revert this change.
dougw 2013/02/20 23:35:11 Done.
77 81
78 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); 82 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
79 EXPECT_FALSE(omnibox()->model()->has_focus()); 83 EXPECT_FALSE(omnibox()->model()->has_focus());
80 84
81 // Delete any existing preview. 85 // Delete any existing preview.
82 instant()->overlay_.reset(); 86 instant()->overlay_.reset();
83 EXPECT_FALSE(instant()->GetPreviewContents()); 87 EXPECT_FALSE(instant()->GetPreviewContents());
84 88
85 // Refocus the omnibox. The InstantController should've preloaded Instant. 89 // Refocus the omnibox. The InstantController should've preloaded Instant.
86 FocusOmniboxAndWaitForInstantSupport(); 90 FocusOmniboxAndWaitForInstantSupport();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXPECT_TRUE(preview_tab); 123 EXPECT_TRUE(preview_tab);
120 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); 124 EXPECT_FALSE(instant()->IsPreviewingSearchResults());
121 EXPECT_TRUE(instant()->model()->mode().is_default()); 125 EXPECT_TRUE(instant()->model()->mode().is_default());
122 126
123 // Typing in the omnibox should show the overlay. 127 // Typing in the omnibox should show the overlay.
124 SetOmniboxTextAndWaitForInstantToShow("query"); 128 SetOmniboxTextAndWaitForInstantToShow("query");
125 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 129 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
126 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); 130 EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
127 } 131 }
128 132
133 // Test that middle clicking on a suggestion opens the result in a new tab.
134 IN_PROC_BROWSER_TEST_F(
135 InstantExtendedTest, MiddleClickOnSuggestionOpensInNewTab) {
sreeram 2013/02/20 22:53:32 Reformat like so: ...(InstantExtendedTest, Mid
dougw 2013/02/20 23:35:11 Done.
136 ASSERT_NO_FATAL_FAILURE(SetupInstant());
137 FocusOmniboxAndWaitForInstantSupport();
138 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
139
140 EXPECT_EQ(1, browser()->tab_strip_model()->count());
141
142 // Typing in the omnibox should show the overlay.
143 SetOmniboxTextAndWaitForInstantToShow("santa");
144 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
145
146 // Create an event listener that opens the top suggestion in a new tab.
147 EXPECT_TRUE(ExecuteScript(
148 "var nativeSuggestions = getApiHandle().nativeSuggestions;"
149 "var rid = nativeSuggestions[0].rid;"
150 "document.body.addEventListener(\"click\", function() {"
151 "if (nativeSuggestions.length > 0) {"
sreeram 2013/02/20 22:53:32 Why are you testing for nativeSuggestions here? Yo
dougw 2013/02/20 23:35:11 Done. That's a cached copy of nativeSuggestions -
152 "chrome.embeddedSearch.navigateContentWindow("
153 "rid, 2);}});"
sreeram 2013/02/20 22:53:32 The indentation of this code block (within the str
dougw 2013/02/20 23:35:11 Done. On 2013/02/20 22:53:32, sreeram wrote:
154 ));
155
156 EXPECT_EQ(100, instant()->model()->height());
157 EXPECT_EQ(INSTANT_SIZE_PERCENT, instant()->model()->height_units());
158 EXPECT_TRUE(instant()->IsPreviewingSearchResults());
sreeram 2013/02/20 22:53:32 No need for these expectations. Perhaps just delet
dougw 2013/02/20 23:35:11 Done.
159
160 content::WindowedNotificationObserver observer(
161 chrome::NOTIFICATION_TAB_ADDED,
162 content::NotificationService::AllSources());
163
164 // Click to trigger the event listener.
165 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
166
167 // Wait for the new tab to be added.
168 observer.Wait();
169
170 // Check that the new tab url is as expected.
sreeram 2013/02/20 22:53:32 url -> URL
dougw 2013/02/20 23:35:11 Done.
171 content::WebContents* newTabContents =
sreeram 2013/02/20 22:53:32 newTabContents -> new_tab_contents
dougw 2013/02/20 23:35:11 Done.
172 browser()->tab_strip_model()->GetWebContentsAt(1);
173 EXPECT_EQ(newTabContents->GetURL().possibly_invalid_spec(),
174 instant_url_.possibly_invalid_spec()+"q=santa");
sreeram 2013/02/20 22:53:32 I think you can just use ".spec()" here, since we
dougw 2013/02/20 23:35:11 Done.
175
176 // Check that there are now two tabs.
177 EXPECT_EQ(2, browser()->tab_strip_model()->count());
178 }
179
129 // TODO(sreeram): Enable this test once @mathp's CL lands: 180 // TODO(sreeram): Enable this test once @mathp's CL lands:
130 // https://codereview.chromium.org/12179025/ 181 // https://codereview.chromium.org/12179025/
131 // 182 //
132 // Test that omnibox text is correctly set when overlay is committed with Enter. 183 // Test that omnibox text is correctly set when overlay is committed with Enter.
133 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 184 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
134 DISABLED_OmniboxTextUponEnterCommit) { 185 DISABLED_OmniboxTextUponEnterCommit) {
135 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 186 ASSERT_NO_FATAL_FAILURE(SetupInstant());
136 FocusOmniboxAndWaitForInstantSupport(); 187 FocusOmniboxAndWaitForInstantSupport();
137 188
138 // The page will autocomplete once we set the omnibox value. 189 // The page will autocomplete once we set the omnibox value.
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 content::WebContents* active_tab = 454 content::WebContents* active_tab =
404 browser()->tab_strip_model()->GetActiveWebContents(); 455 browser()->tab_strip_model()->GetActiveWebContents();
405 EXPECT_TRUE(instant_service->IsInstantProcess( 456 EXPECT_TRUE(instant_service->IsInstantProcess(
406 active_tab->GetRenderProcessHost()->GetID())); 457 active_tab->GetRenderProcessHost()->GetID()));
407 458
408 // Navigating elsewhere should not use the Instant render process. 459 // Navigating elsewhere should not use the Instant render process.
409 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 460 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
410 EXPECT_FALSE(instant_service->IsInstantProcess( 461 EXPECT_FALSE(instant_service->IsInstantProcess(
411 active_tab->GetRenderProcessHost()->GetID())); 462 active_tab->GetRenderProcessHost()->GetID()));
412 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698