| 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/environment.h" | 6 #include "base/environment.h" |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
| 9 #include "ui/base/ui_base_switches.h" | 9 #include "ui/base/ui_base_switches.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // A class that over-writes the system locale only in a scope. To emulate the | 13 // A class that over-writes the system locale only in a scope. To emulate the |
| 14 // specified environment on Linux, this class over-writes a LC_ALL environment | 14 // specified environment on Linux, this class over-writes a LC_ALL environment |
| 15 // variable when creating a LocaleTest object and restore it with the original | 15 // variable when creating a LocaleTest object and restore it with the original |
| 16 // value when deleting the object. (This environment variable may affect other | 16 // value when deleting the object. (This environment variable may affect other |
| 17 // tests and we have to restore it regardless of the results of LocaleTests.) | 17 // tests and we have to restore it regardless of the results of LocaleTests.) |
| 18 class ScopedLocale { | 18 class ScopedLocale { |
| 19 public: | 19 public: |
| 20 explicit ScopedLocale(const char* locale) : locale_(locale) { | 20 explicit ScopedLocale(const char* locale) : locale_(locale) { |
| 21 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
| 22 old_locale_ = getenv("LC_ALL"); | 22 old_locale_ = getenv("LC_ALL"); |
| 23 | 23 |
| 24 static const struct { | 24 static const struct { |
| 25 const char* chrome_locale; | 25 const char* chrome_locale; |
| 26 const char* system_locale; | 26 const char* system_locale; |
| 27 } kLocales[] = { | 27 } kLocales[] = { |
| 28 { "da", "da_DK.UTF-8" }, | 28 { "da", "da_DK.UTF-8" }, |
| 29 { "he", "he_IL.UTF-8" }, | 29 { "he", "he_IL.UTF-8" }, |
| 30 { "zh-TW", "zh-TW.UTF-8" } | 30 { "zh-TW", "zh_TW.UTF-8" } |
| 31 }; | 31 }; |
| 32 bool found_locale = false; | 32 bool found_locale = false; |
| 33 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kLocales); ++i) { | 33 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kLocales); ++i) { |
| 34 if (kLocales[i].chrome_locale == locale) { | 34 if (kLocales[i].chrome_locale == locale) { |
| 35 found_locale = true; | 35 found_locale = true; |
| 36 setenv("LC_ALL", kLocales[i].system_locale, 1); | 36 setenv("LC_ALL", kLocales[i].system_locale, 1); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 DCHECK(found_locale); | 39 DCHECK(found_locale); |
| 40 #endif | 40 #endif |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // code here because they just verify we can start Chrome and shut it down | 114 // code here because they just verify we can start Chrome and shut it down |
| 115 // cleanly on these locales. | 115 // cleanly on these locales. |
| 116 IN_PROC_BROWSER_TEST_F(LocaleTestDanish, MAYBE_TestStart) { | 116 IN_PROC_BROWSER_TEST_F(LocaleTestDanish, MAYBE_TestStart) { |
| 117 } | 117 } |
| 118 | 118 |
| 119 IN_PROC_BROWSER_TEST_F(LocaleTestHebrew, MAYBE_TestStart) { | 119 IN_PROC_BROWSER_TEST_F(LocaleTestHebrew, MAYBE_TestStart) { |
| 120 } | 120 } |
| 121 | 121 |
| 122 IN_PROC_BROWSER_TEST_F(LocaleTestTraditionalChinese, MAYBE_TestStart) { | 122 IN_PROC_BROWSER_TEST_F(LocaleTestTraditionalChinese, MAYBE_TestStart) { |
| 123 } | 123 } |
| OLD | NEW |