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

Unified Diff: ui/gfx/transform_unittest.cc

Issue 15972006: TransformOperations should be able to blend outside the range [0, 1] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 7 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/transform.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/transform_unittest.cc
diff --git a/ui/gfx/transform_unittest.cc b/ui/gfx/transform_unittest.cc
index 72abeef9b8a8215a452ddcc32c3a4623981d553b..7ccde8c6df94be675a937101bf1a703b0eaa1547 100644
--- a/ui/gfx/transform_unittest.cc
+++ b/ui/gfx/transform_unittest.cc
@@ -12,6 +12,7 @@
#include <limits>
#include "base/basictypes.h"
+#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/point.h"
#include "ui/gfx/point3_f.h"
@@ -654,7 +655,7 @@ TEST(XFormTest, SetRotate2D) {
TEST(XFormTest, BlendTranslate) {
Transform from;
- for (int i = 0; i < 10; ++i) {
+ for (int i = -5; i < 15; ++i) {
Transform to;
to.Translate3d(1, 1, 1);
double t = i / 9.0;
@@ -674,7 +675,7 @@ TEST(XFormTest, BlendRotate) {
};
Transform from;
for (size_t index = 0; index < ARRAYSIZE_UNSAFE(axes); ++index) {
- for (int i = 0; i < 10; ++i) {
+ for (int i = -5; i < 15; ++i) {
Transform to;
to.RotateAbout(axes[index], 90);
double t = i / 9.0;
@@ -698,7 +699,7 @@ TEST(XFormTest, BlendRotateFollowsShortestPath) {
Vector3dF(1, 1, 1)
};
for (size_t index = 0; index < ARRAYSIZE_UNSAFE(axes); ++index) {
- for (int i = 0; i < 10; ++i) {
+ for (int i = -5; i < 15; ++i) {
Transform from1;
from1.RotateAbout(axes[index], 130.0);
Transform to1;
@@ -734,7 +735,7 @@ TEST(XFormTest, CanBlend180DegreeRotation) {
};
Transform from;
for (size_t index = 0; index < ARRAYSIZE_UNSAFE(axes); ++index) {
- for (int i = 0; i < 10; ++i) {
+ for (int i = -5; i < 15; ++i) {
Transform to;
to.RotateAbout(axes[index], 180);
double t = i / 9.0;
@@ -750,7 +751,7 @@ TEST(XFormTest, CanBlend180DegreeRotation) {
TEST(XFormTest, BlendScale) {
Transform from;
- for (int i = 0; i < 10; ++i) {
+ for (int i = -5; i < 15; ++i) {
Transform to;
to.Scale3d(5, 4, 3);
double t = i / 9.0;
@@ -776,15 +777,29 @@ TEST(XFormTest, BlendSkew) {
}
}
+TEST(XFormTest, ExtrapolateSkew) {
+ Transform from;
+ for (int i = -1; i < 2; ++i) {
+ Transform to;
+ to.SkewX(20);
+ double t = i;
+ Transform expected;
+ expected.SkewX(t * 20);
+ EXPECT_TRUE(to.Blend(from, t));
+ EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
+ }
+}
+
TEST(XFormTest, BlendPerspective) {
Transform from;
from.ApplyPerspectiveDepth(200);
- for (int i = 0; i < 2; ++i) {
+ for (int i = -1; i < 3; ++i) {
Transform to;
to.ApplyPerspectiveDepth(800);
double t = i;
+ double depth = 1.0 / ((1.0 / 200) * (1.0 - t) + (1.0 / 800) * t);
Transform expected;
- expected.ApplyPerspectiveDepth(t * 600 + 200);
+ expected.ApplyPerspectiveDepth(depth);
EXPECT_TRUE(to.Blend(from, t));
EXPECT_TRUE(MatricesAreNearlyEqual(expected, to));
}
« no previous file with comments | « ui/gfx/transform.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698