Chromium Code Reviews| 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/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram_base.h" | 9 #include "base/metrics/histogram_base.h" |
| 10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
| 11 #include "base/metrics/statistics_recorder.h" | 11 #include "base/metrics/statistics_recorder.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 18 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 20 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_result.h" | 21 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 22 #include "chrome/browser/autocomplete/search_provider.h" | 22 #include "chrome/browser/autocomplete/search_provider.h" |
| 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 24 #include "chrome/browser/bookmarks/bookmark_utils.h" | 24 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 25 #include "chrome/browser/browser_process.h" | |
| 25 #include "chrome/browser/extensions/extension_browsertest.h" | 26 #include "chrome/browser/extensions/extension_browsertest.h" |
| 26 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 27 #include "chrome/browser/favicon/favicon_tab_helper.h" | 28 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 28 #include "chrome/browser/history/history_db_task.h" | 29 #include "chrome/browser/history/history_db_task.h" |
| 29 #include "chrome/browser/history/history_service.h" | 30 #include "chrome/browser/history/history_service.h" |
| 30 #include "chrome/browser/history/history_service_factory.h" | 31 #include "chrome/browser/history/history_service_factory.h" |
| 31 #include "chrome/browser/history/history_types.h" | 32 #include "chrome/browser/history/history_types.h" |
| 32 #include "chrome/browser/history/top_sites.h" | 33 #include "chrome/browser/history/top_sites.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/search/instant_service.h" | 35 #include "chrome/browser/search/instant_service.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 #include "content/public/browser/web_contents.h" | 72 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/browser/web_contents_view.h" | 73 #include "content/public/browser/web_contents_view.h" |
| 73 #include "content/public/common/bindings_policy.h" | 74 #include "content/public/common/bindings_policy.h" |
| 74 #include "content/public/common/renderer_preferences.h" | 75 #include "content/public/common/renderer_preferences.h" |
| 75 #include "content/public/test/browser_test_utils.h" | 76 #include "content/public/test/browser_test_utils.h" |
| 76 #include "content/public/test/test_utils.h" | 77 #include "content/public/test/test_utils.h" |
| 77 #include "grit/generated_resources.h" | 78 #include "grit/generated_resources.h" |
| 78 #include "testing/gmock/include/gmock/gmock.h" | 79 #include "testing/gmock/include/gmock/gmock.h" |
| 79 #include "third_party/skia/include/core/SkBitmap.h" | 80 #include "third_party/skia/include/core/SkBitmap.h" |
| 80 #include "ui/base/l10n/l10n_util.h" | 81 #include "ui/base/l10n/l10n_util.h" |
| 82 #include "ui/base/resource/resource_bundle.h" | |
| 81 | 83 |
| 82 using testing::HasSubstr; | 84 using testing::HasSubstr; |
| 83 | 85 |
| 84 namespace { | 86 namespace { |
| 85 | 87 |
| 86 // Creates a bitmap of the specified color. Caller takes ownership. | 88 // Creates a bitmap of the specified color. Caller takes ownership. |
| 87 gfx::Image CreateBitmap(SkColor color) { | 89 gfx::Image CreateBitmap(SkColor color) { |
| 88 SkBitmap thumbnail; | 90 SkBitmap thumbnail; |
| 89 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); | 91 thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4); |
| 90 thumbnail.allocPixels(); | 92 thumbnail.allocPixels(); |
| (...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2890 browser()->tab_strip_model()->ActivateTabAt(0, false); | 2892 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 2891 | 2893 |
| 2892 // Switch back to new tab. | 2894 // Switch back to new tab. |
| 2893 browser()->tab_strip_model()->ActivateTabAt(1, false); | 2895 browser()->tab_strip_model()->ActivateTabAt(1, false); |
| 2894 | 2896 |
| 2895 // Confirm that new tab got no onmostvisitedchanged event. | 2897 // Confirm that new tab got no onmostvisitedchanged event. |
| 2896 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2898 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2897 EXPECT_TRUE(UpdateSearchState(active_tab)); | 2899 EXPECT_TRUE(UpdateSearchState(active_tab)); |
| 2898 EXPECT_EQ(2, on_most_visited_change_calls_); | 2900 EXPECT_EQ(2, on_most_visited_change_calls_); |
| 2899 } | 2901 } |
| 2902 | |
| 2903 // Flaky on Linux Tests bot. | |
| 2904 #if defined(OS_LINUX) | |
| 2905 #define MAYBE_NTPRespectsBrowserLanguageSetting DISABLED_NTPRespectsBrowserLangu ageSetting | |
| 2906 #else | |
| 2907 #define MAYBE_NTPRespectsBrowserLanguageSetting NTPRespectsBrowserLanguageSettin g | |
| 2908 #endif | |
| 2909 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | |
| 2910 MAYBE_NTPRespectsBrowserLanguageSetting) { | |
|
Jered
2013/06/19 22:29:32
Put this test in local_ntp_browsertest.
kmadhusu
2013/06/21 18:27:58
Done.
| |
| 2911 std::string default_locale = g_browser_process->GetApplicationLocale(); | |
| 2912 EXPECT_EQ("en-US", default_locale); | |
|
Jered
2013/06/19 22:29:32
Why do we need to test the default locale?
kmadhusu
2013/06/21 18:27:58
Before loading "fr" as application locale, I wante
| |
| 2913 | |
| 2914 // Switch browser language. | |
| 2915 std::string loaded_locale = | |
| 2916 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); | |
| 2917 EXPECT_EQ("fr", loaded_locale); | |
| 2918 g_browser_process->SetApplicationLocale(loaded_locale); | |
| 2919 PrefService* prefs = g_browser_process->local_state(); | |
| 2920 prefs->SetString(prefs::kApplicationLocale, loaded_locale); | |
| 2921 | |
| 2922 // Setup Instant. | |
| 2923 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | |
| 2924 | |
| 2925 // The second argument says to use only the local overlay and NTP. | |
| 2926 instant()->SetInstantEnabled(false, true); | |
| 2927 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); | |
| 2928 | |
| 2929 // Open a new tab. | |
| 2930 ui_test_utils::NavigateToURLWithDisposition( | |
| 2931 browser(), | |
| 2932 GURL(chrome::kChromeUINewTabURL), | |
| 2933 NEW_FOREGROUND_TAB, | |
| 2934 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
| 2935 | |
| 2936 // Verify that the NTP is in French. | |
| 2937 content::WebContents* active_tab = | |
| 2938 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 2939 EXPECT_EQ(ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle()); | |
| 2940 } | |
| OLD | NEW |