| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 9 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #define MAYBE(TestName) TestName | 45 #define MAYBE(TestName) TestName |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 class InstantTest : public InProcessBrowserTest { | 48 class InstantTest : public InProcessBrowserTest { |
| 49 public: | 49 public: |
| 50 InstantTest() { | 50 InstantTest() { |
| 51 EnableDOMAutomation(); | 51 EnableDOMAutomation(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void EnableInstant() { | 54 void EnableInstant() { |
| 55 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 56 switches::kInstantFieldTrial, switches::kInstantFieldTrialInstant); |
| 55 InstantController::Enable(browser()->profile()); | 57 InstantController::Enable(browser()->profile()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void SetupInstantProvider(const std::string& page) { | 60 void SetupInstantProvider(const std::string& page) { |
| 59 Profile* profile = browser()->profile(); | 61 Profile* profile = browser()->profile(); |
| 60 TemplateURLService* model = | 62 TemplateURLService* model = |
| 61 TemplateURLServiceFactory::GetForProfile(profile); | 63 TemplateURLServiceFactory::GetForProfile(profile); |
| 62 | 64 |
| 63 ui_test_utils::WindowedNotificationObserver observer( | 65 ui_test_utils::WindowedNotificationObserver observer( |
| 64 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 66 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 } | 726 } |
| 725 | 727 |
| 726 // Tests that instant search is preloaded whenever the omnibox gets focus. | 728 // Tests that instant search is preloaded whenever the omnibox gets focus. |
| 727 // PreloadsInstant fails on linux_chromeos trybots all the time, possibly | 729 // PreloadsInstant fails on linux_chromeos trybots all the time, possibly |
| 728 // because of http://crbug.com/80118. | 730 // because of http://crbug.com/80118. |
| 729 #if defined(OS_CHROMEOS) | 731 #if defined(OS_CHROMEOS) |
| 730 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_PreloadsInstant) { | 732 IN_PROC_BROWSER_TEST_F(InstantTest, DISABLED_PreloadsInstant) { |
| 731 #else | 733 #else |
| 732 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(PreloadsInstant)) { | 734 IN_PROC_BROWSER_TEST_F(InstantTest, MAYBE(PreloadsInstant)) { |
| 733 #endif | 735 #endif |
| 734 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 735 switches::kPreloadInstantSearch); | |
| 736 ASSERT_TRUE(test_server()->Start()); | 736 ASSERT_TRUE(test_server()->Start()); |
| 737 EnableInstant(); | 737 EnableInstant(); |
| 738 SetupInstantProvider("instant.html"); | 738 SetupInstantProvider("instant.html"); |
| 739 | 739 |
| 740 // The omnibox gets focus before the test begins. At that time, there was no | 740 // The omnibox gets focus before the test begins. At that time, there was no |
| 741 // instant controller (which was only created after EnableInstant()), so no | 741 // instant controller (which was only created after EnableInstant()), so no |
| 742 // preloading happened. Unfocus the omnibox with ClickOnView(), so that when | 742 // preloading happened. Unfocus the omnibox with ClickOnView(), so that when |
| 743 // we focus it again, the controller will preload instant search. | 743 // we focus it again, the controller will preload instant search. |
| 744 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 744 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 745 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); | 745 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 // Press <Enter> in the omnibox, causing the preview to be committed. | 1003 // Press <Enter> in the omnibox, causing the preview to be committed. |
| 1004 WebContents* preview_tab = preview()->web_contents(); | 1004 WebContents* preview_tab = preview()->web_contents(); |
| 1005 ASSERT_TRUE(PressEnter()); | 1005 ASSERT_TRUE(PressEnter()); |
| 1006 | 1006 |
| 1007 // The preview contents should now be the active tab contents. | 1007 // The preview contents should now be the active tab contents. |
| 1008 EXPECT_FALSE(preview()); | 1008 EXPECT_FALSE(preview()); |
| 1009 EXPECT_FALSE(instant()->is_displayable()); | 1009 EXPECT_FALSE(instant()->is_displayable()); |
| 1010 EXPECT_FALSE(instant()->IsCurrent()); | 1010 EXPECT_FALSE(instant()->IsCurrent()); |
| 1011 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); | 1011 EXPECT_EQ(preview_tab, browser()->GetSelectedWebContents()); |
| 1012 } | 1012 } |
| OLD | NEW |