From b70d8b334c4f714a046d72ea0a5f1a8378fd55b9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jun 2022 14:50:27 +0200 Subject: qtpy2cpp: Set up test infrastructure Add test code and move the files to baseline. Task-number: PYSIDE-1945 Pick-to: 6.3 Change-Id: I57975c774d53a4dc5f77ca671652ca32c04809de Reviewed-by: Shyamnath Premnadh Reviewed-by: Christian Tismer --- tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp (limited to 'tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp') diff --git a/tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp b/tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp new file mode 100644 index 000000000..8ee7be31e --- /dev/null +++ b/tools/qtpy2cpp_lib/tests/baseline/basic_test.cpp @@ -0,0 +1,62 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +// Converted from basic_test.py +#include +#include +#include +#include +#include +#include +#include + +class Window : public QWidget +{ +public: + + Window(QWidget * parent = nullptr) + { + super()->__init__(parent); + } + + void paintEvent(QPaintEvent * e) + { + paint("bla"); + } + + void paint(const QString & what, color = Qt::blue) + { + { // Converted from context manager + p = QPainter(); + p->setPen(QColor(color)); + rect = rect(); + w = rect->width(); + h = rect->height(); + p->drawLine(0, 0, w, h); + p->drawLine(0, h, w, 0); + p->drawText(rect->center(), what); + } + } + + void sum() + { + values = {1, 2, 3}; + result = 0; + for (v: values) { + result += v + } + return result; + } +}; + +int main(int argc, char *argv[]) +{ + QApplication app(sys->argv); + window = Window(); + auto *sc = new QShortcut((Qt::CTRL | Qt::Key_Q), window); + sc->activated->connect(window->close); + window->setWindowTitle("Test"); + window->show(); + sys->exit(app.exec()); + return 0; +} -- cgit v1.2.3