Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f5cc3921da5f5a7a6d4da6dd221fec104f90ea05 |
| --- /dev/null |
| +++ b/chrome/browser/instant/instant_extended_browsertest.cc |
| @@ -0,0 +1,80 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
|
sreeram
2013/01/17 23:54:18
2012 -> 2013.
samarth
2013/01/18 00:06:45
Done.
|
| +// 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_test_utils.h" |
| +#include "chrome/browser/ui/search/search.h" |
| + |
| +class InstantExtendedTest : public InstantTestBase { |
| + protected: |
| + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| + chrome::search::EnableInstantExtendedAPIForTesting(); |
| + ASSERT_TRUE(test_server()->Start()); |
| + instant_url_ = test_server()->GetURL("files/instant_extended.html"); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + EXPECT_TRUE(instant()->extended_enabled_); |
| +} |
| + |
| +// Test that Instant is preloaded when the omnibox is focused. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + |
| + // Explicitly unfocus the omnibox. |
| + EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| + ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| + |
| + EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| + EXPECT_FALSE(omnibox()->model()->has_focus()); |
| + |
| + // Delete any existing preview. |
| + instant()->loader_.reset(); |
| + EXPECT_FALSE(instant()->GetPreviewContents()); |
| + |
| + // Refocus the omnibox. The InstantController should've preloaded Instant. |
| + FocusOmniboxAndWaitForInstantSupport(); |
| + |
| + EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| + EXPECT_TRUE(omnibox()->model()->has_focus()); |
| + |
| + content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| + EXPECT_TRUE(preview_tab); |
| + |
| + // Check that the page supports Instant, but it isn't showing. |
| + EXPECT_TRUE(instant()->loader_->supports_instant()); |
| + EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| + EXPECT_TRUE(instant()->model()->mode().is_default()); |
| + |
| + // Adding a new tab shouldn't delete or recreate the preview; otherwise, |
| + // what's the point of preloading? |
| + AddBlankTabAndShow(browser()); |
| + EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| + |
| + // Unfocusing and refocusing the omnibox should also preserve the preview. |
| + ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| + EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| + |
| + FocusOmnibox(); |
| + EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); |
| + EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + |
| + // Focus omnibox and confirm overlay isn't shown. |
| + FocusOmniboxAndWaitForInstantSupport(); |
| + content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| + EXPECT_TRUE(preview_tab); |
| + EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| + EXPECT_TRUE(instant()->model()->mode().is_default()); |
| + |
| + // Typing in the omnibox should show the overlay. |
| + SetOmniboxTextAndWaitForInstantToShow("query"); |
| + EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| + EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| +} |