summary refs log tree commit diff
path: root/nixos/tests/musescore.nix
blob: 6aeb0558a49dbaf918de6214f51a3f35f9038b4b (plain) (blame)
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
import ./make-test-python.nix ({ pkgs, ...} :

let
  # Make sure we don't have to go through the startup tutorial
  customMuseScoreConfig = pkgs.writeText "MuseScore4.ini" ''
    [application]
    hasCompletedFirstLaunchSetup=true

    [project]
    preferredScoreCreationMode=1
    '';
in
{
  name = "musescore";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ turion ];
  };

  nodes.machine = { ... }:

  {
    imports = [
      ./common/x11.nix
    ];

    services.xserver.enable = true;
    environment.systemPackages = with pkgs; [
      musescore
      pdfgrep
    ];
  };

  enableOCR = true;

  testScript = { ... }: ''
    start_all()
    machine.wait_for_x()

    # Inject custom settings
    machine.succeed("mkdir -p /root/.config/MuseScore/")
    machine.succeed(
        "cp ${customMuseScoreConfig} /root/.config/MuseScore/MuseScore4.ini"
    )

    # Start MuseScore window
    machine.execute("DISPLAY=:0.0 mscore >&2 &")

    # Wait until MuseScore has launched
    machine.wait_for_window("MuseScore 4")

    # Wait until the window has completely initialised
    machine.wait_for_text("MuseScore 4")

    machine.screenshot("MuseScore0")

    # Create a new score
    machine.send_key("ctrl-n")

    # Wait until the creation wizard appears
    machine.wait_for_window("New score")

    machine.screenshot("MuseScore1")

    machine.send_key("tab")
    machine.send_key("tab")
    machine.send_key("tab")
    machine.send_key("tab")
    machine.send_key("right")
    machine.send_key("right")
    machine.send_key("ret")

    machine.sleep(1)

    # Type the beginning of https://de.wikipedia.org/wiki/Alle_meine_Entchen
    machine.send_chars("cdef6gg5aaaa7g")
    machine.sleep(1)

    machine.screenshot("MuseScore2")

    # Go to the export dialogue and create a PDF
    machine.send_key("alt-f")
    machine.sleep(1)
    machine.send_key("e")

    # Wait until the export dialogue appears.
    machine.wait_for_text("Export")

    machine.screenshot("MuseScore3")

    machine.send_key("shift-tab")
    machine.sleep(1)
    machine.send_key("ret")
    machine.sleep(1)
    machine.send_key("ret")

    machine.screenshot("MuseScore4")

    # Wait until PDF is exported
    machine.wait_for_file('"/root/Documents/MuseScore4/Scores/Untitled score.pdf"')

    # Check that it contains the title of the score
    machine.succeed('pdfgrep "Untitled score" "/root/Documents/MuseScore4/Scores/Untitled score.pdf"')

    machine.screenshot("MuseScore5")
  '';
})