| 1 |
# WinDictator: |
|---|
| 2 |
# Dictate in Windows, have the text typed in Linux via X faked keystroke events |
|---|
| 3 |
# |
|---|
| 4 |
# Copyright (C) 2005-2006 by Edwin A. Suominen, http://www.eepatents.com |
|---|
| 5 |
# |
|---|
| 6 |
# This program is free software; you can redistribute it and/or modify it under |
|---|
| 7 |
# the terms of the GNU General Public License as published by the Free Software |
|---|
| 8 |
# Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 9 |
# version. |
|---|
| 10 |
# |
|---|
| 11 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 13 |
# FOR A PARTICULAR PURPOSE. See the file COPYING for more details. |
|---|
| 14 |
# |
|---|
| 15 |
# You should have received a copy of the GNU General Public License along with |
|---|
| 16 |
# this program; if not, write to the Free Software Foundation, Inc., 51 |
|---|
| 17 |
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
""" |
|---|
| 21 |
Unit tests for windictator.linux.keycodes |
|---|
| 22 |
""" |
|---|
| 23 |
|
|---|
| 24 |
from twisted.trial.unittest import TestCase |
|---|
| 25 |
|
|---|
| 26 |
import windictator.linux.keycodes as keycodes |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
class TestKeyCoder(TestCase): |
|---|
| 30 |
def setUp(self): |
|---|
| 31 |
self.kc = keycodes.KeyCoder() |
|---|
| 32 |
|
|---|
| 33 |
def testTTK_Simple(self): |
|---|
| 34 |
text = 'abc123' |
|---|
| 35 |
keyList = self.kc.textToKeys(text) |
|---|
| 36 |
expectedList = [(x,) for x in text] |
|---|
| 37 |
self.failUnlessEqual(keyList, expectedList) |
|---|
| 38 |
|
|---|
| 39 |
def testTTK_Shifts(self): |
|---|
| 40 |
keyList = self.kc.textToKeys('aAbB') |
|---|
| 41 |
expectedList = [('a',), ('Shift_L', 'a'), ('b',), ('Shift_L', 'b')] |
|---|
| 42 |
self.failUnlessEqual(keyList, expectedList) |
|---|
| 43 |
|
|---|
| 44 |
def testTTK_Complex(self): |
|---|
| 45 |
keyList = self.kc.textToKeys('1@\n\tab\\c') |
|---|
| 46 |
expectedList = [('1',), ('Shift_L', '2'), ('Return',), |
|---|
| 47 |
('Tab',), ('a',), ('b',), ('backslash',), ('c',)] |
|---|
| 48 |
self.failUnlessEqual(keyList, expectedList) |
|---|