tests: Enable tst_tabbingWithAffinities for QtQuick

This commit is contained in:
Sergio Martins
2020-10-10 11:13:53 +01:00
parent 5abf118b8c
commit b0ad939db8
4 changed files with 64 additions and 55 deletions

View File

@@ -25,6 +25,8 @@
#include "MultiSplitter_p.h"
#include "DropIndicatorOverlayInterface_p.h"
class TestCommon;
namespace KDDockWidgets {
class Frame;
@@ -64,6 +66,7 @@ private:
Q_DISABLE_COPY(DropArea)
friend class Frame;
friend class TestDocks;
friend class ::TestCommon;
friend class DropIndicatorOverlayInterface;
friend class AnimatedIndicators;
friend class FloatingWindow;

View File

@@ -136,6 +136,22 @@ namespace Testing {
QSize m_minSz;
};
}
struct SetExpectedWarning
{
explicit SetExpectedWarning(const QString &s)
{
if (!s.isEmpty())
Testing::setExpectedWarning(s);
}
~SetExpectedWarning()
{
Testing::setExpectedWarning({});
}
Q_DISABLE_COPY(SetExpectedWarning)
};
}
#endif

View File

@@ -19,14 +19,19 @@
#include "private/MultiSplitter_p.h"
#include "TitleBar_p.h"
#include "Position_p.h"
#include "DropAreaWithCentralFrame_p.h"
#include <QtTest/QtTest>
#include <QObject>
#include <QApplication>
#ifdef KDDOCKWIDGETS_QTQUICK
# include "quick/DockWidgetQuick.h"
# include <QQmlEngine>
# include <QQuickStyle>
# else
# include "DockWidget.h"
#endif
using namespace KDDockWidgets;
@@ -68,6 +73,7 @@ private Q_SLOTS:
void tst_detachFromMainWindow();
void tst_detachPos();
void tst_floatingWindowSize();
void tst_tabbingWithAffinities();
};
void TestCommon::tst_simple1()
@@ -250,6 +256,45 @@ void TestCommon::tst_floatingWindowSize()
delete fw1;
}
void TestCommon::tst_tabbingWithAffinities()
{
EnsureTopLevelsDeleted e;
// Tests that dock widgets with different affinities should not tab together
auto m1 = createMainWindow(QSize(1000, 1000), MainWindowOption_None);
m1->setAffinities({ "af1", "af2" });
auto dw1 = new DockWidgetType("1");
dw1->setAffinities({ "af1" });
dw1->show();
auto dw2 = new DockWidgetType("2");
dw2->setAffinities({ "af2" });
dw2->show();
FloatingWindow *fw1 = dw1->floatingWindow();
FloatingWindow *fw2 = dw2->floatingWindow();
{
SetExpectedWarning ignoreWarning("Refusing to dock widget with incompatible affinity");
dw1->addDockWidgetAsTab(dw2);
QVERIFY(dw1->window() != dw2->window());
}
m1->addDockWidget(dw1, Location_OnBottom);
QVERIFY(!dw1->isFloating());
{
SetExpectedWarning ignoreWarning("Refusing to dock widget with incompatible affinity");
auto dropArea = m1->dropArea();
QVERIFY(!dropArea->drop(fw2, dw1->frame(), DropIndicatorOverlayInterface::DropLocation_Center));
QVERIFY(dw1->window() != dw2->window());
}
delete fw1;
delete fw2;
}
int main(int argc, char *argv[])
{
if (!qpaPassedAsArgument(argc, argv)) {

View File

@@ -163,21 +163,6 @@ inline int widgetMinLength(const QWidget *w, Qt::Orientation o)
return o == Qt::Vertical ? sz.height() : sz.width();
}
struct SetExpectedWarning
{
explicit SetExpectedWarning(const QString &s)
{
if (!s.isEmpty())
Testing::setExpectedWarning(s);
}
~SetExpectedWarning()
{
Testing::setExpectedWarning({});
}
Q_DISABLE_COPY(SetExpectedWarning)
};
struct WidgetResize
{
int length;
@@ -438,7 +423,6 @@ private Q_SLOTS:
void tst_tabTitleChanges();
void tst_dockWidgetGetsFocusWhenDocked();
void tst_sizeAfterRedock();
void tst_tabbingWithAffinities();
private:
std::unique_ptr<MultiSplitter> createMultiSplitterFromSetup(MultiSplitterSetup setup, QHash<QWidget *, Frame *> &frameMap) const;
};
@@ -6176,45 +6160,6 @@ void TestDocks::tst_sizeAfterRedock()
delete oldFw2;
}
void TestDocks::tst_tabbingWithAffinities()
{
EnsureTopLevelsDeleted e;
// Tests that dock widgets with different affinities should not tab together
auto m1 = createMainWindow(QSize(1000, 1000), MainWindowOption_None);
m1->setAffinities({ "af1", "af2" });
auto dw1 = new DockWidget("1");
dw1->setAffinities({ "af1" });
dw1->show();
auto dw2 = new DockWidget("2");
dw2->setAffinities({ "af2" });
dw2->show();
FloatingWindow *fw1 = dw1->floatingWindow();
FloatingWindow *fw2 = dw2->floatingWindow();
{
SetExpectedWarning ignoreWarning("Refusing to dock widget with incompatible affinity");
dw1->addDockWidgetAsTab(dw2);
QVERIFY(dw1->window() != dw2->window());
}
m1->addDockWidget(dw1, Location_OnBottom);
QVERIFY(!dw1->isFloating());
{
SetExpectedWarning ignoreWarning("Refusing to dock widget with incompatible affinity");
DropArea *dropArea = m1->dropArea();
QVERIFY(!dropArea->drop(fw2, dw1->frame(), DropIndicatorOverlayInterface::DropLocation_Center));
QVERIFY(dw1->window() != dw2->window());
}
delete fw1;
delete fw2;
}
int main(int argc, char *argv[])
{
if (!qpaPassedAsArgument(argc, argv)) {