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

Unified Diff: ui/gfx/geometry/scale_unittest.cc

Issue 1315633002: gfx: Converge scale precision related differences to single class. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected simple nit. Created 5 years, 4 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
« no previous file with comments | « ui/gfx/geometry/scale.cc ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/gfx/geometry/scale.cc ('k') | ui/gfx/gfx.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698