From 69aadfd64301902249ef9c22279f6e90cde0f01f Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Thu, 3 Mar 2022 20:00:24 +0100 Subject: [PATCH] :tada: Add test mode --- extension.js | 17 ++++++++++++----- ...shell.extensions.burn-my-windows.gschema.xml | 6 ++++++ src/BrokenGlass.js | 6 +++++- src/EnergizeA.js | 6 +++++- src/EnergizeB.js | 6 +++++- src/TRexAttack.js | 6 +++++- src/Wisps.js | 6 +++++- 7 files changed, 43 insertions(+), 10 deletions(-) diff --git a/extension.js b/extension.js index ccaaec4..4ae77d5 100644 --- a/extension.js +++ b/extension.js @@ -381,11 +381,16 @@ class Extension { // ----------------------------------------------------------- tweak actor transitions + // If we are currently performing integration test, all animations are set to a fixed + // duration and show a fixed frame from the middle of the animation. + const testMode = this._settings.get_boolean('test-mode'); + // The following is used to tweak the ongoing transitions of a window actor. Usually // windows are faded in / out scaled up / down slightly by GNOME Shell. Here, we allow // modifications to this behavior by the effects. const config = this._currentEffect.tweakTransition(actor, this._settings, forOpening); - const duration = + const duration = testMode ? + 5000 : this._settings.get_int(this._currentEffect.getNick() + '-animation-time'); // All animations are relative to the window's center. @@ -416,9 +421,10 @@ class Extension { // Tweak the transition according to the config object. For some reason, there are // rare cases, where no transition is set up. This happens from time to time... if (transition) { + const middle = (config[property].to + config[property].from) / 2; transition.set_duration(duration); - transition.set_to(config[property].to); - transition.set_from(config[property].from); + transition.set_to(testMode ? middle : config[property].to); + transition.set_from(testMode ? middle : config[property].from); transition.set_progress_mode(config[property].mode); } } @@ -454,8 +460,9 @@ class Extension { // Update uniforms at each frame. transition.connect('new-frame', (t) => { - shader.set_uniform_value('uProgress', t.get_progress()); - shader.set_uniform_value('uTime', 0.001 * t.get_elapsed_time()); + shader.set_uniform_value('uProgress', testMode ? 0.5 : t.get_progress()); + shader.set_uniform_value( + 'uTime', testMode ? duration / 2 : 0.001 * t.get_elapsed_time()); shader.set_uniform_value('uSizeX', actor.width); shader.set_uniform_value('uSizeY', actor.height); }); diff --git a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml index 4631aca..4d3d3a5 100644 --- a/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml +++ b/schemas/org.gnome.shell.extensions.burn-my-windows.gschema.xml @@ -25,6 +25,12 @@ The effect with this nick will be used for the next window-open animation. + + false + Test Mode + If set to true, all animations will show only one still frame to allow for continuous integration tests. + + diff --git a/src/BrokenGlass.js b/src/BrokenGlass.js index 6171ca0..184a86d 100644 --- a/src/BrokenGlass.js +++ b/src/BrokenGlass.js @@ -150,6 +150,9 @@ if (utils.isInShellProcess()) { epicenterY = localY / actor.height; } + // If we are currently performing integration test, the animation uses a fixed seed. + const testMode = settings.get_boolean('test-mode'); + this.set_shader_source(` // Inject some common shader snippets. @@ -157,7 +160,8 @@ if (utils.isInShellProcess()) { uniform sampler2D uShardTexture; - const vec2 SEED = vec2(${Math.random()}, ${Math.random()}); + const vec2 SEED = vec2(${testMode ? 0 : Math.random()}, + ${testMode ? 0 : Math.random()}); const float SHARD_SCALE = ${settings.get_double('broken-glass-scale')}; const float SHARD_LAYERS = 5; const float BLOW_FORCE = ${settings.get_double('broken-glass-blow-force')}; diff --git a/src/EnergizeA.js b/src/EnergizeA.js index 79d8c5d..56a75b1 100644 --- a/src/EnergizeA.js +++ b/src/EnergizeA.js @@ -117,6 +117,9 @@ if (utils.isInShellProcess()) { const color = Clutter.Color.from_string(settings.get_string('energize-a-color'))[1]; + // If we are currently performing integration test, the animation uses a fixed seed. + const testMode = settings.get_boolean('test-mode'); + this.set_shader_source(` // Inject some common shader snippets. @@ -124,7 +127,8 @@ if (utils.isInShellProcess()) { ${shaderSnippets.noise()} ${shaderSnippets.edgeMask()} - const vec2 SEED = vec2(${Math.random()}, ${Math.random()}); + const vec2 SEED = vec2(${testMode ? 0 : Math.random()}, + ${testMode ? 0 : Math.random()}); const float FADE_IN_TIME = 0.3; const float FADE_OUT_TIME = 0.6; const float HEART_FADE_TIME = 0.3; diff --git a/src/EnergizeB.js b/src/EnergizeB.js index 9d64d71..6bddbb0 100644 --- a/src/EnergizeB.js +++ b/src/EnergizeB.js @@ -117,6 +117,9 @@ if (utils.isInShellProcess()) { const color = Clutter.Color.from_string(settings.get_string('energize-b-color'))[1]; + // If we are currently performing integration test, the animation uses a fixed seed. + const testMode = settings.get_boolean('test-mode'); + this.set_shader_source(` // Inject some common shader snippets. @@ -124,7 +127,8 @@ if (utils.isInShellProcess()) { ${shaderSnippets.noise()} ${shaderSnippets.edgeMask()} - const vec2 SEED = vec2(${Math.random()}, ${Math.random()}); + const vec2 SEED = vec2(${testMode ? 0 : Math.random()}, + ${testMode ? 0 : Math.random()}); const float SHOWER_TIME = 0.3; const float SHOWER_WIDTH = 0.3; const float STREAK_TIME = 0.6; diff --git a/src/TRexAttack.js b/src/TRexAttack.js index a5f167a..19a971e 100644 --- a/src/TRexAttack.js +++ b/src/TRexAttack.js @@ -132,6 +132,9 @@ if (utils.isInShellProcess()) { const color = Clutter.Color.from_string(settings.get_string('claw-scratch-color'))[1]; + // If we are currently performing integration test, the animation uses a fixed seed. + const testMode = settings.get_boolean('test-mode'); + this.set_shader_source(` // Inject some common shader snippets. @@ -141,7 +144,8 @@ if (utils.isInShellProcess()) { // See assets/README.md for how this texture was created. uniform sampler2D uClawTexture; - const vec2 SEED = vec2(${Math.random()}, ${Math.random()}); + const vec2 SEED = vec2(${testMode ? 0 : Math.random()}, + ${testMode ? 0 : Math.random()}); const float CLAW_SIZE = ${settings.get_double('claw-scratch-scale')}; const float NUM_CLAWS = ${settings.get_int('claw-scratch-count')}; const float WARP_INTENSITY = 1.0 + ${settings.get_double('claw-scratch-warp')}; diff --git a/src/Wisps.js b/src/Wisps.js index 42b17d5..ccbc608 100644 --- a/src/Wisps.js +++ b/src/Wisps.js @@ -118,6 +118,9 @@ if (utils.isInShellProcess()) { const color = Clutter.Color.from_string(settings.get_string('wisps-color'))[1]; + // If we are currently performing integration test, the animation uses a fixed seed. + const testMode = settings.get_boolean('test-mode'); + this.set_shader_source(` // Inject some common shader snippets. @@ -125,7 +128,8 @@ if (utils.isInShellProcess()) { ${shaderSnippets.noise()} ${shaderSnippets.edgeMask()} - const vec2 SEED = vec2(${Math.random()}, ${Math.random()}); + const vec2 SEED = vec2(${testMode ? 0 : Math.random()}, + ${testMode ? 0 : Math.random()}); const float WISPS_RADIUS = 20.0; const float WISPS_SPEED = 10.0; const float WISPS_SPACING = 40 + WISPS_RADIUS;