mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
make mumble vm test more robust
This test should have a more robust retry loop and handles wrong focus on all windows.
This commit is contained in:
parent
e087b0d12f
commit
7baf620218
2 changed files with 75 additions and 29 deletions
|
@ -566,14 +566,25 @@ sub getWindowNames {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub hasWindow {
|
||||||
|
my ($self, $regexp) = @_;
|
||||||
|
my @names = $self->getWindowNames;
|
||||||
|
foreach my $n (@names) {
|
||||||
|
if ($n =~ /$regexp/) {
|
||||||
|
$self->log("match '$n' on '$regexp'");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
$self->log("no match '$n' on '$regexp'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub waitForWindow {
|
sub waitForWindow {
|
||||||
my ($self, $regexp) = @_;
|
my ($self, $regexp) = @_;
|
||||||
$self->nest("waiting for a window to appear", sub {
|
$self->nest("waiting for a window to appear", sub {
|
||||||
retry sub {
|
retry sub {
|
||||||
my @names = $self->getWindowNames;
|
return $self->hasWindow($regexp)
|
||||||
foreach my $n (@names) {
|
|
||||||
return 1 if $n =~ /$regexp/;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,34 +33,69 @@ in
|
||||||
$client1->execute("mumble mumble://client1\@server/test &");
|
$client1->execute("mumble mumble://client1\@server/test &");
|
||||||
$client2->execute("mumble mumble://client2\@server/test &");
|
$client2->execute("mumble mumble://client2\@server/test &");
|
||||||
|
|
||||||
# cancel client audio configuration
|
sub retry {
|
||||||
$client1->waitForWindow(qr/Audio Tuning Wizard/);
|
my ($coderef) = @_;
|
||||||
$client2->waitForWindow(qr/Audio Tuning Wizard/);
|
my $n;
|
||||||
$server->sleep(5); # wait because mumble is slow to register event handlers
|
for ($n = 0; $n < 900; $n++) {
|
||||||
$client1->sendKeys("esc");
|
return if &$coderef;
|
||||||
$client2->sendKeys("esc");
|
sleep 1;
|
||||||
|
}
|
||||||
|
die "action timed out after $n seconds";
|
||||||
|
}
|
||||||
|
|
||||||
# cancel client cert configuration
|
my @clients = ($client1, $client2);
|
||||||
$client1->waitForWindow(qr/Certificate Management/);
|
foreach my $cl (@clients) {
|
||||||
$client2->waitForWindow(qr/Certificate Management/);
|
# cancel client audio configuration
|
||||||
$server->sleep(5); # wait because mumble is slow to register event handlers
|
my $audiore = qr/Audio Tuning Wizard/;
|
||||||
$client1->sendKeys("esc");
|
$cl->waitForWindow($audiore);
|
||||||
$client2->sendKeys("esc");
|
$cl->sleep(5);
|
||||||
|
$cl->nest("Cancel Audio Tuning Wizard", sub {
|
||||||
|
my $c = 0;
|
||||||
|
retry(sub {
|
||||||
|
return 1 if !$cl->hasWindow($audiore);
|
||||||
|
if ($c % 2 > 0) {
|
||||||
|
$cl->sendKeys("alt-tab");
|
||||||
|
$cl->sleep(5);
|
||||||
|
}
|
||||||
|
$cl->sendKeys("esc");
|
||||||
|
$c++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
# accept server certificate
|
# cancel client cert configuration
|
||||||
$client1->waitForWindow(qr/^Mumble$/);
|
my $certre = qr/Certificate Management/;
|
||||||
$client2->waitForWindow(qr/^Mumble$/);
|
$cl->waitForWindow($certre);
|
||||||
$server->sleep(5); # wait because mumble is slow to register event handlers
|
$cl->sleep(5);
|
||||||
$client1->sendChars("y");
|
$cl->nest("Cancel Certificate Management", sub {
|
||||||
$client2->sendChars("y");
|
my $c = 0;
|
||||||
$server->sleep(5); # wait because mumble is slow to register event handlers
|
retry(sub {
|
||||||
|
return 1 if !$cl->hasWindow($certre);
|
||||||
|
if ($c % 2 > 0) {
|
||||||
|
$cl->sendKeys("alt-tab");
|
||||||
|
$cl->sleep(5);
|
||||||
|
}
|
||||||
|
$cl->sendKeys("esc");
|
||||||
|
$c++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
# sometimes the wrong of the 2 windows is focused, we switch focus and try pressing "y" again
|
# accept server certificate
|
||||||
$client1->sendKeys("alt-tab");
|
my $acceptre = qr/^Mumble$/;
|
||||||
$client2->sendKeys("alt-tab");
|
$cl->waitForWindow($acceptre);
|
||||||
$server->sleep(5); # wait because mumble is slow to register event handlers
|
$cl->sleep(5);
|
||||||
$client1->sendChars("y");
|
$cl->nest("Accept Server Certificate", sub {
|
||||||
$client2->sendChars("y");
|
my $c = 0;
|
||||||
|
retry(sub {
|
||||||
|
return 1 if !$cl->hasWindow($acceptre);
|
||||||
|
if ($c % 2 > 0) {
|
||||||
|
$cl->sendKeys("alt-tab");
|
||||||
|
$cl->sleep(5);
|
||||||
|
}
|
||||||
|
$cl->sendChars("y");
|
||||||
|
$c++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
# Find clients in logs
|
# Find clients in logs
|
||||||
$server->waitUntilSucceeds("grep -q 'client1' /var/log/murmur/murmurd.log");
|
$server->waitUntilSucceeds("grep -q 'client1' /var/log/murmur/murmurd.log");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue