at 25.11-pre 6.5 kB view raw
1{ lib, ... }: 2{ 3 name = "lomiri-gallery-app-standalone"; 4 meta.maintainers = lib.teams.lomiri.members; 5 6 nodes.machine = 7 { config, pkgs, ... }: 8 { 9 imports = [ ./common/x11.nix ]; 10 11 services.xserver.enable = true; 12 13 environment = { 14 systemPackages = 15 with pkgs; 16 [ 17 ffmpeg # make a video from the image 18 (imagemagick.override { ghostscriptSupport = true; }) # example image creation 19 mpv # URI dispatching for video support 20 xdotool # mouse movement 21 ] 22 ++ (with pkgs.lomiri; [ 23 suru-icon-theme 24 lomiri-gallery-app 25 lomiri-thumbnailer # finds new images & generates thumbnails 26 ]); 27 variables = { 28 UITK_ICON_THEME = "suru"; 29 }; 30 }; 31 32 i18n.supportedLocales = [ "all" ]; 33 34 fonts = { 35 packages = with pkgs; [ 36 # Intended font & helps with OCR 37 ubuntu-classic 38 ]; 39 }; 40 }; 41 42 enableOCR = true; 43 44 testScript = 45 let 46 imageLabel = "Image"; 47 in 48 '' 49 machine.wait_for_x() 50 51 with subtest("lomiri gallery launches"): 52 machine.succeed("lomiri-gallery-app >&2 &") 53 machine.sleep(2) 54 machine.wait_for_text(r"(Albums|Events|Photos)") 55 machine.screenshot("lomiri-gallery_open") 56 57 machine.succeed("pkill -f lomiri-gallery-app") 58 59 machine.succeed("mkdir /root/Pictures /root/Videos") 60 # Setup example data, OCR-friendly: 61 # - White square, black text 62 # - Small text for display OCR 63 # - Big text for gallery preview OCR 64 # - uppercase extension 65 machine.succeed( 66 "magick -size 500x500 -background white -fill black canvas:white " 67 + "-pointsize 20 -annotate +100+100 '${imageLabel}' " 68 + "-pointsize 50 -annotate +100+300 '${imageLabel}' " 69 + "/root/Pictures/output.PNG" 70 ) 71 72 # Different image formats 73 machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.JPG") 74 machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.BMP") 75 machine.succeed("magick /root/Pictures/output.PNG /root/Pictures/output.GIF") 76 77 # Video for dispatching 78 machine.succeed("ffmpeg -loop 1 -r 1 -i /root/Pictures/output.PNG -t 100 -pix_fmt yuv420p /root/Videos/output.MP4") 79 80 with subtest("lomiri gallery handles files"): 81 machine.succeed("lomiri-gallery-app >&2 &") 82 machine.sleep(2) 83 machine.wait_for_text(r"(Albums|Events|Photos|${imageLabel})") 84 85 machine.succeed("xdotool mousemove 30 40 click 1") # burger menu for categories 86 machine.sleep(2) 87 machine.succeed("xdotool mousemove 30 180 click 1") # photos 88 machine.sleep(2) 89 machine.wait_for_text("${imageLabel}") # should see thumbnail of at least one of them 90 machine.screenshot("lomiri-gallery_photos") 91 92 machine.succeed("xdotool mousemove 80 140 click 1") # select newest one 93 machine.sleep(2) 94 machine.succeed("xdotool mousemove 80 140 click 1") # enable top-bar 95 machine.sleep(2) 96 97 with subtest("lomiri gallery handles mp4"): 98 machine.succeed("xdotool mousemove 870 50 click 1") # open media information 99 machine.sleep(2) 100 machine.wait_for_text("MP4") # make sure we're looking at the right file 101 machine.screenshot("lomiri-gallery_mp4_info") 102 machine.send_key("esc") 103 104 machine.wait_for_text("${imageLabel}") # make sure thumbnail rendering worked 105 106 machine.succeed("xdotool mousemove 450 350 click 1") # dispatch to system's video handler 107 machine.wait_until_succeeds("pgrep -u root -f mpv") # wait for video to start 108 machine.sleep(10) 109 machine.succeed("pgrep -u root -f mpv") # should still be playing 110 machine.screenshot("lomiri-gallery_mp4_dispatch") 111 112 machine.send_key("q") 113 machine.wait_until_fails("pgrep mpv") # wait for video to stop 114 115 machine.send_key("right") 116 117 with subtest("lomiri gallery handles gif"): 118 machine.succeed("xdotool mousemove 870 50 click 1") # open media information 119 machine.sleep(2) 120 machine.wait_for_text("GIF") # make sure we're looking at the right file 121 machine.screenshot("lomiri-gallery_gif_info") 122 machine.send_key("esc") 123 124 machine.wait_for_text("${imageLabel}") # make sure media shows fine 125 machine.send_key("right") 126 127 with subtest("lomiri gallery handles bmp"): 128 machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location) 129 machine.sleep(2) 130 machine.wait_for_text("BMP") # make sure we're looking at the right file 131 machine.screenshot("lomiri-gallery_bmp_info") 132 machine.send_key("esc") 133 134 machine.wait_for_text("${imageLabel}") # make sure media shows fine 135 machine.send_key("right") 136 137 with subtest("lomiri gallery handles jpg"): 138 machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location) 139 machine.sleep(2) 140 machine.wait_for_text("JPG") # make sure we're looking at the right file 141 machine.screenshot("lomiri-gallery_jpg_info") 142 machine.send_key("esc") 143 144 machine.wait_for_text("${imageLabel}") # make sure media shows fine 145 machine.send_key("right") 146 147 with subtest("lomiri gallery handles png"): 148 machine.succeed("xdotool mousemove 840 50 click 1") # open media information (extra icon, different location) 149 machine.sleep(2) 150 machine.wait_for_text("PNG") # make sure we're looking at the right file 151 machine.screenshot("lomiri-gallery_png_info") 152 machine.send_key("esc") 153 154 machine.wait_for_text("${imageLabel}") # make sure media shows fine 155 156 machine.succeed("pkill -f lomiri-gallery-app") 157 158 with subtest("lomiri gallery localisation works"): 159 machine.succeed("env LANG=de_DE.UTF-8 lomiri-gallery-app >&2 &") 160 machine.wait_for_text(r"(Alben|Ereignisse|Fotos)") 161 machine.screenshot("lomiri-gallery_localised") 162 ''; 163}