12#include "kddockwidgets/KDDockWidgets.h"
14#include "views/View.h"
15#include "kddockwidgets/qtquick/views/MainWindow.h"
16#include "kddockwidgets/core/MainWindow.h"
18#include "core/View_p.h"
19#include "core/Logging_p.h"
21#include <QGuiApplication>
26#include <QtTest/QTest>
31#ifdef DOCKS_TESTING_METHODS
38 explicit TestView(Core::CreateViewOptions opts, QQuickItem *parent)
42 setMinimumSize(opts.minSize);
43 setMaximumSize(opts.maxSize);
49 Core::CreateViewOptions m_opts;
52TestView::~TestView() =
default;
54inline QCoreApplication *createCoreApplication(
int &argc,
char **argv,
bool defaultToOffscreenQPA)
56 if (defaultToOffscreenQPA)
57 QtCommon::Platform_qt::maybeSetOffscreenQPA(argc, argv);
65 : Platform_qt(createCoreApplication(argc, argv, defaultToOffscreenQPA))
66 , m_qquickHelpers(new QtQuickHelpers())
71void Platform::tests_initPlatform_impl()
73 Platform_qt::tests_initPlatform_impl();
75 QQuickStyle::setStyle(QStringLiteral(
"Material"));
79void Platform::tests_deinitPlatform_impl()
82 auto windows = qGuiApp->topLevelWindows();
85 windows = qGuiApp->topLevelWindows();
88 Platform_qt::tests_deinitPlatform_impl();
94 auto newItem =
new TestView(opts, parentItem);
96 if (!parentItem && opts.createWindow) {
97 auto view =
new QQuickView(m_qmlEngine,
nullptr);
98 view->resize(
QSize(800, 800));
100 newItem->QQuickItem::setParentItem(view->contentItem());
101 newItem->QQuickItem::setParent(view->contentItem());
103 newItem->QtQuick::View::setVisible(
true);
111Core::View *Platform::tests_createFocusableView(Core::CreateViewOptions opts,
Core::View *parent)
113 auto view = tests_createView(opts, parent);
121 Core::CreateViewOptions opts;
123 auto view = tests_createView(opts, parent);
130 Core::CreateViewOptions viewOpts,
131 MainWindowOptions options,
Core::View *parent,
137 auto view =
new QQuickView(m_qmlEngine,
nullptr);
138 view->resize(viewOpts.size);
140 view->setResizeMode(QQuickView::SizeRootObjectToView);
141 view->setSource(
QUrl(QStringLiteral(
"qrc:/main.qml")));
143 if (viewOpts.isVisible)
146 parentItem = view->rootObject();
152 return view->mainWindow();
155std::shared_ptr<Core::Window> Platform::tests_createWindow()
157 Core::CreateViewOptions viewOpts;
158 viewOpts.isVisible =
true;
161 auto mainWindow = createMainWindow(QStringLiteral(
"testWindow-%1").arg(
id), viewOpts);
162 return mainWindow->view()->window();
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some c...
A docking area for dock widgets Named MainWindow as it's the QtWidgets/QMainWindow counterpart....