Unverified Commit d3b00101 authored by Cosima Neidahl's avatar Cosima Neidahl Committed by GitHub
Browse files

lomiri.lomiri-gallery-app: 3.1.0 -> 3.1.1 (#407191)

parents 666f18cc aff794fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -773,7 +773,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 = runTest ./lxqt.nix;
+297 −149
Original line number Diff line number Diff line
{ lib, ... }:
let
  makeTest = import ./make-test-python.nix;
  imageDataDir = "gallery-app-sampledata";
  imageLabel = "Image";

  makeFormatTest =
    {
  name = "lomiri-gallery-app-standalone";
      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 =
@@ -11,11 +33,39 @@
            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;
                [
            ffmpeg # make a video from the image
            (imagemagick.override { ghostscriptSupport = true; }) # example image creation
                  glib # Poke thumbnailer to process media via gdbus
                  mpv # URI dispatching for video support
                  xdotool # mouse movement
                ]
@@ -29,7 +79,14 @@
              };
            };

      i18n.supportedLocales = [ "all" ];
            # Allow us to start thumbnailer ahead-of-time, hopefully let thumbnails get processed in peace
            systemd.user.services."dbus-com.lomiri.Thumbnailer" = {
              serviceConfig = {
                Type = "dbus";
                BusName = "com.lomiri.Thumbnailer";
                ExecStart = "${pkgs.lomiri.lomiri-thumbnailer}/libexec/lomiri-thumbnailer/thumbnailer-service";
              };
            };

            fonts = {
              packages = with pkgs; [
@@ -42,122 +99,213 @@
        enableOCR = true;

        testScript =
    let
      imageLabel = "Image";
    in
          ''
            machine.wait_for_x()

      with subtest("lomiri gallery launches"):
          machine.succeed("lomiri-gallery-app >&2 &")
          machine.sleep(2)
          machine.wait_for_text(r"(Albums|Events|Photos)")
          machine.screenshot("lomiri-gallery_open")

      machine.succeed("pkill -f lomiri-gallery-app")
            machine.succeed("mkdir /root/${builtins.dirOf file}")
            machine.succeed("cp -vr /etc/${imageDataDir}/${file} /root/${builtins.dirOf file}")

      machine.succeed("mkdir /root/Pictures /root/Videos")
      # Setup example data, OCR-friendly:
      # - White square, black text
      # - Small text for display OCR
      # - Big text for gallery preview OCR
      # - uppercase extension
      machine.succeed(
          "magick -size 500x500 -background white -fill black canvas:white "
          + "-pointsize 20 -annotate +100+100 '${imageLabel}' "
          + "-pointsize 50 -annotate +100+300 '${imageLabel}' "
          + "/root/Pictures/output.PNG"
            # Start thumbnailer, wait for idle shutdown
            machine.systemctl("start dbus-com.lomiri.Thumbnailer", "root")
            machine.wait_until_succeeds(
                "env XDG_RUNTIME_DIR=/run/user/0 "
                + "systemctl --user is-active dbus-com.lomiri.Thumbnailer"
            )
            machine.wait_for_console_text("thumbnail cache:")

      # Different image formats
      machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.JPG")
      machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.BMP")
      machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.GIF")
            # Request thumbnail processing, get initial thumbnail image into cache
            # This can randomly take abit longer, just run it until it succeeds
            # Touch file to invalidate failure cache
            machine.wait_until_succeeds(
                "touch '/root/${file}' && "
                + "env XDG_RUNTIME_DIR=/run/user/0 "
                + "gdbus call -e "
                + "-d com.lomiri.Thumbnailer -o /com/lomiri/Thumbnailer "
                + "-m com.lomiri.Thumbnailer.GetThumbnail "
                + "'/root/${file}' "
                # Same size as source, to reduce processing - we're very close to hitting 20s on slow hardware here
                + "'@(ii) (500,500)'"
            )

      # Video for dispatching
      machine.succeed("ffmpeg -loop 1 -r 1 -i /root/Pictures/output.PNG -t 100 -pix_fmt yuv420p /root/Videos/output.MP4")
            machine.wait_for_console_text("Idle timeout reached")
            machine.wait_until_fails(
                "env XDG_RUNTIME_DIR=/run/user/0 "
                + "systemctl --user is-active dbus-com.lomiri.Thumbnailer"
            )

      with subtest("lomiri gallery handles files"):
            with subtest("lomiri gallery finds files"):
                machine.succeed("lomiri-gallery-app >&2 &")
          machine.sleep(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.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)

          with subtest("lomiri gallery handles mp4"):
              machine.succeed("xdotool mousemove 870 50 click 1") # open media information
          ''
          + (
            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("MP4") # make sure we're looking at the right file
              machine.screenshot("lomiri-gallery_mp4_info")
                    machine.screenshot("lomiri-gallery_${format}_info")
                    machine.send_key("esc")
                    machine.sleep(2)
                    machine.wait_for_text("${imageLabel}") # make sure media shows fine
              ''
          );

              machine.wait_for_text("${imageLabel}") # make sure thumbnail rendering worked

              machine.succeed("xdotool mousemove 450 350 click 1") # dispatch to system's video handler
              machine.wait_until_succeeds("pgrep -u root -f mpv") # wait for video to start
              machine.sleep(10)
              machine.succeed("pgrep -u root -f mpv") # should still be playing
              machine.screenshot("lomiri-gallery_mp4_dispatch")

              machine.send_key("q")
              machine.wait_until_fails("pgrep mpv") # wait for video to stop
      }
    );
  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;

              machine.send_key("right")
      nodes.machine =
        { config, pkgs, ... }:
        {
          imports = [ ./common/x11.nix ];

          with subtest("lomiri gallery handles gif"):
              machine.succeed("xdotool mousemove 870 50 click 1") # open media information
              machine.sleep(2)
              machine.wait_for_text("GIF") # make sure we're looking at the right file
              machine.screenshot("lomiri-gallery_gif_info")
              machine.send_key("esc")
          services.xserver.enable = true;

              machine.wait_for_text("${imageLabel}") # make sure media shows fine
              machine.send_key("right")
          environment = {
            systemPackages =
              with pkgs;
              [
                xdotool # mouse movement
              ]
              ++ (with pkgs.lomiri; [
                suru-icon-theme
                lomiri-gallery-app
              ]);
            variables = {
              UITK_ICON_THEME = "suru";
            };
          };

          with subtest("lomiri gallery handles bmp"):
              machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location)
              machine.sleep(2)
              machine.wait_for_text("BMP") # make sure we're looking at the right file
              machine.screenshot("lomiri-gallery_bmp_info")
              machine.send_key("esc")
          i18n.supportedLocales = [ "all" ];

              machine.wait_for_text("${imageLabel}") # make sure media shows fine
              machine.send_key("right")
          fonts = {
            packages = with pkgs; [
              # Intended font & helps with OCR
              ubuntu-classic
            ];
          };
        };

          with subtest("lomiri gallery handles jpg"):
              machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location)
              machine.sleep(2)
              machine.wait_for_text("JPG") # make sure we're looking at the right file
              machine.screenshot("lomiri-gallery_jpg_info")
              machine.send_key("esc")
      enableOCR = true;

              machine.wait_for_text("${imageLabel}") # make sure media shows fine
              machine.send_key("right")
      testScript = ''
        machine.wait_for_x()

          with subtest("lomiri gallery handles png"):
              machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location)
              machine.sleep(2)
              machine.wait_for_text("PNG") # make sure we're looking at the right file
              machine.screenshot("lomiri-gallery_png_info")
              machine.send_key("esc")
        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.wait_for_text("${imageLabel}") # make sure media shows fine
        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("pkill -f lomiri-gallery-app")

        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)
          machine.screenshot("lomiri-gallery_mp4_info")
          machine.send_key("esc")
          machine.sleep(2)

          machine.wait_for_text("${imageLabel}") # make sure thumbnail processing worked
          machine.screenshot("lomiri-gallery_mp4_thumbnail")

          machine.succeed("xdotool mousemove 510 380 click 1") # dispatch to system's video handler
          machine.wait_until_succeeds("pgrep -u root -f mpv") # wait for video to start
          machine.sleep(10)
          machine.succeed("pgrep -u root -f mpv") # should still be playing
          machine.screenshot("lomiri-gallery_mp4_dispatch")
    '';
  }
  {
    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;
  }
]
+16 −20
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
  stdenv,
  lib,
  fetchFromGitLab,
  fetchpatch,
  gitUpdater,
  nixosTests,
  cmake,
@@ -25,29 +24,15 @@

stdenv.mkDerivation (finalAttrs: {
  pname = "lomiri-gallery-app";
  version = "3.1.0";
  version = "3.1.1";

  src = fetchFromGitLab {
    owner = "ubports";
    repo = "development/apps/lomiri-gallery-app";
    rev = "v${finalAttrs.version}";
    hash = "sha256-uKGPic9XYUj0rLA05i6GjLM+n17MYgiFJMWnLXHKmIU=";
    tag = "v${finalAttrs.version}";
    hash = "sha256-5/mZszPEsSZqgioJ+Mc7+0gEcpUKr7n/LgyXJ20P2Zg=";
  };

  patches = [
    # Remove when https://gitlab.com/ubports/development/apps/lomiri-gallery-app/-/merge_requests/152 merged & in release
    (fetchpatch {
      name = "0001-lomiri-gallery-app-bindtextdomain.patch";
      url = "https://gitlab.com/ubports/development/apps/lomiri-gallery-app/-/commit/592eff118cb5056886b73e6698f8941c7a16f2e0.patch";
      hash = "sha256-aR/Lnzvq4RuRLI75mMd4xTGMAcijm1adSAGVFZZ++No=";
    })
    (fetchpatch {
      name = "0002-lomiri-gallery-app-C++ify-i18n.patch";
      url = "https://gitlab.com/ubports/development/apps/lomiri-gallery-app/-/commit/a7582abbe0acef4d49c77a4395bc22dbd1707ef3.patch";
      hash = "sha256-qzqTXqIYX+enoOwwV9d9fxe7tVYLuh1WkL8Ij/Qx0H0=";
    })
  ];

  postPatch = ''
    # Make splash path in desktop file relative
    substituteInPlace desktop/lomiri-gallery-app.desktop.in.in \
@@ -118,14 +103,25 @@ 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"; };
  };

  meta = {
    description = "Photo gallery application for Ubuntu Touch devices";
    homepage = "https://gitlab.com/ubports/development/apps/lomiri-gallery-app";
    changelog = "https://gitlab.com/ubports/development/apps/lomiri-gallery-app/-/blob/v${finalAttrs.version}/ChangeLog";
    changelog = "https://gitlab.com/ubports/development/apps/lomiri-gallery-app/-/blob/${
      if (!builtins.isNull finalAttrs.src.tag) then finalAttrs.src.tag else finalAttrs.src.rev
    }/ChangeLog";
    license = with lib.licenses; [
      gpl3Only
      cc-by-sa-30
+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;