def doTimingOfAction(self, commandString, timeWanted, epsilon=0.2): t0 = time.time() actions.doAction(commandString) t1 = time.time() self.assert_equal(timeWanted, t1 - t0, mess="timing not as expected", epsilon=epsilon)
def test_Something_in_unimacro(self): self.log('testing something') actions.doAction("W") lang = unimacroutils.getLanguage() self.assert_equal( "enx", lang, "testing should be done from an English speech profile, not: %s" % lang)
def tttest_Something_in_unimacro(self): testWindowContents = self.doTestWindowContents actions.doKeystroke("testing") expected = "testing" testWindowContents(expected, "Something testing in ClipboardTest went wrong") # tearDown when DragonPad is already closed: actions.doAction("KW") print("test_Something_in_unimacro done")
def tttest_Copy_and_paste_clipboard(self): testWindowContents = self.doTestWindowContents # This test handles several copy and paste meta actions. actions.doKeystroke("testing") actions.doAction("<<selectall>><<copy>>{ctrl+end}") actions.doAction("<<paste>>") # Note in DragonPad it apparently endswith "\r\n"... expected = "testingtesting\n" # natqh getClipboard removes '\r', which was in natlink.getClipboard testWindowContents(expected, "Something copying and pasting went wrong")
def tttest_complete_CLIP_action(self): testWindowContents = self.doTestWindowContents testActionResult = self.doTestActionResult ## This test saves the clipboard, copies two letters ## so the test CLIPISNOTEMPTY returns true ## and the clipboard should be restored next ## do not forget CLIPRESTORE! actions.doKeystroke("testing") actions.doAction("<<selectall>><<copy>>{ctrl+end}") actions.doAction('CLIPSAVE; {shift+left 4}<<copy>>{ctrl+end}; CLIPISNOTEMPTY; {ctrl+end}abcd<<paste>>defg; CLIPRESTORE; <<paste>>') testWindowContents("testingabcdtingdefgtesting")
def tttest_NON_complete_CLIP_action(self): testWindowContents = self.doTestWindowContents testActionResult = self.doTestActionResult ## This test saves the clipboard,breaks off so does not return the ending actions.doKeystroke("testing") actions.doAction("<<selectall>><<copy>>{ctrl+end}") actions.doAction('CLIPSAVE; <<copy>>{ctrl+end}; CLIPISNOTEMPTY; {ctrl+end}abcd<<paste>>defg; CLIPRESTORE; <<paste>>') testWindowContents("testing") t = unimacroutils.getClipboard() # ??? x after testing in test procedure artefact:: self.assert_equal("testing", t, "Clipboard should filled again now" )
def doTestActionResult(self, expected, commandString): result = actions.doAction(commandString) if expected and result: pass elif not expected and not result: pass else: self.assert_equal(expected, result, "result of action not as expected")
def tttest_Non_Empty_clipboard_and_restore(self): testWindowContents = self.doTestWindowContents testActionResult = self.doTestActionResult ## This test saves the clipboard, copies two letters ## so the test CLIPISNOTEMPTY returns true ## and the clipboard should be restored next actions.doKeystroke("testing") actions.doAction("<<selectall>><<copy>>{ctrl+end}") actions.doAction('CLIPSAVE') t = unimacroutils.getClipboard() self.assert_equal("", t, "Clipboard should be empty now" ) actions.doAction("{shift+left 2}<<copy>>{ctrl+end}") t = unimacroutils.getClipboard() self.assert_equal("ng", t, "Clipboard should contain two letters now" ) testActionResult(1, "CLIPISNOTEMPTY") actions.doAction("CLIPRESTORE") t = unimacroutils.getClipboard() self.assert_equal("testing", t, "Clipboard should filled now" )
def test_Empty_clipboard(self): testWindowContents = self.doTestWindowContents # This test first empties the clipboard, copies with no selection on ## and tests if the clipboard is empty. ## If it is so it restores the previous clipboard and exits testActionResult = self.doTestActionResult actions.doKeystroke("testing") actions.doAction("<<selectall>>;<<copy>>;{ctrl+end}") time.sleep(4) actions.doAction('CLIPSAVE') t = unimacroutils.getClipboard() self.assert_equal("", t, "Clipboard should be empty now" ) actions.doAction("<<copy>>") t = unimacroutils.getClipboard() self.assert_equal("", t, "Clipboard should still be empty" ) testActionResult(0, "CLIPISNOTEMPTY") ## with empty clipboard restore goes automatically: actions.doAction("CLIPRESTORE") t = unimacroutils.getClipboard() self.assert_equal("testing", t, "Clipboard should filled again" )
def test_matchModule(self): """check if dragonpad is reported as top window and the open dialog as child window behaviour changed in python version 2.3.4!! """ progInfo = unimacroutils.getProgInfo() self.log("progInfo: %s" % repr(progInfo)) actions.doAction("LW") ## changed in 2013 from 3 to 4 items: self.assert_equal(4, len(progInfo), "progInfo should be tuple of 4") self.assert_equal(u'top', progInfo[2], "DragonPad should be a top window") actions.doAction("<<fileopen>>") progInfo = unimacroutils.getProgInfo() actions.doAction("{esc}") self.assert_equal(4, len(progInfo), "progInfo should be tuple of 4") self.assert_equal(u'child', progInfo[2], "DragonPad open dialog should be a child window")
def log(self, mess): if type(mess) == list: mess = '\n'.join(mess) actions.doAction(str(mess))
def tearDown(self): actions.doAction("BRINGUP dragonpad; KW")
def setUp(self): actions.doAction("BRINGUP dragonpad")
def setUp(self): actions.doAction("BRINGUP dragonpad; <<selectall>><<delete>>")