1 When /^I(?:| try to) open "([^"]+)" with Evince$/ do |filename|
2 step "I run \"evince #{filename}\" in GNOME Terminal"
5 Then /^I can print the current document to "([^"]+)"$/ do |output_file|
6 @screen.press('ctrl', 'p')
7 @screen.wait('EvincePrintDialog.png', 10)
8 @screen.wait('EvincePrintToFile.png', 10).click
9 @screen.wait('EvincePrintOutputFileButton.png', 10).click
10 @screen.wait('Gtk3PrintFileDialog.png', 10)
11 # At this point, the destination file's basename *without its extension*
12 # is selected. So, to replace it, accordingly we paste only the desired
13 # destination file's name *without its extension*.
14 $vm.set_clipboard(output_file.sub(/[.]pdf$/, ''))
15 @screen.press('ctrl', 'v')
16 sleep 1 # Wait for the paste operation to register.
17 @screen.press('Return')
18 @screen.wait('Gtk3PrintButton.png', 10).click
19 try_for(10, msg: "The document was not printed to #{output_file}") do
20 $vm.file_exist?(output_file)
24 When /^I close Evince$/ do
25 @screen.press('ctrl', 'w')
26 step 'process "evince" has stopped running after at most 20 seconds'