Files
KDDockWidgets/tests/tst_common.cpp
2020-08-13 00:46:55 +01:00

70 lines
1.9 KiB
C++

/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 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.
*/
// We don't care about performance related checks in the tests
// clazy:excludeall=ctor-missing-parent-argument,missing-qobject-macro,range-loop,missing-typeinfo,detaching-member,function-args-by-ref,non-pod-global-static,reserve-candidates,qstring-allocations
#include "Testing.h"
#include "utils.h"
#include "DockWidgetBase.h"
#include "private/MultiSplitter_p.h"
#include <QtTest/QtTest>
#include <QObject>
#include <QApplication>
using namespace KDDockWidgets;
using namespace KDDockWidgets::Tests;
class TestCommon : public QObject
{
Q_OBJECT
public Q_SLOTS:
void initTestCase()
{
qputenv("KDDOCKWIDGETS_SHOW_DEBUG_WINDOW", "");
qApp->setOrganizationName("KDAB");
qApp->setApplicationName("dockwidgets-unit-tests");
Testing::installFatalMessageHandler();
// auto m = createMainWindow(); TODO
// QTest::qWait(10); // the DND state machine needs the event loop to start, otherwise activeState() is nullptr. (for offscreen QPA)
}
private Q_SLOTS:
void tst_simple1();
};
void TestCommon::tst_simple1()
{
// Simply create a MainWindow
EnsureTopLevelsDeleted e;
auto m = createMainWindow();
m->multiSplitter()->checkSanity();
}
int main(int argc, char *argv[])
{
if (!qpaPassedAsArgument(argc, argv)) {
// Use offscreen by default as it's less annoying, doesn't create visible windows
qputenv("QT_QPA_PLATFORM", "offscreen");
}
QApplication app(argc, argv);
TestCommon test;
return QTest::qExec(&test, argc, argv);
}
#include "tst_common.moc"