mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
nixosTests.lomiri-gallery-app: Split format checks into separate tests
This commit is contained in:
@@ -756,7 +756,7 @@ in
|
||||
lomiri-filemanager-app = runTest ./lomiri-filemanager-app.nix;
|
||||
lomiri-mediaplayer-app = runTest ./lomiri-mediaplayer-app.nix;
|
||||
lomiri-music-app = runTest ./lomiri-music-app.nix;
|
||||
lomiri-gallery-app = runTest ./lomiri-gallery-app.nix;
|
||||
lomiri-gallery-app = discoverTests (import ./lomiri-gallery-app.nix);
|
||||
lomiri-system-settings = runTest ./lomiri-system-settings.nix;
|
||||
lorri = handleTest ./lorri/default.nix { };
|
||||
lxqt = handleTest ./lxqt.nix { };
|
||||
|
||||
@@ -1,117 +1,240 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
makeTest = import ./make-test-python.nix;
|
||||
imageDataDir = "gallery-app-sampledata";
|
||||
imageLabel = "Image";
|
||||
|
||||
makeFormatTest =
|
||||
{
|
||||
file,
|
||||
buttonIsOffset ? null,
|
||||
customTest ? null,
|
||||
}:
|
||||
|
||||
makeTest (
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
assert lib.asserts.assertMsg (
|
||||
buttonIsOffset != null || customTest != null
|
||||
) "Must either clarify button position, or define custom test code";
|
||||
|
||||
let
|
||||
format = lib.lists.last (lib.strings.splitString "." file);
|
||||
in
|
||||
|
||||
{
|
||||
name = "lomiri-gallery-app-standalone-format-${format}";
|
||||
meta.maintainers = lib.teams.lomiri.members;
|
||||
|
||||
nodes.machine =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [ ./common/x11.nix ];
|
||||
|
||||
services.xserver.enable = true;
|
||||
|
||||
environment = {
|
||||
etc."${imageDataDir}".source =
|
||||
pkgs.runCommand imageDataDir
|
||||
{
|
||||
nativeBuildInputs = with pkgs; [
|
||||
ffmpeg # make a video from the image
|
||||
(imagemagick.override { ghostscriptSupport = true; }) # add label for OCR
|
||||
];
|
||||
}
|
||||
''
|
||||
mkdir -p $out/{Pictures,Videos}
|
||||
|
||||
# Setup example data, OCR-friendly:
|
||||
# - White square, black text
|
||||
# - Small text for display OCR
|
||||
# - Big text for gallery preview OCR
|
||||
# - uppercase extension
|
||||
magick -size 500x500 -background white -fill black canvas:white \
|
||||
-pointsize 20 -annotate +100+100 '${imageLabel}' \
|
||||
-pointsize 70 -annotate +100+300 '${imageLabel}' \
|
||||
$out/Pictures/output.PNG
|
||||
|
||||
# Different image formats
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.JPG
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.BMP
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.GIF
|
||||
|
||||
# Video for dispatching
|
||||
ffmpeg -loop 1 -r 1 -i $out/Pictures/output.PNG -t 100 -pix_fmt yuv420p $out/Videos/output.MP4
|
||||
'';
|
||||
systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
mpv # URI dispatching for video support
|
||||
xdotool # mouse movement
|
||||
]
|
||||
++ (with pkgs.lomiri; [
|
||||
suru-icon-theme
|
||||
lomiri-gallery-app
|
||||
lomiri-thumbnailer # finds new images & generates thumbnails
|
||||
]);
|
||||
variables = {
|
||||
UITK_ICON_THEME = "suru";
|
||||
};
|
||||
};
|
||||
|
||||
i18n.supportedLocales = [ "all" ];
|
||||
|
||||
fonts = {
|
||||
packages = with pkgs; [
|
||||
# Intended font & helps with OCR
|
||||
ubuntu-classic
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
enableOCR = true;
|
||||
|
||||
testScript =
|
||||
''
|
||||
machine.wait_for_x()
|
||||
|
||||
machine.succeed("mkdir /root/${builtins.dirOf file}")
|
||||
machine.succeed("cp -vr /etc/${imageDataDir}/${file} /root/${builtins.dirOf file}")
|
||||
|
||||
with subtest("lomiri gallery finds files"):
|
||||
machine.succeed("lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Albums|Events|Photos|${imageLabel})")
|
||||
|
||||
machine.succeed("xdotool mousemove 30 40 click 1") # burger menu for categories
|
||||
machine.sleep(2)
|
||||
machine.succeed("xdotool mousemove 30 180 click 1") # photos
|
||||
machine.sleep(2)
|
||||
machine.screenshot("lomiri-gallery_photos")
|
||||
|
||||
machine.succeed("xdotool mousemove 80 140 click 1") # select first one
|
||||
machine.sleep(2)
|
||||
machine.succeed("xdotool mousemove 80 140 click 1") # enable top-bar
|
||||
machine.sleep(2)
|
||||
|
||||
''
|
||||
+ (
|
||||
if (customTest != null) then
|
||||
customTest
|
||||
else
|
||||
''
|
||||
with subtest("lomiri gallery handles ${format}"):
|
||||
machine.succeed("xdotool mousemove ${
|
||||
if buttonIsOffset then "900" else "940"
|
||||
} 50 click 1") # open media information
|
||||
machine.sleep(2)
|
||||
machine.wait_for_text("${format}") # make sure we're looking at the right file
|
||||
machine.screenshot("lomiri-gallery_${format}_info")
|
||||
machine.send_key("esc")
|
||||
machine.wait_for_text("${imageLabel}") # make sure media shows fine
|
||||
''
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
makeFormatTests =
|
||||
detailsList:
|
||||
builtins.listToAttrs (
|
||||
builtins.map (
|
||||
{
|
||||
name,
|
||||
file,
|
||||
buttonIsOffset ? null,
|
||||
customTest ? null,
|
||||
}:
|
||||
{
|
||||
name = "format-${name}";
|
||||
value = makeFormatTest {
|
||||
inherit
|
||||
file
|
||||
buttonIsOffset
|
||||
customTest
|
||||
;
|
||||
};
|
||||
}
|
||||
) detailsList
|
||||
);
|
||||
in
|
||||
{
|
||||
name = "lomiri-gallery-app-standalone";
|
||||
meta.maintainers = lib.teams.lomiri.members;
|
||||
|
||||
nodes.machine =
|
||||
{ config, pkgs, ... }:
|
||||
basic = makeTest (
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [ ./common/x11.nix ];
|
||||
name = "lomiri-gallery-app-standalone-basic";
|
||||
meta.maintainers = lib.teams.lomiri.members;
|
||||
|
||||
services.xserver.enable = true;
|
||||
nodes.machine =
|
||||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [ ./common/x11.nix ];
|
||||
|
||||
environment = {
|
||||
etc."${imageDataDir}".source =
|
||||
pkgs.runCommand imageDataDir
|
||||
{
|
||||
nativeBuildInputs = with pkgs; [
|
||||
ffmpeg # make a video from the image
|
||||
(imagemagick.override { ghostscriptSupport = true; }) # add label for OCR
|
||||
];
|
||||
}
|
||||
''
|
||||
mkdir -p $out/{Pictures,Videos}
|
||||
services.xserver.enable = true;
|
||||
|
||||
# Setup example data, OCR-friendly:
|
||||
# - White square, black text
|
||||
# - Small text for display OCR
|
||||
# - Big text for gallery preview OCR
|
||||
# - uppercase extension
|
||||
magick -size 500x500 -background white -fill black canvas:white \
|
||||
-pointsize 20 -annotate +100+100 '${imageLabel}' \
|
||||
-pointsize 70 -annotate +100+300 '${imageLabel}' \
|
||||
$out/Pictures/output.PNG
|
||||
environment = {
|
||||
systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
xdotool # mouse movement
|
||||
]
|
||||
++ (with pkgs.lomiri; [
|
||||
suru-icon-theme
|
||||
lomiri-gallery-app
|
||||
]);
|
||||
variables = {
|
||||
UITK_ICON_THEME = "suru";
|
||||
};
|
||||
};
|
||||
|
||||
# Different image formats
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.JPG
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.BMP
|
||||
magick $out/Pictures/output.PNG $out/Pictures/output.GIF
|
||||
i18n.supportedLocales = [ "all" ];
|
||||
|
||||
# Video for dispatching
|
||||
ffmpeg -loop 1 -r 1 -i $out/Pictures/output.PNG -t 100 -pix_fmt yuv420p $out/Videos/output.MP4
|
||||
'';
|
||||
systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
mpv # URI dispatching for video support
|
||||
xdotool # mouse movement
|
||||
]
|
||||
++ (with pkgs.lomiri; [
|
||||
suru-icon-theme
|
||||
lomiri-gallery-app
|
||||
lomiri-thumbnailer # finds new images & generates thumbnails
|
||||
]);
|
||||
variables = {
|
||||
UITK_ICON_THEME = "suru";
|
||||
fonts = {
|
||||
packages = with pkgs; [
|
||||
# Intended font & helps with OCR
|
||||
ubuntu-classic
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
i18n.supportedLocales = [ "all" ];
|
||||
enableOCR = true;
|
||||
|
||||
fonts = {
|
||||
packages = with pkgs; [
|
||||
# Intended font & helps with OCR
|
||||
ubuntu-classic
|
||||
];
|
||||
};
|
||||
};
|
||||
testScript = ''
|
||||
machine.wait_for_x()
|
||||
|
||||
enableOCR = true;
|
||||
with subtest("lomiri gallery launches"):
|
||||
machine.succeed("lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Albums|Events|Photos)")
|
||||
machine.screenshot("lomiri-gallery_open")
|
||||
|
||||
testScript =
|
||||
''
|
||||
machine.wait_for_x()
|
||||
machine.succeed("pgrep -afx lomiri-gallery-app >&2")
|
||||
machine.succeed("pkill -efx lomiri-gallery-app >&2")
|
||||
machine.wait_until_fails("pgrep -afx lomiri-gallery-app >&2")
|
||||
|
||||
with subtest("lomiri gallery launches"):
|
||||
machine.succeed("lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Albums|Events|Photos)")
|
||||
machine.screenshot("lomiri-gallery_open")
|
||||
|
||||
machine.succeed("pgrep -afx lomiri-gallery-app >&2")
|
||||
machine.succeed("pkill -efx lomiri-gallery-app >&2")
|
||||
machine.wait_until_fails("pgrep -afx lomiri-gallery-app >&2")
|
||||
|
||||
machine.succeed("cp -vr /etc/${imageDataDir}/* /root")
|
||||
|
||||
with subtest("lomiri gallery finds files"):
|
||||
machine.succeed("lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Albums|Events|Photos|${imageLabel})")
|
||||
|
||||
machine.succeed("xdotool mousemove 30 40 click 1") # burger menu for categories
|
||||
machine.sleep(2)
|
||||
machine.succeed("xdotool mousemove 30 180 click 1") # photos
|
||||
machine.sleep(2)
|
||||
machine.wait_for_text("${imageLabel}") # should see thumbnail of at least one of them
|
||||
machine.screenshot("lomiri-gallery_photos")
|
||||
|
||||
machine.succeed("xdotool mousemove 80 140 click 1") # select newest one
|
||||
machine.sleep(2)
|
||||
machine.succeed("xdotool mousemove 80 140 click 1") # enable top-bar
|
||||
machine.sleep(2)
|
||||
|
||||
# MP4 gets special treatment
|
||||
with subtest("lomiri gallery localisation works"):
|
||||
machine.succeed("env LANG=de_DE.UTF-8 lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Alben|Ereignisse|Fotos)")
|
||||
machine.screenshot("lomiri-gallery_localised")
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
// makeFormatTests [
|
||||
{
|
||||
name = "mp4";
|
||||
file = "Videos/output.MP4";
|
||||
# MP4 gets special treatment
|
||||
customTest = ''
|
||||
with subtest("lomiri gallery handles mp4"):
|
||||
machine.succeed("xdotool mousemove 935 40 click 1") # open media information
|
||||
machine.sleep(2)
|
||||
@@ -129,57 +252,26 @@ in
|
||||
|
||||
machine.send_key("q")
|
||||
machine.wait_until_fails("pgrep mpv") # wait for video to stop
|
||||
|
||||
machine.send_key("right")
|
||||
''
|
||||
+
|
||||
lib.concatMapStringsSep
|
||||
''
|
||||
machine.send_key("right")
|
||||
''
|
||||
(format: ''
|
||||
with subtest("lomiri gallery handles ${format.ext}"):
|
||||
machine.succeed("xdotool mousemove ${
|
||||
if format.buttonIsOffset then "900" else "940"
|
||||
} 50 click 1") # open media information
|
||||
machine.sleep(2)
|
||||
machine.wait_for_text("${format.ext}") # make sure we're looking at the right file
|
||||
machine.screenshot("lomiri-gallery_${format.ext}_info")
|
||||
machine.send_key("esc")
|
||||
machine.wait_for_text("${imageLabel}") # make sure media shows fine
|
||||
'')
|
||||
[
|
||||
{
|
||||
ext = "GIF";
|
||||
buttonIsOffset = false;
|
||||
}
|
||||
{
|
||||
ext = "BMP";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
{
|
||||
ext = "JPG";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
{
|
||||
ext = "PNG";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
]
|
||||
+ ''
|
||||
|
||||
machine.succeed("pgrep -afx lomiri-gallery-app >&2")
|
||||
machine.succeed("pkill -efx lomiri-gallery-app >&2")
|
||||
machine.wait_until_fails("pgrep -afx lomiri-gallery-app >&2")
|
||||
|
||||
|
||||
with subtest("lomiri gallery localisation works"):
|
||||
machine.succeed("env LANG=de_DE.UTF-8 lomiri-gallery-app >&2 &")
|
||||
machine.wait_for_console_text("qq= AlbumsOverview") # logged when album page actually gets loaded
|
||||
machine.sleep(10)
|
||||
machine.send_key("alt-f10")
|
||||
machine.sleep(5)
|
||||
machine.wait_for_text(r"(Alben|Ereignisse|Fotos)")
|
||||
machine.screenshot("lomiri-gallery_localised")
|
||||
'';
|
||||
}
|
||||
}
|
||||
{
|
||||
name = "gif";
|
||||
file = "Pictures/output.GIF";
|
||||
buttonIsOffset = false;
|
||||
}
|
||||
{
|
||||
name = "bmp";
|
||||
file = "Pictures/output.BMP";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
{
|
||||
name = "jpg";
|
||||
file = "Pictures/output.JPG";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
{
|
||||
name = "png";
|
||||
file = "Pictures/output.PNG";
|
||||
buttonIsOffset = true;
|
||||
}
|
||||
]
|
||||
|
||||
@@ -103,7 +103,16 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests.vm = nixosTests.lomiri-gallery-app;
|
||||
tests = {
|
||||
inherit (nixosTests.lomiri-gallery-app)
|
||||
basic
|
||||
format-mp4
|
||||
format-gif
|
||||
format-bmp
|
||||
format-jpg
|
||||
format-png
|
||||
;
|
||||
};
|
||||
updateScript = gitUpdater { rev-prefix = "v"; };
|
||||
};
|
||||
|
||||
|
||||
@@ -188,7 +188,13 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
passthru = {
|
||||
tests = {
|
||||
# gallery app delegates to thumbnailer, tests various formats
|
||||
gallery-app = nixosTests.lomiri-gallery-app;
|
||||
inherit (nixosTests.lomiri-gallery-app)
|
||||
format-mp4
|
||||
format-gif
|
||||
format-bmp
|
||||
format-jpg
|
||||
format-png
|
||||
;
|
||||
|
||||
# music app relies on thumbnailer to extract embedded cover art
|
||||
music-app = nixosTests.lomiri-music-app;
|
||||
|
||||
Reference in New Issue
Block a user