Skip to content

Commit 85d04fd

Browse files
authored
Add qpolygonF autotest (#918)
1 parent bd1b9e2 commit 85d04fd

File tree

6 files changed

+68
-0
lines changed

6 files changed

+68
-0
lines changed

tests/qt_types_standalone/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ add_executable(${APP_NAME}
6767
cpp/qpoint.h
6868
cpp/qpointf.h
6969
cpp/qpolygon.h
70+
cpp/qpolygonf.h
7071
cpp/qqmlapplicationengine.h
7172
cpp/qqmlengine.h
7273
cpp/qrect.h

tests/qt_types_standalone/cpp/main.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qpoint.h"
2727
#include "qpointf.h"
2828
#include "qpolygon.h"
29+
#include "qpolygonf.h"
2930
#include "qqmlapplicationengine.h"
3031
#include "qqmlengine.h"
3132
#include "qrect.h"
@@ -93,6 +94,7 @@ main(int argc, char* argv[])
9394
runTest(QScopedPointer<QObject>(new QVector3DTest));
9495
runTest(QScopedPointer<QObject>(new QVector4DTest));
9596
runTest(QScopedPointer<QObject>(new QPolygonTest));
97+
runTest(QScopedPointer<QObject>(new QPolygonFTest));
9698
runTest(QScopedPointer<QObject>(new QRegionTest));
9799

98100
return status;
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// clang-format off
2+
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
3+
// clang-format on
4+
// SPDX-FileContributor: Laurent Montel <[email protected]>
5+
//
6+
// SPDX-License-Identifier: MIT OR Apache-2.0
7+
#pragma once
8+
9+
#include <QtGui/QPolygonF>
10+
#include <QtTest/QTest>
11+
12+
#include "cxx-qt-gen/qpolygonf.cxx.h"
13+
14+
class QPolygonFTest : public QObject
15+
{
16+
Q_OBJECT
17+
18+
private Q_SLOTS:
19+
void construct()
20+
{
21+
const auto m = construct_qpolygonf();
22+
QVERIFY(m.isEmpty());
23+
}
24+
void clone()
25+
{
26+
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
27+
const auto m = QPolygonF(QList<QPoint>() << QPoint(1, 2) << QPoint(3, 4));
28+
#else
29+
const auto m = QPolygonF(QVector<QPoint>() << QPoint(1, 2) << QPoint(3, 4));
30+
#endif
31+
const auto c = clone_qpolygonf(m);
32+
QCOMPARE(c.toPolygon().point(0), QPoint(1, 2));
33+
QCOMPARE(c.toPolygon().point(1), QPoint(3, 4));
34+
}
35+
};

tests/qt_types_standalone/rust/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ fn main() {
2626
.file("src/qpoint.rs")
2727
.file("src/qpointf.rs")
2828
.file("src/qpolygon.rs")
29+
.file("src/qpolygonf.rs")
2930
.file("src/qqmlapplicationengine.rs")
3031
.file("src/qqmlengine.rs")
3132
.file("src/qrect.rs")

tests/qt_types_standalone/rust/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mod qpersistentmodelindex;
2323
mod qpoint;
2424
mod qpointf;
2525
mod qpolygon;
26+
mod qpolygonf;
2627
mod qqmlapplicationengine;
2728
mod qqmlengine;
2829
mod qrect;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
// SPDX-FileContributor: Laurent Montel <[email protected]>
3+
//
4+
// SPDX-License-Identifier: MIT OR Apache-2.0
5+
6+
use cxx_qt_lib::QPolygonF;
7+
8+
#[cxx::bridge]
9+
mod qpolygonf_cxx {
10+
unsafe extern "C++" {
11+
include!("cxx-qt-lib/qpolygonf.h");
12+
13+
type QPolygonF = cxx_qt_lib::QPolygonF;
14+
}
15+
16+
extern "Rust" {
17+
fn clone_qpolygonf(p: &QPolygonF) -> QPolygonF;
18+
fn construct_qpolygonf() -> QPolygonF;
19+
}
20+
}
21+
22+
fn construct_qpolygonf() -> QPolygonF {
23+
QPolygonF::default()
24+
}
25+
26+
fn clone_qpolygonf(p: &QPolygonF) -> QPolygonF {
27+
p.clone()
28+
}

0 commit comments

Comments
 (0)