Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qpolygonF autotest #103

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/qt_types_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ add_executable(${APP_NAME}
cpp/qpoint.h
cpp/qpointf.h
cpp/qpolygon.h
cpp/qpolygonf.h
cpp/qqmlapplicationengine.h
cpp/qqmlengine.h
cpp/qrect.h
Expand Down
2 changes: 2 additions & 0 deletions tests/qt_types_standalone/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qpoint.h"
#include "qpointf.h"
#include "qpolygon.h"
#include "qpolygonf.h"
#include "qqmlapplicationengine.h"
#include "qqmlengine.h"
#include "qrect.h"
Expand Down Expand Up @@ -93,6 +94,7 @@ main(int argc, char* argv[])
runTest(QScopedPointer<QObject>(new QVector3DTest));
runTest(QScopedPointer<QObject>(new QVector4DTest));
runTest(QScopedPointer<QObject>(new QPolygonTest));
runTest(QScopedPointer<QObject>(new QPolygonFTest));
runTest(QScopedPointer<QObject>(new QRegionTest));

return status;
Expand Down
35 changes: 35 additions & 0 deletions tests/qt_types_standalone/cpp/qpolygonf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// clang-format off
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
// clang-format on
// SPDX-FileContributor: Laurent Montel <[email protected]>
//
// SPDX-License-Identifier: MIT OR Apache-2.0
#pragma once

#include <QtGui/QPolygonF>
#include <QtTest/QTest>

#include "cxx-qt-gen/qpolygonf.cxx.h"

class QPolygonFTest : public QObject
{
Q_OBJECT

private Q_SLOTS:
void construct()
{
const auto m = construct_qpolygonf();
QVERIFY(m.isEmpty());
}
void clone()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
const auto m = QPolygonF(QList<QPoint>() << QPoint(1, 2) << QPoint(3, 4));
#else
const auto m = QPolygonF(QVector<QPoint>() << QPoint(1, 2) << QPoint(3, 4));
#endif
const auto c = clone_qpolygonf(m);
QCOMPARE(c.toPolygon().point(0), QPoint(1, 2));
QCOMPARE(c.toPolygon().point(1), QPoint(3, 4));
}
};
1 change: 1 addition & 0 deletions tests/qt_types_standalone/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fn main() {
.file("src/qpoint.rs")
.file("src/qpointf.rs")
.file("src/qpolygon.rs")
.file("src/qpolygonf.rs")
.file("src/qqmlapplicationengine.rs")
.file("src/qqmlengine.rs")
.file("src/qrect.rs")
Expand Down
1 change: 1 addition & 0 deletions tests/qt_types_standalone/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod qpersistentmodelindex;
mod qpoint;
mod qpointf;
mod qpolygon;
mod qpolygonf;
mod qqmlapplicationengine;
mod qqmlengine;
mod qrect;
Expand Down
28 changes: 28 additions & 0 deletions tests/qt_types_standalone/rust/src/qpolygonf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
// SPDX-FileContributor: Laurent Montel <[email protected]>
//
// SPDX-License-Identifier: MIT OR Apache-2.0

use cxx_qt_lib::QPolygonF;

#[cxx::bridge]
mod qpolygonf_cxx {
unsafe extern "C++" {
include!("cxx-qt-lib/qpolygonf.h");

type QPolygonF = cxx_qt_lib::QPolygonF;
}

extern "Rust" {
fn clone_qpolygonf(p: &QPolygonF) -> QPolygonF;
fn construct_qpolygonf() -> QPolygonF;
}
}

fn construct_qpolygonf() -> QPolygonF {
QPolygonF::default()
}

fn clone_qpolygonf(p: &QPolygonF) -> QPolygonF {
p.clone()
}
Loading