* A function to wait until a window exists.

svn path=/nixos/trunk/; revision=19246
wip/yesman
Eelco Dolstra 15 years ago
parent 0f5b178fcf
commit 5cc99487cb
  1. 20
      lib/test-driver/Machine.pm
  2. 3
      modules/testing/test-instrumentation.nix
  3. 12
      tests/kde4.nix

@ -287,4 +287,24 @@ sub screenshot {
}
sub getWindowNames {
my ($self) = @_;
my $res = $self->mustSucceed(
q{DISPLAY=:0.0 xwininfo -root -tree | sed 's/.*0x[0-9a-f]* \"\([^\"]*\)\".*/\1/; t; d'});
return split /\n/, $res;
}
sub waitForWindow {
my ($self, $regexp) = @_;
while (1) {
my @names = $self->getWindowNames;
foreach my $n (@names) {
return if $n =~ /$regexp/;
}
sleep 2;
}
};
1;

@ -48,6 +48,9 @@ with pkgs.lib;
# Panic if an error occurs in stage 1 (rather than waiting for
# user intervention).
boot.kernelParams = [ "stage1panic" ];
# `xwininfo' is used by the test driver to query open windows.
environment.systemPackages = [ pkgs.xorg.xwininfo ];
};

@ -36,18 +36,16 @@
testScript =
''
$machine->waitForFile("/tmp/.X11-unix/X0");
sleep 70;
$machine->waitForWindow(qr/plasma-desktop/);
$machine->execute("su - alice -c 'DISPLAY=:0.0 kwrite /var/log/messages &'");
sleep 10;
$machine->execute("su - alice -c 'DISPLAY=:0.0 konqueror http://localhost/ &'");
sleep 10;
$machine->waitForWindow(qr/messages.*KWrite/);
$machine->waitForWindow(qr/Valgrind.*Konqueror/);
sleep 5;
$machine->screenshot("screen");
'';

Loading…
Cancel
Save