Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 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 "ash/system/night_light/night_light_time.h" | |
| 6 | |
| 7 #include "base/time/time.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace ash { | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 TEST(NightLightTimeTest, TestSeveralOffsets) { | |
| 15 // 6:32 PM ==> 18:32. | |
| 16 NightLightTime time1(18 * 60 + 32); | |
| 17 EXPECT_EQ("6:32 PM", time1.ToString()); | |
| 18 | |
| 19 // 9:59 AM. | |
| 20 NightLightTime time2(9 * 60 + 59); | |
| 21 EXPECT_EQ("9:59 AM", time2.ToString()); | |
| 22 | |
| 23 // Border times: 00:00 and 24:00. | |
| 24 NightLightTime time3(0); | |
| 25 NightLightTime time4(24 * 60); | |
| 26 EXPECT_EQ("12:00 AM", time3.ToString()); | |
| 27 EXPECT_EQ("12:00 AM", time4.ToString()); | |
| 28 } | |
| 29 | |
| 30 TEST(NightLightTimeTest, TestFromTime) { | |
| 31 // "Now" today and "now" tomorrow should have the same minutes offset from | |
| 32 // 00:00. | |
| 33 base::Time now_today = base::Time::Now(); | |
|
James Cook
2017/05/23 16:34:59
Can you use a fixed time, rather than Now()?
Now
afakhry
2017/05/24 04:21:11
Done.
| |
| 34 base::Time now_tomorrow = now_today + base::TimeDelta::FromDays(1); | |
| 35 EXPECT_EQ(NightLightTime::FromTime(now_today), | |
| 36 NightLightTime::FromTime(now_tomorrow)); | |
| 37 } | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 } // namespace ash | |
| OLD | NEW |