tests: Enable tst_tabbingWithAffinities for QtQuick
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
#include "MultiSplitter_p.h"
|
#include "MultiSplitter_p.h"
|
||||||
#include "DropIndicatorOverlayInterface_p.h"
|
#include "DropIndicatorOverlayInterface_p.h"
|
||||||
|
|
||||||
|
class TestCommon;
|
||||||
|
|
||||||
namespace KDDockWidgets {
|
namespace KDDockWidgets {
|
||||||
|
|
||||||
class Frame;
|
class Frame;
|
||||||
@@ -64,6 +66,7 @@ private:
|
|||||||
Q_DISABLE_COPY(DropArea)
|
Q_DISABLE_COPY(DropArea)
|
||||||
friend class Frame;
|
friend class Frame;
|
||||||
friend class TestDocks;
|
friend class TestDocks;
|
||||||
|
friend class ::TestCommon;
|
||||||
friend class DropIndicatorOverlayInterface;
|
friend class DropIndicatorOverlayInterface;
|
||||||
friend class AnimatedIndicators;
|
friend class AnimatedIndicators;
|
||||||
friend class FloatingWindow;
|
friend class FloatingWindow;
|
||||||
|
|||||||
@@ -136,6 +136,22 @@ namespace Testing {
|
|||||||
QSize m_minSz;
|
QSize m_minSz;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SetExpectedWarning
|
||||||
|
{
|
||||||
|
explicit SetExpectedWarning(const QString &s)
|
||||||
|
{
|
||||||
|
if (!s.isEmpty())
|
||||||
|
Testing::setExpectedWarning(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
~SetExpectedWarning()
|
||||||
|
{
|
||||||
|
Testing::setExpectedWarning({});
|
||||||
|
}
|
||||||
|
Q_DISABLE_COPY(SetExpectedWarning)
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,14 +19,19 @@
|
|||||||
#include "private/MultiSplitter_p.h"
|
#include "private/MultiSplitter_p.h"
|
||||||
#include "TitleBar_p.h"
|
#include "TitleBar_p.h"
|
||||||
#include "Position_p.h"
|
#include "Position_p.h"
|
||||||
|
#include "DropAreaWithCentralFrame_p.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#ifdef KDDOCKWIDGETS_QTQUICK
|
#ifdef KDDOCKWIDGETS_QTQUICK
|
||||||
|
# include "quick/DockWidgetQuick.h"
|
||||||
|
|
||||||
# include <QQmlEngine>
|
# include <QQmlEngine>
|
||||||
# include <QQuickStyle>
|
# include <QQuickStyle>
|
||||||
|
# else
|
||||||
|
# include "DockWidget.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace KDDockWidgets;
|
using namespace KDDockWidgets;
|
||||||
@@ -68,6 +73,7 @@ private Q_SLOTS:
|
|||||||
void tst_detachFromMainWindow();
|
void tst_detachFromMainWindow();
|
||||||
void tst_detachPos();
|
void tst_detachPos();
|
||||||
void tst_floatingWindowSize();
|
void tst_floatingWindowSize();
|
||||||
|
void tst_tabbingWithAffinities();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestCommon::tst_simple1()
|
void TestCommon::tst_simple1()
|
||||||
@@ -250,6 +256,45 @@ void TestCommon::tst_floatingWindowSize()
|
|||||||
delete fw1;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!qpaPassedAsArgument(argc, argv)) {
|
if (!qpaPassedAsArgument(argc, argv)) {
|
||||||
|
|||||||
@@ -163,21 +163,6 @@ inline int widgetMinLength(const QWidget *w, Qt::Orientation o)
|
|||||||
return o == Qt::Vertical ? sz.height() : sz.width();
|
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
|
struct WidgetResize
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
@@ -438,7 +423,6 @@ private Q_SLOTS:
|
|||||||
void tst_tabTitleChanges();
|
void tst_tabTitleChanges();
|
||||||
void tst_dockWidgetGetsFocusWhenDocked();
|
void tst_dockWidgetGetsFocusWhenDocked();
|
||||||
void tst_sizeAfterRedock();
|
void tst_sizeAfterRedock();
|
||||||
void tst_tabbingWithAffinities();
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<MultiSplitter> createMultiSplitterFromSetup(MultiSplitterSetup setup, QHash<QWidget *, Frame *> &frameMap) const;
|
std::unique_ptr<MultiSplitter> createMultiSplitterFromSetup(MultiSplitterSetup setup, QHash<QWidget *, Frame *> &frameMap) const;
|
||||||
};
|
};
|
||||||
@@ -6176,45 +6160,6 @@ void TestDocks::tst_sizeAfterRedock()
|
|||||||
delete oldFw2;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!qpaPassedAsArgument(argc, argv)) {
|
if (!qpaPassedAsArgument(argc, argv)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user