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" |
| 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/browser_process.h" |
5 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.h" |
6 #include "chrome/browser/ui/search/instant_test_utils.h" | 9 #include "chrome/browser/ui/search/instant_test_utils.h" |
7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/common/url_constants.h" |
8 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
10 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "ui/base/resource/resource_bundle.h" |
11 | 17 |
12 class LocalNTPTest : public InProcessBrowserTest, | 18 class LocalNTPTest : public InProcessBrowserTest, |
13 public InstantTestBase { | 19 public InstantTestBase { |
14 public: | 20 public: |
15 LocalNTPTest() {} | 21 LocalNTPTest() {} |
16 | 22 |
17 protected: | 23 protected: |
18 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 24 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
19 chrome::EnableInstantExtendedAPIForTesting(); | 25 chrome::EnableInstantExtendedAPIForTesting(); |
20 ASSERT_TRUE(https_test_server().Start()); | 26 ASSERT_TRUE(https_test_server().Start()); |
(...skipping 13 matching lines...) Expand all Loading... |
34 NEW_FOREGROUND_TAB, | 40 NEW_FOREGROUND_TAB, |
35 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | | 41 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB | |
36 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 42 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
37 content::WebContents* active_tab = | 43 content::WebContents* active_tab = |
38 browser()->tab_strip_model()->GetActiveWebContents(); | 44 browser()->tab_strip_model()->GetActiveWebContents(); |
39 ASSERT_TRUE(chrome::IsInstantNTP(active_tab)); | 45 ASSERT_TRUE(chrome::IsInstantNTP(active_tab)); |
40 bool success = false; | 46 bool success = false; |
41 ASSERT_TRUE(GetBoolFromJS(active_tab, "!!runTests()", &success)); | 47 ASSERT_TRUE(GetBoolFromJS(active_tab, "!!runTests()", &success)); |
42 EXPECT_TRUE(success); | 48 EXPECT_TRUE(success); |
43 } | 49 } |
| 50 |
| 51 // Flaky on Linux Tests bot. |
| 52 #if defined(OS_LINUX) |
| 53 #define MAYBE_NTPRespectsBrowserLanguageSetting DISABLED_NTPRespectsBrowserLangu
ageSetting |
| 54 #else |
| 55 #define MAYBE_NTPRespectsBrowserLanguageSetting NTPRespectsBrowserLanguageSettin
g |
| 56 #endif |
| 57 IN_PROC_BROWSER_TEST_F(LocalNTPTest, MAYBE_NTPRespectsBrowserLanguageSetting) { |
| 58 // Make sure the default language is not French. |
| 59 std::string default_locale = g_browser_process->GetApplicationLocale(); |
| 60 EXPECT_NE("fr", default_locale); |
| 61 |
| 62 // Switch browser language to French. |
| 63 std::string loaded_locale = |
| 64 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); |
| 65 EXPECT_EQ("fr", loaded_locale); |
| 66 g_browser_process->SetApplicationLocale(loaded_locale); |
| 67 PrefService* prefs = g_browser_process->local_state(); |
| 68 prefs->SetString(prefs::kApplicationLocale, loaded_locale); |
| 69 |
| 70 // Setup Instant. |
| 71 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 72 |
| 73 // The second argument says to use only the local overlay and NTP. |
| 74 instant()->SetInstantEnabled(false, true); |
| 75 FocusOmniboxAndWaitForInstantNTPSupport(); |
| 76 |
| 77 // Open a new tab. |
| 78 ui_test_utils::NavigateToURLWithDisposition( |
| 79 browser(), |
| 80 GURL(chrome::kChromeUINewTabURL), |
| 81 NEW_FOREGROUND_TAB, |
| 82 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 83 |
| 84 // Verify that the NTP is in French. |
| 85 content::WebContents* active_tab = |
| 86 browser()->tab_strip_model()->GetActiveWebContents(); |
| 87 EXPECT_EQ(ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle()); |
| 88 } |
OLD | NEW |