OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/html/forms/StepRange.h" | 5 #include "core/html/forms/StepRange.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 TEST(StepRangeTest, ClampValueWithOutStepMatchedValue) { | 11 TEST(StepRangeTest, ClampValueWithOutStepMatchedValue) { |
12 // <input type=range value=200 min=0 max=100 step=1000> | 12 // <input type=range value=200 min=0 max=100 step=1000> |
13 StepRange stepRange(Decimal(200), Decimal(0), Decimal(100), true, | 13 StepRange stepRange(Decimal(200), Decimal(0), Decimal(100), true, |
14 Decimal(1000), StepRange::StepDescription()); | 14 Decimal(1000), StepRange::StepDescription()); |
15 | 15 |
16 EXPECT_EQ(Decimal(100), stepRange.clampValue(Decimal(200))); | 16 EXPECT_EQ(Decimal(100), stepRange.clampValue(Decimal(200))); |
17 EXPECT_EQ(Decimal(0), stepRange.clampValue(Decimal(-100))); | 17 EXPECT_EQ(Decimal(0), stepRange.clampValue(Decimal(-100))); |
18 } | 18 } |
19 | 19 |
20 TEST(StepRangeTest, StepSnappedMaximum) { | 20 TEST(StepRangeTest, StepSnappedMaximum) { |
21 // <input type=number value="1110" max=100 step="20"> | 21 // <input type=number value="1110" max=100 step="20"> |
22 StepRange stepRange(Decimal::fromDouble(1110), Decimal(0), Decimal(100), true, | 22 StepRange stepRange(Decimal::fromDouble(1110), Decimal(0), Decimal(100), true, |
23 Decimal(20), StepRange::StepDescription()); | 23 Decimal(20), StepRange::StepDescription()); |
24 EXPECT_EQ(Decimal(90), stepRange.stepSnappedMaximum()); | 24 EXPECT_EQ(Decimal(90), stepRange.stepSnappedMaximum()); |
25 | 25 |
26 // crbug.com/617809 | 26 // crbug.com/617809 |
27 // <input type=number value="8624024784918570374158793713225864658725102756338
79852148634946190044949831586501406540691859218103463361836334980788740491507277
6534917803019477033072906290735591367789665757384135591225430117374220731087966"
min=0 max=100 step="18446744073709551575"> | 27 // <input type=number |
| 28 // value="86240247849185703741587937132258646587251027563387985214863494619004
49498315865014065406918592181034633618363349807887404915072776534917803019477033
072906290735591367789665757384135591225430117374220731087966" |
| 29 // min=0 max=100 step="18446744073709551575"> |
28 StepRange stepRange2(Decimal::fromDouble(8.62402e+207), Decimal(0), | 30 StepRange stepRange2(Decimal::fromDouble(8.62402e+207), Decimal(0), |
29 Decimal(100), true, Decimal::fromDouble(1.84467e+19), | 31 Decimal(100), true, Decimal::fromDouble(1.84467e+19), |
30 StepRange::StepDescription()); | 32 StepRange::StepDescription()); |
31 EXPECT_FALSE(stepRange2.stepSnappedMaximum().isFinite()); | 33 EXPECT_FALSE(stepRange2.stepSnappedMaximum().isFinite()); |
32 } | 34 } |
33 | 35 |
34 } // namespace blink | 36 } // namespace blink |
OLD | NEW |