OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/system/chromeos/power/power_status.h" | 5 #include "ash/system/chromeos/power/power_status.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // Check that minutes are rounded. | 131 // Check that minutes are rounded. |
132 PowerStatus::SplitTimeIntoHoursAndMinutes( | 132 PowerStatus::SplitTimeIntoHoursAndMinutes( |
133 base::TimeDelta::FromSeconds(2 * 3600 + 3 * 60 + 30), &hours, &minutes); | 133 base::TimeDelta::FromSeconds(2 * 3600 + 3 * 60 + 30), &hours, &minutes); |
134 EXPECT_EQ(2, hours); | 134 EXPECT_EQ(2, hours); |
135 EXPECT_EQ(4, minutes); | 135 EXPECT_EQ(4, minutes); |
136 | 136 |
137 PowerStatus::SplitTimeIntoHoursAndMinutes( | 137 PowerStatus::SplitTimeIntoHoursAndMinutes( |
138 base::TimeDelta::FromSeconds(2 * 3600 + 3 * 60 + 29), &hours, &minutes); | 138 base::TimeDelta::FromSeconds(2 * 3600 + 3 * 60 + 29), &hours, &minutes); |
139 EXPECT_EQ(2, hours); | 139 EXPECT_EQ(2, hours); |
140 EXPECT_EQ(3, minutes); | 140 EXPECT_EQ(3, minutes); |
| 141 |
| 142 // Check that times close to hour boundaries aren't incorrectly rounded such |
| 143 // that they display 60 minutes: http://crbug.com/368261 |
| 144 PowerStatus::SplitTimeIntoHoursAndMinutes( |
| 145 base::TimeDelta::FromSecondsD(3599.9), &hours, &minutes); |
| 146 EXPECT_EQ(1, hours); |
| 147 EXPECT_EQ(0, minutes); |
| 148 |
| 149 PowerStatus::SplitTimeIntoHoursAndMinutes( |
| 150 base::TimeDelta::FromSecondsD(3600.1), &hours, &minutes); |
| 151 EXPECT_EQ(1, hours); |
| 152 EXPECT_EQ(0, minutes); |
141 } | 153 } |
142 | 154 |
143 } // namespace ash | 155 } // namespace ash |
OLD | NEW |