Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert_screen_change #689

Merged
merged 1 commit into from
Jan 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 21 additions & 2 deletions testapi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ our @EXPORT = qw($realname $username $password $serialdev %cmd %vars
upload_asset upload_image data_url assert_shutdown parse_junit_log
upload_logs
wait_idle wait_screen_change wait_still_screen wait_serial record_soft_failure
wait_idle wait_screen_change assert_screen_change wait_still_screen wait_serial
record_soft_failure
become_root x11_start_program ensure_installed eject_cd power
save_memory_dump save_storage_drives freeze_vm resume_vm
Expand Down Expand Up @@ -353,7 +354,7 @@ sub assert_and_dclick {

=head2 wait_screen_change
wait_screen_change { CODEREF [,$timeout] };
wait_screen_change(CODEREF [,$timeout]);
Wrapper around code that is supposed to change the screen.
This is the opposite to C<wait_still_screen>. Make sure to put the commands to change the screen
Expand Down Expand Up @@ -396,6 +397,24 @@ sub wait_screen_change(&@) {
return 0;
}

=head2 assert_screen_change
assert_screen_change(CODEREF [,$timeout]);
Run C<CODEREF> with C<wait_screen_change> but C<die> if screen did not change
within timeout. Look into C<wait_screen_change> for details.
Example:
assert_screen_change { send_key 'alt-f4' };
=cut

sub assert_screen_change(&@) {
::wait_screen_change(@_) or die 'assert_screen_change failed to detect a screen change';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know perl, what does :: do here? I just want to call the other method in the same file and without that it didn't work. Also, deleting the parameter part (&@) on both wait_screen_change and assert_screen_change did not work, ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perl black magic, ::wait_screen_change is short for main::wait_screen_change

use strict;
use warnings;

sub foo {
    print "They called me!";
}

::foo;
foo;

}


=head2 wait_still_screen
=for stopwords stilltime
Expand Down