Commit 9293bae2 authored by OPNA2608's avatar OPNA2608
Browse files

nixosTests.lomiri-gallery-app: Split format checks into separate tests

parent 8bf28aa1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 { };
+240 −148
Original line number Diff line number Diff line
{ 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";
        name = "lomiri-gallery-app-standalone-format-${format}";
        meta.maintainers = lib.teams.lomiri.members;

        nodes.machine =
@@ -76,20 +94,8 @@ in
          ''
            machine.wait_for_x()

      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")
            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 &")
@@ -103,15 +109,132 @@ in
                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.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
{
  basic = makeTest (
    { lib, ... }:
    {
      name = "lomiri-gallery-app-standalone-basic";
      meta.maintainers = lib.teams.lomiri.members;

      nodes.machine =
        { config, pkgs, ... }:
        {
          imports = [ ./common/x11.nix ];

          services.xserver.enable = true;

          environment = {
            systemPackages =
              with pkgs;
              [
                xdotool # mouse movement
              ]
              ++ (with pkgs.lomiri; [
                suru-icon-theme
                lomiri-gallery-app
              ]);
            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()

        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")


        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";
    name = "gif";
    file = "Pictures/output.GIF";
    buttonIsOffset = false;
  }
  {
            ext = "BMP";
    name = "bmp";
    file = "Pictures/output.BMP";
    buttonIsOffset = true;
  }
  {
            ext = "JPG";
    name = "jpg";
    file = "Pictures/output.JPG";
    buttonIsOffset = true;
  }
  {
            ext = "PNG";
    name = "png";
    file = "Pictures/output.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")
    '';
}
+10 −1
Original line number Diff line number Diff line
@@ -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"; };
  };

+7 −1
Original line number Diff line number Diff line
@@ -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;