| 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 "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.h" |
| 9 #include "chrome/browser/ui/search/instant_test_utils.h" | 9 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 24 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 25 ASSERT_TRUE(https_test_server().Start()); | 25 ASSERT_TRUE(https_test_server().Start()); |
| 26 GURL instant_url = https_test_server().GetURL( | 26 GURL instant_url = https_test_server().GetURL( |
| 27 "files/instant_extended.html?strk=1&"); | 27 "files/instant_extended.html?strk=1&"); |
| 28 GURL ntp_url = https_test_server().GetURL( | 28 GURL ntp_url = https_test_server().GetURL( |
| 29 "files/local_ntp_browsertest.html?strk=1&"); | 29 "files/local_ntp_browsertest.html?strk=1&"); |
| 30 InstantTestBase::Init(instant_url, ntp_url, false); | 30 InstantTestBase::Init(instant_url, ntp_url, false); |
| 31 } | 31 } |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // Flaky: crbug.com/267117 | 34 IN_PROC_BROWSER_TEST_F(LocalNTPTest, LocalNTPJavascriptTest) { |
| 35 IN_PROC_BROWSER_TEST_F(LocalNTPTest, DISABLED_LocalNTPJavascriptTest) { | |
| 36 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 35 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 37 FocusOmnibox(); | 36 FocusOmnibox(); |
| 38 | 37 |
| 39 ui_test_utils::NavigateToURLWithDisposition( | 38 ui_test_utils::NavigateToURLWithDisposition( |
| 40 browser(), | 39 browser(), |
| 41 instant_url(), | 40 ntp_url(), |
| 42 NEW_FOREGROUND_TAB, | 41 NEW_FOREGROUND_TAB, |
| 43 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 42 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | |
| 44 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 43 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 45 content::WebContents* active_tab = | 44 content::WebContents* active_tab = |
| 46 browser()->tab_strip_model()->GetActiveWebContents(); | 45 browser()->tab_strip_model()->GetActiveWebContents(); |
| 47 ASSERT_TRUE(chrome::IsInstantNTP(active_tab)); | 46 ASSERT_TRUE(chrome::IsInstantNTP(active_tab)); |
| 48 bool success = false; | 47 bool success = false; |
| 49 ASSERT_TRUE(GetBoolFromJS(active_tab, "!!runTests()", &success)); | 48 ASSERT_TRUE(GetBoolFromJS(active_tab, "!!runTests()", &success)); |
| 50 EXPECT_TRUE(success); | 49 EXPECT_TRUE(success); |
| 51 } | 50 } |
| 52 | 51 |
| 53 // Flaky. | |
| 54 IN_PROC_BROWSER_TEST_F(LocalNTPTest, | 52 IN_PROC_BROWSER_TEST_F(LocalNTPTest, |
| 55 DISABLED_NTPRespectsBrowserLanguageSetting) { | 53 NTPRespectsBrowserLanguageSetting) { |
| 56 // Make sure the default language is not French. | 54 // Make sure the default language is not French. |
| 57 std::string default_locale = g_browser_process->GetApplicationLocale(); | 55 std::string default_locale = g_browser_process->GetApplicationLocale(); |
| 58 EXPECT_NE("fr", default_locale); | 56 EXPECT_NE("fr", default_locale); |
| 59 | 57 |
| 60 // Switch browser language to French. | 58 // Switch browser language to French. |
| 61 std::string loaded_locale = | 59 std::string loaded_locale = |
| 62 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); | 60 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); |
| 63 EXPECT_EQ("fr", loaded_locale); | 61 |
| 62 // The platform cannot load the French locale (GetApplicationLocale() is |
| 63 // platform specific, and has been observed to fail on a small number of |
| 64 // platforms). Abort the test. |
| 65 if (loaded_locale != "fr") |
| 66 return; |
| 67 |
| 64 g_browser_process->SetApplicationLocale(loaded_locale); | 68 g_browser_process->SetApplicationLocale(loaded_locale); |
| 65 PrefService* prefs = g_browser_process->local_state(); | 69 PrefService* prefs = g_browser_process->local_state(); |
| 66 prefs->SetString(prefs::kApplicationLocale, loaded_locale); | 70 prefs->SetString(prefs::kApplicationLocale, loaded_locale); |
| 67 | 71 |
| 68 // Setup Instant. | 72 // Setup Instant. |
| 69 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 73 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 70 FocusOmnibox(); | 74 FocusOmnibox(); |
| 71 | 75 |
| 72 // Open a new tab. | 76 // Open a new tab. |
| 73 ui_test_utils::NavigateToURLWithDisposition( | 77 ui_test_utils::NavigateToURLWithDisposition( |
| 74 browser(), | 78 browser(), |
| 75 GURL(chrome::kChromeUINewTabURL), | 79 GURL(chrome::kChromeUINewTabURL), |
| 76 NEW_FOREGROUND_TAB, | 80 NEW_FOREGROUND_TAB, |
| 77 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 81 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | |
| 78 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 82 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 79 | 83 |
| 80 // Verify that the NTP is in French. | 84 // Verify that the NTP is in French. |
| 81 content::WebContents* active_tab = | 85 content::WebContents* active_tab = |
| 82 browser()->tab_strip_model()->GetActiveWebContents(); | 86 browser()->tab_strip_model()->GetActiveWebContents(); |
| 83 EXPECT_EQ(base::ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle()); | 87 EXPECT_EQ(base::ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle()); |
| 84 } | 88 } |
| OLD | NEW |