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 69 70
|
/*
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 "../utils.h"
#include "core/DropArea.h"
#include "core/Group.h"
#include "Config.h"
#include "core/DockWidget.h"
#include "core/ViewFactory.h"
#include "core/Platform.h"
#include <QTest>
using namespace KDDockWidgets;
using namespace KDDockWidgets::Core;
class TestDropArea : public QObject
{
Q_OBJECT
private Q_SLOTS:
void tst_dropAreaCtor();
void tst_addWidget();
void tst_addWidgetHidden();
};
void TestDropArea::tst_dropAreaCtor()
{
// Tests that ctor runs and doesn't leak
Core::DropArea da(nullptr, {});
}
void TestDropArea::tst_addWidget()
{
auto group = new Core::Group();
Core::DropArea da(nullptr, {});
da.addWidget(group->view(), KDDockWidgets::Location_OnLeft);
}
void TestDropArea::tst_addWidgetHidden()
{
// Test adding a widget that starts hidden
auto dw = Config::self().viewFactory()->createDockWidget("dw1")->asDockWidgetController();
Core::DropArea da(nullptr, {});
da.addDockWidget(dw, KDDockWidgets::Location_OnLeft, nullptr,
InitialVisibilityOption::StartHidden);
QVERIFY(!dw->isOpen());
QVERIFY(!dw->toggleAction()->isChecked());
dw->open();
QVERIFY(dw->isOpen());
QVERIFY(dw->toggleAction()->isChecked());
auto group = dw->dptr()->group();
delete dw;
WAIT_FOR_DELETED(group);
}
#define KDDW_TEST_NAME TestDropArea
#include "../test_main_qt.h"
#include "tst_droparea.moc"
|