From 0a1ce91cea1f771411825bedbe7054c8351f7456 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Sat, 14 May 2022 21:28:53 -0700 Subject: [PATCH] nixos/tests/phosh: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/phosh.nix | 69 +++++++++++++++++++ .../window-managers/phosh/default.nix | 3 + 3 files changed, 73 insertions(+) create mode 100644 nixos/tests/phosh.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 099b8e7972c9c..8c2dd1f436a4f 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -421,6 +421,7 @@ in { pgadmin4-standalone = handleTest ./pgadmin4-standalone.nix {}; pgjwt = handleTest ./pgjwt.nix {}; pgmanage = handleTest ./pgmanage.nix {}; + phosh = handleTest ./phosh.nix {}; php = handleTest ./php {}; php80 = handleTest ./php { php = pkgs.php80; }; php81 = handleTest ./php { php = pkgs.php81; }; diff --git a/nixos/tests/phosh.nix b/nixos/tests/phosh.nix new file mode 100644 index 0000000000000..08c4823da3564 --- /dev/null +++ b/nixos/tests/phosh.nix @@ -0,0 +1,69 @@ +import ./make-test-python.nix ({ pkgs, ...}: let + pin = "1234"; +in { + name = "phosh"; + meta = with pkgs.lib.maintainers; { + maintainers = [ zhaofengli ]; + }; + + nodes = { + phone = { config, pkgs, ... }: { + users.users.nixos = { + isNormalUser = true; + password = pin; + }; + + services.xserver.desktopManager.phosh = { + enable = true; + user = "nixos"; + group = "users"; + + phocConfig = { + outputs.Virtual-1 = { + scale = 2; + }; + }; + }; + + virtualisation.resolution = { x = 720; y = 1440; }; + virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci,xres=720,yres=1440" ]; + }; + }; + + enableOCR = true; + + testScript = '' + import time + + start_all() + phone.wait_for_unit("phosh.service") + + with subtest("Check that we can see the lock screen info page"): + # Saturday, January 1 + phone.succeed("timedatectl set-time '2022-01-01 07:00'") + + phone.wait_for_text("Saturday") + phone.screenshot("01lockinfo") + + with subtest("Check that we can unlock the screen"): + phone.send_chars("${pin}", delay=0.2) + time.sleep(1) + phone.screenshot("02unlock") + + phone.send_chars("\n") + + phone.wait_for_text("All Apps") + phone.screenshot("03launcher") + + with subtest("Check that we can launch an app"): + phone.send_chars("settings\n\n", delay=0.2) + + phone.wait_for_text("Network") + phone.screenshot("04settings") + + with subtest("Check that we can summon the on-screen keyboard"): + phone.succeed("busctl call --machine=nixos@.host --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true") + phone.wait_for_text("123") # Button label for the number layer + phone.screenshot("05keyboard") + ''; +}) diff --git a/pkgs/applications/window-managers/phosh/default.nix b/pkgs/applications/window-managers/phosh/default.nix index 6a37809bb5f55..1bb67777af732 100644 --- a/pkgs/applications/window-managers/phosh/default.nix +++ b/pkgs/applications/window-managers/phosh/default.nix @@ -27,6 +27,7 @@ , networkmanager , polkit , libsecret +, nixosTests }: stdenv.mkDerivation rec { @@ -115,6 +116,8 @@ stdenv.mkDerivation rec { providedSessions = [ "sm.puri.Phosh" ]; + + tests.moonraker = nixosTests.phosh; }; meta = with lib; {