Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
[email protected] | 08aa0276 | 2011-11-11 16:09:31 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/build_time.h" |
Will Harris | 064192c | 2023-03-16 17:34:50 | [diff] [blame] | 6 | |
zforman | 08d91b7 | 2016-02-12 06:23:42 | [diff] [blame] | 7 | #include "base/time/time.h" |
Scott Graham | 0352ec7 | 2020-03-10 23:52:11 | [diff] [blame] | 8 | #include "build/build_config.h" |
[email protected] | 08aa0276 | 2011-11-11 16:09:31 | [diff] [blame] | 9 | #include "testing/gtest/include/gtest/gtest.h" |
| 10 | |
| 11 | TEST(BuildTime, DateLooksValid) { |
Will Harris | 064192c | 2023-03-16 17:34:50 | [diff] [blame] | 12 | base::Time build_time = base::GetBuildTime(); |
| 13 | base::Time::Exploded exploded_build_time; |
| 14 | build_time.UTCExplode(&exploded_build_time); |
| 15 | ASSERT_TRUE(exploded_build_time.HasValidValues()); |
[email protected] | 08aa0276 | 2011-11-11 16:09:31 | [diff] [blame] | 16 | |
Bruce Dawson | e572743 | 2019-08-16 02:22:22 | [diff] [blame] | 17 | #if !defined(OFFICIAL_BUILD) |
Will Harris | 064192c | 2023-03-16 17:34:50 | [diff] [blame] | 18 | EXPECT_EQ(exploded_build_time.hour, 5); |
| 19 | EXPECT_EQ(exploded_build_time.minute, 0); |
| 20 | EXPECT_EQ(exploded_build_time.second, 0); |
Bruce Dawson | e572743 | 2019-08-16 02:22:22 | [diff] [blame] | 21 | #endif |
[email protected] | 08aa0276 | 2011-11-11 16:09:31 | [diff] [blame] | 22 | } |
| 23 | |
Ivana Žužić | c10e02b | 2023-08-22 15:12:44 | [diff] [blame] | 24 | // Disabled on Android due to flakes; see https://crbug.com/1474884. |
| 25 | #if BUILDFLAG(IS_ANDROID) |
| 26 | #define MAYBE_InThePast DISABLED_InThePast |
| 27 | #else |
| 28 | #define MAYBE_InThePast InThePast |
| 29 | #endif |
| 30 | TEST(BuildTime, MAYBE_InThePast) { |
maruel | 1c9b0223 | 2016-04-04 20:21:41 | [diff] [blame] | 31 | EXPECT_LT(base::GetBuildTime(), base::Time::Now()); |
| 32 | EXPECT_LT(base::GetBuildTime(), base::Time::NowFromSystemTime()); |
| 33 | } |