Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_util_unittest.cc

Issue 10914173: Wrap ChromeOS specific functions with OS_CHROMEOS macro (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/chromeos/gdata/gdata_util.h" 5 #include "chrome/browser/chromeos/gdata/gdata_util.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 #if defined(OS_CHROMEOS)
10 #include "chrome/browser/chromeos/system/timezone_settings.h" 13 #include "chrome/browser/chromeos/system/timezone_settings.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #endif // OS_CHROMEOS
12 15
13 namespace gdata { 16 namespace gdata {
14 namespace util { 17 namespace util {
15 namespace { 18 namespace {
16 19
17 std::string FormatTime(const base::Time& time) { 20 std::string FormatTime(const base::Time& time) {
18 return UTF16ToUTF8(TimeFormatShortDateAndTime(time)); 21 return UTF16ToUTF8(TimeFormatShortDateAndTime(time));
19 } 22 }
20 23
21 } // namespace 24 } // namespace
22 25
26 // TODO(yoshiki): Find platform independent way to get/set local timezone.
27 // (http://crbug.com/147524).
28 #if defined(OS_CHROMEOS)
23 TEST(GDataUtilTest, GetTimeFromStringLocalTimezone) { 29 TEST(GDataUtilTest, GetTimeFromStringLocalTimezone) {
24 // Creates time object GMT. 30 // Creates time object GMT.
25 base::Time::Exploded exploded = {2012, 7, 0, 14, 1, 3, 21, 151}; 31 base::Time::Exploded exploded = {2012, 7, 0, 14, 1, 3, 21, 151};
26 base::Time target_time = base::Time::FromUTCExploded(exploded); 32 base::Time target_time = base::Time::FromUTCExploded(exploded);
27 33
28 // Creates time object as the local time. 34 // Creates time object as the local time.
29 base::Time test_time; 35 base::Time test_time;
30 ASSERT_TRUE(GetTimeFromString("2012-07-14T01:03:21.151", &test_time)); 36 ASSERT_TRUE(GetTimeFromString("2012-07-14T01:03:21.151", &test_time));
31 37
32 // Gets the offset between the local time and GMT. 38 // Gets the offset between the local time and GMT.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 base::Time::Exploded target_time2 = {2005, 8, 0, 9, 17, 57, 0, 0}; 84 base::Time::Exploded target_time2 = {2005, 8, 0, 9, 17, 57, 0, 0};
79 EXPECT_TRUE(GetTimeFromString("2005-08-09T09:57:00-08:00", &test_time)); 85 EXPECT_TRUE(GetTimeFromString("2005-08-09T09:57:00-08:00", &test_time));
80 EXPECT_EQ(FormatTime(base::Time::FromUTCExploded(target_time2)), 86 EXPECT_EQ(FormatTime(base::Time::FromUTCExploded(target_time2)),
81 FormatTime(test_time)); 87 FormatTime(test_time));
82 88
83 base::Time::Exploded target_time3 = {2005, 1, 0, 7, 8, 2, 0, 123}; 89 base::Time::Exploded target_time3 = {2005, 1, 0, 7, 8, 2, 0, 123};
84 EXPECT_TRUE(GetTimeFromString("2005-01-07T08:02:00.123Z", &test_time)); 90 EXPECT_TRUE(GetTimeFromString("2005-01-07T08:02:00.123Z", &test_time));
85 EXPECT_EQ(FormatTime(base::Time::FromUTCExploded(target_time3)), 91 EXPECT_EQ(FormatTime(base::Time::FromUTCExploded(target_time3)),
86 FormatTime(test_time)); 92 FormatTime(test_time));
87 } 93 }
94 #endif // OS_CHROMEOS
88 95
89 TEST(GDataUtilTest, FormatTimeAsString) { 96 TEST(GDataUtilTest, FormatTimeAsString) {
90 base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123}; 97 base::Time::Exploded exploded_time = {2012, 7, 0, 19, 15, 59, 13, 123};
91 base::Time time = base::Time::FromUTCExploded(exploded_time); 98 base::Time time = base::Time::FromUTCExploded(exploded_time);
92 EXPECT_EQ("2012-07-19T15:59:13.123Z", FormatTimeAsString(time)); 99 EXPECT_EQ("2012-07-19T15:59:13.123Z", FormatTimeAsString(time));
93 } 100 }
94 101
95 } // namespace util 102 } // namespace util
96 } // namespace gdata 103 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698