File: run.py

package info (click to toggle)
openmsx-catapult 19.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,952 kB
  • sloc: cpp: 6,592; python: 458; makefile: 43; sed: 37; sh: 25
file content (84 lines) | stat: -rwxr-xr-x 2,100 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python3

import dogtail.tc
from dogtail.procedural import *
from dogtail.utils import run
from dogtail.predicate import GenericPredicate
import os
import time
import traceback
os.environ['LANG'] = 'en_US.UTF-8'

class NotFound(Exception):
	pass

def find(*a, **ka):
	"Find a widget in the current window by name (and index, if there's more than one."
	if 'idx' in ka:
		idx = ka.pop('idx')
	else:
		idx = None
	window = tree.root.application('openmsx-catapult')
	targets = window.findChildren(GenericPredicate(*a, **ka))
	if idx is None:
		idx = 0
		if len(targets) > 1:
			print('Warning: multiple elements with name "%s" were found' % name, file = sys.stderr)
	if len(targets) <= idx:
		raise NotFound('not found')
	return targets[idx]

def start():
	'Start the application and focus the window. If the configuration chooser pops up, dismiss it.'
	run('openmsx-catapult')
	
	try:
		find('Check for working hardware configurations after closing this dialog').click()
		find('OK').click()
	except:
		pass

	# Wait for main window to open.
	time.sleep(2)

	focus.application('openmsx-catapult')

def test_detect():
	'Run machine detection, the quit.'
	start()

	find('File').click()
	find('Test MSX Hardware').click()

	#focus.widget.findByPredicate(GenericPredicate(name = 'Checking openMSX configurations'))
	for i in range(600):
		try:
			done = find('Done', idx = 1)
			break
		except NotFound:
			time.sleep(1)
	done.click()

	find('File').click()
	find('Quit').click()

def test_run_msx():
	'Start the emulator.'
	start()
	find('Start').click()
	time.sleep(3)
	# Check that a Stop button has appeared.
	find('Stop')
	marker = 'autopkgtest is sending bytes'
	os.system(r"xvkbd -xsendevent -window 'openMSX 1*' -text '\D1\{F10}puts stderr \"\\n" + marker + r"\\n\"\r\D3quit\r'")
	time.sleep(3)
	# Check that there is a start button again.
	find('Start')
	messages = find(description = 'Info, warning and error messages')
	# Find the output that should have been sent.
	assert marker in messages.text.split('\n')
	find('File').click()
	find('Quit').click()

test_detect()
test_run_msx()