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

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

Issue 12114050: [Instant] Instant Extended tests for search term extraction. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cleaner Created 7 years, 10 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/instant/instant_commit_type.h"
5 #include "chrome/browser/instant/instant_loader.h" 6 #include "chrome/browser/instant/instant_loader.h"
6 #include "chrome/browser/instant/instant_test_utils.h" 7 #include "chrome/browser/instant/instant_test_utils.h"
7 #include "chrome/browser/ui/search/search.h" 8 #include "chrome/browser/ui/search/search.h"
9 #include "chrome/common/instant_types.h"
10 #include "chrome/common/search_types.h"
8 #include "chrome/test/base/interactive_test_utils.h" 11 #include "chrome/test/base/interactive_test_utils.h"
9 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
10 13
11 class InstantExtendedTest : public InstantTestBase { 14 class InstantExtendedTest : public InstantTestBase {
12 protected: 15 protected:
13 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 16 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
14 chrome::search::EnableInstantExtendedAPIForTesting(); 17 chrome::search::EnableInstantExtendedAPIForTesting();
15 ASSERT_TRUE(test_server()->Start()); 18 ASSERT_TRUE(https_test_server_->Start());
16 instant_url_ = test_server()->GetURL("files/instant_extended.html"); 19 instant_url_ = https_test_server_->
20 GetURL("files/instant_extended.html?espv=1");
17 } 21 }
18 }; 22 };
19 23
20 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { 24 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) {
21 ASSERT_NO_FATAL_FAILURE(SetupInstant()); 25 ASSERT_NO_FATAL_FAILURE(SetupInstant());
22 EXPECT_TRUE(instant()->extended_enabled_); 26 EXPECT_TRUE(instant()->extended_enabled_);
23 } 27 }
24 28
25 // Test that Instant is preloaded when the omnibox is focused. 29 // Test that Instant is preloaded when the omnibox is focused.
26 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { 30 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 content::WebContents* preview_tab = instant()->GetPreviewContents(); 77 content::WebContents* preview_tab = instant()->GetPreviewContents();
74 EXPECT_TRUE(preview_tab); 78 EXPECT_TRUE(preview_tab);
75 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); 79 EXPECT_FALSE(instant()->IsPreviewingSearchResults());
76 EXPECT_TRUE(instant()->model()->mode().is_default()); 80 EXPECT_TRUE(instant()->model()->mode().is_default());
77 81
78 // Typing in the omnibox should show the overlay. 82 // Typing in the omnibox should show the overlay.
79 SetOmniboxTextAndWaitForInstantToShow("query"); 83 SetOmniboxTextAndWaitForInstantToShow("query");
80 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); 84 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
81 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); 85 EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
82 } 86 }
87
88 // Test that omnibox text is correctly set when overlay is committed with Enter.
89 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) {
90 ASSERT_NO_FATAL_FAILURE(SetupInstant());
91 FocusOmniboxAndWaitForInstantSupport();
92
93 // Set the text, and wait for suggestions to show up.
94 SetOmniboxTextAndWaitForInstantToShow("santa");
95 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText());
96
97 // Set autocomplete text (grey text).
98 EXPECT_TRUE(ExecuteScript(
99 "window.chrome.searchBox.setAutocompleteText('santa claus', 2)"));
100
101 // Make the InstantController think we are in Search Suggestions.
102 chrome::search::Mode mode;
103 mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS;
104 instant()->model()->SetPreviewState(mode, 100, INSTANT_SIZE_PERCENT);
sreeram 2013/02/01 22:03:24 These lines (98-104) are hacking the public APIs t
Mathieu 2013/02/04 20:37:36 Done.
105
106 // Commit the overlay by pressing 'Enter'.
107 instant()->CommitIfPossible(INSTANT_COMMIT_PRESSED_ENTER);
108
109 // 'Enter' commits the query as it was typed.
110 EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText());
sreeram 2013/02/01 22:03:24 You should check that omnibox()->GetInstantSuggest
Mathieu 2013/02/04 20:37:36 Done.
111 }
112
113 // Test that omnibox text is correctly set when overlay is committed with focus
114 // lost.
115 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) {
116 ASSERT_NO_FATAL_FAILURE(SetupInstant());
117 FocusOmniboxAndWaitForInstantSupport();
118
119 // Set the text, and wait for suggestions to show up.
120 SetOmniboxTextAndWaitForInstantToShow("johnny");
121 EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText());
122
123 // Set autocomplete text (grey text).
124 EXPECT_TRUE(ExecuteScript(
125 "window.chrome.searchBox.setAutocompleteText('johnny depp', 2)"));
126
127 // Make the InstantController think we are in Search Suggestions.
128 chrome::search::Mode mode;
129 mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS;
130 instant()->model()->SetPreviewState(mode, 100, INSTANT_SIZE_PERCENT);
131
132 // Commit the overlay by lost focus (e.g. clicking on the page).
133 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST);
134
135 // Search term extraction should kick in with the autocompleted text.
136 EXPECT_EQ(ASCIIToUTF16("johnny depp"), omnibox()->GetText());
137 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_test_utils.h » ('j') | chrome/browser/instant/instant_test_utils.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698