tests: use wait_for_window/enter_keys_in_window wrappers when applicable
Reduce code duplication.
This commit is contained in:
parent
db35e03aa7
commit
d7ab2d985d
@ -555,8 +555,7 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
|
|||||||
self.testvm2.name, passio_popen=True,
|
self.testvm2.name, passio_popen=True,
|
||||||
passio_stderr=True)
|
passio_stderr=True)
|
||||||
# Confirm transfer
|
# Confirm transfer
|
||||||
subprocess.check_call(
|
self.enter_keys_in_window('Question', ['y'])
|
||||||
['xdotool', 'search', '--sync', '--name', 'Question', 'key', 'y'])
|
|
||||||
p.wait()
|
p.wait()
|
||||||
self.assertEqual(p.returncode, 0, "qvm-copy-to-vm failed: %s" %
|
self.assertEqual(p.returncode, 0, "qvm-copy-to-vm failed: %s" %
|
||||||
p.stderr.read())
|
p.stderr.read())
|
||||||
@ -856,23 +855,14 @@ class TC_20_DispVMMixin(qubes.tests.SystemTestsMixin):
|
|||||||
try:
|
try:
|
||||||
window_title = 'user@%s' % (dispvm.template.name + "-dvm")
|
window_title = 'user@%s' % (dispvm.template.name + "-dvm")
|
||||||
p.stdin.write("xterm -e "
|
p.stdin.write("xterm -e "
|
||||||
"\"sh -s -c 'echo \\\"\033]0;{}\007\\\";read;'\"\n".
|
"\"sh -s -c 'echo \\\"\033]0;{}\007\\\";read x;'\"\n".
|
||||||
format(window_title))
|
format(window_title))
|
||||||
self.wait_for_window(window_title)
|
self.wait_for_window(window_title)
|
||||||
|
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
subprocess.check_call(['xdotool', 'search', '--name', window_title,
|
self.enter_keys_in_window(window_title, ['Return'])
|
||||||
'windowactivate', 'key', 'Return'])
|
# Wait for window to close
|
||||||
|
self.wait_for_window(window_title, show=False)
|
||||||
wait_count = 0
|
|
||||||
while subprocess.call(['xdotool', 'search', '--name', window_title],
|
|
||||||
stdout=open(os.path.devnull, 'w'),
|
|
||||||
stderr=subprocess.STDOUT) == 0:
|
|
||||||
wait_count += 1
|
|
||||||
if wait_count > 100:
|
|
||||||
self.fail("Timeout while waiting for gnome-terminal "
|
|
||||||
"termination")
|
|
||||||
time.sleep(0.1)
|
|
||||||
finally:
|
finally:
|
||||||
p.stdin.close()
|
p.stdin.close()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user