summaryrefslogtreecommitdiffstatshomepage
path: root/tests/fixtures/panel-lifecycle.js
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@sommerfeld.dev>2026-09-17 15:05:37 +0100
committersommerfeld <sommerfeld@sommerfeld.dev>2026-09-17 15:05:37 +0100
commit9b9b7b6824cb9219f93d1a70414b2412ea7d3585 (patch)
tree96aa6c1f0ede43d6d1e63df186017847345f69fe /tests/fixtures/panel-lifecycle.js
parentf25d094d0652e8dedff206ca56671b3548f755ff (diff)
downloaddotfiles-9b9b7b6824cb9219f93d1a70414b2412ea7d3585.tar.gz
dotfiles-9b9b7b6824cb9219f93d1a70414b2412ea7d3585.tar.bz2
dotfiles-9b9b7b6824cb9219f93d1a70414b2412ea7d3585.zip
Add GNOME panel status and corporate desktop tools
Diffstat (limited to 'tests/fixtures/panel-lifecycle.js')
-rw-r--r--tests/fixtures/panel-lifecycle.js112
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/fixtures/panel-lifecycle.js b/tests/fixtures/panel-lifecycle.js
new file mode 100644
index 0000000..d035289
--- /dev/null
+++ b/tests/fixtures/panel-lifecycle.js
@@ -0,0 +1,112 @@
+import assert from "node:assert/strict";
+
+const callbacks = [];
+let killed = 0;
+let removed = 0;
+class Actor {
+ constructor(props = {}) {
+ Object.assign(this, props);
+ }
+ add_child() {}
+ set_text(text) {
+ this.text = text;
+ }
+ set_style_class_name(name) {
+ this.style = name;
+ }
+ destroy() {
+ this.destroyed = true;
+ }
+}
+class Button extends Actor {
+ menu = { addMenuItem() {}, addAction() {} };
+}
+class Item {
+ label = new Actor();
+}
+class Extension {
+ uuid = "test";
+}
+const St = { BoxLayout: Actor, Label: Actor };
+const Clutter = { ActorAlign: { CENTER: 0 } };
+const PanelMenu = { Button };
+const PopupMenu = { PopupMenuItem: Item };
+const Main = { panel: { addToStatusArea() {} }, notifyError() {} };
+const GLib = {
+ PRIORITY_DEFAULT: 0,
+ SOURCE_CONTINUE: true,
+ timeout_add_seconds: () => 1,
+ Source: {
+ remove() {
+ removed++;
+ },
+ },
+ get_home_dir: () => "/home/test",
+ build_filenamev: (parts) => parts.join("/"),
+};
+const Gio = {
+ Cancellable: class {
+ cancelled = false;
+ cancel() {
+ this.cancelled = true;
+ }
+ is_cancelled() {
+ return this.cancelled;
+ }
+ },
+ SubprocessFlags: { NONE: 0, STDOUT_PIPE: 1, STDERR_PIPE: 2 },
+ Subprocess: {
+ new() {
+ return {
+ communicate_utf8_async(_input, _token, callback) {
+ callbacks.push(callback);
+ },
+ force_exit() {
+ killed++;
+ },
+ };
+ },
+ },
+};
+
+// EXTENSION
+
+const panel = new CorporatePanel();
+panel.enable();
+panel._refresh();
+assert.equal(callbacks.length, 1, "Do not overlap status processes");
+panel._render({
+ displays: "EXT 1",
+ updates: "APT 3",
+ failed: "FAIL 1",
+ reboot: "",
+ errors: "",
+});
+assert.equal(panel._labels.failed.style, "corporate-critical");
+assert.equal(panel._labels.updates.style, "corporate-warning");
+assert.equal(panel._labels.reboot.visible, false);
+const button = panel._button;
+panel.disable();
+assert.equal(killed, 1);
+assert.equal(removed, 1);
+assert.equal(button.destroyed, true);
+panel.enable();
+callbacks[0]({}, {});
+assert.ok(panel._process, "Old callbacks cannot clear the new process");
+const data = {
+ displays: "EXT 0",
+ updates: "APT 0",
+ failed: "FAIL 0",
+ reboot: "REBOOT",
+ errors: "",
+};
+callbacks[1](
+ {
+ communicate_utf8_finish: () => [true, JSON.stringify(data), ""],
+ get_successful: () => true,
+ },
+ {},
+);
+assert.equal(panel._labels.reboot.visible, true);
+assert.equal(panel._process, null);
+panel.disable();