OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 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 <limits> |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/gfx/geometry/scale.h" |
| 11 #include "ui/gfx/switches.h" |
| 12 |
| 13 namespace gfx { |
| 14 |
| 15 TEST(ScaleTest, ScaleOperations) { |
| 16 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 17 switches::kEnableFixedPrecisionScale); |
| 18 |
| 19 Scale scale1(7.33907556533813f); |
| 20 Scale scale2(7.33907508850098f); |
| 21 Scale scale3(2.33907508850098f); |
| 22 |
| 23 EXPECT_TRUE(scale1 == scale2); |
| 24 EXPECT_FALSE(scale1 == scale3); |
| 25 |
| 26 // For higher scale values (e.g. >= 10), the absolute values may get |
| 27 // represented same as computed values. |
| 28 EXPECT_FALSE(scale1.AbsoluteValue() == scale2.AbsoluteValue()); |
| 29 |
| 30 EXPECT_TRUE(scale2 != scale3); |
| 31 EXPECT_TRUE(scale3 < scale1); |
| 32 EXPECT_TRUE(scale1 > scale3); |
| 33 |
| 34 scale3 = Scale(7.33907556533813f); |
| 35 EXPECT_TRUE(scale1 == scale3); |
| 36 |
| 37 Scale scale4(scale3); |
| 38 EXPECT_TRUE(scale3 == scale4); |
| 39 } |
| 40 |
| 41 } // namespace gfx |
OLD | NEW |