2020-07-31 01:42:01 +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 St from 'gi://St';
|
2020-07-31 01:42:01 +00:00
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
const MessageTray = imports.ui.messageTray;
|
|
|
|
const Scripting = imports.ui.scripting;
|
|
|
|
|
|
|
|
// This script tests the most important (basic) functionality of the shell.
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export var METRICS = {};
|
2020-07-31 01:42:01 +00:00
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export async function run() {
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Running basic perf test');
|
|
|
|
|
2020-07-31 01:42:01 +00:00
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
Scripting.defineScriptEvent('topBarNavStart', 'Starting to navigate the top bar');
|
|
|
|
Scripting.defineScriptEvent('topBarNavDone', 'Done navigating the top bar');
|
|
|
|
Scripting.defineScriptEvent('notificationShowStart', 'Showing a notification');
|
|
|
|
Scripting.defineScriptEvent('notificationShowDone', 'Done showing a notification');
|
|
|
|
Scripting.defineScriptEvent('notificationCloseStart', 'Closing a notification');
|
|
|
|
Scripting.defineScriptEvent('notificationCloseDone', 'Done closing a notification');
|
|
|
|
Scripting.defineScriptEvent('overviewShowStart', 'Starting to show the overview');
|
|
|
|
Scripting.defineScriptEvent('overviewShowDone', 'Overview finished showing');
|
|
|
|
Scripting.defineScriptEvent('applicationsShowStart', 'Starting to switch to applications view');
|
|
|
|
Scripting.defineScriptEvent('applicationsShowDone', 'Done switching to applications view');
|
|
|
|
|
|
|
|
Main.overview.connect('shown',
|
|
|
|
() => Scripting.scriptEvent('overviewShowDone'));
|
|
|
|
|
|
|
|
await Scripting.sleep(1000);
|
|
|
|
|
|
|
|
// navigate through top bar
|
2021-03-16 09:27:46 +00:00
|
|
|
|
|
|
|
console.debug('Navigate through top bar');
|
2020-07-31 01:42:01 +00:00
|
|
|
Scripting.scriptEvent('topBarNavStart');
|
2022-08-16 10:40:34 +00:00
|
|
|
Main.panel.statusArea.quickSettings.menu.open();
|
2020-07-31 01:42:01 +00:00
|
|
|
await Scripting.sleep(400);
|
|
|
|
|
|
|
|
const { menuManager } = Main.panel;
|
|
|
|
while (menuManager.activeMenu &&
|
|
|
|
Main.panel.navigate_focus(menuManager.activeMenu.sourceActor,
|
|
|
|
St.DirectionType.TAB_BACKWARD, false))
|
|
|
|
await Scripting.sleep(400);
|
|
|
|
Scripting.scriptEvent('topBarNavDone');
|
|
|
|
|
|
|
|
await Scripting.sleep(1000);
|
|
|
|
|
|
|
|
// notification
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Show notification message');
|
2020-07-31 01:42:01 +00:00
|
|
|
const source = new MessageTray.SystemNotificationSource();
|
|
|
|
Main.messageTray.add(source);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('notificationShowStart');
|
|
|
|
source.connect('notification-show',
|
|
|
|
() => Scripting.scriptEvent('notificationShowDone'));
|
|
|
|
|
|
|
|
const notification = new MessageTray.Notification(source,
|
|
|
|
'A test notification');
|
|
|
|
source.showNotification(notification);
|
|
|
|
await Scripting.sleep(400);
|
|
|
|
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Show date menu');
|
2020-07-31 01:42:01 +00:00
|
|
|
Main.panel.statusArea.dateMenu.menu.open();
|
|
|
|
await Scripting.sleep(400);
|
|
|
|
|
|
|
|
Scripting.scriptEvent('notificationCloseStart');
|
|
|
|
notification.connect('destroy',
|
|
|
|
() => Scripting.scriptEvent('notificationCloseDone'));
|
|
|
|
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Destroy notification message');
|
2020-07-31 01:42:01 +00:00
|
|
|
notification.destroy();
|
|
|
|
await Scripting.sleep(400);
|
|
|
|
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Close date menu');
|
2020-07-31 01:42:01 +00:00
|
|
|
Main.panel.statusArea.dateMenu.menu.close();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
|
|
|
await Scripting.sleep(1000);
|
|
|
|
|
|
|
|
// overview (window picker)
|
|
|
|
Scripting.scriptEvent('overviewShowStart');
|
|
|
|
Main.overview.show();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
Main.overview.hide();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
|
|
|
await Scripting.sleep(1000);
|
|
|
|
|
|
|
|
// overview (app picker)
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Showing overview');
|
2020-07-31 01:42:01 +00:00
|
|
|
Main.overview.show();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
|
|
|
Scripting.scriptEvent('applicationsShowStart');
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Showing applications');
|
2020-07-31 01:42:01 +00:00
|
|
|
// eslint-disable-next-line require-atomic-updates
|
|
|
|
Main.overview.dash.showAppsButton.checked = true;
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
Scripting.scriptEvent('applicationsShowDone');
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Hiding applications');
|
2020-07-31 01:42:01 +00:00
|
|
|
// eslint-disable-next-line require-atomic-updates
|
|
|
|
Main.overview.dash.showAppsButton.checked = false;
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
|
2021-03-16 09:27:46 +00:00
|
|
|
console.debug('Hiding overview');
|
2020-07-31 01:42:01 +00:00
|
|
|
Main.overview.hide();
|
|
|
|
await Scripting.waitLeisure();
|
|
|
|
/* eslint-enable no-await-in-loop */
|
2021-03-16 09:27:46 +00:00
|
|
|
|
|
|
|
console.debug('Finished basic perf test');
|
2020-07-31 01:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let topBarNav = false;
|
|
|
|
let notificationShown = false;
|
|
|
|
let notificationClosed = false;
|
|
|
|
let windowPickerShown = false;
|
|
|
|
let appPickerShown = false;
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_topBarNavDone() {
|
2020-07-31 01:42:01 +00:00
|
|
|
topBarNav = true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_notificationShowDone() {
|
2020-07-31 01:42:01 +00:00
|
|
|
notificationShown = true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_notificationCloseDone() {
|
2020-07-31 01:42:01 +00:00
|
|
|
notificationClosed = true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_overviewShowDone() {
|
2020-07-31 01:42:01 +00:00
|
|
|
windowPickerShown = true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function script_applicationsShowDone() {
|
2020-07-31 01:42:01 +00:00
|
|
|
appPickerShown = true;
|
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
export function finish() {
|
2020-07-31 01:42:01 +00:00
|
|
|
if (!topBarNav)
|
|
|
|
throw new Error('Failed to navigate top bar');
|
|
|
|
|
|
|
|
if (!notificationShown)
|
|
|
|
throw new Error('Failed to show notification');
|
|
|
|
|
|
|
|
if (!notificationClosed)
|
|
|
|
throw new Error('Failed to close notification');
|
|
|
|
|
|
|
|
if (!windowPickerShown)
|
|
|
|
throw new Error('Failed to show window picker');
|
|
|
|
|
|
|
|
if (!appPickerShown)
|
|
|
|
throw new Error('Failed to show app picker');
|
|
|
|
}
|