blob: 318c0f02a7386e4396e104464a8dbf8886507458 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2011 The Chromium Authors
[email protected]08aa02762011-11-11 16:09:312// 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 Harris064192c2023-03-16 17:34:506
zforman08d91b72016-02-12 06:23:427#include "base/time/time.h"
Scott Graham0352ec72020-03-10 23:52:118#include "build/build_config.h"
[email protected]08aa02762011-11-11 16:09:319#include "testing/gtest/include/gtest/gtest.h"
10
11TEST(BuildTime, DateLooksValid) {
Will Harris064192c2023-03-16 17:34:5012 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]08aa02762011-11-11 16:09:3116
Bruce Dawsone5727432019-08-16 02:22:2217#if !defined(OFFICIAL_BUILD)
Will Harris064192c2023-03-16 17:34:5018 EXPECT_EQ(exploded_build_time.hour, 5);
19 EXPECT_EQ(exploded_build_time.minute, 0);
20 EXPECT_EQ(exploded_build_time.second, 0);
Bruce Dawsone5727432019-08-16 02:22:2221#endif
[email protected]08aa02762011-11-11 16:09:3122}
23
Ivana Žužićc10e02b2023-08-22 15:12:4424// 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
30TEST(BuildTime, MAYBE_InThePast) {
maruel1c9b02232016-04-04 20:21:4131 EXPECT_LT(base::GetBuildTime(), base::Time::Now());
32 EXPECT_LT(base::GetBuildTime(), base::Time::NowFromSystemTime());
33}