[autotests] Adjust to changes regarding AbstractClient

We need a Mock for AbstractClient and our mock Client needs to
inherit from it.
icc-effect-5.14.5
Martin Gräßlin 2015-04-29 14:13:20 +02:00
parent 912ab71abd
commit 6826b9eb94
8 changed files with 176 additions and 97 deletions

View File

@ -197,6 +197,7 @@ target_link_libraries(effectversionplugin kwineffects)
########################################################
set( testScreens_SRCS
test_screens.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp
@ -224,6 +225,7 @@ ecm_mark_as_test(testScreens)
########################################################
set( testXRandRScreens_SRCS
test_xrandr_screens.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp
@ -259,6 +261,7 @@ ecm_mark_as_test(testXRandRScreens)
########################################################
set( testScreenEdges_SRCS
test_screen_edges.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp

View File

@ -0,0 +1 @@
#include "mock_abstract_client.h"

View File

@ -0,0 +1,94 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "mock_abstract_client.h"
namespace KWin
{
AbstractClient::AbstractClient(QObject *parent)
: QObject(parent)
, m_active(false)
, m_screen(0)
, m_fullscreen(false)
, m_hiddenInternal(false)
, m_geometry()
{
}
AbstractClient::~AbstractClient() = default;
bool AbstractClient::isActive() const
{
return m_active;
}
void AbstractClient::setActive(bool active)
{
m_active = active;
}
void AbstractClient::setScreen(int screen)
{
m_screen = screen;
}
bool AbstractClient::isOnScreen(int screen) const
{
// TODO: mock checking client geometry
return screen == m_screen;
}
int AbstractClient::screen() const
{
return m_screen;
}
void AbstractClient::setFullScreen(bool set)
{
m_fullscreen = set;
}
bool AbstractClient::isFullScreen() const
{
return m_fullscreen;
}
bool AbstractClient::isHiddenInternal() const
{
return m_hiddenInternal;
}
void AbstractClient::setHiddenInternal(bool set)
{
m_hiddenInternal = set;
}
void AbstractClient::setGeometry(const QRect &rect)
{
m_geometry = rect;
emit geometryChanged();
}
QRect AbstractClient::geometry() const
{
return m_geometry;
}
}

View File

@ -0,0 +1,62 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_MOCK_ABSTRACT_CLIENT_H
#define KWIN_MOCK_ABSTRACT_CLIENT_H
#include <QObject>
#include <QRect>
namespace KWin
{
class AbstractClient : public QObject
{
Q_OBJECT
public:
explicit AbstractClient(QObject *parent);
virtual ~AbstractClient();
int screen() const;
bool isOnScreen(int screen) const;
bool isActive() const;
bool isFullScreen() const;
bool isHiddenInternal() const;
QRect geometry() const;
void setActive(bool active);
void setScreen(int screen);
void setFullScreen(bool set);
void setHiddenInternal(bool set);
void setGeometry(const QRect &rect);
Q_SIGNALS:
void geometryChanged();
private:
bool m_active;
int m_screen;
bool m_fullscreen;
bool m_hiddenInternal;
QRect m_geometry;
};
}
#endif

View File

@ -23,77 +23,15 @@ namespace KWin
{
Client::Client(QObject *parent)
: QObject(parent)
, m_active(false)
, m_screen(0)
, m_fullscreen(false)
, m_hiddenInternal(false)
, m_geometry()
: AbstractClient(parent)
{
}
Client::~Client() = default;
bool Client::isActive() const
{
return m_active;
}
void Client::setActive(bool active)
{
m_active = active;
}
void Client::setScreen(int screen)
{
m_screen = screen;
}
bool Client::isOnScreen(int screen) const
{
// TODO: mock checking client geometry
return screen == m_screen;
}
int Client::screen() const
{
return m_screen;
}
void Client::showOnScreenEdge()
{
setHiddenInternal(false);
}
void Client::setFullScreen(bool set)
{
m_fullscreen = set;
}
bool Client::isFullScreen() const
{
return m_fullscreen;
}
bool Client::isHiddenInternal() const
{
return m_hiddenInternal;
}
void Client::setHiddenInternal(bool set)
{
m_hiddenInternal = set;
}
void Client::setGeometry(const QRect &rect)
{
m_geometry = rect;
emit geometryChanged();
}
QRect Client::geometry() const
{
return m_geometry;
}
}

View File

@ -20,43 +20,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef KWIN_MOCK_CLIENT_H
#define KWIN_MOCK_CLIENT_H
#include <abstract_client.h>
#include <QObject>
#include <QRect>
namespace KWin
{
class Client : public QObject
class Client : public AbstractClient
{
Q_OBJECT
public:
explicit Client(QObject *parent);
virtual ~Client();
int screen() const;
bool isOnScreen(int screen) const;
bool isActive() const;
bool isFullScreen() const;
bool isHiddenInternal() const;
QRect geometry() const;
void setActive(bool active);
void setScreen(int screen);
void setFullScreen(bool set);
void setHiddenInternal(bool set);
void setGeometry(const QRect &rect);
void showOnScreenEdge();
Q_SIGNALS:
void geometryChanged();
private:
bool m_active;
int m_screen;
bool m_fullscreen;
bool m_hiddenInternal;
QRect m_geometry;
};
}

View File

@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "mock_workspace.h"
#include "mock_client.h"
#include "mock_abstract_client.h"
namespace KWin
{
@ -39,22 +39,22 @@ MockWorkspace::~MockWorkspace()
s_self = nullptr;
}
Client *MockWorkspace::activeClient() const
AbstractClient *MockWorkspace::activeClient() const
{
return m_activeClient;
}
void MockWorkspace::setActiveClient(Client *c)
void MockWorkspace::setActiveClient(AbstractClient *c)
{
m_activeClient = c;
}
Client *MockWorkspace::getMovingClient() const
AbstractClient *MockWorkspace::getMovingClient() const
{
return m_movingClient;
}
void MockWorkspace::setMovingClient(Client *c)
void MockWorkspace::setMovingClient(AbstractClient *c)
{
m_movingClient = c;
}

View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin
{
class AbstractClient;
class Client;
class X11EventFilter;
@ -38,14 +39,14 @@ class MockWorkspace : public QObject
public:
explicit MockWorkspace(QObject *parent = nullptr);
virtual ~MockWorkspace();
Client *activeClient() const;
Client *getMovingClient() const;
AbstractClient *activeClient() const;
AbstractClient *getMovingClient() const;
void setShowingDesktop(bool showing);
bool showingDesktop() const;
QRect clientArea(clientAreaOption, int screen, int desktop) const;
void setActiveClient(Client *c);
void setMovingClient(Client *c);
void setActiveClient(AbstractClient *c);
void setMovingClient(AbstractClient *c);
void registerEventFilter(X11EventFilter *filter);
void unregisterEventFilter(X11EventFilter *filter);
@ -56,8 +57,8 @@ Q_SIGNALS:
void clientRemoved(KWin::Client*);
private:
Client *m_activeClient;
Client *m_movingClient;
AbstractClient *m_activeClient;
AbstractClient *m_movingClient;
bool m_showingDesktop;
static Workspace *s_self;
};