Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9507)

Unified Diff: ash/system/night_light/night_light_time_unittest.cc

Issue 2887913004: [Night Light] CL4: Automatic schedule backend. (Closed)
Patch Set: Working Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/night_light/night_light_time_unittest.cc
diff --git a/ash/system/night_light/night_light_time_unittest.cc b/ash/system/night_light/night_light_time_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..66ddcea463fafa818583885873f023f45b043872
--- /dev/null
+++ b/ash/system/night_light/night_light_time_unittest.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/night_light/night_light_time.h"
+
+#include "base/time/time.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace ash {
+
+namespace {
+
+TEST(NightLightTimeTest, TestSeveralOffsets) {
+ // 6:32 PM ==> 18:32.
+ NightLightTime time1(18 * 60 + 32);
+ EXPECT_EQ("6:32 PM", time1.ToString());
+
+ // 9:59 AM.
+ NightLightTime time2(9 * 60 + 59);
+ EXPECT_EQ("9:59 AM", time2.ToString());
+
+ // Border times: 00:00 and 24:00.
+ NightLightTime time3(0);
+ NightLightTime time4(24 * 60);
+ EXPECT_EQ("12:00 AM", time3.ToString());
+ EXPECT_EQ("12:00 AM", time4.ToString());
+}
+
+TEST(NightLightTimeTest, TestFromTime) {
+ // "Now" today and "now" tomorrow should have the same minutes offset from
+ // 00:00.
+ 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.
+ base::Time now_tomorrow = now_today + base::TimeDelta::FromDays(1);
+ EXPECT_EQ(NightLightTime::FromTime(now_today),
+ NightLightTime::FromTime(now_tomorrow));
+}
+
+} // namespace
+
+} // namespace ash
« ash/system/night_light/night_light_time.cc ('K') | « ash/system/night_light/night_light_time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698