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

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

Issue 11592004: InstantExtended: tests! (Closed) Base URL: http://git.chromium.org/chromium/src.git@fixmyterms
Patch Set: Dont have a testing mode. 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
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
67 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.
68 ASSERT_NO_FATAL_FAILURE(SetupInstant());
69
70 // Focus omnibox and confirm dropdown isn't shown.
71 FocusOmniboxAndWaitForInstantSupport();
72 content::WebContents* preview_tab = instant()->GetPreviewContents();
73 EXPECT_TRUE(preview_tab);
74 EXPECT_FALSE(instant()->IsPreviewingSearchResults());
75 EXPECT_TRUE(instant()->model()->mode().is_default());
76
77 // Typing in the omnibox should show the dropdown.
78 SetOmniboxTextAndWaitForInstantToShow("query");
79 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
80 EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698