Example #1
0
 def doTestClipboard(self, expected, testName=None):
     text = 'testing the clipboard'
     if testName:
         text += ': ' + testName
     action = actions.doAction
     contents = unimacroutils.getClipboard()
     self.assert_equal(expected, contents, text)
Example #2
0
 def gotResultsInit(self, words, fullResults):
     """initialize values
     """
     self.note = ""
     self.rythm = ""
     self.point = ""  # for rythms, halving a note or rest
     self.noteaddition = ""  # up, down, slur
     self.separator = ""  # bar
     self.pitch = ""  # up or down octave(s)
     self.wordsList, self.notesIndexes = [], []  # for notesnavigate
     self.afterNotesList = []  # list items after the selected notes
     self.notesWanted = 0  # also for notesnavigate...
     self.newNotes = []
     self.hadFigure = 0
     self.nextchars = None
     self.prevchars = None
     self.justInsert = 1
     t0 = time.time()
     self.hasSelection = self.frescobaldi.hasSelection()
     t1 = time.time()
     print 'hasSelection, (%.4f seconds): %s' % (t1 - t0, self.hasSelection)
     self.justLeft = self.justRight = None  # to be filled with getPrevNext()
     self.inMiddleOfWord = None
     if self.hasSelection:
         print 'hasSelection, selected text: %s' % unimacroutils.getClipboard(
         )
     self.hasAllInfoNext = False  ## set to true if nextlines end with double \n
     self.hasAllInfoPrev = False  ## set to true if prevlines contains a double \n so starts with ir
Example #3
0
 def getWindowContents(self):
     action = actions.doAction
     action('CLIPSAVE')
     action("<<selectall>><<copy>>")
     contents = unimacroutils.getClipboard()
     action('CLIPRESTORE')
     return contents
    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 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" ) 
Example #7
0
    def checkContents(self, expected, comment=""):
        """check expected tuple (clipboard, before, after)

        if selection was active, it came through a forward search, feeble part!
        
        """
        text = 'checking contents'
        if comment:
            text += ': %s' % comment
        action = actions.doAction
        action('CLIPSAVE')
        action("<<copy>>")
        clip = unimacroutils.getClipboard()
        lenClip = len(clip)
        # get to the left of the selection:
        action(
            '<<leftafterforwardsearch %s>>{shift+ctrl+home}<<copy>>{ctrl+home}'
            % lenClip)
        begin = unimacroutils.getClipboard()
        lenBegin = len(begin)
        lengths = lenBegin + lenClip
        action('{right %s}' % lengths)
        action('{shift+ctrl+end}<<copy>>')
        end = unimacroutils.getClipboard()
        end = end.rstrip()
        lenEnd = len(end)
        action('<<selectall>><<copy>>')
        all = unimacroutils.getClipboard()
        all = all.rstrip()
        lenAll = len(all)
        action('CLIPRESTORE')
        self.assertEqual(
            lenAll, lenBegin + lenClip + lenEnd,
            text + 'lengths do not match, total: %s, parts: %s, %s, %s' %
            (lenAll, lenBegin, lenClip, lenEnd))
        action('VW')
        action("{ctrl+home}{right %s}{shift+right %s}" % (lenBegin, lenClip))
        self.assert_equal(expected, (begin, clip, end), text)