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. 4 5 #include "base/i18n/timezone.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 9 namespace base { 10 namespace { 11 TEST(TimezoneTest,CountryCodeForCurrentTimezone)12TEST(TimezoneTest, CountryCodeForCurrentTimezone) { 13 std::string country_code = CountryCodeForCurrentTimezone(); 14 // On some systems (such as Android or some flavors of Linux), ICU may come up 15 // empty. With https://chromium-review.googlesource.com/c/512282/ , ICU will 16 // not fail any more. See also http://bugs.icu-project.org/trac/ticket/13208 . 17 // Even with that, ICU returns '001' (world) for region-agnostic timezones 18 // such as Etc/UTC and |CountryCodeForCurrentTimezone| returns an empty 19 // string so that the next fallback can be tried by a customer. 20 // TODO(jshin): Revise this to test for actual timezones using 21 // use ScopedRestoreICUDefaultTimezone. 22 if (!country_code.empty()) 23 EXPECT_EQ(2U, country_code.size()) << "country_code = " << country_code; 24 } 25 26 } // namespace 27 } // namespace base 28