| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 EXPECT_TRUE(overlay); | 308 EXPECT_TRUE(overlay); |
| 309 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); | 309 EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| 310 EXPECT_TRUE(instant()->model()->mode().is_default()); | 310 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 311 | 311 |
| 312 // Typing in the omnibox should show the overlay. | 312 // Typing in the omnibox should show the overlay. |
| 313 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); | 313 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 314 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 314 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 315 EXPECT_EQ(overlay, instant()->GetOverlayContents()); | 315 EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| 316 } | 316 } |
| 317 | 317 |
| 318 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, UsesOverlayIfTabNotReady) { |
| 319 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 320 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 321 |
| 322 // Open a new tab and start typing before InstantTab is properly hooked up. |
| 323 // Should use the overlay. |
| 324 ui_test_utils::NavigateToURLWithDisposition(browser(), |
| 325 GURL(chrome::kChromeUINewTabURL), |
| 326 NEW_FOREGROUND_TAB, |
| 327 ui_test_utils::BROWSER_TEST_NONE); |
| 328 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); |
| 329 |
| 330 // But Instant tab should still exist. |
| 331 ASSERT_NE(static_cast<InstantTab*>(NULL), instant()->instant_tab()); |
| 332 EXPECT_FALSE(instant()->UseTabForSuggestions()); |
| 333 |
| 334 // Wait for Instant Tab support if it still hasn't finished loading. |
| 335 if (!instant()->instant_tab()->supports_instant()) { |
| 336 content::WindowedNotificationObserver instant_tab_observer( |
| 337 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| 338 content::NotificationService::AllSources()); |
| 339 instant_tab_observer.Wait(); |
| 340 } |
| 341 |
| 342 // Hide the overlay. Now, we should be using Instant tab for suggestions. |
| 343 instant()->HideOverlay(); |
| 344 EXPECT_TRUE(instant()->UseTabForSuggestions()); |
| 345 } |
| 346 |
| 318 // Test that middle clicking on a suggestion opens the result in a new tab. | 347 // Test that middle clicking on a suggestion opens the result in a new tab. |
| 319 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 348 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| 320 MiddleClickOnSuggestionOpensInNewTab) { | 349 MiddleClickOnSuggestionOpensInNewTab) { |
| 321 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 350 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 322 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | 351 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| 323 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 352 EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 324 | 353 |
| 325 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 354 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 326 | 355 |
| 327 // Typing in the omnibox should show the overlay. | 356 // Typing in the omnibox should show the overlay. |
| (...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 ASSERT_TRUE(AddSearchToHistory(ASCIIToUTF16("query"), 10000)); | 2307 ASSERT_TRUE(AddSearchToHistory(ASCIIToUTF16("query"), 10000)); |
| 2279 BlockUntilHistoryProcessesPendingRequests(); | 2308 BlockUntilHistoryProcessesPendingRequests(); |
| 2280 | 2309 |
| 2281 SetOmniboxText("quer"); | 2310 SetOmniboxText("quer"); |
| 2282 | 2311 |
| 2283 // Should get 2 suggestions from SearchProvider: | 2312 // Should get 2 suggestions from SearchProvider: |
| 2284 // - SWYT for "quer" | 2313 // - SWYT for "quer" |
| 2285 // - Search history suggestion for "query" | 2314 // - Search history suggestion for "query" |
| 2286 EXPECT_EQ(2, CountSearchProviderSuggestions()); | 2315 EXPECT_EQ(2, CountSearchProviderSuggestions()); |
| 2287 } | 2316 } |
| OLD | NEW |