Merge lp:~xpresser-team/xpresser/xpresser-with-special-keys into lp:xpresser

Proposed by Chris Wayne
Status: Merged
Merged at revision: 13
Proposed branch: lp:~xpresser-team/xpresser/xpresser-with-special-keys
Merge into: lp:xpresser
Diff against target: 194 lines (+97/-9)
7 files modified
debian/changelog (+26/-0)
debian/control (+5/-3)
debian/copyright (+17/-5)
debian/watch (+3/-0)
setup.py (+1/-1)
xpresser/tests/test_xutils.py (+13/-0)
xpresser/xutils.py (+32/-0)
To merge this branch: bzr merge lp:~xpresser-team/xpresser/xpresser-with-special-keys
Reviewer Review Type Date Requested Status
Chris Gagnon (community) Approve
Review via email: mp+121060@code.launchpad.net

Description of the change

Adding in special key support!

To post a comment you must log in.
24. By Chris Wayne

Adding in Enter key per Chris Gagnon's request

Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

the keycode for enter is 28

review: Needs Fixing
Revision history for this message
Chris Wayne (cwayne) wrote :

Using 28 makes it type a 't'

Revision history for this message
Chris Gagnon (chris.gagnon) wrote :

The keycode is correct, enter is not 28... showkey does not return the correct value, xev does.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-07-05 13:52:37 +0000
+++ debian/changelog 2012-08-23 17:34:19 +0000
@@ -1,3 +1,29 @@
1xpresser (1.1.3) precise; urgency=low
2
3 * Adding in special key support
4
5 [Chris Gagnon]
6 * reversed keys_to_press for key release so things like ctrl-alt-
7 backspace wont delete a typed key
8
9 [Chris Wayne]
10 * Fixed sleep after each key press
11 * Added some more special keys (all F keys, Function, and others)
12
13 -- Chris Wayne <chris.wayne@canonical.com> Sat, 18 Aug 2012 14:36:12 -0400
14
15xpresser (1.1.2) precise; urgency=low
16
17 * Small fix
18
19 -- Chris Wayne <chris.wayne@canonical.com> Thu, 19 Jul 2012 21:01:24 -0400
20
21xpresser (1.1.1) precise; urgency=low
22
23 * Adding in python-gi-cairo as a build dependency
24
25 -- Chris Wayne <chris.wayne@canonical.com> Thu, 19 Jul 2012 20:29:24 -0400
26
1xpresser (1.1) precise; urgency=low27xpresser (1.1) precise; urgency=low
228
3 * Initial Precise release into Xpresser PPA29 * Initial Precise release into Xpresser PPA
430
=== modified file 'debian/control'
--- debian/control 2012-07-05 15:56:48 +0000
+++ debian/control 2012-08-23 17:34:19 +0000
@@ -1,12 +1,14 @@
1Source: xpresser1Source: xpresser
2Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>2Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
3XSBC-Original-Maintainer: Xpresser Team <xpresser-team@lists.canonical.com>
4Section: python3Section: python
5Priority: optional4Priority: extra
6Build-Depends: python-all (>= 2.6.6-3), debhelper (>= 9)5Build-Depends: python-all (>= 2.6.6-3), debhelper (>= 9)
7Standards-Version: 3.9.36Standards-Version: 3.9.3
87
9Package: python-xpresser8Package: python-xpresser
10Architecture: all9Architecture: all
11Depends: ${misc:Depends}, ${python:Depends}, python-opencv, python-pyatspi2, python-numpy, python-simplecv10Depends: ${misc:Depends}, ${python:Depends}, python-opencv, python-pyatspi2, python-numpy, python-simplecv, python-gi-cairo
12Description: Python library to script Graphic User Interfaces.11Description: Python library to script Graphic User Interfaces.
12 Xpresser is a python library to automate GUI testing. It uses screenshot matching
13 to make automation easy, and can emulate actual user testing, rather than through
14 introspection.
1315
=== modified file 'debian/copyright'
--- debian/copyright 2012-07-05 15:56:48 +0000
+++ debian/copyright 2012-08-23 17:34:19 +0000
@@ -1,11 +1,23 @@
1Format: http://dep.debian.net/deps/dep51Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2Upstream-Name: python-xpresser2Upstream-Name: python-xpresser
3Source: http://bazaar.launchpad.net/~xpresser-team/xpresser3Source: http://bazaar.launchpad.net/~xpresser-team/xpresser
44
5Files: *5Files: *
6Copyright: 2012 Canonical Ltd.6Copyright: 2012 Canonical Ltd.
7License: LGPL-3.07License: LGPL-3
88
9Files: debian/*9License: LGPL-3
10Copyright: 2012 Canonical Ltd.10 This program is free software: you can redistribute it and/or modify
11License: LGPL-3.011 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation, version 3 of the License.
13 .
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18 .
19 You should have received a copy of the GNU Lesser General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 .
22 On Debian systems, the full text of the GNU Lesser General Public License
23 version 3 can be found in the file /usr/share/common-licenses/LGPL-3.
1224
=== added file 'debian/watch'
--- debian/watch 1970-01-01 00:00:00 +0000
+++ debian/watch 2012-08-23 17:34:19 +0000
@@ -0,0 +1,3 @@
1version=3
2http://launchpad.net/xpresser/+download .*/Xpresser-(.+)\.tar\.gz
3
04
=== added directory 'dist'
=== added file 'dist/Xpresser-1.1.tar.gz'
1Binary files dist/Xpresser-1.1.tar.gz 1970-01-01 00:00:00 +0000 and dist/Xpresser-1.1.tar.gz 2012-08-23 17:34:19 +0000 differ5Binary files dist/Xpresser-1.1.tar.gz 1970-01-01 00:00:00 +0000 and dist/Xpresser-1.1.tar.gz 2012-08-23 17:34:19 +0000 differ
=== modified file 'setup.py'
--- setup.py 2010-07-22 14:04:17 +0000
+++ setup.py 2012-08-23 17:34:19 +0000
@@ -3,7 +3,7 @@
3from distutils.core import setup3from distutils.core import setup
44
5setup(name='Xpresser',5setup(name='Xpresser',
6 version='1.0',6 version='1.1',
7 description='Python library to script Graphic User Interfaces.',7 description='Python library to script Graphic User Interfaces.',
8 author='Gustavo Niemeyer',8 author='Gustavo Niemeyer',
9 author_email='gustavo.niemeyer@canonical.com',9 author_email='gustavo.niemeyer@canonical.com',
1010
=== modified file 'xpresser/tests/test_xutils.py'
--- xpresser/tests/test_xutils.py 2012-05-21 19:57:09 +0000
+++ xpresser/tests/test_xutils.py 2012-08-23 17:34:19 +0000
@@ -86,6 +86,19 @@
86 finally:86 finally:
87 window.destroy()87 window.destroy()
8888
89 def test_type_special(self):
90 entry = Gtk.Entry()
91 window = self.create_window(entry)
92 try:
93 window.present()
94 entry.grab_focus()
95 self.flush_gtk()
96 xutils.type(["<Shift>", "hi there"])
97 self.flush_gtk()
98 self.assertEquals(entry.get_text(), "HI THERE")
99 finally:
100 window.destroy()
101
89 def test_take_screenshot(self):102 def test_take_screenshot(self):
90 """Verify that take_screenshot works, with a real screenshot.103 """Verify that take_screenshot works, with a real screenshot.
91104
92105
=== modified file 'xpresser/xutils.py'
--- xpresser/xutils.py 2012-05-21 19:57:09 +0000
+++ xpresser/xutils.py 2012-08-23 17:34:19 +0000
@@ -19,10 +19,19 @@
19#19#
20import pyatspi20import pyatspi
21import SimpleCV21import SimpleCV
22import types
23import time
22from xpresser.image import Image24from xpresser.image import Image
23from tempfile import NamedTemporaryFile25from tempfile import NamedTemporaryFile
24from gi.repository import Gdk26from gi.repository import Gdk
2527
28specialkeys = {'<Ctrl>' : 37, "<Shift>" : 50, "<Alt>" : 64, "<Meta>" : 133,
29 '<Tab>' : 23, '<Super>' : 133, '<Fn>' : 151, '<PgUp>' : 112,
30 '<PgDn>' : 117, '<Delete>' : 119, '<Home>' : 110, '<Esc>' : 9,
31 '<F1>' : 67, '<F2>' : 68, '<F3>' : 69, '<F4>' : 70, '<F5>' : 71,
32 '<F6>' : 72, '<F7>' : 73, '<F8>' : 74, '<F9>' : 75, '<F10>' : 76,
33 '<F11>' : 95, '<F12>' : 96, '<Enter>' : 36}
34
2635
27def click(x, y):36def click(x, y):
28 pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_B1C)37 pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_B1C)
@@ -37,10 +46,33 @@
37 pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_ABS)46 pyatspi.Registry.generateMouseEvent(x, y, pyatspi.MOUSE_ABS)
3847
39def type(string):48def type(string):
49 if isinstance(string, types.ListType):
50 keys_to_press = []
51 for string_part in string:
52 if string_part in specialkeys:
53 keys_to_press.append(specialkeys[string_part])
54 __press_key(keys_to_press[-1])
55 else:
56 __type_standard(string_part)
57 keys_to_press.reverse()
58 #hold the key long enough to constitute a hold, not a tap
59 time.sleep(.4)
60 for keys in keys_to_press:
61 __release_key(keys)
62 else:
63 __type_standard(string)
64
65def __type_standard(string):
40 for char in string:66 for char in string:
41 keyval = Gdk.unicode_to_keyval(ord(char))67 keyval = Gdk.unicode_to_keyval(ord(char))
42 pyatspi.Registry.generateKeyboardEvent(keyval, None, pyatspi.KEY_SYM)68 pyatspi.Registry.generateKeyboardEvent(keyval, None, pyatspi.KEY_SYM)
4369
70def __press_key(keycode):
71 pyatspi.Registry.generateKeyboardEvent(keycode, None, pyatspi.KEY_PRESS)
72
73def __release_key(keycode):
74 pyatspi.Registry.generateKeyboardEvent(keycode, None, pyatspi.KEY_RELEASE)
75
44def take_screenshot():76def take_screenshot():
45 window = Gdk.get_default_root_window()77 window = Gdk.get_default_root_window()
46 surface = Gdk.cairo_create(window).get_target()78 surface = Gdk.cairo_create(window).get_target()

Subscribers

People subscribed via source and target branches

to all changes: