2023-02-02 15:28:06 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
/* eslint camelcase: ["error", { properties: "never", allow: ["^script_"] }] */
|
|
|
|
|
2023-07-11 12:57:41 +00:00
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import MetaTest from 'gi://MetaTest';
|
|
|
|
import Shell from 'gi://Shell';
|
2023-02-02 15:28:06 +00:00
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
2023-07-06 01:08:09 +00:00
|
|
|
import * as Scripting from 'resource://org/gnome/shell/ui/scripting.js';
|
2023-02-02 15:28:06 +00:00
|
|
|
|
|
|
|
// This script tests that the shell handles connecting monitors after startup
|
|
|
|
// is properly handled.
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export var METRICS = {};
|
2023-02-02 15:28:06 +00:00
|
|
|
|
|
|
|
let _testMonitor = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* init:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export function init() {
|
2023-02-02 15:28:06 +00:00
|
|
|
global.connect('shutdown', () => {
|
|
|
|
_testMonitor?.destroy();
|
|
|
|
});
|
2023-06-07 15:58:08 +00:00
|
|
|
GLib.timeout_add_seconds(
|
|
|
|
GLib.PRIORITY_LOW, 2,
|
2023-02-02 15:28:06 +00:00
|
|
|
() => {
|
2023-06-07 15:58:08 +00:00
|
|
|
log('Connecting 1280x720 test monitor');
|
|
|
|
_testMonitor = MetaTest.TestMonitor.new(
|
|
|
|
global.context, 1280, 720, 60.0);
|
2023-02-02 15:28:06 +00:00
|
|
|
});
|
|
|
|
Scripting.defineScriptEvent('monitorsChanged', 'Monitors changed');
|
|
|
|
|
|
|
|
const display = global.display;
|
|
|
|
console.assert(display.get_n_monitors() === 0, 'Not running headless');
|
|
|
|
|
|
|
|
const monitorManager = global.backend.get_monitor_manager();
|
|
|
|
const monitorsChangedHandlerId = monitorManager.connect('monitors-changed',
|
|
|
|
() => {
|
|
|
|
console.assert(display.get_n_monitors() === 1,
|
|
|
|
'Expected a single monitor');
|
|
|
|
Scripting.scriptEvent('monitorsChanged');
|
|
|
|
monitorManager.disconnect(monitorsChangedHandlerId);
|
|
|
|
});
|
|
|
|
Shell.PerfLog.get_default().set_enabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* run:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export async function run() {
|
2023-02-02 15:28:06 +00:00
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
Scripting.defineScriptEvent('overviewShowDone', 'Overview finished showing');
|
|
|
|
Scripting.defineScriptEvent('overviewHideDone', 'Overview finished hiding');
|
|
|
|
|
|
|
|
Main.overview.connect('shown',
|
|
|
|
() => Scripting.scriptEvent('overviewShowDone'));
|
|
|
|
Main.overview.connect('hidden',
|
|
|
|
() => Scripting.scriptEvent('overviewHideDone'));
|
|
|
|
|
|
|
|
Main.overview.hide();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
|
|
|
Main.overview.show();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
|
|
|
/* eslint-enable no-await-in-loop */
|
|
|
|
}
|
|
|
|
|
|
|
|
let monitorsChanged = false;
|
|
|
|
let overviewHidden = false;
|
|
|
|
let overviewShown = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* script_monitorsChanged:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_monitorsChanged() {
|
2023-02-02 15:28:06 +00:00
|
|
|
monitorsChanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* script_overviewHideDone:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_overviewHideDone() {
|
2023-02-02 15:28:06 +00:00
|
|
|
overviewHidden = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* script_overviewShowDone:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_overviewShowDone() {
|
2023-02-02 15:28:06 +00:00
|
|
|
overviewShown = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* finish:
|
|
|
|
*/
|
2023-06-13 00:13:01 +00:00
|
|
|
export function finish() {
|
2023-02-02 15:28:06 +00:00
|
|
|
if (!monitorsChanged)
|
|
|
|
throw new Error('Monitors never changed');
|
|
|
|
|
|
|
|
if (!overviewHidden)
|
|
|
|
throw new Error('Failed to hide overview');
|
|
|
|
|
|
|
|
if (!overviewShown)
|
|
|
|
throw new Error('Failed to show overview');
|
|
|
|
}
|