ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / chromeos / settings / timezone_settings_unittest.cc
blobd8b5b5f8b92d65458c8b67280a7123d8e09d0696
1 // Copyright 2015 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/memory/scoped_ptr.h"
6 #include "base/stl_util.h"
7 #include "chromeos/settings/timezone_settings_helper.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/icu/source/common/unicode/unistr.h"
10 #include "third_party/icu/source/i18n/unicode/timezone.h"
12 namespace chromeos {
13 namespace system {
15 using icu::TimeZone;
16 using icu::UnicodeString;
18 const char* kTimeZones[] = {
19 "America/Los_Angeles",
20 "America/Vancouver",
21 "America/Chicago",
22 "America/Winnipeg",
23 "America/Mexico_City",
24 "America/Buenos_Aires",
25 "Asia/Ho_Chi_Minh",
26 "Asia/Seoul",
27 "Europe/Athens",
28 "Asia/Ulaanbaatar",
31 class KnownTimeZoneTest : public testing::Test {
32 public:
33 KnownTimeZoneTest() {}
34 ~KnownTimeZoneTest() override {}
36 void SetUp() override {
37 for (const char* id : kTimeZones) {
38 timezones_.push_back(TimeZone::createTimeZone(UnicodeString(id)));
42 void TearDown() override { STLDeleteElements(&timezones_); }
44 protected:
45 std::vector<TimeZone*> timezones_;
48 TEST_F(KnownTimeZoneTest, IdMatch) {
49 static struct {
50 const char* id;
51 const char* matched;
52 } timezone_match_list[] = {
53 // Self matches
54 {"America/Los_Angeles", "America/Los_Angeles"},
55 {"America/Vancouver", "America/Vancouver"}, // Should not be Los_Angeles
56 {"America/Winnipeg", "America/Winnipeg"},
57 {"Asia/Seoul", "Asia/Seoul"},
58 // Canonical ID matches
59 {"Canada/Pacific", "America/Vancouver"},
60 {"US/Pacific", "America/Los_Angeles"},
61 {"US/Central", "America/Chicago"},
62 {"Mexico/General", "America/Mexico_City"},
63 {"Asia/Ulan_Bator", "Asia/Ulaanbaatar"},
64 // Asia/Saigon is canonical, but the list has Asia/Ho_Chi_Minh
65 {"Asia/Saigon", "Asia/Ho_Chi_Minh"},
68 for (const auto& pair : timezone_match_list) {
69 scoped_ptr<TimeZone> input(
70 TimeZone::createTimeZone(UnicodeString(pair.id)));
71 scoped_ptr<TimeZone> expected(
72 TimeZone::createTimeZone(UnicodeString(pair.matched)));
73 const TimeZone* actual = GetKnownTimezoneOrNull(*input, timezones_);
74 EXPECT_NE(nullptr, actual) << "input=" << pair.id;
75 if (actual == nullptr)
76 continue;
77 UnicodeString actual_id;
78 actual->getID(actual_id);
79 std::string actual_id_str;
80 actual_id.toUTF8String(actual_id_str);
81 EXPECT_EQ(*expected, *actual) << "input=" << pair.id << ", "
82 << "expected=" << pair.matched << ", "
83 << "actual=" << actual_id_str;
87 TEST_F(KnownTimeZoneTest, NoMatch) {
88 static const char* no_match_list[] = {
89 "Africa/Juba", // Not in the list
90 "Africa/Tripoli", // UTC+2 with no DST != Europe/Athens
91 "America/Tijuana", // Historically != America/Los_Angeles
92 "Europe/Sofia", // Historically != Europe/Athens
93 "America/Argentina/Cordoba", // Historically != America/Buenos_Aires
94 "Asia/Tokyo", // Historically != Asia/Seoul
96 for (const char* id : no_match_list) {
97 scoped_ptr<TimeZone> input(TimeZone::createTimeZone(UnicodeString(id)));
98 EXPECT_EQ(NULL, GetKnownTimezoneOrNull(*input, timezones_))
99 << "input=" << id;
103 } // namespace system
104 } // namespace chromeos