Skip to content

Commit 17b1fc9

Browse files
committed
Fix tests
1 parent 795dd2c commit 17b1fc9

File tree

10 files changed

+25
-20
lines changed

10 files changed

+25
-20
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ jobs:
7474
export UBUNTU=${{ matrix.ubuntu }}
7575
export TAG=ghcr.io/rectalogic/renderwindow:${UBUNTU}-${{ github.ref_name }}
7676
builders/Linux/docker-run.sh
77+
builders/Linux/docker-run.sh /renderwindow/builders/renderwindow-test.sh --verbose
7778
- name: Build renderwindow vulkan
7879
if: matrix.ubuntu == 'noble'
7980
run: |
8081
export TARGET=vulkan
8182
export UBUNTU=${{ matrix.ubuntu }}
8283
export TAG=ghcr.io/rectalogic/renderwindow:${UBUNTU}-${{ github.ref_name }}
8384
builders/Linux/docker-run.sh
85+
builders/Linux/docker-run.sh /renderwindow/builders/renderwindow-test.sh --verbose
8486
- name: Archive
8587
id: archive
8688
if: github.ref_type == 'tag' && matrix.ubuntu == 'noble'
@@ -127,6 +129,7 @@ jobs:
127129
- name: Build renderwindow
128130
run: |
129131
builders/renderwindow-build.sh
132+
builders/renderwindow-test.sh --verbose
130133
- name: Archive
131134
id: archive
132135
if: github.ref_type == 'tag'

MediaFX/RenderWindow/render_window.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ RenderWindow::RenderWindow()
4545
m_isValid = true;
4646
}
4747

48-
RenderWindow::~RenderWindow() {
48+
RenderWindow::~RenderWindow()
49+
{
4950
if (m_animationDriver)
5051
m_animationDriver->uninstall();
5152
}

tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
find_package(Qt6 REQUIRED COMPONENTS Test)
55

6+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
67
set(CMAKE_AUTOMOC ON)
78

89
qt_add_executable(tst_render tst_render.cpp)

tests/Render.qml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ import QtQuick
22
import MediaFX.RenderWindow
33

44
RenderWindow {
5-
width: 160
6-
height: 160
5+
width: 100
6+
height: 100
77

88
Rectangle {
9-
width: 100
10-
height: 100
9+
width: 60
10+
height: 40
1111
color: "green"
1212
anchors.centerIn: parent
1313
RotationAnimation on rotation {
14-
loops: Animation.Infinite
15-
duration: 2000
14+
duration: 1000
1615
from: 0
17-
to: 360
16+
to: 90
1817
}
1918
}
2019
}

tests/fixtures/render-0.png

354 Bytes
Loading

tests/fixtures/render-1.png

630 Bytes
Loading

tests/fixtures/render-2.png

704 Bytes
Loading

tests/fixtures/render-3.png

613 Bytes
Loading

tests/fixtures/render-4.png

354 Bytes
Loading

tests/tst_render.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,39 @@
44
#include <QByteArray>
55
#include <QImage>
66
#include <QObject>
7+
#include <QQmlApplicationEngine>
78
#include <QSize>
89
#include <QString>
910
#include <QWindow>
10-
#include <QtTest>
1111
#include <QtCore>
12-
#include <QQmlApplicationEngine>
12+
#include <QtTest>
1313
using namespace Qt::Literals::StringLiterals;
1414

1515
class tst_Render : public QObject {
1616
Q_OBJECT
1717

1818
public slots:
19-
void onCreated(QObject *object, const QUrl &url)
19+
void onCreated(QObject* object, const QUrl& url)
2020
{
2121
QVERIFY(object);
22-
QWindow *window = qobject_cast<QWindow*>(object);
22+
QWindow* window = qobject_cast<QWindow*>(object);
2323
QSize size = window->size();
24-
QByteArray data;
25-
for (int i = 0; i < 5; i++) {
24+
for (int i = 0; i < 5; i++) { // NOLINT
25+
QByteArray data;
2626
QMetaObject::invokeMethod(object, "render",
2727
Q_RETURN_ARG(QByteArray, data),
28-
Q_ARG(qint64, i * 500));
28+
Q_ARG(qint64, static_cast<qint64>(i * 250)));
2929
QVERIFY(!data.isNull());
30-
QImage image(reinterpret_cast<const uchar*>(data.constData()), size.width(), size.height(), QImage::Format_RGBA8888);
31-
//XXX specify directory
32-
image.save(u"render-%1.png"_s.arg(i));
30+
QImage fixture(QFINDTESTDATA(u"fixtures/render-%1.png"_s.arg(i)));
31+
QImage image(reinterpret_cast<const uchar*>(data.constData()), size.width(), size.height(), QImage::Format_RGBA8888_Premultiplied); // NOLINT
32+
// image.save(u"render-%1.png"_s.arg(i));
33+
QCOMPARE_EQ(image, fixture.convertToFormat(QImage::Format_RGBA8888_Premultiplied));
34+
QTest::qWait(100); // NOLINT
3335
}
3436
}
3537

36-
3738
private slots:
38-
void decode()
39+
void render()
3940
{
4041
QQmlApplicationEngine engine;
4142
connect(&engine, &QQmlApplicationEngine::objectCreated, this, &tst_Render::onCreated);

0 commit comments

Comments
 (0)