Commit 5d279a0d authored by David Edmundson's avatar David Edmundson

[autotests] Unit most scripted effects API

Summary:
Ready for QJSEngine port and upcoming other fixes.
Split as it makes it easier to do any before/after testing.

Test Plan:
All tests pass with the current QScriptEngine
Verified expected API against a wiki page and current code.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14482
parent 7b65aa91
......@@ -5,3 +5,4 @@ if (XCB_ICCCM_FOUND)
endif()
integrationTest(NAME testFade SRCS fade_test.cpp)
integrationTest(WAYLAND_ONLY NAME testEffectWindowGeometry SRCS windowgeometry_test.cpp)
integrationTest(NAME testScriptedEffects SRCS scripted_effects_test.cpp)
This diff is collapsed.
effects.windowAdded.connect(function(w) {
w.anim1 = effect.animate(w, Effect.Scale, 100, 1.4, 0.2);
sendTestResponse(typeof(w.anim1) == "number");
});
effects.windowUnminimized.connect(function(w) {
cancel(w.anim1);
});
effects.windowMinimized.connect(function(w) {
retarget(w.anim1, 1.5, 200);
});
effects.windowAdded.connect(function(w) {
w.anim1 = animate({
window: w,
duration: 100,
animations: [{
type: Effect.Scale,
curve: Effect.GaussianCurve,
to: 1.4
}, {
type: Effect.Opacity,
curve: Effect.GaussianCurve,
to: 0.0
}]
});
sendTestResponse(typeof(w.anim1) == "object" && Array.isArray(w.anim1));
});
effects.windowUnminimized.connect(function(w) {
cancel(w.anim1);
});
effects.windowMinimized.connect(function(w) {
retarget(w.anim1, 1.5, 200);
});
sendTestResponse(displayWidth() + "x" + displayHeight());
sendTestResponse(animationTime(100));
//test enums for Effect / QEasingCurve
sendTestResponse(Effect.Saturation)
sendTestResponse(QEasingCurve.Linear)
effects.windowAdded.connect(function(window) {
sendTestResponse("windowAdded - " + window.caption);
});
effects.windowClosed.connect(function(window) {
sendTestResponse("windowClosed - " + window.caption);
});
effects.windowMinimized.connect(function(window) {
sendTestResponse("windowMinimized - " + window.caption);
});
effects.windowUnminimized.connect(function(window) {
sendTestResponse("windowUnminimized - " + window.caption);
});
effects['desktopChanged(int,int)'].connect(function(old, current) {
sendTestResponse("desktopChanged - " + old + " " + current);
});
registerScreenEdge(1, function() {
sendTestResponse("triggered");
});
registerTouchScreenEdge(1, function() {
sendTestResponse("triggered");
});
registerShortcut("testShortcut", "Test Shortcut", "Meta+Shift+Y", function() {
sendTestResponse("shortcutTriggered");
});
......@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace KWin {
class AniData {
class KWINEFFECTS_EXPORT AniData {
public:
AniData();
AniData(AnimationEffect::Attribute a, int meta, int ms, const FPx2 &to,
......
......@@ -948,5 +948,11 @@ QString AnimationEffect::debug(const QString &/*parameter*/) const
return dbg;
}
AnimationEffect::AniMap AnimationEffect::state() const
{
Q_D(const AnimationEffect);
return d->m_animations;
}
#include "moc_kwinanimationeffect.cpp"
......@@ -97,6 +97,8 @@ class KWINEFFECTS_EXPORT AnimationEffect : public Effect
Q_ENUMS(Attribute)
Q_ENUMS(MetaType)
public:
typedef QMap< EffectWindow*, QPair<QList<AniData>, QRect> > AniMap;
enum Anchor { Left = 1<<0, Top = 1<<1, Right = 1<<2, Bottom = 1<<3,
Horizontal = Left|Right, Vertical = Top|Bottom, Mouse = 1<<4 };
enum Attribute {
......@@ -205,6 +207,9 @@ protected:
virtual void genericAnimation( EffectWindow *w, WindowPaintData &data, float progress, uint meta )
{Q_UNUSED(w); Q_UNUSED(data); Q_UNUSED(progress); Q_UNUSED(meta);}
//Internal for unit tests
AniMap state() const;
private:
quint64 p_animate( EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, QEasingCurve curve, int delay, FPx2 from, bool keepAtTarget );
QRect clipRect(const QRect &windowRect, const AniData&) const;
......@@ -222,7 +227,6 @@ private Q_SLOTS:
void _expandedGeometryChanged(KWin::EffectWindow *w, const QRect &old);
private:
static QElapsedTimer s_clock;
typedef QMap< EffectWindow*, QPair<QList<AniData>, QRect> > AniMap;
AnimationEffectPrivate * const d_ptr;
Q_DECLARE_PRIVATE(AnimationEffect)
};
......
......@@ -678,4 +678,9 @@ bool ScriptedEffect::unregisterTouchScreenCallback(int edge)
return true;
}
QScriptEngine *ScriptedEffect::engine() const
{
return m_engine;
}
} // namespace
......@@ -109,14 +109,15 @@ Q_SIGNALS:
void animationEnded(KWin::EffectWindow *w, quint64 animationId);
protected:
ScriptedEffect();
QScriptEngine *engine() const;
bool init(const QString &effectName, const QString &pathToScript);
void animationEnded(KWin::EffectWindow *w, Attribute a, uint meta);
private Q_SLOTS:
void signalHandlerException(const QScriptValue &value);
void globalShortcutTriggered();
private:
ScriptedEffect();
bool init(const QString &effectName, const QString &pathToScript);
QScriptEngine *m_engine;
QString m_effectName;
QString m_scriptFile;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment