nixos/test-driver: Add new waitForText function.

As promised in the previous commit, this can be used similarly to
$machine->waitForWindow, where you supply a regular expression and it's
retrying OCR until the regexp matches.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2015-05-21 19:49:08 +02:00
parent 235c2228ca
commit 8bd025a75e
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961
2 changed files with 18 additions and 0 deletions

View file

@ -244,6 +244,13 @@ startAll;
connections.</para></listitem>
</varlistentry>
<varlistentry>
<term><methodname>waitForText</methodname></term>
<listitem><para>Wait until the supplied regular expressions matches
the textual contents of the screen by using optical character recognition
(see <methodname>getScreenText</methodname>).</para></listitem>
</varlistentry>
<varlistentry>
<term><methodname>waitForWindow</methodname></term>
<listitem><para>Wait until an X11 window has appeared whose name

View file

@ -518,6 +518,17 @@ sub getScreenText {
}
# Wait until a specific regexp matches the textual contents of the screen.
sub waitForText {
my ($self, $regexp) = @_;
$self->nest("waiting for $regexp to appear on the screen", sub {
retry sub {
return 1 if $self->getScreenText =~ /$regexp/;
}
});
}
# Wait until it is possible to connect to the X server. Note that
# testing the existence of /tmp/.X11-unix/X0 is insufficient.
sub waitForX {