OLD | NEW |
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 "base/time.h" |
| 6 |
5 #include <time.h> | 7 #include <time.h> |
6 | 8 |
| 9 #include "base/compiler_specific.h" |
7 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
8 #include "base/time.h" | |
9 #include "build/build_config.h" | 11 #include "build/build_config.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 | 13 |
12 using base::Time; | 14 using base::Time; |
13 using base::TimeDelta; | 15 using base::TimeDelta; |
14 using base::TimeTicks; | 16 using base::TimeTicks; |
15 | 17 |
16 // Specialized test fixture allowing time strings without timezones to be | 18 // Specialized test fixture allowing time strings without timezones to be |
17 // tested by comparing them to a known time in the local zone. | 19 // tested by comparing them to a known time in the local zone. |
18 // See also pr_time_unittests.cc | 20 // See also pr_time_unittests.cc |
19 class TimeTest : public testing::Test { | 21 class TimeTest : public testing::Test { |
20 protected: | 22 protected: |
21 virtual void SetUp() { | 23 virtual void SetUp() OVERRIDE { |
22 // Use mktime to get a time_t, and turn it into a PRTime by converting | 24 // Use mktime to get a time_t, and turn it into a PRTime by converting |
23 // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This | 25 // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This |
24 // must be a time guaranteed to be outside of a DST fallback hour in | 26 // must be a time guaranteed to be outside of a DST fallback hour in |
25 // any timezone. | 27 // any timezone. |
26 struct tm local_comparison_tm = { | 28 struct tm local_comparison_tm = { |
27 0, // second | 29 0, // second |
28 45, // minute | 30 45, // minute |
29 12, // hour | 31 12, // hour |
30 15, // day of month | 32 15, // day of month |
31 10 - 1, // month | 33 10 - 1, // month |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 exploded.minute = 0; | 554 exploded.minute = 0; |
553 exploded.second = 0; | 555 exploded.second = 0; |
554 exploded.millisecond = 0; | 556 exploded.millisecond = 0; |
555 Time t = Time::FromUTCExploded(exploded); | 557 Time t = Time::FromUTCExploded(exploded); |
556 // Unix 1970 epoch. | 558 // Unix 1970 epoch. |
557 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue()); | 559 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue()); |
558 | 560 |
559 // We can't test 1601 epoch, since the system time functions on Linux | 561 // We can't test 1601 epoch, since the system time functions on Linux |
560 // only compute years starting from 1900. | 562 // only compute years starting from 1900. |
561 } | 563 } |
OLD | NEW |