diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-09-06 10:32:40 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-09-06 10:32:40 +0200 |
commit | 2d33b998c72d57abcde836bd2985ad72265d9697 (patch) | |
tree | 7e6cb902694ac348b6b785a14a997451d0b80951 /gfx/tests/gtest | |
parent | 47f4227deac7db16fbb8f4aec0376f552fc296b5 (diff) | |
parent | 9fdff854ebf1fe1a118061d57fd0a2d6c5c7dfd7 (diff) | |
download | UXP-2d33b998c72d57abcde836bd2985ad72265d9697.tar UXP-2d33b998c72d57abcde836bd2985ad72265d9697.tar.gz UXP-2d33b998c72d57abcde836bd2985ad72265d9697.tar.lz UXP-2d33b998c72d57abcde836bd2985ad72265d9697.tar.xz UXP-2d33b998c72d57abcde836bd2985ad72265d9697.zip |
Merge branch 'release' into Pale_Moon-release
# Conflicts:
# application/palemoon/config/version.txt
Diffstat (limited to 'gfx/tests/gtest')
-rw-r--r-- | gfx/tests/gtest/TestMatrix.cpp | 61 | ||||
-rw-r--r-- | gfx/tests/gtest/moz.build | 1 |
2 files changed, 62 insertions, 0 deletions
diff --git a/gfx/tests/gtest/TestMatrix.cpp b/gfx/tests/gtest/TestMatrix.cpp new file mode 100644 index 000000000..bc2f9e63c --- /dev/null +++ b/gfx/tests/gtest/TestMatrix.cpp @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gtest/gtest.h" +#include "mozilla/gfx/Matrix.h" + +using namespace mozilla; +using namespace mozilla::gfx; + +static Rect NudgedToInt(const Rect& aRect) { + Rect r(aRect); + r.NudgeToIntegers(); + return r; +} + +TEST(Matrix, TransformAndClipRect) +{ + Rect c(100, 100, 100, 100); + Matrix4x4 m; + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 50, 20, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(250, 50, 20, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(250, 250, 20, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 250, 20, 20), c).IsEmpty()); + + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 50, 100, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(150, 50, 100, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 250, 100, 20), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(150, 250, 100, 20), c).IsEmpty()); + + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 50, 20, 100), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(50, 150, 20, 100), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(250, 50, 20, 100), c).IsEmpty()); + EXPECT_TRUE(m.TransformAndClipBounds(Rect(250, 150, 20, 100), c).IsEmpty()); + + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 50, 100, 100), c)) + .IsEqualInterior(Rect(100, 100, 50, 50))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(150, 50, 100, 100), c)) + .IsEqualInterior(Rect(150, 100, 50, 50))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(150, 150, 100, 100), c)) + .IsEqualInterior(Rect(150, 150, 50, 50))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 150, 100, 100), c)) + .IsEqualInterior(Rect(100, 150, 50, 50))); + + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(110, 110, 80, 80), c)) + .IsEqualInterior(Rect(110, 110, 80, 80))); + + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 50, 200, 200), c)) + .IsEqualInterior(Rect(100, 100, 100, 100))); + + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 50, 200, 100), c)) + .IsEqualInterior(Rect(100, 100, 100, 50))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 150, 200, 100), c)) + .IsEqualInterior(Rect(100, 150, 100, 50))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(50, 50, 100, 200), c)) + .IsEqualInterior(Rect(100, 100, 50, 100))); + EXPECT_TRUE(NudgedToInt(m.TransformAndClipBounds(Rect(150, 50, 100, 200), c)) + .IsEqualInterior(Rect(150, 100, 50, 100))); +} diff --git a/gfx/tests/gtest/moz.build b/gfx/tests/gtest/moz.build index 23b019d1b..ea18c1e3b 100644 --- a/gfx/tests/gtest/moz.build +++ b/gfx/tests/gtest/moz.build @@ -17,6 +17,7 @@ UNIFIED_SOURCES += [ 'TestGfxWidgets.cpp', 'TestJobScheduler.cpp', 'TestLayers.cpp', + 'TestMatrix.cpp', 'TestMoz2D.cpp', 'TestPolygon.cpp', 'TestQcms.cpp', |