tests: Add tests for DockWidget and FloatingWindow ctor
To catch potential QML errors in the .qml files.
This commit is contained in:
@@ -361,6 +361,8 @@ if(${PROJECT_NAME}_TESTS)
|
||||
add_test(NAME tst_stack COMMAND tst_stack)
|
||||
add_test(NAME tst_tabbar COMMAND tst_tabbar)
|
||||
add_test(NAME tst_separator COMMAND tst_separator)
|
||||
add_test(NAME tst_floatingwindow COMMAND tst_floatingwindow)
|
||||
add_test(NAME tst_dockwidget COMMAND tst_dockwidget)
|
||||
|
||||
if(NOT ${PROJECT_NAME}_QTQUICK)
|
||||
# tst_multisplitter depends on QWidget
|
||||
|
||||
@@ -59,8 +59,6 @@ DockWidget_qtquick::DockWidget_qtquick(Controllers::DockWidget *controller,
|
||||
: View_qtquick(controller, Type::DockWidget, nullptr, windowFlags)
|
||||
, d(new Private(this, controller, engine ? engine : plat()->qmlEngine()))
|
||||
{
|
||||
// To mimic what QtWidgets does when creating a new QWidget.
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
DockWidget_qtquick::~DockWidget_qtquick()
|
||||
@@ -68,6 +66,12 @@ DockWidget_qtquick::~DockWidget_qtquick()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void DockWidget_qtquick::init()
|
||||
{
|
||||
// To mimic what QtWidgets does when creating a new QWidget.
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void DockWidget_qtquick::setWidget(const QString &qmlFilename)
|
||||
{
|
||||
QQuickItem *guest = createItem(d->m_qmlEngine, qmlFilename);
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
/// Similar to Controllers::DockWidget::setWidget(QQuickItem*)
|
||||
void setWidget(const QString &qmlFilename);
|
||||
|
||||
void init() override;
|
||||
|
||||
/// @reimp // TODOv2: Rename to setGuestView
|
||||
Q_INVOKABLE void setWidget(QQuickItem *widget);
|
||||
|
||||
|
||||
@@ -75,4 +75,10 @@ add_executable(tst_tabbar controllers/tst_tabbar.cpp ${TESTING_RESOURCES})
|
||||
target_link_libraries(tst_tabbar kddockwidgets)
|
||||
|
||||
add_executable(tst_separator controllers/tst_separator.cpp ${TESTING_RESOURCES})
|
||||
target_link_libraries(tst_separator kddockwidgets)
|
||||
target_link_libraries(tst_separator kddockwidgets)
|
||||
|
||||
add_executable(tst_floatingwindow controllers/tst_floatingwindow.cpp ${TESTING_RESOURCES})
|
||||
target_link_libraries(tst_floatingwindow kddockwidgets)
|
||||
|
||||
add_executable(tst_dockwidget controllers/tst_dockwidget.cpp ${TESTING_RESOURCES})
|
||||
target_link_libraries(tst_dockwidget kddockwidgets)
|
||||
|
||||
26
tests/controllers/tst_dockwidget.cpp
Normal file
26
tests/controllers/tst_dockwidget.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "../main.h"
|
||||
#include "controllers/DockWidget.h"
|
||||
|
||||
#include "qtquick/Platform_qtquick.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
|
||||
TEST_CASE("DockWidget Ctor")
|
||||
{
|
||||
auto dw = new Controllers::DockWidget("dw1");
|
||||
dw->view()->show();
|
||||
|
||||
delete dw;
|
||||
}
|
||||
37
tests/controllers/tst_floatingwindow.cpp
Normal file
37
tests/controllers/tst_floatingwindow.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "../main.h"
|
||||
#include "controllers/FloatingWindow.h"
|
||||
#include "controllers/Frame.h"
|
||||
#include "controllers/DockWidget.h"
|
||||
|
||||
#include "qtquick/Platform_qtquick.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
|
||||
TEST_CASE("FloatingWindow Ctor")
|
||||
{
|
||||
auto dw = new Controllers::DockWidget("dw1");
|
||||
// CHECK(dw->view()->rootView()->is(Type::DockWidget));
|
||||
dw->view()->show();
|
||||
|
||||
/// Wait for FloatingWindow to be created
|
||||
// Platform::instance()->tests_wait(100);
|
||||
|
||||
auto rootView = dw->view()->rootView();
|
||||
REQUIRE(rootView);
|
||||
|
||||
// CHECK(rootView->is(Type::FloatingWindow));
|
||||
|
||||
delete dw;
|
||||
}
|
||||
Reference in New Issue
Block a user