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

Unified Diff: chrome/browser/instant/instant_extended_browsertest.cc

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_extended_browsertest.cc
diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc
index 08f8b4d094579c90ea12e3e047faf8820e4c4b55..48a1a5b7c9ba86e93464d0891bf42474e5d6d92f 100644
--- a/chrome/browser/instant/instant_extended_browsertest.cc
+++ b/chrome/browser/instant/instant_extended_browsertest.cc
@@ -2,11 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/instant/instant_loader.h"
+#include "chrome/browser/instant/instant_ntp.h"
+#include "chrome/browser/instant/instant_overlay.h"
+#include "chrome/browser/instant/instant_service.h"
+#include "chrome/browser/instant/instant_service_factory.h"
#include "chrome/browser/instant/instant_test_utils.h"
#include "chrome/browser/ui/search/search.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/url_constants.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
class InstantExtendedTest : public InstantTestBase {
protected:
@@ -34,7 +41,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
EXPECT_FALSE(omnibox()->model()->has_focus());
// Delete any existing preview.
- instant()->loader_.reset();
+ instant()->overlay_.reset();
EXPECT_FALSE(instant()->GetPreviewContents());
// Refocus the omnibox. The InstantController should've preloaded Instant.
@@ -47,7 +54,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
EXPECT_TRUE(preview_tab);
// Check that the page supports Instant, but it isn't showing.
- EXPECT_TRUE(instant()->loader_->supports_instant());
+ EXPECT_TRUE(instant()->overlay_->supports_instant());
EXPECT_FALSE(instant()->IsPreviewingSearchResults());
EXPECT_TRUE(instant()->model()->mode().is_default());
@@ -80,3 +87,155 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) {
EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) {
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ // NTP contents should be preloaded.
+ EXPECT_TRUE(instant()->ntp_.get());
dhollowa 2013/01/29 02:37:53 ASSERT_NE(static_cast<InstantNTP>(NULL), instant()
samarth 2013/01/29 05:42:01 Done.
+ content::WebContents* ntp_contents = instant()->ntp_->contents();
+ EXPECT_TRUE(ntp_contents);
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) {
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ // NTP contents should be preloaded.
+ EXPECT_TRUE(instant()->ntp_.get());
dhollowa 2013/01/29 02:37:53 ASSERT_NE(static_cast<InstantNTP>(NULL), ...
samarth 2013/01/29 05:42:01 Done.
+ content::WebContents* ntp_contents = instant()->ntp_->contents();
+ EXPECT_TRUE(ntp_contents);
+
+ // Open new tab. Preloaded NTP contents should have been used.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
+ content::WebContents* active_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_EQ(ntp_contents, active_tab);
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) {
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ // NTP contents should be preloaded.
+ EXPECT_TRUE(instant()->ntp_.get());
dhollowa 2013/01/29 02:37:53 ASSERT_NE(static_cast<InstantNTP>(NULL), ...
samarth 2013/01/29 05:42:01 Done.
+ content::WebContents* ntp_contents = instant()->ntp_->contents();
+ EXPECT_TRUE(ntp_contents);
+
+ // Open new tab. Preloaded NTP contents should have been used.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_NONE);
+ content::WebContents* active_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_EQ(ntp_contents, active_tab);
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) {
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ // Explicitly unfocus the omnibox.
+ EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ EXPECT_FALSE(omnibox()->model()->has_focus());
+
+ // Open new tab. Preloaded NTP contents should have been used.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
+
+ // Omnibox should have focus.
+ EXPECT_TRUE(omnibox()->model()->has_focus());
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) {
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ // Open new tab. Preloaded NTP contents should have been used.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_NONE);
+
+ // Omnibox should be empty.
+ EXPECT_TRUE(omnibox()->GetText().empty());
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+
+ // Focus omnibox and confirm overlay isn't shown.
+ FocusOmniboxAndWaitForInstantSupport();
+ content::WebContents* preview_tab = instant()->GetPreviewContents();
+ EXPECT_TRUE(preview_tab);
dhollowa 2013/01/29 02:37:53 ASSERT_NE(static_cast<InstantNTP>(NULL), ...? Wil
samarth 2013/01/29 05:42:01 No, it won't.
+ EXPECT_FALSE(instant()->IsPreviewingSearchResults());
+ EXPECT_TRUE(instant()->model()->mode().is_default());
+
+ // Navigate to the NTP.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_NONE);
+
+ // Typing in the omnibox should not show the overlay.
+ SetOmniboxText("query");
+ EXPECT_FALSE(instant()->IsPreviewingSearchResults());
+ EXPECT_TRUE(instant()->model()->mode().is_default());
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
+ // Prior to setup no render process is dedicated to Instant.
+ InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(browser()->profile());
+ ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
+ EXPECT_EQ(0, instant_service->GetInstantProcessCount());
+
+ // Setup Instant.
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
dhollowa 2013/01/29 02:37:53 As we discussed, this is most likely racey because
samarth 2013/01/29 05:42:01 Done.
+
+ // Now there should be a registered Instant render process.
+ EXPECT_LT(0, instant_service->GetInstantProcessCount());
+
+ // And the Instant overlay and ntp should live inside it.
+ content::WebContents* preview = instant()->GetPreviewContents();
+ EXPECT_TRUE(instant_service->IsInstantProcess(
+ preview->GetRenderProcessHost()->GetID()));
+ content::WebContents* ntp_contents = instant()->ntp_->contents();
+ EXPECT_TRUE(instant_service->IsInstantProcess(
+ ntp_contents->GetRenderProcessHost()->GetID()));
+
+ // Navigating to the NTP should use the Instant render process.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(chrome::kChromeUINewTabURL),
+ CURRENT_TAB,
+ ui_test_utils::BROWSER_TEST_NONE);
+ content::WebContents* active_tab =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ EXPECT_TRUE(instant_service->IsInstantProcess(
+ active_tab->GetRenderProcessHost()->GetID()));
+
+ // Navigating elsewhere should not use the Instant render process.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
+ EXPECT_FALSE(instant_service->IsInstantProcess(
+ active_tab->GetRenderProcessHost()->GetID()));
+}

Powered by Google App Engine
This is Rietveld 408576698