Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

functional: add screen capture tests

  • Loading branch information...
commit c4a710e64e2a65f6b646983115f401da5ad7e631 1 parent db38c1e
Marc Sibson authored
2  MANIFEST.in
View
@@ -2,4 +2,4 @@ include *.txt README.rst
include setup.py setup.cfg
include scripts/vncdotool
include vncdotool/*.py
-include tests/*.py
+recursive-include tests *.py *.png
55 tests/functional/test_screen.py
View
@@ -0,0 +1,55 @@
+import pexpect
+import sys
+import os.path
+
+DATADIR = os.path.join(os.path.dirname(__file__), 'data')
+
+
+class TestVNCCapture(object):
+
+ def tearDown(self):
+ self.server.terminate(force=True)
+
+ def run_server(self, server):
+ cmd = '%s -rfbport 5910 -rfbwait 1000' % server
+ self.server = pexpect.spawn(cmd, timeout=2)
+ self.server.logfile_read = sys.stdout
+
+ def run_vncdotool(self, commands, exitcode=0):
+ cmd = 'vncdotool -d 10 ' + commands
+ vnc = pexpect.spawn(cmd, logfile=sys.stdout, timeout=5)
+ vnc.logfile_read = sys.stdout
+ vnc.expect(pexpect.EOF)
+ if vnc.isalive():
+ vnc.wait()
+
+ assert vnc.exitstatus == exitcode, vnc.exitstatus
+
+ def assertFilesEqual(self, filename, othername):
+ content = open(filename, 'rb').read()
+ othercontent = open(othername, 'rb').read()
+
+ assert content == othercontent
+
+ def testCaptureExample(self):
+ fname = 'test_capture_example.png'
+ self.run_server('example')
+ self.run_vncdotool('capture %s' % fname)
+ self.assertFilesEqual(fname, os.path.join(DATADIR, 'example.png'))
+
+ def testExpectExampleExactly(self):
+ self.run_server('example')
+ self.run_vncdotool('expect %s 0' % os.path.join(DATADIR, 'example.png'))
+
+ def testExpectExampleSloppy(self):
+ self.run_server('example')
+ example = os.path.join(DATADIR, 'example.png')
+ self.run_vncdotool('move 30 20 expect %s 20' % example)
+
+ def testExpectFailsExample(self):
+ self.run_server('example')
+ simple = os.path.join(DATADIR, 'simple.png')
+ try:
+ self.run_vncdotool('expect %s 0' % simple, exitcode=10)
+ except pexpect.TIMEOUT:
+ pas:), exitcode=10)), exitcode=10)
2  tests/functional/test_send_events.py
View
@@ -1,5 +1,3 @@
-# Copyright 07-Feb-2011 Evertz Microsystems Ltd. All rights reserved.
-
import pexpect
import unittest
import sys
Please sign in to comment.
Something went wrong with that request. Please try again.