Repository navigation
Expand file tree
/
Copy pathdev.js
More file actions
534 lines (498 loc) · 25.2 KB
/
Copy pathdev.js
File metadata and controls
534 lines (498 loc) · 25.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
// Dev only: click test for tools/klicktest.sh (FUMMEL_DEV=<dir> in a headless shell with the fake
// voice service). Plays every flow from the README with shortcuts, clicks and the wake word and
// checks the bubble. Lines "FUMMEL_TEST ..." go to the shell log.
import Clutter from 'gi://Clutter';
import GLib from 'gi://GLib';
import Gio from 'gi://Gio';
import Shell from 'gi://Shell';
import St from 'gi://St';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
const RUN = GLib.get_user_runtime_dir();
// Long enough for the paste to be over and the clipboard to be put back (CLIPBOARD_RESTORE_MS).
const CLIPBOARD_WAIT_MS = 1200;
let fails = 0;
function out(line) {
log(`FUMMEL_TEST ${line}`);
}
function check(name, ok, info = '') {
out(`${ok ? 'OK ' : 'FAIL'} ${name}${info ? ` (${info})` : ''}`);
if (!ok)
fails++;
return ok;
}
function sleep(ms) {
return new Promise(resolve => GLib.timeout_add(GLib.PRIORITY_DEFAULT, ms, () => {
resolve();
return GLib.SOURCE_REMOVE;
}));
}
// Waits until fn() is true, at most ms.
async function until(fn, ms = 3000) {
for (let t = 0; t < ms; t += 50) {
if (fn())
return true;
await sleep(50);
}
return !!fn();
}
const fakeText = text => GLib.file_set_contents(`${RUN}/fake-text`, text);
const sayWake = (group = '') => GLib.file_set_contents(`${RUN}/fake-wake`, group);
const clipboard = type => new Promise(resolve =>
St.Clipboard.get_default().get_text(type, (c, text) => resolve(text)));
function shot(name) {
return new Promise(resolve => {
const stream = Gio.File.new_for_path(`${GLib.getenv('FUMMEL_DEV')}/${name}.png`).replace(null, false, 0, null);
new Shell.Screenshot().screenshot(false, stream, (o, res) => {
try {
o.screenshot_finish(res);
} catch (e) {
logError(e);
}
stream.close(null);
resolve();
});
});
}
// One copy of the skin per state in a grid, upper half on dark, lower half on white, one
// screenshot (aussehen.png) to judge the look. Moves of a skin with its own entrance and exit
// are started so that the screenshot catches them in the middle.
async function lookTour(Skin, dir) {
const states = [
['spricht leise', s => s.setState('recording') || s.pushLevel(0.25)],
['spricht laut', s => s.setState('recording') || s.pushLevel(1)],
['schreibt', s => s.setState('transcribing')],
['liest vor', s => s.setState('speaking') || s.setMouth(0.8)],
['pausiert', s => s.setState('paused')],
['nichts verstanden', s => s.hint('Nichts verstanden', 60000, () => {})],
['Zwischenablage', s => s.hint('In der Zwischenablage', 60000, () => {})],
['nichts markiert', s => s.hint('Erst Text markieren', 60000, () => {})],
['Gute Nacht', s => s.hint('Gute Nacht', 60000, () => {})],
['Hilfe', s => s.hint('Hilfe', 60000, () => {})],
['liest leise', s => s.setState('speaking') || s.setMouth(0.25)],
['wartet', s => s.setState('waking')],
];
// [name, start, seconds before the screenshot]
const moves = Skin.prototype.appear ? [
['taucht auf', s => s.appear(), 0.15],
['blinzelt', s => Object.assign(s._blink, {at: s._t, next: Infinity}), 0.09],
['freut sich (eingefügt)', s => s.setState('transcribing') || s.setState(null) || s.leave(() => {}), 0.3],
['Tschüss', s => s.setState('transcribing') || s.setState(null) || s.leave(() => {}), 1.25],
['bläht sich auf', s => s.leave(() => {}), 0.1],
['platzt', s => s.leave(() => {}), 0.25],
] : [];
const all = [...states.map(([n, set]) => [n, set, 0]), ...moves];
const actors = [];
const white = new St.Widget({style: 'background-color: white;', x: 0, y: 400, width: 1280, height: 400});
Main.uiGroup.add_child(white);
actors.push(white);
const skins = [];
for (const [bg, y0] of [[0, 30], [1, 410]]) {
all.forEach(([name, set, delay], i) => {
const [col, y] = [i % 7, y0 + Math.floor(i / 7) * 185];
const skin = new Skin(() => {}, dir);
Main.uiGroup.add_child(skin);
skin._reposition = () => {};
const place = () => skin.set_position(10 + col * 180 + (180 - skin.width) / 2, y + 170 - skin.height);
place();
skin.connect('notify::width', place);
if (!delay)
set(skin);
else
skins.push([skin, set, delay]);
const label = new St.Label({text: name, x: 10 + col * 180 + 30, y: y + 168,
style: `color: ${bg ? 'black' : 'white'}; font-size: 12px;`});
Main.uiGroup.add_child(label);
actors.push(skin, label);
});
}
await sleep(1200);
skins.sort((a, b) => b[2] - a[2]);
let left = skins[0]?.[2] ?? 0;
for (const [skin, set, delay] of skins) {
await sleep(Math.round((left - delay) * 1000));
set(skin);
left = delay;
}
await sleep(Math.round(left * 1000));
await shot('aussehen');
actors.forEach(a => a.destroy());
}
export async function run(ext) {
const now = () => GLib.get_monotonic_time();
const seat = Clutter.get_default_backend().get_default_seat();
const pointer = seat.create_virtual_device(Clutter.InputDeviceType.POINTER_DEVICE);
const keyboard = seat.create_virtual_device(Clutter.InputDeviceType.KEYBOARD_DEVICE);
const b = ext._bubble;
const shown = () => b.visible && ext._shown;
const gone = () => !b.visible && !ext._shown;
const click = async () => {
const [x, y] = b.get_transformed_position();
const [w, h] = b.get_transformed_size();
pointer.notify_absolute_motion(now(), x + h / 2, y + h / 2);
await sleep(30);
pointer.notify_button(now(), Clutter.BUTTON_PRIMARY, Clutter.ButtonState.PRESSED);
pointer.notify_button(now(), Clutter.BUTTON_PRIMARY, Clutter.ButtonState.RELEASED);
await sleep(100);
};
const key = async keyval => {
keyboard.notify_keyval(now(), keyval, Clutter.KeyState.PRESSED);
keyboard.notify_keyval(now(), keyval, Clutter.KeyState.RELEASED);
await sleep(100);
};
const settle = async () => {
ext.voice.stop();
ext.voice.cancelListening();
await until(() => !ext.state && !b.hinting && gone() && ext.voice.waking, 5000);
await sleep(300);
};
// One dictation from start to its end, until the bubble is gone again. Other events update
// the bubble at any time (service, wake word, Super let go), so this calls _update() all the
// time and counts how often the bubble opens: more than once is the close-and-open bug.
// start() begins it, end() ends it (or nothing: hands-free).
const dictation = async (name, start, end, text = 'Testdiktat') => {
await settle();
fakeText(text);
const seen = [];
const setState = b.setState.bind(b);
b.setState = st => {
if (String(st) !== seen.at(-1))
seen.push(String(st));
setState(st);
};
let opens = 0, was = false;
const watch = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 10, () => {
ext._update();
opens += !was && ext._shown;
was = ext._shown;
return GLib.SOURCE_CONTINUE;
});
await start();
check(`${name}: Aufnahme mit Bubble`, await until(() => ext.state === 'recording' && shown()), ext.state);
check(`${name}: Wachwort schweigt`, !ext.voice.waking);
await end();
await until(() => !ext.state && !ext._pasting && gone(), 6000);
GLib.source_remove(watch);
b.setState = setState;
check(`${name}: Bubble geht nur einmal auf`, opens === 1, `${opens}×`);
check(`${name}: Ablauf`, !seen.slice(seen[0] === 'null' ? 1 : 0, -1).includes('null'), seen.join(' → '));
};
// Every hint shown, recorded by wrapping the bubble's hint().
const hints = [];
const hint = b.hint.bind(b);
b.hint = (text, ...rest) => {
hints.push(text);
hint(text, ...rest);
};
const hintThenGone = async (name, text) => {
check(`${name}: Hinweis „${text}“`, await until(() => hints.includes(text), 2000), hints.join(', '));
check(`${name}: Bubble zu nach Hinweis`, await until(() => gone(), 4000));
hints.length = 0;
};
await sleep(2500);
if (ext._disabled)
return;
out('START');
check('Start: Fummel läuft', !!ext._bubble);
check('Ruhe: Bubble unsichtbar', gone());
check('Ruhe: Wachwort hört zu', await until(() => ext.voice.waking));
// --- Super+T, kein Textfeld ---
await dictation('Super+T', () => void ext.toggleDictation(), async () => {
await sleep(300);
ext.toggleDictation();
check('Super+T: „Schreibt…“', await until(() => b.label === 'Schreibt…', 2000), b.label);
});
await hintThenGone('kein Textfeld', 'In der Zwischenablage');
check('kein Textfeld: Text in der Zwischenablage', await clipboard(St.ClipboardType.CLIPBOARD) === 'Testdiktat');
check('danach hört Wachwort wieder', await until(() => ext.voice.waking));
// --- Super+T mit Textfeld: einfügen, ohne Hinweis zu ---
St.Clipboard.get_default().set_text(St.ClipboardType.CLIPBOARD, 'vorher');
const pressed = [];
ext._textField = () => true;
ext._pressKeys = keys => pressed.push(keys.join('+'));
ext._waitForModifiers = () => sleep(400); // Super of Super+T still held
hints.length = 0;
await dictation('Textfeld', () => void ext.toggleDictation(), () => ext.toggleDictation());
check('Textfeld: Strg+V gedrückt', pressed.length === 1, pressed.join(' '));
check('Textfeld: Bubble zu', await until(() => gone(), 4000));
check('Textfeld: kein Hinweis', !hints.length, hints.join(', '));
await sleep(800);
check('Textfeld: alte Zwischenablage zurück', await clipboard(St.ClipboardType.CLIPBOARD) === 'vorher');
delete ext._textField;
delete ext._pressKeys;
delete ext._waitForModifiers;
// --- Klick aufs Mikrofon ---
await dictation('Klick', () => void ext.toggleDictation(), click);
await hintThenGone('Klick', 'In der Zwischenablage');
// --- Esc: beendet wie Super+T, der Rest wird noch eingefügt ---
await settle();
hints.length = 0;
fakeText(''); // nothing said
ext.toggleDictation();
await until(() => ext.state === 'recording');
await key(Clutter.KEY_Escape);
check('Esc ohne Text: „Nichts verstanden“', await until(() => hints.includes('Nichts verstanden'), 3000), hints.join(', '));
check('Esc: beendet', await until(() => !ext.state, 2000), ext.state);
check('Esc: Bubble zu nach dem Hinweis', await until(() => gone(), 6000));
check('Esc: danach nicht mehr gebunden', !ext._cancelBound);
hints.length = 0;
// --- Nichts erkannt ---
await dictation('Nichts', () => void ext.toggleDictation(), () => void ext.toggleDictation(), '');
await hintThenGone('Nichts', 'Nichts verstanden');
// --- Wachwort: endet selbst, oder per Klick, oder per Super+T ---
await dictation('Wachwort', sayWake, async () => {});
await hintThenGone('Wachwort', 'In der Zwischenablage');
await dictation('Wachwort+Klick', sayWake, click);
await hintThenGone('Wachwort+Klick', 'In der Zwischenablage');
await dictation('Wachwort+Super+T', sayWake, () => ext.toggleDictation());
await hintThenGone('Wachwort+Super+T', 'In der Zwischenablage');
// --- Teile nach jeder Sprechpause, Codewort am Ende ---
const pasted = [];
const paste = ext._paste;
ext._textField = () => true;
ext._pressKeys = () => {};
ext._paste = (text, wait) => {
pasted.push(text);
return paste.call(ext, text, wait);
};
await dictation('Teile', () => void ext.toggleDictation(), async () => {
check('Teile: eingefügt während der Aufnahme',
await until(() => pasted.length === 2, 3000) && ext.state === 'recording', `${pasted.length} ${ext.state}`);
ext.toggleDictation();
}, 'Erster Satz.|Zweiter Satz.|Rest');
check('Teile: alle drei in Reihe, mit Leerzeichen', pasted.join('') === 'Erster Satz. Zweiter Satz. Rest', JSON.stringify(pasted));
pasted.length = 0;
hints.length = 0;
await dictation('Codewort', () => void ext.toggleDictation(), async () => {}, 'Hallo Welt.|<fertig>');
check('Codewort: beendet selbst, Text eingefügt', pasted.join('') === 'Hallo Welt.', JSON.stringify(pasted));
check('Codewort: kein Hinweis', !hints.length, hints.join(', '));
pasted.length = 0;
const keys = [];
ext._pressKeys = k => keys.push(k);
await dictation('Senden', () => void ext.toggleDictation(), async () => {}, 'Nachricht.|<senden>');
check('Senden: eingefügt, dann Enter', pasted.join('') === 'Nachricht.' &&
JSON.stringify(keys.at(-1)) === JSON.stringify([Clutter.KEY_Return]), `${JSON.stringify(pasted)} ${JSON.stringify(keys)}`);
keys.length = 0;
await dictation('Fertig ohne Senden', () => void ext.toggleDictation(), async () => {}, 'Nachricht.|<fertig>');
check('Fertig: kein Enter', !keys.some(k => k.includes(Clutter.KEY_Return)), JSON.stringify(keys));
ext._pressKeys = () => {};
pasted.length = 0;
await settle();
fakeText('Schon drin.|Weg');
ext.toggleDictation();
await until(() => pasted.length === 1, 3000);
await key(Clutter.KEY_Escape);
check('Esc nach einem Teil: Rest kommt auch noch rein', await until(() => !ext.state && gone(), 6000) &&
pasted.join('') === 'Schon drin. Weg', JSON.stringify(pasted));
// --- Super+R im Diktat: Text geht rein, dann liest es vor ---
await settle();
pasted.length = 0;
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'Ein Testsatz.');
fakeText('Weiter so.');
ext.toggleDictation();
await until(() => ext.state === 'recording');
ext.toggleSpeak();
check('Super+R im Diktat: liest danach vor', await until(() => ext.state === 'speaking', 4000), ext.state);
check('Super+R im Diktat: Text war vorher eingefügt', pasted.join('') === 'Weiter so.', JSON.stringify(pasted));
ext.toggleSpeak();
await until(() => !ext.state, 3000);
// --- Zwischenablage: der alte Inhalt kommt erst zurück, wenn das Diktat durch ist ---
await settle();
pasted.length = 0;
St.Clipboard.get_default().set_text(St.ClipboardType.CLIPBOARD, 'Alter Inhalt');
await sleep(200);
fakeText('Erster.|Zweiter');
ext.toggleDictation();
await until(() => pasted.length === 1, 3000);
check('Beim ersten Teil liegt der neue Text in der Zwischenablage',
await clipboard(St.ClipboardType.CLIPBOARD) === 'Erster.', await clipboard(St.ClipboardType.CLIPBOARD));
ext.toggleDictation();
await until(() => !ext.state && pasted.length === 2, 4000);
await sleep(CLIPBOARD_WAIT_MS);
check('Nach dem Diktat ist der alte Inhalt zurück',
await clipboard(St.ClipboardType.CLIPBOARD) === 'Alter Inhalt', await clipboard(St.ClipboardType.CLIPBOARD));
ext._paste = paste;
delete ext._textField;
delete ext._pressKeys;
await dictation('Teile ohne Textfeld', () => void ext.toggleDictation(), () => ext.toggleDictation(), 'Eins.|Zwei.|Drei.');
await hintThenGone('Teile ohne Textfeld', 'In der Zwischenablage');
check('Teile ohne Textfeld: alles in der Zwischenablage',
await clipboard(St.ClipboardType.CLIPBOARD) === 'Eins. Zwei. Drei.', await clipboard(St.ClipboardType.CLIPBOARD));
// --- Vorlesen und Stopp per Sprache ---
await settle();
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'Ein Testsatz.');
sayWake('read');
check('„Fummel, vorlesen“: liest vor', await until(() => ext.state === 'speaking' && shown()), ext.state);
check('beim Vorlesen hört er auf „Fummel, halt“', await until(() => ext.voice._wake?.key.includes('stop')));
sayWake('stop');
check('„Fummel, halt“: Stopp, zu', await until(() => !ext.state && gone(), 3000), ext.state);
check('danach wieder Diktat und Vorlesen per Sprache', await until(() => ext.voice._wake?.key.includes('read')));
// --- Vorlesen: Pause per Klick und per Sprache ---
await settle();
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'Ein Testsatz.');
ext.toggleSpeak();
await until(() => ext.state === 'speaking' && shown());
await sleep(300);
await click();
check('Klick beim Vorlesen: Pause, Fummel bleibt', await until(() => ext.state === 'paused') && shown(), ext.state);
check('Pause: „Pausiert“', b.label === 'Pausiert', b.label);
// On the drawn skins (monster, yeti) the label is only on screen if the skin says it.
if (b._say)
check('Pause: steht auf Fummel', await until(() => b._say.visible && b._say.text === 'Pausiert', 1000),
`${b._say.visible} „${b._say.text}“`);
check('Pause: hört auf „weiter“ und „halt“', await until(() => ext.voice._wake?.key.includes('resume') && ext.voice._wake.key.includes('stop')));
await click();
check('Klick nochmal: liest weiter', await until(() => ext.state === 'speaking'), ext.state);
if (b._say)
check('Weiter: „Pausiert“ ist wieder weg', await until(() => !b._say.visible, 1000));
sayWake('pause');
check('„Fummel, Pause“', await until(() => ext.state === 'paused'), ext.state);
sayWake('resume');
check('„Fummel, weiter“', await until(() => ext.state === 'speaking'), ext.state);
await click();
await until(() => ext.state === 'paused');
ext.toggleSpeak();
check('Super+R in der Pause: Stopp, zu', await until(() => !ext.state && gone()), ext.state);
const pauses = GLib.file_get_contents(`${GLib.getenv('FUMMEL_DEV')}/voice-requests.log`)[1];
check('Pause/Weiter erreichen den Dienst', new TextDecoder().decode(pauses).includes('{"pause": true}') &&
new TextDecoder().decode(pauses).includes('{"pause": false}'));
// --- Esc beendet auch das Vorlesen ---
await settle();
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'Ein Testsatz.');
ext.toggleSpeak();
await until(() => ext.state === 'speaking' && shown());
await key(Clutter.KEY_Escape);
check('Esc stoppt das Vorlesen', await until(() => !ext.state && gone(), 3000), ext.state);
check('Esc danach wieder freigegeben', !ext._cancelBound);
// --- Dienst beenden (der Knopf in den Einstellungen zählt nur hoch) ---
await settle();
ext._settings.set_uint('stop-service', ext._settings.get_uint('stop-service') + 1);
check('Knopf „Dienst beenden“ stoppt den Dienst',
await until(() => !ext.voice.running && !ext.voice.waking, 4000),
`${ext.voice.running} ${ext.voice.waking}`);
// Without the sleep flag the next _update would start it right back up for the wake word.
await sleep(2500);
check('… und der Dienst bleibt aus', !ext.voice.running && !ext.voice.waking && ext.sleeping,
`${ext.voice.running} ${ext.voice.waking} ${ext.sleeping}`);
ext.toggleSleep();
await settle();
// --- Schlafen ---
await settle();
ext.toggleSleep();
check('Super+S: „Gute Nacht“', await until(() => hints.includes('Gute Nacht'), 2000), hints.join(', '));
check('Schlaf: kein Wachwort, Dienst aus', await until(() => !ext.voice.waking && !ext.voice.running, 3000),
`${ext.voice.waking} ${ext.voice.running}`);
await until(() => gone(), 4000);
await dictation('Diktat weckt', () => void ext.toggleDictation(), () => ext.toggleDictation());
check('Diktat aus dem Schlaf weckt', await until(() => !ext.sleeping && ext.voice.running, 4000),
`${ext.sleeping} ${ext.voice.running}`);
hints.length = 0;
ext.toggleSleep();
check('Super+S danach: „Gute Nacht“ statt „Bin wach“',
await until(() => hints.includes('Gute Nacht') && !ext.voice.running, 4000), hints.join(', '));
hints.length = 0;
ext.toggleSleep();
check('Super+S nochmal: „Bin wach“, Wachwort hört', await until(() => hints.includes('Bin wach') && ext.voice.waking, 4000));
await settle();
sayWake('sleep');
check('„Fummel, schlaf gut“', await until(() => ext.sleeping && !ext.voice.running, 4000));
ext.toggleSleep();
await settle();
ext._fullscreen = () => true;
ext._onFullscreen();
check('Vollbild: schläft', ext.sleeping && await until(() => !ext.voice.running, 3000));
ext._fullscreen = () => false;
ext._onFullscreen();
check('Vollbild zu: wach', !ext.sleeping && await until(() => ext.voice.waking, 4000));
ext.toggleSleep();
ext._fullscreen = () => true;
ext._onFullscreen();
ext._fullscreen = () => false;
ext._onFullscreen();
check('von Hand eingeschlafen: Vollbild zu weckt nicht', ext.sleeping);
ext.toggleSleep();
delete ext._fullscreen;
await settle();
// --- Hilfe führt ins Einstellungsfenster, statt eine eigene Karte zu zeigen ---
const opened = [];
ext._openSettings = name => opened.push(name);
await settle();
sayWake('help');
check('„Fummel, Hilfe“: Einstellungen auf der Hilfe-Seite',
await until(() => opened.includes('help'), 3000), opened.join(', '));
opened.length = 0;
ext._openSettings('help');
check('OpenSettings bekommt die Hilfe-Seite', opened.join(',') === 'help', opened.join(','));
check('Keine eigene Hilfe-Karte mehr', ext._help === undefined && !ext._toggleHelp);
// --- GNOME-Kürzel ---
const gnome = (schema, key) => new Gio.Settings({schema_id: schema}).get_strv(key);
check('Super+S/H von GNOME übernommen', !gnome('org.gnome.shell.keybindings', 'toggle-quick-settings').includes('<Super>s') &&
!gnome('org.gnome.desktop.wm.keybindings', 'minimize').includes('<Super>h'));
// --- Vorlesen ---
await settle();
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, 'Ein Testsatz.');
ext.toggleSpeak();
check('Super+R: liest vor', await until(() => ext.state === 'speaking' && shown()), ext.state);
check('Vorlesen: „Liest vor“', b.label === 'Liest vor', b.label);
check('Vorlesen: hört auf Stopp und Pause', /"stop".*"pause"/.test(ext.voice._wake?.key ?? ''), ext.voice._wake?.key);
ext.toggleSpeak();
check('Super+R nochmal: Stopp, Bubble zu', await until(() => !ext.state && gone()), ext.state);
await settle();
ext.toggleSpeak();
await until(() => ext.state === 'speaking');
ext.toggleDictation();
check('Super+T beim Vorlesen: Diktat statt Vorlesen', await until(() => ext.state === 'recording'), ext.state);
await settle();
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, '');
ext.toggleSpeak();
await hintThenGone('nichts markiert', 'Erst Text markieren');
// --- Bildwechsel beim Zuhören (Yeti): nicht bei jeder Silbe ---
if (b._choose) {
await settle();
ext.toggleDictation();
await until(() => ext.state === 'recording');
let switches = 0, last = b._listen;
for (let i = 0; i < 60; i++) {
b.pushLevel(Math.floor(i / 3) % 2); // laut, leise, laut … alle 150 ms
await sleep(50);
if (b._listen !== last) {
switches++;
last = b._listen;
}
}
check('Yeti: wechselt beim Zuhören höchstens alle 1,5 s', switches <= 2, `${switches} Wechsel in 3 s`);
ext.voice.cancelListening();
}
if (GLib.getenv('FUMMEL_LOOK'))
await lookTour(ext._bubble.constructor, ext.path);
check('kein Grab offen', !global.stage.get_grab_actor() && Main.modalCount === 0);
// --- Sprache umschalten: andere Stimme, anderes Modell, andere Befehlswörter ---
await settle();
const germanVoice = ext.voice._paths.voice;
ext._settings.set_string('language', 'en');
check('Sprache en: englische Stimme und v3 als Diktat-Modell',
await until(() => ext.voice._paths.voice.endsWith('en_US-ryan-high.onnx'), 2000) &&
ext.voice._paths.model.endsWith('parakeet-tdt-0.6b-v3-Q8_0.gguf'),
JSON.stringify(ext.voice._paths));
check('Sprache en: englische Befehlswörter', ext.commands.end[0] === 'Fummel done',
ext.commands.end.join(' / '));
ext._settings.set_string('language', 'de');
check('Sprache de: wieder Thorsten und primeline',
await until(() => ext.voice._paths.voice === germanVoice, 2000) &&
ext.voice._paths.model.endsWith('parakeet-primeline-Q8_0.gguf'), ext.voice._paths.voice);
await settle();
// --- Ausgeschaltet: Super+S/H wieder bei GNOME (zuletzt, beendet diesen Test) ---
// Only the extension knows its own schema, so read the note before it lets go of the settings.
const settings = ext._settings;
check('An: die weggenommenen Kürzel sind notiert', settings.get_strv('taken-keys').length === 2,
settings.get_strv('taken-keys').join(', '));
ext.disable();
check('Aus: Super+S/H wieder bei GNOME',
gnome('org.gnome.shell.keybindings', 'toggle-quick-settings').includes('<Super>s') &&
gnome('org.gnome.desktop.wm.keybindings', 'minimize').includes('<Super>h'));
check('Aus: nichts mehr notiert, das noch zurück müsste', settings.get_strv('taken-keys').length === 0,
settings.get_strv('taken-keys').join(', '));
out(`ENDE ${fails} Fehler`);
pointer.run_dispose();
keyboard.run_dispose();
global.context.terminate();
}