Commit Graph

168 Commits

Author SHA1 Message Date
Evan Welsh
3f12f3a87c scripting: Convert to ES module and migrate tests
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
9a2c3da868 environment: Port environment.js to be an ES module
Removes the init() function in favor of executing all environment
changes when the file is imported.

Additionally ports all unit tests using imports.gi.environment.init() to
use the updated module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
26fa1046a3 tests: Load unit tests as modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
c570011376 tests/unit: Fix remaining ESLint errors
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
26e018206d tests/shell: Fix remaining ESlint errors
All tests are currently excluded from linting, so errors can sneak
in more easily.

We should change that, so quickly fix up any remaining errors.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
9e84891240 insertSorted: Refactor comparator functions to be arrow functions
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Evan Welsh
df8fb2899d tests: Move assertArrayEquals to shared assertions file
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
2023-07-15 02:35:56 +00:00
Florian Müllner
476bf23041 tests: Use different suites
This makes it easier to only run unit- or automation tests.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2845>
2023-07-14 00:56:26 +02:00
Florian Müllner
b0384bee99 tests/shell: Also import built-in modules as modules
The "System" module is provided by gjs itself, and also available
as module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2836>
2023-07-11 16:44:11 +02:00
Florian Müllner
0929b2a307 tests/shell: Import introspected libraries as modules
Since commit 5e93791708 tests scripts are loaded as modules,
so we can (and should) use "proper" imports.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2835>
2023-07-11 15:59:18 +02:00
Florian Müllner
e7d290bbfb tests: Stop bundling "perf" tests with gnome-shell
Now that scripts are loaded as external modules, there's no reason
anymore for bundling them with the gnome-shell executable. Just
move the scripts into a dedicated folder in tests/ and run them
from there.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
e4da6a347b test-tool: Require script argument
The purpose of the tool has shifted from running a limited set
of performance tests repeatedly to collect performance data
and catch regressions, to a wrapper that drives gnome-shell via
scripts for tests.

With that, the concept of a "default" script doesn't really make
sense anymore.

Instead, turn the argument from an optional flag into a required
parameter. This will allow us to stop bundling the existing tests
in a follow-up commit.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
9bb003463c test-tool: Rename perf-tool
The original purpose of the tool was to collect performance data
that would optionally be uploaded to a server in Owen's living
room. While the corresponding scripts are still included (although
the server was probably dismantled years ago), the tool is mainly
used for running gnome-shell with scripted tests nowadays.

Rename the tool to reflect that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
bf9b9838c2 main: Pass script on CLI instead of via environment
Environment variables aren't the best option to pass parameters
to a process (wouldn't it be "fun" if SHELL_PERF_MODULE appeared
in a regular user session?).

Instead, use a (hidden) --automation-script command line flag to
specify a script file that should be used to drive an automated
session.

As a side effect, the script no longer has to be relative to the
main module itself, so it will be possible to run scripts that
aren't bundled with the shell sources.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2812>
2023-07-07 19:43:28 +02:00
Florian Müllner
d1784fe312 tests: Remove interactive tests
The tests rely on the ability to run Clutter as stand-alone app,
which hasn't been possible for quite a while now. Event handling
was broken long before that, plus tests that need a human to run
them and evaluate the result aren't that useful to begin with.

It would be neat to test our CSS rendering by setting up a stage,
capturing it and comparing it to a reference image. But writing
some code that exercises backgrounds, borders etc. is hardly the
obstacle to make that happen, and not worth carrying around dead
code.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2811>
2023-06-29 17:55:19 +00:00
Evan Welsh
1e9b906cbc js: Split gi imports to be on new lines to prepare for ES modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2794>
2023-06-21 04:50:33 -07:00
Florian Müllner
fb927d5196 tests: Port to Gtk4
There's another remaining bit of Gtk3 code in a small test program
that changes a window title to a random character sequence every
five seconds. While the value of that test is a bit questionable,
it doesn't hurt either and a port is trivial.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
2023-06-07 11:12:40 +00:00
Florian Müllner
99973f56fd tests: Stop using Gtk.PolicyType
St got its own enum type years ago, so use that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
2023-06-07 11:12:40 +00:00
Florian Müllner
efd5b91dab tests: Remove gapplication test app
Its only purpose is to provide a test case for the remote app menu,
but that support was removed in gnome-shell years ago. We don't
need a test case for GTK's fallback app menu support, so remove
the whole thing.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
2023-06-07 11:12:40 +00:00
Jonas Ådahl
d272b16e50 tests/perf: Add test for shutdown with open window
This would without the applied fix trigger
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6536.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2722>
2023-04-20 14:49:38 +02:00
Marco Trevisan (Treviño)
2709d15ae0 tests: Set GNOME_SHELL_SESSION_MODE to user
This may not be unset in some environments, so let's override it with the
default value.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2661>
2023-03-19 19:40:27 +00:00
Marco Trevisan (Treviño)
5bccd35906 tests: Add default test setup with common env settings
Add common test environment variables to a default test setup so that they
don't need to be repeated everywhere.

Also ensures that we're always using the gsettings memory backend to never
interfere with local environment.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2661>
2023-03-19 19:40:27 +00:00
Jonas Ådahl
9dd3d887d2 Add 'headless start' perf test
This tests that GNOME Shell will launch sucessfully despite there being
no monitors on startup, and successfully hide and then show the
overview, once the monitor is connected.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2623>
2023-02-06 18:10:01 +00:00
Jonas Ådahl
4bcbe9be83 tests: Make perf tests non-parallel
We currently hard code the display name, and running multiple instances
at the same time will probably just make things too slow for CI.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2623>
2023-02-06 18:10:01 +00:00
Jonas Ådahl
dc3ee1a9a2 tests/background-size: Get backend from global
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2557>
2022-12-16 22:12:59 +01:00
Jonas Ådahl
207b9bb3c0 tests: Fail on warnings too
Getting warnings are always bad and means something is broken, we
shouldn't pass the test suite with them.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:10:27 +01:00
Jonas Ådahl
f4934c0421 tests/perf: Use custom solid background in tests
They don't measure performance, and we don't want to have to install
gnome-backgrounds, so bundle a solid color background image to use
instead.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:09:54 +01:00
Jonas Ådahl
bcc4d15fdf tests: Add test running basic perf test
This test runs all of GNOME Shell using the headless backend inside a
mocked D-Bus environment. The basic test tests, well, basic things, like
the panel menu, the overview, showing the app grid view, as well as
going back to the session view.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:09:53 +01:00
Jonas Ådahl
c628b9f6bc tests: Add dbus runner
This adds a dbus-runner ala meta-dbus-runner.py. It extends the one used
in mutter, and adds various mocked services needed by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:09:37 +01:00
Jonas Ådahl
65a6ceddca tests: Add accounts_service mock service
This is a shrunk copy of the accounts_service.py service previously
found in upstream python-dbusmock. It also adds parental control
properties to make GNOME Shell happy.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>
2022-11-25 22:09:37 +01:00
Alessandro Bono
b63c6ac0ef cleanup: Use deepUnpack() intead of deep_unpack()
deep_unpack() is just a backwards compability alias for deepUnpack()[1].
The new name makes it more clear that this is not a C function, start to
use it.

[1] 13e662a29d

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2416>
2022-08-10 10:29:24 +00:00
Evan Welsh
a88e59c1a8 Adopt EventEmitter class instead of injecting Signal methods
Introduce a new class, EventEmitter, which implements signal
handling for pure JavaScript classes. EventEmitter still
utilizes GJS' addSignalMethods internally.

EventEmitter allows static typechecking to understand the
structure of event-emitting JS classes and makes creating
child classes simpler.

The name 'EventEmitter' mirrors a common name for this pattern
in Node and in JS libraries.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2043>
2022-07-04 18:30:49 -04:00
Florian Müllner
fc4f9f61fa signalTracker: Explicitly register destroyable types
We currently assume that any '::destroy' signal on a GObject type
has the semantics of the ClutterActor/GtkWidget signal, and should
therefore result in all signals being disconnected.

But we already have a case where the assumption doesn't hold: ShellWM
uses '::destroy' for the closing animation of windows, and the ShellWM
object itself remains very valid after the emission.

So rather than making assumptions about '::destroy', check objects
against a list of destroyable types that are explicitly registered
as such.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2226>
2022-03-06 00:10:03 +00:00
Florian Müllner
cf29ec2f22 signalTracker: Add TransientSignalHolder class
There are cases where we want to connect to a number of signals
for the lifetime of an object, but also other signals for a
limited period (say: between show and hide).

It is currently not possible to use disconnectObject() for the
latter, because it will disconnect all signals.

To address this use case, add a small class that can be used as
a transient signal holder, while still benefiting from autocleanup
by proxying the real owner.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2221>
2022-03-05 00:12:27 +00:00
Florian Müllner
f45ccc9143 signalTracker: Provide monkey-patching for (dis)connectObject()
The module exports a `addObjectSignalMethods()` method that extends
the provided prototype with `connectObject()` and `disconnectObject()`
methods.

In its simplest form, `connectObject()` looks like the regular
`connect()` method, except for an additional parameter:

```js
    this._button.connectObject('clicked',
        () => this._onButtonClicked(), this);
```

The additional object can be used to disconnect all handlers on the
instance that were connected with that object, similar to
`g_signal_handlers_disconnect_by_data()` (which cannot be used
from introspection).

For objects that are subclasses of Clutter.Actor, that will happen
automatically when the actor is destroyed, similar to
`g_signal_connect_object()`.

Finally, `connectObject()` allows to conveniently connect multiple
signals at once, similar to `g_object_connect()`:

```js
    this._toggleButton.connect(
        'clicked', () => this._onClicked(),
        'notify::checked', () => this._onChecked(), this);
```

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1953>
2022-03-04 14:14:37 +00:00
Florian Müllner
daf729de11 build: Replace deprecated meson functions
Replace deprecated functions with their direct replacements:

 - dep.get_pkgconfig_variable() → dep.get_variable()
 - prg.path() → prg.full_path()
 - source/build_root() → project_source/build_root()

In one case we need meson.global_source_root() that was only
added in meson 0.58, so bump the requirement to that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2077>
2021-12-23 15:52:21 +00:00
Sebastian Keller
a4b6b07d78 tests: Add unit test for highlighter
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2033>
2021-12-22 16:47:18 +00:00
Bastien Nocera
b0a48fad57 util: Add a GNOME version comparison function
Add a function that can compare GNOME versions, including the new naming
scheme for GNOME 40 and later.

Used in https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3632

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1619>
2021-02-05 13:41:26 +00:00
Jonas Dreßler
012af56b37 tests/background-size: Remove ClutterActor::paint signal handler usage
The background-size interactive test includes a test-case which uses the
ClutterActor::paint signal to hijack the painting of the actor. We're
removing that signal from Clutter, so remove that signal handler and
paint the outer border unconditionally to mark the boundaries of the
widget (the outer border actually never worked to force the cairo/cogl
path). To fix the test, change it to not paint a border on the inner
container in the useCairo=false case, which should make sure the cogl
path gets used.

Also remove the useless useCairo argument from addTestLine().

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1479
2020-10-24 23:21:39 +02:00
Jonas Dreßler
9b99b67fea Remove ClutterAllocationFlags
Those flags were removed from Clutter since they're pretty much unused,
so remove them here, too.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1245
2020-05-20 15:12:03 +02:00
Jonas Ådahl
632a643994 Use paint and pick context to get framebuffer
Mutter and Clutter was changed to pass around the current target
framebuffer via the paint context instead of via the deprecated Cogl
framebuffer stack.

The framebuffer stack has also been removed from Cogl so change to use
the one in the paint context instead.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/827
2019-12-03 19:07:15 +00:00
Florian Müllner
1e203f4631 cleanup: Replace deprecated lower/raise calls
Those methods have been deprecated for a long time, so
move to the drop-in replacement.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/808
2019-11-06 09:42:57 +01:00
Florian Müllner
43cf466d09 js: Replace Clutter.Actor.get_allocation_geometry()
The function was deprecated and has now been dropped from mutter.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/776
2019-10-21 18:41:35 +02:00
Marco Trevisan (Treviño)
c4c5c4fd5c cleanup: Use inheritance for Actor classes instead of composition
Remove the `this.actor = ...` and `this.actor._delegate = this` patterns in most
of classes, by inheriting all the actor container classes.

Uses interfaces when needed for making sure that multiple classes will implement
some required methods or to avoid redefining the same code multiple times.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
2019-10-16 15:26:13 +00:00
Florian Müllner
252e694979 util: Handle trailing LTR/RTL markers in URLs
Some electron apps apparently spread those generously over their
notification text, so may sure to not include them accidentally
in URLs.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1614
2019-09-16 20:41:47 +00:00
Florian Müllner
2fc4987c73 cleanup: Stop using Mainloop module
It is deprecated in favor of the regular GLib functions.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/718
2019-09-12 19:09:24 +02:00
Florian Müllner
1778adae0d tests: Add Params.parse() unit tests
Commit 46874eed0 accidentally changed the behavior of the function in
an incompatible way. Before addressing the actual issue, add a reproducer
to the unit tests to hopefully prevent future breakage.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/615
2019-07-05 18:28:26 +02:00
Florian Müllner
1398aa6562 style: Fix indentation errors
While we have some style inconsistencies - mostly regarding split lines,
i.e. aligning to the first arguments vs. a four-space indent - there are
a couple of places where the spacing is simply wrong. Fix those.

Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608
2019-07-02 12:17:46 +00:00
Jonas Dreßler
02c76695e5 tests: Stop using global grabs
Global grabs are being removed from Clutter in favour of input device
grabs.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/495
2019-07-02 01:18:15 +00:00
Florian Müllner
29b04fcbf2 style: Fix stray/missing semi-colons
Spotted by eslint.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/607
2019-07-01 23:44:11 +02:00