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 QPainterPath autotest #919

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion crates/cxx-qt-lib/src/gui/qpainterpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ mod ffi {

#[repr(C)]
pub struct QPainterPath {
_cspec: MaybeUninit<i32>,
_cspec: MaybeUninit<usize>,
}

impl Default for QPainterPath {
Expand Down
1 change: 1 addition & 0 deletions tests/qt_types_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ add_executable(${APP_NAME}
cpp/qmarginsf.h
cpp/qmetaobjectconnection.h
cpp/qmodelindex.h
cpp/qpainterpath.h
cpp/qpersistentmodelindex.h
cpp/qpoint.h
cpp/qpointf.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 @@ -22,6 +22,7 @@
#include "qmarginsf.h"
#include "qmetaobjectconnection.h"
#include "qmodelindex.h"
#include "qpainterpath.h"
#include "qpersistentmodelindex.h"
#include "qpoint.h"
#include "qpointf.h"
Expand Down Expand Up @@ -92,6 +93,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 QPainterPathTest));

return status;
}
33 changes: 33 additions & 0 deletions tests/qt_types_standalone/cpp/qpainterpath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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/QPainterPath>
#include <QtTest/QTest>

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

class QPainterPathTest : public QObject
{
Q_OBJECT

private Q_SLOTS:
void construct()
{
const auto p = construct_qpainterpath();
QVERIFY(p.isEmpty());
}

void clone()
{
auto p = QPainterPath();
p.addEllipse(12, 5, 7, 9);
const auto c = clone_qpainterpath(p);
QVERIFY(!c.isEmpty());
QCOMPARE(c.elementCount(), p.elementCount());
}
};
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 @@ -22,6 +22,7 @@ fn main() {
.file("src/qmarginsf.rs")
.file("src/qmetaobjectconnection.rs")
.file("src/qmodelindex.rs")
.file("src/qpainterpath.rs")
.file("src/qpersistentmodelindex.rs")
.file("src/qpoint.rs")
.file("src/qpointf.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 @@ -19,6 +19,7 @@ mod qmargins;
mod qmarginsf;
mod qmetaobjectconnection;
mod qmodelindex;
mod qpainterpath;
mod qpersistentmodelindex;
mod qpoint;
mod qpointf;
Expand Down
28 changes: 28 additions & 0 deletions tests/qt_types_standalone/rust/src/qpainterpath.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::QPainterPath;

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

type QPainterPath = cxx_qt_lib::QPainterPath;
}

extern "Rust" {
fn construct_qpainterpath() -> QPainterPath;
fn clone_qpainterpath(p: &QPainterPath) -> QPainterPath;
}
}

fn construct_qpainterpath() -> QPainterPath {
QPainterPath::default()
}

fn clone_qpainterpath(p: &QPainterPath) -> QPainterPath {
p.clone()
}
Loading