From 86bf0212e46f7348f608fbfe41356f3b62b2f97f Mon Sep 17 00:00:00 2001 From: Znurre Date: Wed, 28 Mar 2018 17:14:10 +0200 Subject: [PATCH] Added Splitter layout tests --- tests/auto/layouts/layouts.pro | 9 +++-- tests/auto/layouts/qml.qrc | 1 + tests/auto/layouts/qml/SplitterTest.qml | 37 ++++++++++++++++++ tests/auto/layouts/splitter.cpp | 42 ++++++++++++++++++++ tests/auto/layouts/splitter.h | 52 +++++++++++++++++++++++++ tests/auto/layouts/splitter.ui | 18 +++++++++ tests/auto/layouts/tst_layouts.cpp | 23 +++++++++++ 7 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 tests/auto/layouts/qml/SplitterTest.qml create mode 100644 tests/auto/layouts/splitter.cpp create mode 100644 tests/auto/layouts/splitter.h create mode 100644 tests/auto/layouts/splitter.ui diff --git a/tests/auto/layouts/layouts.pro b/tests/auto/layouts/layouts.pro index 82ad540..77eb65e 100644 --- a/tests/auto/layouts/layouts.pro +++ b/tests/auto/layouts/layouts.pro @@ -6,7 +6,8 @@ SOURCES += tst_layouts.cpp \ formlayoutwidget.cpp \ gridlayoutwidget.cpp \ stackedlayoutwidget.cpp \ - stackedwidget.cpp + stackedwidget.cpp \ + splitter.cpp RESOURCES += \ qml.qrc @@ -16,7 +17,8 @@ FORMS += \ vboxlayout.ui \ formlayout.ui \ gridlayout.ui \ - stackedwidget.ui + stackedwidget.ui \ + splitter.ui HEADERS += \ hboxlayoutwidget.h \ @@ -24,4 +26,5 @@ HEADERS += \ formlayoutwidget.h \ gridlayoutwidget.h \ stackedlayoutwidget.h \ - stackedwidget.h + stackedwidget.h \ + splitter.h diff --git a/tests/auto/layouts/qml.qrc b/tests/auto/layouts/qml.qrc index a71de82..c150531 100644 --- a/tests/auto/layouts/qml.qrc +++ b/tests/auto/layouts/qml.qrc @@ -6,5 +6,6 @@ qml/GridLayoutTest.qml qml/StackedLayoutTest.qml qml/StackedWidgetTest.qml + qml/SplitterTest.qml diff --git a/tests/auto/layouts/qml/SplitterTest.qml b/tests/auto/layouts/qml/SplitterTest.qml new file mode 100644 index 0000000..d3b5bbf --- /dev/null +++ b/tests/auto/layouts/qml/SplitterTest.qml @@ -0,0 +1,37 @@ +/* + SplitterTest.qml + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import QtWidgets 1.0 + +Splitter { + Label { + text: "Label 1" + } + Label { + text: "Label 2" + } +} diff --git a/tests/auto/layouts/splitter.cpp b/tests/auto/layouts/splitter.cpp new file mode 100644 index 0000000..ff1b881 --- /dev/null +++ b/tests/auto/layouts/splitter.cpp @@ -0,0 +1,42 @@ +/* + splitter.cpp + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "splitter.h" + +#include "ui_splitter.h" + +Splitter::Splitter(QWidget *parent) + : QSplitter(parent) + , ui(new Ui::Splitter) +{ + ui->setupUi(this); +} + +Splitter::~Splitter() +{ + delete ui; +} diff --git a/tests/auto/layouts/splitter.h b/tests/auto/layouts/splitter.h new file mode 100644 index 0000000..894229a --- /dev/null +++ b/tests/auto/layouts/splitter.h @@ -0,0 +1,52 @@ +/* + splitter.h + + This file is part of DeclarativeWidgets, library and tools for creating QtWidget UIs with QML. + + Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Lova Widmark + + Licensees holding valid commercial KDAB DeclarativeWidgets licenses may use this file in + accordance with DeclarativeWidgets Commercial License Agreement provided with the Software. + + Contact info@kdab.com if any conditions of this licensing are not clear to you. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef SPLITTER_H +#define SPLITTER_H + +#include + +QT_BEGIN_NAMESPACE +namespace Ui +{ + class Splitter; +} +QT_END_NAMESPACE + +class Splitter : public QSplitter +{ + Q_OBJECT + + public: + explicit Splitter(QWidget *parent = Q_NULLPTR); + ~Splitter(); + + private: + Ui::Splitter *ui; +}; + +#endif // SPLITTER_H diff --git a/tests/auto/layouts/splitter.ui b/tests/auto/layouts/splitter.ui new file mode 100644 index 0000000..434d5ed --- /dev/null +++ b/tests/auto/layouts/splitter.ui @@ -0,0 +1,18 @@ + + + Splitter + + + + Label 1 + + + + + Label 2 + + + + + + diff --git a/tests/auto/layouts/tst_layouts.cpp b/tests/auto/layouts/tst_layouts.cpp index 8eefa78..b81f1a3 100644 --- a/tests/auto/layouts/tst_layouts.cpp +++ b/tests/auto/layouts/tst_layouts.cpp @@ -31,6 +31,7 @@ #include "vboxlayoutwidget.h" #include "formlayoutwidget.h" #include "gridlayoutwidget.h" +#include "splitter.h" #include "stackedlayoutwidget.h" #include "stackedwidget.h" @@ -65,6 +66,8 @@ private slots: void stackedWidget(); void sizePolicy_data(); void sizePolicy(); + void splitter_data(); + void splitter(); private: QQmlEngine* m_qmlEngine; @@ -214,6 +217,26 @@ void tst_Layouts::stackedWidget() testLayouts(uiWidget, declarativeWidget); } +void tst_Layouts::splitter_data() +{ + QQmlComponent component(m_qmlEngine, QUrl(QStringLiteral("qrc:/qml/SplitterTest.qml"))); + QWidgetPtr declarativeWidget(qobject_cast(component.create())); + QVERIFY(declarativeWidget != nullptr); + + QTest::addColumn("uiWidget"); + QTest::addColumn("declarativeWidget"); + + QTest::newRow("splitterWidget") << QWidgetPtr(new Splitter()) << declarativeWidget; +} + +void tst_Layouts::splitter() +{ + QFETCH(QWidgetPtr, uiWidget); + QFETCH(QWidgetPtr, declarativeWidget); + + testLayouts(uiWidget, declarativeWidget); +} + void tst_Layouts::sizePolicy_data() { // QSizePolicy::ControlType is not registered with the meta-type system.