OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/instant/instant_loader.h" | |
6 #include "chrome/browser/instant/instant_test_utils.h" | |
7 #include "chrome/browser/ui/search/search.h" | |
8 | |
9 class InstantExtendedTest : public InstantTestBase { | |
10 protected: | |
11 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
12 chrome::search::EnableInstantExtendedAPIForTesting(); | |
13 ASSERT_TRUE(test_server()->Start()); | |
14 instant_url_ = test_server()->GetURL("files/instant_extended.html"); | |
15 } | |
16 }; | |
17 | |
18 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { | |
19 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | |
20 EXPECT_TRUE(instant()->extended_enabled_); | |
21 } | |
22 | |
23 // Test that Instant is preloaded when the omnibox is focused. | |
24 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { | |
25 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | |
26 | |
27 // Explicitly unfocus the omnibox. | |
28 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | |
29 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | |
30 | |
31 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
32 EXPECT_FALSE(omnibox()->model()->has_focus()); | |
33 | |
34 // Delete any existing preview. | |
35 instant()->loader_.reset(); | |
36 EXPECT_FALSE(instant()->GetPreviewContents()); | |
37 | |
38 // Refocus the omnibox. The InstantController should've preloaded Instant. | |
39 FocusOmniboxAndWaitForInstantSupport(); | |
40 | |
41 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
42 EXPECT_TRUE(omnibox()->model()->has_focus()); | |
43 | |
44 content::WebContents* preview_tab = instant()->GetPreviewContents(); | |
45 EXPECT_TRUE(preview_tab); | |
46 | |
47 // Check that the page supports Instant, but it isn't showing. | |
48 EXPECT_TRUE(instant()->loader_->supports_instant()); | |
49 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | |
50 EXPECT_TRUE(instant()->model()->mode().is_default()); | |
51 | |
52 // Adding a new tab shouldn't delete or recreate the preview; otherwise, | |
53 // what's the point of preloading? | |
54 AddBlankTabAndShow(browser()); | |
55 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | |
56 | |
57 // Unfocusing and refocusing the omnibox should also preserve the preview. | |
58 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | |
59 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
60 | |
61 FocusOmnibox(); | |
62 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER)); | |
63 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | |
64 } | |
65 | |
66 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { | |
67 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | |
68 | |
69 // Focus omnibox and confirm overlay isn't shown. | |
70 FocusOmniboxAndWaitForInstantSupport(); | |
71 content::WebContents* preview_tab = instant()->GetPreviewContents(); | |
72 EXPECT_TRUE(preview_tab); | |
73 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | |
74 EXPECT_TRUE(instant()->model()->mode().is_default()); | |
75 | |
76 // Typing in the omnibox should show the overlay. | |
77 SetOmniboxTextAndWaitForInstantToShow("query"); | |
78 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | |
79 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | |
80 } | |
OLD | NEW |