1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019 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 "core/View_p.h"
#include "core/ViewFactory.h"
#include "core/Platform.h"
#include "Config.h"
#include <QTest>
#include <string>
using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;
class TestPlatform : public QObject
{
Q_OBJECT
private Q_SLOTS:
void tst_platform();
void tst_name();
void tst_createDefaultViewFactory();
void tst_startDragDistance();
};
void TestPlatform::tst_platform()
{
auto plat = Platform::instance();
QVERIFY(plat);
}
void TestPlatform::tst_name()
{
// Checks that Platform::name() returns something
auto plat = Platform::instance();
QVERIFY(!std::string(plat->name()).empty());
}
void TestPlatform::tst_createDefaultViewFactory()
{
auto plat = Platform::instance();
ViewFactory *vf = plat->createDefaultViewFactory();
QVERIFY(vf);
delete vf;
}
void TestPlatform::tst_startDragDistance()
{
auto plat = Platform::instance();
const int defaultDistance = plat->startDragDistance();
QVERIFY(defaultDistance >= -1);
const int newDistance = defaultDistance + 1;
KDDockWidgets::Config::self().setStartDragDistance(newDistance);
QCOMPARE(plat->startDragDistance(), newDistance);
}
#define KDDW_TEST_NAME TestPlatform
#include "test_main_qt.h"
#include "tst_platform.moc"
|