nixos/tests/firefox: use the module

This should exercise the module a bit in the test, and also removes an awkward override.
This commit is contained in:
K900 2023-10-22 17:13:50 +03:00
parent 60421a1622
commit e6f5980d87

View File

@ -1,14 +1,7 @@
import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }:
let firefoxPackage' = firefoxPackage.override (args: {
extraPrefsFiles = (args.extraPrefsFiles or []) ++ [
# make sure that autoplay is enabled by default for the audio test
(builtins.toString (builtins.toFile "autoplay-pref.js" ''defaultPref("media.autoplay.default",0);''))
];
});
in
{ {
name = firefoxPackage'.unwrapped.pname; name = firefoxPackage.pname;
meta = with pkgs.lib.maintainers; { meta = with pkgs.lib.maintainers; {
maintainers = [ eelco shlevy ]; maintainers = [ eelco shlevy ];
}; };
@ -17,10 +10,13 @@ in
{ pkgs, ... }: { pkgs, ... }:
{ imports = [ ./common/x11.nix ]; { imports = [ ./common/x11.nix ];
environment.systemPackages = [ environment.systemPackages = [ pkgs.xdotool ];
firefoxPackage'
pkgs.xdotool programs.firefox = {
]; enable = true;
preferences."media.autoplay.default" = 0;
package = firefoxPackage;
};
# Create a virtual sound device, with mixing # Create a virtual sound device, with mixing
# and all, for recording audio. # and all, for recording audio.
@ -58,7 +54,9 @@ in
}; };
testScript = '' testScript = let
exe = firefoxPackage.unwrapped.binaryName;
in ''
from contextlib import contextmanager from contextlib import contextmanager
@ -97,7 +95,7 @@ in
with subtest("Wait until Firefox has finished loading the Valgrind docs page"): with subtest("Wait until Firefox has finished loading the Valgrind docs page"):
machine.execute( machine.execute(
"xterm -e '${firefoxPackage'.unwrapped.binaryName} file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &" "xterm -e '${exe} file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &"
) )
machine.wait_for_window("Valgrind") machine.wait_for_window("Valgrind")
machine.sleep(40) machine.sleep(40)
@ -105,7 +103,7 @@ in
with subtest("Check whether Firefox can play sound"): with subtest("Check whether Firefox can play sound"):
with record_audio(machine): with record_audio(machine):
machine.succeed( machine.succeed(
"${firefoxPackage'.unwrapped.binaryName} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &" "${exe} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &"
) )
wait_for_sound(machine) wait_for_sound(machine)
machine.copy_from_vm("/tmp/record.wav") machine.copy_from_vm("/tmp/record.wav")