* A function to wait until a window exists.

svn path=/nixos/trunk/; revision=19246
This commit is contained in:
Eelco Dolstra 2010-01-05 23:38:13 +00:00
parent 0f5b178fcf
commit 5cc99487cb
3 changed files with 28 additions and 7 deletions

View File

@ -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;

View File

@ -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 ];
};

View File

@ -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");
'';