From bd87427c7534c02c63c3c45e2637fffe746a27df Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 8 Sep 2024 19:04:12 +0200 Subject: [PATCH] lomiri.lomiri-system-settings: add online-accounts plugin --- .../services/desktop-managers/lomiri.nix | 1 + nixos/tests/lomiri-system-settings.nix | 299 ++++++++++++------ .../lomiri-system-settings/default.nix | 12 +- .../lomiri-system-settings/wrapper.nix | 10 +- 4 files changed, 222 insertions(+), 100 deletions(-) diff --git a/nixos/modules/services/desktop-managers/lomiri.nix b/nixos/modules/services/desktop-managers/lomiri.nix index a8b17d2740600..016b40555d326 100644 --- a/nixos/modules/services/desktop-managers/lomiri.nix +++ b/nixos/modules/services/desktop-managers/lomiri.nix @@ -28,6 +28,7 @@ in { lomiri-download-manager lomiri-filemanager-app lomiri-gallery-app + lomiri-online-accounts lomiri-polkit-agent lomiri-schemas # exposes some required dbus interfaces lomiri-session # wrappers to properly launch the session diff --git a/nixos/tests/lomiri-system-settings.nix b/nixos/tests/lomiri-system-settings.nix index fac5184847520..3f8c6c2c6853a 100644 --- a/nixos/tests/lomiri-system-settings.nix +++ b/nixos/tests/lomiri-system-settings.nix @@ -1,99 +1,202 @@ -import ./make-test-python.nix ({ pkgs, lib, ... }: { - name = "lomiri-system-settings-standalone"; - meta.maintainers = lib.teams.lomiri.members; - - nodes.machine = { config, pkgs, ... }: { - imports = [ - ./common/x11.nix - ]; - - services.xserver.enable = true; - - environment = { - systemPackages = with pkgs.lomiri; [ - suru-icon-theme - lomiri-system-settings - ]; - variables = { - UITK_ICON_THEME = "suru"; +import ./make-test-python.nix ( + { pkgs, lib, ... }: + { + name = "lomiri-system-settings-standalone"; + meta.maintainers = lib.teams.lomiri.members; + + nodes.machine = + { config, pkgs, ... }: + { + imports = [ ./common/x11.nix ]; + + services.xserver.enable = true; + + environment = { + systemPackages = + with pkgs.lomiri; + [ + suru-icon-theme + lomiri-system-settings + + # To test localisation of lomiri-online-accounts-plugins' QML plugin within LSS + lomiri-online-accounts-plugins + ] + ++ (with pkgs; [ + + # Mouse control + xdotool + ]); + variables = { + UITK_ICON_THEME = "suru"; + }; + }; + + i18n.supportedLocales = [ "all" ]; + + fonts.packages = with pkgs; [ + # Intended font & helps with OCR + ubuntu-classic + ]; + + services.upower.enable = true; }; - }; - - i18n.supportedLocales = [ "all" ]; - - fonts.packages = with pkgs; [ - # Intended font & helps with OCR - ubuntu-classic - ]; - - services.upower.enable = true; - }; - - enableOCR = true; - - testScript = let - settingsPages = [ - # Base pages - { name = "wifi"; type = "internal"; element = "networks"; } - { name = "bluetooth"; type = "internal"; element = "discoverable|None detected"; } - # only text we can really look for with VPN is on a button, OCR on CI struggles with it - { name = "vpn"; type = "internal"; element = "Add|Manual|Configuration"; skipOCR = true; } - { name = "appearance"; type = "internal"; element = "Background image|blur effects"; } - { name = "desktop"; type = "internal"; element = "workspaces|Icon size"; } - { name = "sound"; type = "internal"; element = "Silent Mode|Message sound"; } - { name = "language"; type = "internal"; element = "Display language|External keyboard"; } - { name = "notification"; type = "internal"; element = "Apps that notify"; } - { name = "gestures"; type = "internal"; element = "Edge drag"; } - { name = "mouse"; type = "internal"; element = "Cursor speed|Wheel scrolling speed"; } - { name = "timedate"; type = "internal"; element = "Time zone|Set the time and date"; } - - # External plugins - { name = "security-privacy"; type = "external"; element = "Locking|unlocking|permissions"; elementLocalised = "Sperren|Entsperren|Berechtigungen"; } - ]; - in - '' - machine.wait_for_x() - - with subtest("lomiri system settings launches"): - machine.execute("lomiri-system-settings >&2 &") - machine.wait_for_text("System Settings") - machine.screenshot("lss_open") - - # Move focus to start of plugins list for following list of tests - machine.send_key("tab") - machine.send_key("tab") - machine.screenshot("lss_focus") - - # tab through & open all sub-menus, to make sure none of them fail - '' + (lib.strings.concatMapStringsSep "\n" (page: '' - machine.send_key("tab") - machine.send_key("kp_enter") - '' - + lib.optionalString (!(page.skipOCR or false)) '' - with subtest("lomiri system settings ${page.name} works"): - machine.wait_for_text(r"(${page.element})") - machine.screenshot("lss_page_${page.name}") - '') settingsPages) + '' - - machine.execute("pkill -f lomiri-system-settings") - - with subtest("lomiri system settings localisation works"): - machine.execute("env LANG=de_DE.UTF-8 lomiri-system-settings >&2 &") - machine.wait_for_text("Systemeinstellungen") - machine.screenshot("lss_localised_open") - - # Move focus to start of plugins list for following list of tests - machine.send_key("tab") - machine.send_key("tab") - machine.screenshot("lss_focus_localised") - - '' + (lib.strings.concatMapStringsSep "\n" (page: '' - machine.send_key("tab") - machine.send_key("kp_enter") - '' + lib.optionalString (page.type == "external") '' - with subtest("lomiri system settings ${page.name} localisation works"): - machine.wait_for_text(r"(${page.elementLocalised})") - machine.screenshot("lss_localised_page_${page.name}") - '') settingsPages) + '' - ''; -}) + + enableOCR = true; + + testScript = + let + settingsPages = [ + { + name = "wifi"; + element = "networks"; + elementLocalised = "Netzwerke"; + } + { + name = "bluetooth"; + element = "discoverable|None detected"; + elementLocalised = "feststellbar|Keines gefunden"; + } + { + name = "vpn"; + element = "Add|Manual|Configuration"; + # only text we can really look for with VPN is on a button, OCR on CI struggles with it + skipOCR = true; + } + { + name = "appearance"; + element = "Background image|blur effects"; + elementLocalised = "Hintergrundbild|Unschärfeeffekte"; + } + { + name = "desktop"; + element = "workspaces|Icon size"; + # different elements/strings, OCR struggles with diacritics & ß + elementLocalised = "aktivieren|Starter immer"; + } + { + name = "sound"; + element = "Silent Mode|Message sound"; + elementLocalised = "Stiller Modus|Nachrichtenton"; + } + { + name = "language"; + element = "Display language|External keyboard"; + elementLocalised = "Anzeigesprache|Externe Tastatur"; + } + + # localised checks for created account, not same element + { + name = "online-accounts"; + element = "No accounts"; + elementLocalised = "Google"; + # Check that LOA within LSSOA is localised + extraLocalised = '' + machine.succeed("xdotool mousemove 512 102 click 1") + machine.wait_for_text("Kennung") + machine.screenshot("lss_localised_page_online-accounts-plugin") + + # Return focus + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + machine.send_key("shift-tab") + ''; + } + + { + name = "notification"; + element = "Apps that notify"; + elementLocalised = "Apps mit"; + } + { + name = "gestures"; + element = "Edge drag"; + # Struggling with that word, let's pick some from a description + elementLocalised = "Kanten|Wischbereich"; + } + { + name = "mouse"; + element = "Cursor speed|Wheel scrolling speed"; + elementLocalised = "Zeigergeschwindigkeit|Mausradgeschwindigkeit"; + } + { + name = "timedate"; + element = "Time zone|Set the time and date"; + elementLocalised = "Zeitzone|Uhrzeit und Datum einstellen"; + } + + { + name = "security-privacy"; + element = "Locking|unlocking|permissions"; + elementLocalised = "Sperren|Entsperren|Berechtigungen"; + } + ]; + in + '' + machine.wait_for_x() + + with subtest("lomiri system settings launches"): + machine.succeed("lomiri-system-settings >&2 &") + machine.wait_for_text("System Settings") + machine.screenshot("lss_open") + + # Move focus to start of plugins list for following list of tests + machine.send_key("tab") + machine.send_key("tab") + machine.screenshot("lss_focus") + + # tab through & open all sub-menus, to make sure none of them fail + '' + + (lib.strings.concatMapStringsSep "\n" ( + page: + '' + machine.send_key("tab") + machine.send_key("kp_enter") + '' + + lib.optionalString (!(page.skipOCR or false)) '' + with subtest("lomiri system settings ${page.name} works"): + machine.wait_for_text(r"(${page.element})") + machine.screenshot("lss_page_${page.name}") + '' + ) settingsPages) + + '' + + machine.succeed("pkill -f lomiri-system-settings") + + # Preperation for checking i18n of lomiri-online-accounts, within LSS-online-accounts + machine.succeed("lomiri-account-console create google") + + with subtest("lomiri system settings localisation works"): + # XDG_CURRENT_DESKTOP so online-accounts plugins get loaded + machine.succeed("env LANG=de_DE.UTF-8 XDG_CURRENT_DESKTOP=Lomiri lomiri-system-settings >&2 &") + machine.wait_for_text("Systemeinstellungen") + machine.screenshot("lss_localised_open") + + # Move focus to start of plugins list for following list of tests + machine.send_key("tab") + machine.send_key("tab") + machine.screenshot("lss_focus_localised") + + '' + + (lib.strings.concatMapStringsSep "\n" ( + page: + '' + machine.send_key("tab") + machine.send_key("kp_enter") + '' + + lib.optionalString (!(page.skipOCR or false)) ( + '' + with subtest("lomiri system settings ${page.name} localisation works"): + machine.wait_for_text(r"(${page.elementLocalised})") + machine.screenshot("lss_localised_page_${page.name}") + '' + + lib.optionalString (page ? extraLocalised) page.extraLocalised + ) + ) settingsPages); + } +) diff --git a/pkgs/desktops/lomiri/applications/lomiri-system-settings/default.nix b/pkgs/desktops/lomiri/applications/lomiri-system-settings/default.nix index 115d1d01abfc2..1b7d41adf1b9e 100644 --- a/pkgs/desktops/lomiri/applications/lomiri-system-settings/default.nix +++ b/pkgs/desktops/lomiri/applications/lomiri-system-settings/default.nix @@ -2,6 +2,7 @@ stdenv, lib, fetchFromGitLab, + fetchpatch, gitUpdater, testers, accountsservice, @@ -61,7 +62,16 @@ stdenv.mkDerivation (finalAttrs: { "dev" ]; - patches = [ ./2000-Support-wrapping-for-Nixpkgs.patch ]; + patches = [ + # Remove when https://gitlab.com/ubports/development/core/lomiri-system-settings/-/merge_requests/454 merged & in release + (fetchpatch { + name = "0001-lomiri-system-settings-Fix-security-privacy-translations.patch"; + url = "https://gitlab.com/ubports/development/core/lomiri-system-settings/-/commit/38994139041246cd7c4423433912699c9e5a22f7.patch"; + hash = "sha256-6hGhLhEYrO1rdwyb12YIDommM8bXTox5E16n6TiaArc="; + }) + + ./2000-Support-wrapping-for-Nixpkgs.patch + ]; postPatch = '' substituteInPlace CMakeLists.txt \ diff --git a/pkgs/desktops/lomiri/applications/lomiri-system-settings/wrapper.nix b/pkgs/desktops/lomiri/applications/lomiri-system-settings/wrapper.nix index 7a550370ef54b..2551cbe65535f 100644 --- a/pkgs/desktops/lomiri/applications/lomiri-system-settings/wrapper.nix +++ b/pkgs/desktops/lomiri/applications/lomiri-system-settings/wrapper.nix @@ -4,10 +4,11 @@ nixosTests, glib, lndir, + lomiri-system-settings-online-accounts, lomiri-system-settings-unwrapped, wrapGAppsHook3, wrapQtAppsHook, - plugins ? [ ], + plugins ? [ lomiri-system-settings-online-accounts ], }: stdenvNoCC.mkDerivation (finalAttrs: { @@ -57,6 +58,13 @@ stdenvNoCC.mkDerivation (finalAttrs: { preFixup = '' qtWrapperArgs+=( "''${gappsWrapperArgs[@]}" + --prefix XDG_DATA_DIRS : ${ + lib.makeSearchPathOutput "out" "share" ( + lib.lists.foldl ( + prefixes: plugin: prefixes ++ (plugin.passthru.extraSearchPrefixes or [ ]) + ) [ ] plugins + ) + } --set NIX_LSS_PREFIX "$out" ) '';