2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2012-06-03 07:15:10 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2012-06-03 07:15:10 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2012-06-03 07:15:10 +00:00
|
|
|
|
|
|
|
#include <kwineffects.h>
|
2021-02-09 18:18:36 +00:00
|
|
|
|
|
|
|
#include "virtualdesktops.h"
|
2012-06-03 07:15:10 +00:00
|
|
|
|
2013-02-26 07:02:27 +00:00
|
|
|
#include <QGraphicsRotation>
|
|
|
|
#include <QGraphicsScale>
|
2022-03-23 10:13:38 +00:00
|
|
|
#include <QVector2D>
|
2012-06-03 07:15:10 +00:00
|
|
|
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtTest>
|
2012-06-03 07:15:10 +00:00
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
|
2018-11-30 09:58:45 +00:00
|
|
|
class MockEffectWindow : public EffectWindow
|
2012-06-03 07:15:10 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow(QObject *parent = nullptr);
|
|
|
|
QVariant data(int role) const override;
|
|
|
|
QRect decorationInnerRect() const override;
|
|
|
|
void deleteProperty(long int atom) const override;
|
|
|
|
void disablePainting(int reason) override;
|
|
|
|
void enablePainting(int reason) override;
|
2019-01-07 16:29:00 +00:00
|
|
|
void addRepaint(const QRect &r) override;
|
|
|
|
void addRepaint(int x, int y, int w, int h) override;
|
|
|
|
void addRepaintFull() override;
|
|
|
|
void addLayerRepaint(const QRect &r) override;
|
|
|
|
void addLayerRepaint(int x, int y, int w, int h) override;
|
2018-11-30 09:58:45 +00:00
|
|
|
EffectWindow *findModal() override;
|
2020-08-02 10:25:28 +00:00
|
|
|
EffectWindow *transientFor() override;
|
2018-11-30 09:58:45 +00:00
|
|
|
const EffectWindowGroup *group() const override;
|
|
|
|
bool isPaintingEnabled() override;
|
|
|
|
EffectWindowList mainWindows() const override;
|
|
|
|
QByteArray readProperty(long int atom, long int type, int format) const override;
|
|
|
|
void refWindow() override;
|
|
|
|
void unrefWindow() override;
|
|
|
|
void setData(int role, const QVariant &data) override;
|
2019-01-07 16:29:00 +00:00
|
|
|
void minimize() override;
|
|
|
|
void unminimize() override;
|
|
|
|
void closeWindow() override;
|
2022-03-23 10:13:38 +00:00
|
|
|
void referencePreviousWindowPixmap() override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void unreferencePreviousWindowPixmap() override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
QWindow *internalWindow() const override
|
|
|
|
{
|
2019-01-13 16:50:32 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDeleted() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isMinimized() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
double opacity() const override
|
|
|
|
{
|
2012-07-12 15:20:17 +00:00
|
|
|
return m_opacity;
|
2012-06-03 07:15:10 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
void setOpacity(qreal opacity)
|
|
|
|
{
|
2012-07-12 15:20:17 +00:00
|
|
|
m_opacity = opacity;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool hasAlpha() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QStringList activities() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QStringList();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
int desktop() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QVector<uint> desktops() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return {};
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
int x() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
int y() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
int width() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return 100;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
int height() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return 100;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QSize basicUnit() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QSize();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect geometry() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect expandedGeometry() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect frameGeometry() const override
|
|
|
|
{
|
2019-09-28 15:09:12 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect bufferGeometry() const override
|
|
|
|
{
|
2019-09-28 15:09:12 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect clientGeometry() const override
|
|
|
|
{
|
2021-05-28 08:05:28 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
EffectScreen *screen() const override
|
|
|
|
{
|
2021-10-01 07:23:30 +00:00
|
|
|
return nullptr;
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QPoint pos() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QPoint();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QSize size() const override
|
|
|
|
{
|
|
|
|
return QSize(100, 100);
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect rect() const override
|
|
|
|
{
|
|
|
|
return QRect(0, 0, 100, 100);
|
2018-11-30 09:58:45 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isMovable() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isMovableAcrossScreens() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isUserMove() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isUserResize() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect iconGeometry() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDesktop() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDock() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isToolbar() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isMenu() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isNormalWindow() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isSpecialWindow() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDialog() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isSplash() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isUtility() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDropdownMenu() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isPopupMenu() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isTooltip() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isNotification() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isCriticalNotification() const override
|
|
|
|
{
|
2019-05-02 08:29:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isOnScreenDisplay() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isComboBox() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isDNDIcon() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QRect contentsRect() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QRect();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool decorationHasAlpha() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
KDecoration2::Decoration *decoration() const override
|
|
|
|
{
|
2022-02-09 21:00:07 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QString caption() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QIcon icon() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QIcon();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QString windowClass() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
QString windowRole() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return QString();
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
NET::WindowType windowType() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return NET::Normal;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool acceptsFocus() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool keepAbove() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool keepBelow() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isModal() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isSkipSwitcher() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isCurrentTab() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool skipsCloseAnimation() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
KWaylandServer::SurfaceInterface *surface() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isFullScreen() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isUnresponsive() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isPopupWindow() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isManaged() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isWaylandClient() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isX11Client() const override
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isOutline() const override
|
|
|
|
{
|
2019-03-19 14:01:29 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
bool isLockScreen() const override
|
|
|
|
{
|
2021-05-12 18:56:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
pid_t pid() const override
|
|
|
|
{
|
2019-09-26 12:54:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
qlonglong windowId() const override
|
|
|
|
{
|
2020-11-01 14:25:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-07-12 15:20:17 +00:00
|
|
|
|
2018-11-30 09:58:45 +00:00
|
|
|
private:
|
|
|
|
qreal m_opacity = 1.0;
|
2012-06-03 07:15:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
MockEffectWindow::MockEffectWindow(QObject *parent)
|
|
|
|
: EffectWindow(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant MockEffectWindow::data(int role) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(role)
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect MockEffectWindow::decorationInnerRect() const
|
|
|
|
{
|
|
|
|
return QRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::deleteProperty(long int atom) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(atom)
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::disablePainting(int reason)
|
|
|
|
{
|
|
|
|
Q_UNUSED(reason)
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::enablePainting(int reason)
|
|
|
|
{
|
|
|
|
Q_UNUSED(reason)
|
|
|
|
}
|
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void MockEffectWindow::addRepaint(const QRect &r)
|
|
|
|
{
|
|
|
|
Q_UNUSED(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::addRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Q_UNUSED(x)
|
|
|
|
Q_UNUSED(y)
|
|
|
|
Q_UNUSED(w)
|
|
|
|
Q_UNUSED(h)
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::addRepaintFull()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::addLayerRepaint(const QRect &r)
|
|
|
|
{
|
|
|
|
Q_UNUSED(r)
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::addLayerRepaint(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Q_UNUSED(x)
|
|
|
|
Q_UNUSED(y)
|
|
|
|
Q_UNUSED(w)
|
|
|
|
Q_UNUSED(h)
|
|
|
|
}
|
|
|
|
|
2012-06-03 07:15:10 +00:00
|
|
|
EffectWindow *MockEffectWindow::findModal()
|
|
|
|
{
|
2014-01-08 10:13:08 +00:00
|
|
|
return nullptr;
|
2012-06-03 07:15:10 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 10:25:28 +00:00
|
|
|
EffectWindow *MockEffectWindow::transientFor()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-06-03 07:15:10 +00:00
|
|
|
const EffectWindowGroup *MockEffectWindow::group() const
|
|
|
|
{
|
2014-01-08 10:13:08 +00:00
|
|
|
return nullptr;
|
2012-06-03 07:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MockEffectWindow::isPaintingEnabled()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowList MockEffectWindow::mainWindows() const
|
|
|
|
{
|
|
|
|
return EffectWindowList();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray MockEffectWindow::readProperty(long int atom, long int type, int format) const
|
|
|
|
{
|
|
|
|
Q_UNUSED(atom)
|
|
|
|
Q_UNUSED(type)
|
|
|
|
Q_UNUSED(format)
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::refWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::setData(int role, const QVariant &data)
|
|
|
|
{
|
|
|
|
Q_UNUSED(role)
|
|
|
|
Q_UNUSED(data)
|
|
|
|
}
|
|
|
|
|
2019-01-07 16:29:00 +00:00
|
|
|
void MockEffectWindow::minimize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::unminimize()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MockEffectWindow::closeWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-06-03 07:15:10 +00:00
|
|
|
void MockEffectWindow::unrefWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
class TestWindowPaintData : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2013-07-22 14:07:39 +00:00
|
|
|
private Q_SLOTS:
|
2012-06-03 07:15:10 +00:00
|
|
|
void testCtor();
|
|
|
|
void testCopyCtor();
|
|
|
|
void testOperatorMultiplyAssign();
|
|
|
|
void testOperatorPlus();
|
2012-07-12 15:20:17 +00:00
|
|
|
void testMultiplyOpacity();
|
|
|
|
void testMultiplySaturation();
|
|
|
|
void testMultiplyBrightness();
|
2012-06-03 07:15:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void TestWindowPaintData::testCtor()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
|
|
|
w.setOpacity(0.5);
|
2012-06-03 07:15:10 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
QCOMPARE(data.xScale(), 1.0);
|
|
|
|
QCOMPARE(data.yScale(), 1.0);
|
|
|
|
QCOMPARE(data.zScale(), 1.0);
|
|
|
|
QCOMPARE(data.xTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.yTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.zTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.translation(), QVector3D());
|
|
|
|
QCOMPARE(data.rotationAngle(), 0.0);
|
|
|
|
QCOMPARE(data.rotationOrigin(), QVector3D());
|
|
|
|
QCOMPARE(data.rotationAxis(), QVector3D(0.0, 0.0, 1.0));
|
2012-07-12 15:20:17 +00:00
|
|
|
QCOMPARE(data.opacity(), 0.5);
|
|
|
|
QCOMPARE(data.brightness(), 1.0);
|
|
|
|
QCOMPARE(data.saturation(), 1.0);
|
2012-06-03 07:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWindowPaintData::testCopyCtor()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-06-03 07:15:10 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
WindowPaintData data2(data);
|
|
|
|
// no value had been changed
|
|
|
|
QCOMPARE(data2.xScale(), 1.0);
|
|
|
|
QCOMPARE(data2.yScale(), 1.0);
|
|
|
|
QCOMPARE(data2.zScale(), 1.0);
|
|
|
|
QCOMPARE(data2.xTranslation(), 0.0);
|
|
|
|
QCOMPARE(data2.yTranslation(), 0.0);
|
|
|
|
QCOMPARE(data2.zTranslation(), 0.0);
|
|
|
|
QCOMPARE(data2.translation(), QVector3D());
|
|
|
|
QCOMPARE(data2.rotationAngle(), 0.0);
|
|
|
|
QCOMPARE(data2.rotationOrigin(), QVector3D());
|
|
|
|
QCOMPARE(data2.rotationAxis(), QVector3D(0.0, 0.0, 1.0));
|
2012-07-12 15:20:17 +00:00
|
|
|
QCOMPARE(data2.opacity(), 1.0);
|
|
|
|
QCOMPARE(data2.brightness(), 1.0);
|
|
|
|
QCOMPARE(data2.saturation(), 1.0);
|
2012-06-03 07:15:10 +00:00
|
|
|
|
|
|
|
data2.setScale(QVector3D(0.5, 2.0, 3.0));
|
|
|
|
data2.translate(0.5, 2.0, 3.0);
|
|
|
|
data2.setRotationAngle(45.0);
|
|
|
|
data2.setRotationOrigin(QVector3D(1.0, 2.0, 3.0));
|
|
|
|
data2.setRotationAxis(QVector3D(1.0, 1.0, 0.0));
|
2012-07-12 15:20:17 +00:00
|
|
|
data2.setOpacity(0.1);
|
|
|
|
data2.setBrightness(0.3);
|
|
|
|
data2.setSaturation(0.4);
|
2012-06-03 07:15:10 +00:00
|
|
|
|
|
|
|
WindowPaintData data3(data2);
|
|
|
|
QCOMPARE(data3.xScale(), 0.5);
|
|
|
|
QCOMPARE(data3.yScale(), 2.0);
|
|
|
|
QCOMPARE(data3.zScale(), 3.0);
|
|
|
|
QCOMPARE(data3.xTranslation(), 0.5);
|
|
|
|
QCOMPARE(data3.yTranslation(), 2.0);
|
|
|
|
QCOMPARE(data3.zTranslation(), 3.0);
|
|
|
|
QCOMPARE(data3.translation(), QVector3D(0.5, 2.0, 3.0));
|
|
|
|
QCOMPARE(data3.rotationAngle(), 45.0);
|
|
|
|
QCOMPARE(data3.rotationOrigin(), QVector3D(1.0, 2.0, 3.0));
|
|
|
|
QCOMPARE(data3.rotationAxis(), QVector3D(1.0, 1.0, 0.0));
|
2012-07-12 15:20:17 +00:00
|
|
|
QCOMPARE(data3.opacity(), 0.1);
|
|
|
|
QCOMPARE(data3.brightness(), 0.3);
|
|
|
|
QCOMPARE(data3.saturation(), 0.4);
|
2012-06-03 07:15:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestWindowPaintData::testOperatorMultiplyAssign()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-06-03 07:15:10 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
// without anything set, it's 1.0 on all axis
|
|
|
|
QCOMPARE(data.xScale(), 1.0);
|
|
|
|
QCOMPARE(data.yScale(), 1.0);
|
|
|
|
QCOMPARE(data.zScale(), 1.0);
|
|
|
|
// multiplying by a factor should set all components
|
|
|
|
data *= 2.0;
|
|
|
|
QCOMPARE(data.xScale(), 2.0);
|
|
|
|
QCOMPARE(data.yScale(), 2.0);
|
|
|
|
QCOMPARE(data.zScale(), 2.0);
|
|
|
|
// multiplying by a vector2D should set x and y components
|
|
|
|
data *= QVector2D(2.0, 3.0);
|
|
|
|
QCOMPARE(data.xScale(), 4.0);
|
|
|
|
QCOMPARE(data.yScale(), 6.0);
|
|
|
|
QCOMPARE(data.zScale(), 2.0);
|
|
|
|
// multiplying by a vector3d should set all components
|
|
|
|
data *= QVector3D(0.5, 1.5, 2.0);
|
|
|
|
QCOMPARE(data.xScale(), 2.0);
|
|
|
|
QCOMPARE(data.yScale(), 9.0);
|
|
|
|
QCOMPARE(data.zScale(), 4.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWindowPaintData::testOperatorPlus()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-06-03 07:15:10 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
QCOMPARE(data.xTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.yTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.zTranslation(), 0.0);
|
|
|
|
QCOMPARE(data.translation(), QVector3D());
|
|
|
|
// test with point
|
|
|
|
data += QPoint(1, 2);
|
|
|
|
QCOMPARE(data.translation(), QVector3D(1.0, 2.0, 0.0));
|
|
|
|
// test with pointf
|
|
|
|
data += QPointF(0.5, 0.75);
|
|
|
|
QCOMPARE(data.translation(), QVector3D(1.5, 2.75, 0.0));
|
|
|
|
// test with QVector2D
|
|
|
|
data += QVector2D(0.25, 1.5);
|
|
|
|
QCOMPARE(data.translation(), QVector3D(1.75, 4.25, 0.0));
|
|
|
|
// test with QVector3D
|
|
|
|
data += QVector3D(1.0, 2.0, 3.5);
|
|
|
|
QCOMPARE(data.translation(), QVector3D(2.75, 6.25, 3.5));
|
|
|
|
}
|
|
|
|
|
2012-07-12 15:20:17 +00:00
|
|
|
void TestWindowPaintData::testMultiplyBrightness()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-07-12 15:20:17 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
QCOMPARE(0.2, data.multiplyBrightness(0.2));
|
|
|
|
QCOMPARE(0.2, data.brightness());
|
|
|
|
QCOMPARE(0.6, data.multiplyBrightness(3.0));
|
|
|
|
QCOMPARE(0.6, data.brightness());
|
|
|
|
// just for safety
|
|
|
|
QCOMPARE(1.0, data.opacity());
|
|
|
|
QCOMPARE(1.0, data.saturation());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWindowPaintData::testMultiplyOpacity()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-07-12 15:20:17 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
QCOMPARE(0.2, data.multiplyOpacity(0.2));
|
|
|
|
QCOMPARE(0.2, data.opacity());
|
|
|
|
QCOMPARE(0.6, data.multiplyOpacity(3.0));
|
|
|
|
QCOMPARE(0.6, data.opacity());
|
|
|
|
// just for safety
|
|
|
|
QCOMPARE(1.0, data.brightness());
|
|
|
|
QCOMPARE(1.0, data.saturation());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestWindowPaintData::testMultiplySaturation()
|
|
|
|
{
|
2018-11-30 09:58:45 +00:00
|
|
|
MockEffectWindow w;
|
2012-07-12 15:20:17 +00:00
|
|
|
WindowPaintData data(&w);
|
|
|
|
QCOMPARE(0.2, data.multiplySaturation(0.2));
|
|
|
|
QCOMPARE(0.2, data.saturation());
|
|
|
|
QCOMPARE(0.6, data.multiplySaturation(3.0));
|
|
|
|
QCOMPARE(0.6, data.saturation());
|
|
|
|
// just for safety
|
|
|
|
QCOMPARE(1.0, data.brightness());
|
|
|
|
QCOMPARE(1.0, data.opacity());
|
|
|
|
}
|
|
|
|
|
2012-06-03 07:15:10 +00:00
|
|
|
QTEST_MAIN(TestWindowPaintData)
|
|
|
|
#include "test_window_paint_data.moc"
|