OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chromeos/settings/timezone_settings_helper.h" | 8 #include "chromeos/settings/timezone_settings_helper.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/icu/source/common/unicode/unistr.h" | 10 #include "third_party/icu/source/common/unicode/unistr.h" |
11 #include "third_party/icu/source/i18n/unicode/timezone.h" | 11 #include "third_party/icu/source/i18n/unicode/timezone.h" |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 namespace system { | 14 namespace system { |
15 | 15 |
16 using icu::TimeZone; | 16 using icu::TimeZone; |
17 using icu::UnicodeString; | 17 using icu::UnicodeString; |
(...skipping 11 matching lines...) Expand all Loading... |
29 "Asia/Ulaanbaatar", | 29 "Asia/Ulaanbaatar", |
30 }; | 30 }; |
31 | 31 |
32 class KnownTimeZoneTest : public testing::Test { | 32 class KnownTimeZoneTest : public testing::Test { |
33 public: | 33 public: |
34 KnownTimeZoneTest() {} | 34 KnownTimeZoneTest() {} |
35 ~KnownTimeZoneTest() override {} | 35 ~KnownTimeZoneTest() override {} |
36 | 36 |
37 void SetUp() override { | 37 void SetUp() override { |
38 for (const char* id : kTimeZones) { | 38 for (const char* id : kTimeZones) { |
39 timezones_.push_back(TimeZone::createTimeZone(UnicodeString(id))); | 39 timezones_.push_back( |
| 40 base::WrapUnique(TimeZone::createTimeZone(UnicodeString(id)))); |
40 } | 41 } |
41 } | 42 } |
42 | 43 |
43 void TearDown() override { base::STLDeleteElements(&timezones_); } | |
44 | |
45 protected: | 44 protected: |
46 std::vector<TimeZone*> timezones_; | 45 std::vector<std::unique_ptr<TimeZone>> timezones_; |
47 }; | 46 }; |
48 | 47 |
49 TEST_F(KnownTimeZoneTest, IdMatch) { | 48 TEST_F(KnownTimeZoneTest, IdMatch) { |
50 static struct { | 49 static struct { |
51 const char* id; | 50 const char* id; |
52 const char* matched; | 51 const char* matched; |
53 } timezone_match_list[] = { | 52 } timezone_match_list[] = { |
54 // Self matches | 53 // Self matches |
55 {"America/Los_Angeles", "America/Los_Angeles"}, | 54 {"America/Los_Angeles", "America/Los_Angeles"}, |
56 {"America/Vancouver", "America/Vancouver"}, // Should not be Los_Angeles | 55 {"America/Vancouver", "America/Vancouver"}, // Should not be Los_Angeles |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 for (const char* id : no_match_list) { | 96 for (const char* id : no_match_list) { |
98 std::unique_ptr<TimeZone> input( | 97 std::unique_ptr<TimeZone> input( |
99 TimeZone::createTimeZone(UnicodeString(id))); | 98 TimeZone::createTimeZone(UnicodeString(id))); |
100 EXPECT_EQ(NULL, GetKnownTimezoneOrNull(*input, timezones_)) | 99 EXPECT_EQ(NULL, GetKnownTimezoneOrNull(*input, timezones_)) |
101 << "input=" << id; | 100 << "input=" << id; |
102 } | 101 } |
103 } | 102 } |
104 | 103 |
105 } // namespace system | 104 } // namespace system |
106 } // namespace chromeos | 105 } // namespace chromeos |
OLD | NEW |