Index: ui/gfx/geometry/scale_unittest.cc |
diff --git a/ui/gfx/geometry/scale_unittest.cc b/ui/gfx/geometry/scale_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b811038cd67c47c497bdc4064a8254cca6cf210a |
--- /dev/null |
+++ b/ui/gfx/geometry/scale_unittest.cc |
@@ -0,0 +1,41 @@ |
+// Copyright (c) 2015 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 <limits> |
+ |
+#include "base/command_line.h" |
+#include "base/logging.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/gfx/geometry/scale.h" |
+#include "ui/gfx/switches.h" |
+ |
+namespace gfx { |
+ |
+TEST(ScaleTest, ScaleOperations) { |
+ base::CommandLine::ForCurrentProcess()->AppendSwitch( |
+ switches::kEnableFixedPrecisionScale); |
+ |
+ Scale scale1(7.33907556533813f); |
+ Scale scale2(7.33907508850098f); |
+ Scale scale3(2.33907508850098f); |
+ |
+ EXPECT_TRUE(scale1 == scale2); |
+ EXPECT_FALSE(scale1 == scale3); |
+ |
+ // For higher scale values (e.g. >= 10), the absolute values may get |
+ // represented same as computed values. |
+ EXPECT_FALSE(scale1.AbsoluteValue() == scale2.AbsoluteValue()); |
+ |
+ EXPECT_TRUE(scale2 != scale3); |
+ EXPECT_TRUE(scale3 < scale1); |
+ EXPECT_TRUE(scale1 > scale3); |
+ |
+ scale3 = Scale(7.33907556533813f); |
+ EXPECT_TRUE(scale1 == scale3); |
+ |
+ Scale scale4(scale3); |
+ EXPECT_TRUE(scale3 == scale4); |
+} |
+ |
+} // namespace gfx |