Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Added Splitter layout tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Znurre committed Mar 28, 2018
1 parent 39f8031 commit 86bf021
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/auto/layouts/layouts.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ SOURCES += tst_layouts.cpp \
formlayoutwidget.cpp \
gridlayoutwidget.cpp \
stackedlayoutwidget.cpp \
stackedwidget.cpp
stackedwidget.cpp \
splitter.cpp

RESOURCES += \
qml.qrc
Expand All @@ -16,12 +17,14 @@ FORMS += \
vboxlayout.ui \
formlayout.ui \
gridlayout.ui \
stackedwidget.ui
stackedwidget.ui \
splitter.ui

HEADERS += \
hboxlayoutwidget.h \
vboxlayoutwidget.h \
formlayoutwidget.h \
gridlayoutwidget.h \
stackedlayoutwidget.h \
stackedwidget.h
stackedwidget.h \
splitter.h
1 change: 1 addition & 0 deletions tests/auto/layouts/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<file>qml/GridLayoutTest.qml</file>
<file>qml/StackedLayoutTest.qml</file>
<file>qml/StackedWidgetTest.qml</file>
<file>qml/SplitterTest.qml</file>
</qresource>
</RCC>
37 changes: 37 additions & 0 deletions tests/auto/layouts/qml/SplitterTest.qml
Original file line number Diff line number Diff line change
@@ -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 <znurree@gmail.com>
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 <http://www.gnu.org/licenses/>.
*/

import QtWidgets 1.0

Splitter {
Label {
text: "Label 1"
}
Label {
text: "Label 2"
}
}
42 changes: 42 additions & 0 deletions tests/auto/layouts/splitter.cpp
Original file line number Diff line number Diff line change
@@ -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 <znurree@gmail.com>
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 <http://www.gnu.org/licenses/>.
*/

#include "splitter.h"

#include "ui_splitter.h"

Splitter::Splitter(QWidget *parent)
: QSplitter(parent)
, ui(new Ui::Splitter)
{
ui->setupUi(this);
}

Splitter::~Splitter()
{
delete ui;
}
52 changes: 52 additions & 0 deletions tests/auto/layouts/splitter.h
Original file line number Diff line number Diff line change
@@ -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 <znurree@gmail.com>
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 <http://www.gnu.org/licenses/>.
*/

#ifndef SPLITTER_H
#define SPLITTER_H

#include <QSplitter>

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
18 changes: 18 additions & 0 deletions tests/auto/layouts/splitter.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Splitter</class>
<widget class="QSplitter" name="Splitter">
<widget class="QLabel" name="label">
<property name="text">
<string>Label 1</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Label 2</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
23 changes: 23 additions & 0 deletions tests/auto/layouts/tst_layouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "vboxlayoutwidget.h"
#include "formlayoutwidget.h"
#include "gridlayoutwidget.h"
#include "splitter.h"
#include "stackedlayoutwidget.h"
#include "stackedwidget.h"

Expand Down Expand Up @@ -65,6 +66,8 @@ private slots:
void stackedWidget();
void sizePolicy_data();
void sizePolicy();
void splitter_data();
void splitter();

private:
QQmlEngine* m_qmlEngine;
Expand Down Expand Up @@ -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<QWidget *>(component.create()));
QVERIFY(declarativeWidget != nullptr);

QTest::addColumn<QWidgetPtr>("uiWidget");
QTest::addColumn<QWidgetPtr>("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.
Expand Down

0 comments on commit 86bf021

Please sign in to comment.