OLD | NEW |
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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 }; | 130 }; |
131 } // namespace | 131 } // namespace |
132 | 132 |
133 class InstantExtendedTest : public InProcessBrowserTest, | 133 class InstantExtendedTest : public InProcessBrowserTest, |
134 public InstantTestBase { | 134 public InstantTestBase { |
135 public: | 135 public: |
136 InstantExtendedTest() | 136 InstantExtendedTest() |
137 : on_most_visited_change_calls_(0), | 137 : on_most_visited_change_calls_(0), |
138 most_visited_items_count_(0), | 138 most_visited_items_count_(0), |
139 first_most_visited_item_id_(0), | 139 first_most_visited_item_id_(0), |
140 on_native_suggestions_calls_(0), | |
141 on_change_calls_(0), | |
142 submit_count_(0), | 140 submit_count_(0), |
143 on_esc_key_press_event_calls_(0), | |
144 on_focus_changed_calls_(0), | 141 on_focus_changed_calls_(0), |
145 is_focused_(false) {} | 142 is_focused_(false) {} |
146 | 143 |
147 protected: | 144 protected: |
148 void SetUpInProcessBrowserTestFixture() override { | 145 void SetUpInProcessBrowserTestFixture() override { |
149 ASSERT_TRUE(https_test_server().Start()); | 146 ASSERT_TRUE(https_test_server().Start()); |
150 GURL instant_url = | 147 GURL instant_url = |
151 https_test_server().GetURL("/instant_extended.html?strk=1&"); | 148 https_test_server().GetURL("/instant_extended.html?strk=1&"); |
152 GURL ntp_url = | 149 GURL ntp_url = |
153 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); | 150 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); |
(...skipping 11 matching lines...) Expand all Loading... |
165 return histogram->SnapshotSamples()->TotalCount(); | 162 return histogram->SnapshotSamples()->TotalCount(); |
166 } | 163 } |
167 | 164 |
168 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { | 165 bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT { |
169 return GetIntFromJS(contents, "onMostVisitedChangedCalls", | 166 return GetIntFromJS(contents, "onMostVisitedChangedCalls", |
170 &on_most_visited_change_calls_) && | 167 &on_most_visited_change_calls_) && |
171 GetIntFromJS(contents, "mostVisitedItemsCount", | 168 GetIntFromJS(contents, "mostVisitedItemsCount", |
172 &most_visited_items_count_) && | 169 &most_visited_items_count_) && |
173 GetIntFromJS(contents, "firstMostVisitedItemId", | 170 GetIntFromJS(contents, "firstMostVisitedItemId", |
174 &first_most_visited_item_id_) && | 171 &first_most_visited_item_id_) && |
175 GetIntFromJS(contents, "onNativeSuggestionsCalls", | |
176 &on_native_suggestions_calls_) && | |
177 GetIntFromJS(contents, "onChangeCalls", | |
178 &on_change_calls_) && | |
179 GetIntFromJS(contents, "submitCount", | 172 GetIntFromJS(contents, "submitCount", |
180 &submit_count_) && | 173 &submit_count_) && |
181 GetStringFromJS(contents, "apiHandle.value", | 174 GetStringFromJS(contents, "apiHandle.value", |
182 &query_value_) && | 175 &query_value_) && |
183 GetIntFromJS(contents, "onEscKeyPressedCalls", | |
184 &on_esc_key_press_event_calls_) && | |
185 GetIntFromJS(contents, "onFocusChangedCalls", | 176 GetIntFromJS(contents, "onFocusChangedCalls", |
186 &on_focus_changed_calls_) && | 177 &on_focus_changed_calls_) && |
187 GetBoolFromJS(contents, "isFocused", | 178 GetBoolFromJS(contents, "isFocused", |
188 &is_focused_) && | 179 &is_focused_) && |
189 GetStringFromJS(contents, "prefetchQuery", &prefetch_query_value_); | 180 GetStringFromJS(contents, "prefetchQuery", &prefetch_query_value_); |
190 | |
191 } | 181 } |
192 | 182 |
193 TemplateURL* GetDefaultSearchProviderTemplateURL() { | 183 TemplateURL* GetDefaultSearchProviderTemplateURL() { |
194 TemplateURLService* template_url_service = | 184 TemplateURLService* template_url_service = |
195 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 185 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
196 if (template_url_service) | 186 if (template_url_service) |
197 return template_url_service->GetDefaultSearchProvider(); | 187 return template_url_service->GetDefaultSearchProvider(); |
198 return NULL; | 188 return NULL; |
199 } | 189 } |
200 | 190 |
(...skipping 30 matching lines...) Expand all Loading... |
231 } | 221 } |
232 | 222 |
233 int CountSearchProviderSuggestions() { | 223 int CountSearchProviderSuggestions() { |
234 return omnibox()->model()->autocomplete_controller()->search_provider()-> | 224 return omnibox()->model()->autocomplete_controller()->search_provider()-> |
235 matches().size(); | 225 matches().size(); |
236 } | 226 } |
237 | 227 |
238 int on_most_visited_change_calls_; | 228 int on_most_visited_change_calls_; |
239 int most_visited_items_count_; | 229 int most_visited_items_count_; |
240 int first_most_visited_item_id_; | 230 int first_most_visited_item_id_; |
241 int on_native_suggestions_calls_; | |
242 int on_change_calls_; | |
243 int submit_count_; | 231 int submit_count_; |
244 int on_esc_key_press_event_calls_; | |
245 std::string query_value_; | 232 std::string query_value_; |
246 int on_focus_changed_calls_; | 233 int on_focus_changed_calls_; |
247 bool is_focused_; | 234 bool is_focused_; |
248 std::string prefetch_query_value_; | 235 std::string prefetch_query_value_; |
249 }; | 236 }; |
250 | 237 |
251 class InstantExtendedPrefetchTest : public InstantExtendedTest { | 238 class InstantExtendedPrefetchTest : public InstantExtendedTest { |
252 public: | 239 public: |
253 InstantExtendedPrefetchTest() | 240 InstantExtendedPrefetchTest() |
254 : factory_(new net::URLFetcherImplFactory()), | 241 : factory_(new net::URLFetcherImplFactory()), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 browser()->tab_strip_model()->GetActiveWebContents(); | 559 browser()->tab_strip_model()->GetActiveWebContents(); |
573 EXPECT_TRUE(UpdateSearchState(active_tab)); | 560 EXPECT_TRUE(UpdateSearchState(active_tab)); |
574 EXPECT_EQ(1, on_most_visited_change_calls_); | 561 EXPECT_EQ(1, on_most_visited_change_calls_); |
575 | 562 |
576 content::WindowedNotificationObserver observer( | 563 content::WindowedNotificationObserver observer( |
577 content::NOTIFICATION_LOAD_STOP, | 564 content::NOTIFICATION_LOAD_STOP, |
578 content::NotificationService::AllSources()); | 565 content::NotificationService::AllSources()); |
579 // Set the text and press enter to navigate from NTP. | 566 // Set the text and press enter to navigate from NTP. |
580 SetOmniboxText("Pen"); | 567 SetOmniboxText("Pen"); |
581 PressEnterAndWaitForNavigation(); | 568 PressEnterAndWaitForNavigation(); |
582 EXPECT_EQ(ASCIIToUTF16("Pen"), omnibox()->GetText()); | |
583 observer.Wait(); | 569 observer.Wait(); |
584 | 570 |
585 // Navigate back to NTP. | 571 // Navigate back to NTP. |
586 content::WindowedNotificationObserver back_observer( | 572 content::WindowedNotificationObserver back_observer( |
587 content::NOTIFICATION_LOAD_STOP, | 573 content::NOTIFICATION_LOAD_STOP, |
588 content::NotificationService::AllSources()); | 574 content::NotificationService::AllSources()); |
589 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 575 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
590 EXPECT_TRUE(active_tab->GetController().CanGoBack()); | 576 EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
591 active_tab->GetController().GoBack(); | 577 active_tab->GetController().GoBack(); |
592 back_observer.Wait(); | 578 back_observer.Wait(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 stream << "link.href = \"" << result_url.spec() << "\";"; | 728 stream << "link.href = \"" << result_url.spec() << "\";"; |
743 stream << "document.body.appendChild(link);"; | 729 stream << "document.body.appendChild(link);"; |
744 stream << "link.click();"; | 730 stream << "link.click();"; |
745 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 731 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
746 | 732 |
747 content::WaitForLoadStop(contents); | 733 content::WaitForLoadStop(contents); |
748 std::string expected_title = | 734 std::string expected_title = |
749 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 735 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
750 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 736 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
751 } | 737 } |
OLD | NEW |