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