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..48aa21c2d12e1893765bf924713de04557e15926 |
| --- /dev/null |
| +++ b/chrome/browser/instant/instant_extended_browsertest.cc |
| @@ -0,0 +1,81 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
| +// 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, InputShowsDropdown) { |
|
sreeram
2013/01/08 01:10:08
Nit: dropdown -> overlay (or preview), here and be
samarth
2013/01/14 23:59:59
Done.
|
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + |
| + // Focus omnibox and confirm dropdown 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 dropdown. |
| + SetOmniboxTextAndWaitForInstantToShow("query"); |
| + EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| + EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| +} |