2023-12-14 20:37:34 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QTest>
|
|
|
|
|
|
|
|
#include "core/output.h"
|
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
using namespace KWin;
|
|
|
|
|
2023-12-14 20:37:34 +00:00
|
|
|
class TestOutputTransform : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
TestOutputTransform();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void mapSizeF_data();
|
|
|
|
void mapSizeF();
|
2023-12-20 08:58:26 +00:00
|
|
|
void mapSize_data();
|
|
|
|
void mapSize();
|
2023-12-14 20:37:34 +00:00
|
|
|
void mapRectF_data();
|
|
|
|
void mapRectF();
|
2023-12-20 08:58:26 +00:00
|
|
|
void mapRect_data();
|
|
|
|
void mapRect();
|
2023-12-20 09:49:28 +00:00
|
|
|
void mapPointF_data();
|
|
|
|
void mapPointF();
|
|
|
|
void mapPoint_data();
|
|
|
|
void mapPoint();
|
2023-12-14 20:37:34 +00:00
|
|
|
void inverted_data();
|
|
|
|
void inverted();
|
2023-10-06 11:16:45 +00:00
|
|
|
void combine_data();
|
|
|
|
void combine();
|
2023-12-20 08:24:43 +00:00
|
|
|
void matrix_data();
|
|
|
|
void matrix();
|
2023-12-14 20:37:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
TestOutputTransform::TestOutputTransform()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapSizeF_data()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
2023-12-14 20:37:34 +00:00
|
|
|
QTest::addColumn<QSizeF>("source");
|
|
|
|
QTest::addColumn<QSizeF>("target");
|
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QSizeF(10, 20) << QSizeF(10, 20);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QSizeF(10, 20) << QSizeF(20, 10);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QSizeF(10, 20) << QSizeF(10, 20);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QSizeF(10, 20) << QSizeF(20, 10);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QSizeF(10, 20) << QSizeF(10, 20);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QSizeF(10, 20) << QSizeF(20, 10);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QSizeF(10, 20) << QSizeF(10, 20);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QSizeF(10, 20) << QSizeF(20, 10);
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapSizeF()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
2023-12-14 20:37:34 +00:00
|
|
|
QFETCH(QSizeF, source);
|
|
|
|
QFETCH(QSizeF, target);
|
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
QCOMPARE(OutputTransform(kind).map(source), target);
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 08:58:26 +00:00
|
|
|
void TestOutputTransform::mapSize_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<QSize>("source");
|
|
|
|
QTest::addColumn<QSize>("target");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QSize(10, 20) << QSize(10, 20);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QSize(10, 20) << QSize(20, 10);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QSize(10, 20) << QSize(10, 20);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QSize(10, 20) << QSize(20, 10);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QSize(10, 20) << QSize(10, 20);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QSize(10, 20) << QSize(20, 10);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QSize(10, 20) << QSize(10, 20);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QSize(10, 20) << QSize(20, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapSize()
|
|
|
|
{
|
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(QSize, source);
|
|
|
|
QFETCH(QSize, target);
|
|
|
|
|
|
|
|
QCOMPARE(OutputTransform(kind).map(source), target);
|
|
|
|
}
|
|
|
|
|
2023-12-14 20:37:34 +00:00
|
|
|
void TestOutputTransform::mapRectF_data()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
2023-12-14 20:37:34 +00:00
|
|
|
QTest::addColumn<QRectF>("source");
|
|
|
|
QTest::addColumn<QRectF>("target");
|
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QRectF(10, 20, 30, 40) << QRectF(10, 20, 30, 40);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QRectF(10, 20, 30, 40) << QRectF(140, 10, 40, 30);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QRectF(10, 20, 30, 40) << QRectF(60, 140, 30, 40);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QRectF(10, 20, 30, 40) << QRectF(20, 60, 40, 30);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QRectF(10, 20, 30, 40) << QRectF(60, 20, 30, 40);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QRectF(10, 20, 30, 40) << QRectF(20, 10, 40, 30);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QRectF(10, 20, 30, 40) << QRectF(10, 140, 30, 40);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QRectF(10, 20, 30, 40) << QRectF(140, 60, 40, 30);
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapRectF()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
2023-12-14 20:37:34 +00:00
|
|
|
QFETCH(QRectF, source);
|
|
|
|
QFETCH(QRectF, target);
|
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
QCOMPARE(OutputTransform(kind).map(source, QSizeF(100, 200)), target);
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
2023-12-20 08:58:26 +00:00
|
|
|
void TestOutputTransform::mapRect_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<QRect>("source");
|
|
|
|
QTest::addColumn<QRect>("target");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QRect(10, 20, 30, 40) << QRect(10, 20, 30, 40);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QRect(10, 20, 30, 40) << QRect(140, 10, 40, 30);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QRect(10, 20, 30, 40) << QRect(60, 140, 30, 40);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QRect(10, 20, 30, 40) << QRect(20, 60, 40, 30);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QRect(10, 20, 30, 40) << QRect(60, 20, 30, 40);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QRect(10, 20, 30, 40) << QRect(20, 10, 40, 30);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QRect(10, 20, 30, 40) << QRect(10, 140, 30, 40);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QRect(10, 20, 30, 40) << QRect(140, 60, 40, 30);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapRect()
|
|
|
|
{
|
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(QRect, source);
|
|
|
|
QFETCH(QRect, target);
|
|
|
|
|
|
|
|
QCOMPARE(OutputTransform(kind).map(source, QSize(100, 200)), target);
|
|
|
|
}
|
|
|
|
|
2023-12-20 09:49:28 +00:00
|
|
|
void TestOutputTransform::mapPointF_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<QPointF>("source");
|
|
|
|
QTest::addColumn<QPointF>("target");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QPointF(10, 20) << QPointF(10, 20);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QPointF(10, 20) << QPointF(180, 10);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QPointF(10, 20) << QPointF(90, 180);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QPointF(10, 20) << QPointF(20, 90);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QPointF(10, 20) << QPointF(90, 20);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QPointF(10, 20) << QPointF(20, 10);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QPointF(10, 20) << QPointF(10, 180);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QPointF(10, 20) << QPointF(180, 90);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapPointF()
|
|
|
|
{
|
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(QPointF, source);
|
|
|
|
QFETCH(QPointF, target);
|
|
|
|
|
|
|
|
const OutputTransform transform(kind);
|
|
|
|
|
|
|
|
QCOMPARE(transform.map(source, QSizeF(100, 200)), target);
|
|
|
|
QCOMPARE(transform.map(QRectF(source, QSizeF(0, 0)), QSizeF(100, 200)), QRectF(target, QSizeF(0, 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapPoint_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<QPoint>("source");
|
|
|
|
QTest::addColumn<QPoint>("target");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QPoint(10, 20) << QPoint(10, 20);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QPoint(10, 20) << QPoint(180, 10);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QPoint(10, 20) << QPoint(90, 180);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QPoint(10, 20) << QPoint(20, 90);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QPoint(10, 20) << QPoint(90, 20);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QPoint(10, 20) << QPoint(20, 10);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QPoint(10, 20) << QPoint(10, 180);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QPoint(10, 20) << QPoint(180, 90);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::mapPoint()
|
|
|
|
{
|
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(QPoint, source);
|
|
|
|
QFETCH(QPoint, target);
|
|
|
|
|
|
|
|
const OutputTransform transform(kind);
|
|
|
|
|
|
|
|
QCOMPARE(transform.map(source, QSize(100, 200)), target);
|
|
|
|
QCOMPARE(transform.map(QRect(source, QSize(0, 0)), QSize(100, 200)), QRect(target, QSize(0, 0)));
|
|
|
|
}
|
|
|
|
|
2023-12-14 20:37:34 +00:00
|
|
|
void TestOutputTransform::inverted_data()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("inverted");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << OutputTransform::Normal;
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << OutputTransform::Flipped270;
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::inverted()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(OutputTransform::Kind, inverted);
|
2023-12-14 20:37:34 +00:00
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
QCOMPARE(OutputTransform(kind).inverted(), OutputTransform(inverted));
|
2023-12-14 20:37:34 +00:00
|
|
|
}
|
|
|
|
|
2023-10-06 11:16:45 +00:00
|
|
|
void TestOutputTransform::combine_data()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QTest::addColumn<OutputTransform::Kind>("first");
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("second");
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("result");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | rotate-0") << OutputTransform::Normal << OutputTransform::Normal << OutputTransform::Normal;
|
|
|
|
QTest::addRow("rotate-90 | rotate-0") << OutputTransform::Rotated90 << OutputTransform::Normal << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("rotate-180 | rotate-0") << OutputTransform::Rotated180 << OutputTransform::Normal << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("rotate-270 | rotate-0") << OutputTransform::Rotated270 << OutputTransform::Normal << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("flip-0 | rotate-0") << OutputTransform::Flipped << OutputTransform::Normal << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("flip-90 | rotate-0") << OutputTransform::Flipped90 << OutputTransform::Normal << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("flip-180 | rotate-0") << OutputTransform::Flipped180 << OutputTransform::Normal << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("flip-270 | rotate-0") << OutputTransform::Flipped270 << OutputTransform::Normal << OutputTransform::Flipped270;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | rotate-90") << OutputTransform::Normal << OutputTransform::Rotated90 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("rotate-90 | rotate-90") << OutputTransform::Rotated90 << OutputTransform::Rotated90 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("rotate-180 | rotate-90") << OutputTransform::Rotated180 << OutputTransform::Rotated90 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("rotate-270 | rotate-90") << OutputTransform::Rotated270 << OutputTransform::Rotated90 << OutputTransform::Normal;
|
|
|
|
QTest::addRow("flip-0 | rotate-90") << OutputTransform::Flipped << OutputTransform::Rotated90 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("flip-90 | rotate-90") << OutputTransform::Flipped90 << OutputTransform::Rotated90 << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("flip-180 | rotate-90") << OutputTransform::Flipped180 << OutputTransform::Rotated90 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("flip-270 | rotate-90") << OutputTransform::Flipped270 << OutputTransform::Rotated90 << OutputTransform::Flipped180;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | rotate-180") << OutputTransform::Normal << OutputTransform::Rotated180 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("rotate-90 | rotate-180") << OutputTransform::Rotated90 << OutputTransform::Rotated180 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("rotate-180 | rotate-180") << OutputTransform::Rotated180 << OutputTransform::Rotated180 << OutputTransform::Normal;
|
|
|
|
QTest::addRow("rotate-270 | rotate-180") << OutputTransform::Rotated270 << OutputTransform::Rotated180 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("flip-0 | rotate-180") << OutputTransform::Flipped << OutputTransform::Rotated180 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("flip-90 | rotate-180") << OutputTransform::Flipped90 << OutputTransform::Rotated180 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("flip-180 | rotate-180") << OutputTransform::Flipped180 << OutputTransform::Rotated180 << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("flip-270 | rotate-180") << OutputTransform::Flipped270 << OutputTransform::Rotated180 << OutputTransform::Flipped90;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | rotate-270") << OutputTransform::Normal << OutputTransform::Rotated270 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("rotate-90 | rotate-270") << OutputTransform::Rotated90 << OutputTransform::Rotated270 << OutputTransform::Normal;
|
|
|
|
QTest::addRow("rotate-180 | rotate-270") << OutputTransform::Rotated180 << OutputTransform::Rotated270 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("rotate-270 | rotate-270") << OutputTransform::Rotated270 << OutputTransform::Rotated270 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("flip-0 | rotate-270") << OutputTransform::Flipped << OutputTransform::Rotated270 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("flip-90 | rotate-270") << OutputTransform::Flipped90 << OutputTransform::Rotated270 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("flip-180 | rotate-270") << OutputTransform::Flipped180 << OutputTransform::Rotated270 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("flip-270 | rotate-270") << OutputTransform::Flipped270 << OutputTransform::Rotated270 << OutputTransform::Flipped;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | flip-0") << OutputTransform::Normal << OutputTransform::Flipped << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("rotate-90 | flip-0") << OutputTransform::Rotated90 << OutputTransform::Flipped << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("rotate-180 | flip-0") << OutputTransform::Rotated180 << OutputTransform::Flipped << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("rotate-270 | flip-0") << OutputTransform::Rotated270 << OutputTransform::Flipped << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("flip-0 | flip-0") << OutputTransform::Flipped << OutputTransform::Flipped << OutputTransform::Normal;
|
|
|
|
QTest::addRow("flip-90 | flip-0") << OutputTransform::Flipped90 << OutputTransform::Flipped << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("flip-180 | flip-0") << OutputTransform::Flipped180 << OutputTransform::Flipped << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("flip-270 | flip-0") << OutputTransform::Flipped270 << OutputTransform::Flipped << OutputTransform::Rotated270;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | flip-90") << OutputTransform::Normal << OutputTransform::Flipped90 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("rotate-90 | flip-90") << OutputTransform::Rotated90 << OutputTransform::Flipped90 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("rotate-180 | flip-90") << OutputTransform::Rotated180 << OutputTransform::Flipped90 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("rotate-270 | flip-90") << OutputTransform::Rotated270 << OutputTransform::Flipped90 << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("flip-0 | flip-90") << OutputTransform::Flipped << OutputTransform::Flipped90 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("flip-90 | flip-90") << OutputTransform::Flipped90 << OutputTransform::Flipped90 << OutputTransform::Normal;
|
|
|
|
QTest::addRow("flip-180 | flip-90") << OutputTransform::Flipped180 << OutputTransform::Flipped90 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("flip-270 | flip-90") << OutputTransform::Flipped270 << OutputTransform::Flipped90 << OutputTransform::Rotated180;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | flip-180") << OutputTransform::Normal << OutputTransform::Flipped180 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("rotate-90 | flip-180") << OutputTransform::Rotated90 << OutputTransform::Flipped180 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("rotate-180 | flip-180") << OutputTransform::Rotated180 << OutputTransform::Flipped180 << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("rotate-270 | flip-180") << OutputTransform::Rotated270 << OutputTransform::Flipped180 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("flip-0 | flip-180") << OutputTransform::Flipped << OutputTransform::Flipped180 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("flip-90 | flip-180") << OutputTransform::Flipped90 << OutputTransform::Flipped180 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("flip-180 | flip-180") << OutputTransform::Flipped180 << OutputTransform::Flipped180 << OutputTransform::Normal;
|
|
|
|
QTest::addRow("flip-270 | flip-180") << OutputTransform::Flipped270 << OutputTransform::Flipped180 << OutputTransform::Rotated90;
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0 | flip-270") << OutputTransform::Normal << OutputTransform::Flipped270 << OutputTransform::Flipped270;
|
|
|
|
QTest::addRow("rotate-90 | flip-270") << OutputTransform::Rotated90 << OutputTransform::Flipped270 << OutputTransform::Flipped;
|
|
|
|
QTest::addRow("rotate-180 | flip-270") << OutputTransform::Rotated180 << OutputTransform::Flipped270 << OutputTransform::Flipped90;
|
|
|
|
QTest::addRow("rotate-270 | flip-270") << OutputTransform::Rotated270 << OutputTransform::Flipped270 << OutputTransform::Flipped180;
|
|
|
|
QTest::addRow("flip-0 | flip-270") << OutputTransform::Flipped << OutputTransform::Flipped270 << OutputTransform::Rotated90;
|
|
|
|
QTest::addRow("flip-90 | flip-270") << OutputTransform::Flipped90 << OutputTransform::Flipped270 << OutputTransform::Rotated180;
|
|
|
|
QTest::addRow("flip-180 | flip-270") << OutputTransform::Flipped180 << OutputTransform::Flipped270 << OutputTransform::Rotated270;
|
|
|
|
QTest::addRow("flip-270 | flip-270") << OutputTransform::Flipped270 << OutputTransform::Flipped270 << OutputTransform::Normal;
|
2023-10-06 11:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::combine()
|
|
|
|
{
|
2023-12-19 13:40:47 +00:00
|
|
|
QFETCH(OutputTransform::Kind, first);
|
|
|
|
QFETCH(OutputTransform::Kind, second);
|
|
|
|
QFETCH(OutputTransform::Kind, result);
|
2023-10-06 11:16:45 +00:00
|
|
|
|
2023-12-19 13:40:47 +00:00
|
|
|
const OutputTransform firstTransform(first);
|
|
|
|
const OutputTransform secondTransform(second);
|
|
|
|
const OutputTransform combinedTransform = firstTransform.combine(secondTransform);
|
2023-10-06 11:16:45 +00:00
|
|
|
QCOMPARE(combinedTransform.kind(), result);
|
|
|
|
|
|
|
|
const QRectF box(10, 20, 30, 40);
|
|
|
|
const QSizeF bounds(100, 200);
|
|
|
|
QCOMPARE(combinedTransform.map(box, bounds), secondTransform.map(firstTransform.map(box, bounds), firstTransform.map(bounds)));
|
|
|
|
}
|
|
|
|
|
2023-12-20 08:24:43 +00:00
|
|
|
void TestOutputTransform::matrix_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<OutputTransform::Kind>("kind");
|
|
|
|
QTest::addColumn<QRectF>("source");
|
|
|
|
QTest::addColumn<QRectF>("target");
|
|
|
|
|
|
|
|
QTest::addRow("rotate-0") << OutputTransform::Normal << QRectF(10, 20, 30, 40) << QRectF(10, 20, 30, 40);
|
|
|
|
QTest::addRow("rotate-90") << OutputTransform::Rotated90 << QRectF(10, 20, 30, 40) << QRectF(140, 10, 40, 30);
|
|
|
|
QTest::addRow("rotate-180") << OutputTransform::Rotated180 << QRectF(10, 20, 30, 40) << QRectF(60, 140, 30, 40);
|
|
|
|
QTest::addRow("rotate-270") << OutputTransform::Rotated270 << QRectF(10, 20, 30, 40) << QRectF(20, 60, 40, 30);
|
|
|
|
QTest::addRow("flip-0") << OutputTransform::Flipped << QRectF(10, 20, 30, 40) << QRectF(60, 20, 30, 40);
|
|
|
|
QTest::addRow("flip-90") << OutputTransform::Flipped90 << QRectF(10, 20, 30, 40) << QRectF(20, 10, 40, 30);
|
|
|
|
QTest::addRow("flip-180") << OutputTransform::Flipped180 << QRectF(10, 20, 30, 40) << QRectF(10, 140, 30, 40);
|
|
|
|
QTest::addRow("flip-270") << OutputTransform::Flipped270 << QRectF(10, 20, 30, 40) << QRectF(140, 60, 40, 30);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestOutputTransform::matrix()
|
|
|
|
{
|
|
|
|
QFETCH(OutputTransform::Kind, kind);
|
|
|
|
QFETCH(QRectF, source);
|
|
|
|
QFETCH(QRectF, target);
|
|
|
|
|
|
|
|
const OutputTransform transform = kind;
|
|
|
|
const QSizeF sourceBounds = QSizeF(100, 200);
|
|
|
|
const QSizeF targetBounds = transform.map(sourceBounds);
|
|
|
|
|
|
|
|
QMatrix4x4 matrix;
|
|
|
|
matrix.scale(targetBounds.width(), targetBounds.height());
|
|
|
|
matrix.translate(0.5, 0.5);
|
|
|
|
matrix.scale(0.5, -0.5);
|
|
|
|
matrix.scale(1, -1); // flip the y axis back
|
|
|
|
matrix *= transform.toMatrix();
|
|
|
|
matrix.scale(1, -1); // undo ortho() flipping the y axis
|
|
|
|
matrix.ortho(QRectF(0, 0, sourceBounds.width(), sourceBounds.height()));
|
|
|
|
|
|
|
|
const QRectF mapped = matrix.mapRect(source);
|
|
|
|
QCOMPARE(mapped, target);
|
|
|
|
QCOMPARE(mapped, transform.map(source, sourceBounds));
|
|
|
|
}
|
|
|
|
|
2023-12-14 20:37:34 +00:00
|
|
|
QTEST_MAIN(TestOutputTransform)
|
|
|
|
|
|
|
|
#include "output_transform_test.moc"
|