summaryrefslogtreecommitdiffstats
path: root/nixos/tests/lomiri-system-settings.nix
blob: c267a0ef31571cc569074d55b9ad58695a50bfa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{ 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";
        };
      };

      i18n.supportedLocales = [ "all" ];

      fonts.packages = with pkgs; [
        # Intended font & helps with OCR
        ubuntu-classic
      ];

      services.printing.enable = true;
      services.upower.enable = true;
    };

  enableOCR = true;

  testScript =
    let
      settingsPages = [
        # Network
        {
          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;
        }

        # Personal
        {
          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";
        }

        # System
        {
          name = "printing";
          type = "internal";
          element = "no printers configured";
        }
        {
          name = "mouse";
          type = "internal";
          element = "Cursor speed|Wheel scrolling speed";
        }
        {
          name = "timedate";
          type = "internal";
          element = "Time zone|Set the time and date";
        }
        {
          name = "security-privacy";
          type = "internal";
          element = "Locking|unlocking|permissions";
        }
      ];
    in
    ''
      machine.wait_for_x()

      with subtest("lomiri system settings launches"):
          machine.succeed("lomiri-system-settings >&2 &")
          machine.wait_for_console_text("qml: Plugin about does not exist")
          machine.sleep(10)
          machine.send_key("alt-f10")
          machine.sleep(5)
          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.succeed("env LANG=de_DE.UTF-8 lomiri-system-settings >&2 &")
          machine.wait_for_console_text("qml: Plugin about does not exist")
          machine.sleep(10)
          machine.send_key("alt-f10")
          machine.sleep(5)
          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)
    + "";
}