OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This whole test runs as a separate browser_test because it depends on a | 5 // This whole test runs as a separate browser_test because it depends on a |
6 // static initialization inside third_party/icu (gDecimal in digitlst.cpp). | 6 // static initialization inside third_party/icu (gDecimal in digitlst.cpp). |
7 // | 7 // |
8 // That initialization depends on the current locale, and on certain locales | 8 // That initialization depends on the current locale, and on certain locales |
9 // will lead to wrong behavior. To make sure that the locale is set before | 9 // will lead to wrong behavior. To make sure that the locale is set before |
10 // icu is used, and that the "wrong" static value doesn't affect other tests, | 10 // icu is used, and that the "wrong" static value doesn't affect other tests, |
11 // this test is executed on its own process. | 11 // this test is executed on its own process. |
12 | 12 |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/test/scoped_locale.h" | 14 #include "base/test/test_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/common/time_format.h" | 16 #include "chrome/common/time_format.h" |
17 #include "chrome/test/in_process_browser_test.h" | 17 #include "chrome/test/in_process_browser_test.h" |
18 | 18 |
| 19 #if defined(OS_POSIX) |
19 using base::TimeDelta; | 20 using base::TimeDelta; |
20 | 21 |
21 class TimeFormatBrowserTest : public InProcessBrowserTest { | 22 class TimeFormatBrowserTest: public InProcessBrowserTest { |
22 public: | 23 public: |
23 TimeFormatBrowserTest() : scoped_locale_("fr_FR.utf-8") { | 24 TimeFormatBrowserTest(): scoped_locale_("fr_FR.utf-8") {} |
24 } | |
25 | 25 |
26 private: | 26 private: |
27 base::ScopedLocale scoped_locale_; | 27 base::ScopedSetLocale scoped_locale_; |
28 }; | 28 }; |
29 | 29 |
30 IN_PROC_BROWSER_TEST_F(TimeFormatBrowserTest, DecimalPointNotDot) { | 30 IN_PROC_BROWSER_TEST_F(TimeFormatBrowserTest, DecimalPointNotDot) { |
31 // Some locales use a comma ',' instead of a dot '.' as the separator for | 31 // Some locales use a comma ',' instead of a dot '.' as the separator for |
32 // decimal digits. The icu library wasn't handling this, leading to "1" | 32 // decimal digits. The icu library wasn't handling this, leading to "1" |
33 // being internally converted to "+1,0e00" and ultimately leading to "NaN". | 33 // being internally converted to "+1,0e00" and ultimately leading to "NaN". |
34 // This showed up on the browser on estimated download time, for example. | 34 // This showed up on the browser on estimated download time, for example. |
35 // http://crbug.com/60476 | 35 // http://crbug.com/60476 |
36 | 36 |
37 string16 one_min = TimeFormat::TimeRemainingShort(TimeDelta::FromMinutes(1)); | 37 string16 one_min = TimeFormat::TimeRemainingShort(TimeDelta::FromMinutes(1)); |
38 EXPECT_EQ(ASCIIToUTF16("1 min"), one_min); | 38 EXPECT_EQ(ASCIIToUTF16("1 min"), one_min) << "fr_FR.utf-8 locale generates " |
| 39 << one_min; |
39 } | 40 } |
| 41 |
| 42 #endif // defined(OS_POSIX) |
OLD | NEW |