diff --git a/tabbox/autotests/CMakeLists.txt b/tabbox/autotests/CMakeLists.txt index 4e83fa7524..4089801b2d 100644 --- a/tabbox/autotests/CMakeLists.txt +++ b/tabbox/autotests/CMakeLists.txt @@ -1,3 +1,5 @@ +include_directories(${KWIN_SOURCE_DIR}) +add_definitions(-DKWIN_UNIT_TEST) ######################################################## # Test TabBox::ClientModel ######################################################## @@ -7,14 +9,24 @@ set( testTabBoxClientModel_SRCS ../tabboxconfig.cpp ../tabboxhandler.cpp test_tabbox_clientmodel.cpp - mock_declarative.cpp mock_tabboxhandler.cpp mock_tabboxclient.cpp ) -#kde4_add_unit_test( testTabBoxClientModel TESTNAME kwin-testTabBoxClientModel ${testTabBoxClientModel_SRCS} ) - -#target_link_libraries( testTabBoxClientModel ${KDE4_KDEUI_LIBS} Qt5::Declarative ${X11_LIBRARIES} Qt5::Test ) +add_executable( testTabBoxClientModel ${testTabBoxClientModel_SRCS} ) +target_link_libraries( testTabBoxClientModel + Qt5::Core + Qt5::Gui + Qt5::Quick + Qt5::Test + Qt5::X11Extras + KF5::I18n + KF5::Service + KF5::WindowSystem + XCB::XCB +) +add_test(kwin-testTabBoxClientModel testTabBoxClientModel) +ecm_mark_as_test(testTabBoxClientModel) ######################################################## # Test TabBox::TabBoxHandler @@ -25,14 +37,24 @@ set( testTabBoxHandler_SRCS ../tabboxconfig.cpp ../tabboxhandler.cpp test_tabbox_handler.cpp - mock_declarative.cpp mock_tabboxhandler.cpp mock_tabboxclient.cpp ) -# kde4_add_unit_test( testTabBoxHandler TESTNAME kwin-testTabBoxHandler ${testTabBoxHandler_SRCS} ) - -# target_link_libraries( testTabBoxHandler ${KDE4_KDEUI_LIBS} Qt5::Core Qt5::Gui Qt5::Declarative Qt5::Test ${X11_LIBRARIES} ) +add_executable( testTabBoxHandler ${testTabBoxHandler_SRCS} ) +target_link_libraries( testTabBoxHandler + Qt5::Core + Qt5::Gui + Qt5::Quick + Qt5::Test + Qt5::X11Extras + KF5::I18n + KF5::Service + KF5::WindowSystem + XCB::XCB +) +add_test(kwin-testTabBoxHandler testTabBoxHandler) +ecm_mark_as_test(testTabBoxHandler) ######################################################## # Test TabBox::TabBoxConfig diff --git a/tabbox/autotests/mock_declarative.cpp b/tabbox/autotests/mock_declarative.cpp deleted file mode 100644 index 4065acb6d9..0000000000 --- a/tabbox/autotests/mock_declarative.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************** -KWin - the KDE window manager -This file is part of the KDE project. - -Copyright (C) 2012 Martin Gräßlin - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*********************************************************************/ -#include "declarative.h" - -namespace KWin -{ -namespace TabBox -{ -DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent) - : QQuickView(parent) -{ - Q_UNUSED(model) - Q_UNUSED(mode) -} - -void DeclarativeView::currentIndexChanged(int row) -{ - Q_UNUSED(row) -} - -void DeclarativeView::updateQmlSource(bool force) -{ - Q_UNUSED(force) -} - -void DeclarativeView::setCurrentIndex(const QModelIndex &index, bool disableAnimation) -{ - Q_UNUSED(index) - Q_UNUSED(disableAnimation) -} - -bool DeclarativeView::sendKeyEvent(QKeyEvent *e) -{ - Q_UNUSED(e) - return false; -} - -void DeclarativeView::slotEmbeddedChanged(bool enabled) -{ - Q_UNUSED(enabled) -} - -void DeclarativeView::slotUpdateGeometry() -{ -} - -void DeclarativeView::slotWindowChanged(WId wId, unsigned int properties) -{ - Q_UNUSED(wId) - Q_UNUSED(properties) -} - -void DeclarativeView::showEvent(QShowEvent *event) -{ - Q_UNUSED(event) -} - -void DeclarativeView::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event) -} - -void DeclarativeView::hideEvent(QHideEvent *event) -{ - Q_UNUSED(event) -} - -bool DeclarativeView::x11Event(XEvent *e) -{ - Q_UNUSED(e) - return false; -} - -} // namespace Tabbox -} // namespace KWin - -#include "../declarative.moc" diff --git a/tabbox/autotests/mock_tabboxclient.h b/tabbox/autotests/mock_tabboxclient.h index ec438e603e..ba603dc29f 100644 --- a/tabbox/autotests/mock_tabboxclient.h +++ b/tabbox/autotests/mock_tabboxclient.h @@ -21,6 +21,9 @@ along with this program. If not, see . #define KWIN_MOCK_TABBOX_CLIENT_H #include "../tabboxhandler.h" + +#include + namespace KWin { class MockTabBoxClient : public TabBox::TabBoxClient @@ -58,6 +61,9 @@ public: virtual int y() const { return 0; } + virtual QIcon icon() const { + return QIcon(); + } private: QString m_caption; diff --git a/tabbox/autotests/mock_tabboxhandler.cpp b/tabbox/autotests/mock_tabboxhandler.cpp index 20fe8e89fc..1e326e9418 100644 --- a/tabbox/autotests/mock_tabboxhandler.cpp +++ b/tabbox/autotests/mock_tabboxhandler.cpp @@ -23,8 +23,8 @@ along with this program. If not, see . namespace KWin { -MockTabBoxHandler::MockTabBoxHandler() - : TabBoxHandler() +MockTabBoxHandler::MockTabBoxHandler(QObject *parent) + : TabBoxHandler(parent) { } diff --git a/tabbox/autotests/mock_tabboxhandler.h b/tabbox/autotests/mock_tabboxhandler.h index b71bf68c76..4e1af12df1 100644 --- a/tabbox/autotests/mock_tabboxhandler.h +++ b/tabbox/autotests/mock_tabboxhandler.h @@ -27,7 +27,7 @@ class MockTabBoxHandler : public TabBox::TabBoxHandler { Q_OBJECT public: - MockTabBoxHandler(); + MockTabBoxHandler(QObject *parent = nullptr); virtual ~MockTabBoxHandler(); virtual void activateAndClose() { } diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index 6d77ff1a61..cae64e3aec 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -136,6 +136,7 @@ QQuickWindow *TabBoxHandlerPrivate::window() const return m_mainItem->findChild(); } +#ifndef KWIN_UNIT_TEST SwitcherItem *TabBoxHandlerPrivate::switcherItem() const { if (!m_mainItem) { @@ -148,6 +149,7 @@ SwitcherItem *TabBoxHandlerPrivate::switcherItem() const } return m_mainItem->findChild(); } +#endif ClientModel* TabBoxHandlerPrivate::clientModel() const { @@ -226,6 +228,7 @@ void TabBoxHandlerPrivate::endHighlightWindows(bool abort) xcb_delete_property(connection(), config.isShowTabBox() && w ? w->winId() : rootWindow(), m_highlightWindowsAtom); } +#ifndef KWIN_UNIT_TEST QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode) { auto findSwitcher = [this, desktopMode] { @@ -280,9 +283,11 @@ QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode) } return nullptr; } +#endif void TabBoxHandlerPrivate::show() { +#ifndef KWIN_UNIT_TEST if (m_qmlContext.isNull()) { qmlRegisterType("org.kde.kwin", 2, 0, "Switcher"); m_qmlContext.reset(new QQmlContext(Scripting::self()->qmlEngine())); @@ -321,6 +326,7 @@ void TabBoxHandlerPrivate::show() // everything is prepared, so let's make the whole thing visible item->setVisible(true); } +#endif } /*********************************************** @@ -379,9 +385,11 @@ void TabBoxHandler::hide(bool abort) if (d->config.isHighlightWindows()) { d->endHighlightWindows(abort); } +#ifndef KWIN_UNIT_TEST if (SwitcherItem *item = d->switcherItem()) { item->setVisible(false); } +#endif if (QQuickWindow *w = d->window()) { w->hide(); w->destroy();