Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / search / local_ntp_browsertest.cc
blobd889956b8c4737d3d94bd4a8513d34cc669e7f5c
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
3 // found in the LICENSE file.
5 #include "base/prefs/pref_service.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/search/search.h"
9 #include "chrome/browser/ui/search/instant_test_utils.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"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/web_contents.h"
16 #include "ui/base/resource/resource_bundle.h"
18 class LocalNTPTest : public InProcessBrowserTest,
19 public InstantTestBase {
20 public:
21 LocalNTPTest() {}
23 protected:
24 void SetUpInProcessBrowserTestFixture() override {
25 ASSERT_TRUE(https_test_server().Start());
26 GURL instant_url = https_test_server().GetURL(
27 "files/instant_extended.html?strk=1&");
28 GURL ntp_url = https_test_server().GetURL(
29 "files/local_ntp_browsertest.html?strk=1&");
30 InstantTestBase::Init(instant_url, ntp_url, false);
34 IN_PROC_BROWSER_TEST_F(LocalNTPTest, LocalNTPJavascriptTest) {
35 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
36 FocusOmnibox();
38 ui_test_utils::NavigateToURLWithDisposition(
39 browser(),
40 ntp_url(),
41 NEW_FOREGROUND_TAB,
42 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
43 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
44 content::WebContents* active_tab =
45 browser()->tab_strip_model()->GetActiveWebContents();
46 ASSERT_TRUE(chrome::IsInstantNTP(active_tab));
47 bool success = false;
48 ASSERT_TRUE(GetBoolFromJS(active_tab, "!!runTests()", &success));
49 EXPECT_TRUE(success);
52 IN_PROC_BROWSER_TEST_F(LocalNTPTest,
53 NTPRespectsBrowserLanguageSetting) {
54 // Make sure the default language is not French.
55 std::string default_locale = g_browser_process->GetApplicationLocale();
56 EXPECT_NE("fr", default_locale);
58 // Switch browser language to French.
59 std::string loaded_locale =
60 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr");
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;
68 g_browser_process->SetApplicationLocale(loaded_locale);
69 PrefService* prefs = g_browser_process->local_state();
70 prefs->SetString(prefs::kApplicationLocale, loaded_locale);
72 // Setup Instant.
73 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
74 FocusOmnibox();
76 // Open a new tab.
77 ui_test_utils::NavigateToURLWithDisposition(
78 browser(),
79 GURL(chrome::kChromeUINewTabURL),
80 NEW_FOREGROUND_TAB,
81 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
82 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
84 // Verify that the NTP is in French.
85 content::WebContents* active_tab =
86 browser()->tab_strip_model()->GetActiveWebContents();
87 EXPECT_EQ(base::ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle());