xref: /aosp_15_r20/external/cronet/base/build_time_unittest.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2011 The Chromium Authors
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"
6 
7 #include "base/time/time.h"
8 #include "build/build_config.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 
TEST(BuildTime,DateLooksValid)11 TEST(BuildTime, DateLooksValid) {
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());
16 
17 #if !defined(OFFICIAL_BUILD)
18   EXPECT_EQ(exploded_build_time.hour, 5);
19   EXPECT_EQ(exploded_build_time.minute, 0);
20   EXPECT_EQ(exploded_build_time.second, 0);
21 #endif
22 }
23 
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
TEST(BuildTime,MAYBE_InThePast)30 TEST(BuildTime, MAYBE_InThePast) {
31   EXPECT_LT(base::GetBuildTime(), base::Time::Now());
32   EXPECT_LT(base::GetBuildTime(), base::Time::NowFromSystemTime());
33 }
34