예제 #1
0
파일: tests.py 프로젝트: mlyko/tadek-ui
    def getCheckedTests(self):
        '''
        Loads checked tests cases and returns them in a list on success
        or None on failure.
        '''
        def findCheckedNames(tests, item):
            if item.checkState(0) == QtCore.Qt.Checked:
                tests.append(item.testName)
                return
            elif item.checkState(0) == QtCore.Qt.PartiallyChecked:
                for i in xrange(item.childCount()):
                    findCheckedNames(tests, item.child(i))
        
        names = []
        for i in xrange(self._testsTree.topLevelItemCount()):
            findCheckedNames(names, self._testsTree.topLevelItem(i))
        if not names:
            runWarning("Select some test cases first")
            return names
        tests, errors = self._loader.loadFromNames(*names)
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog("Errors occurred while loading "
                                            "test cases", errors)
                dialog.run()
                return []

        return tests
예제 #2
0
    def getCheckedTests(self):
        '''
        Loads checked tests cases and returns them in a list on success
        or None on failure.
        '''
        def findCheckedNames(tests, item):
            if item.checkState(0) == QtCore.Qt.Checked:
                tests.append(item.testName)
                return
            elif item.checkState(0) == QtCore.Qt.PartiallyChecked:
                for i in xrange(item.childCount()):
                    findCheckedNames(tests, item.child(i))

        names = []
        for i in xrange(self._testsTree.topLevelItemCount()):
            findCheckedNames(names, self._testsTree.topLevelItem(i))
        if not names:
            runWarning("Select some test cases first")
            return names
        tests, errors = self._loader.loadFromNames(*names)
        if errors:
            if self._loaded:
                dialog = LoadingErrorDialog(
                    "Errors occurred while loading "
                    "test cases", errors)
                dialog.run()
                return []

        return tests
예제 #3
0
    def find(self, check, deep):
        '''
        Initiates the searching process.
        '''
        if not self._active:
            dialogs.runWarning("Device is disconnected")
            self.searchingStopped.emit()
            return
        log.info("Searching started for name: \"%s\", role: \"%s\", state: "
                 "\"%s\", text: \"%s\", with deep option set to %s)" %
                 (check.name, check.role, check.state, check.text, deep))
        self._manualExpand = True
        self._manualSelect = True
        self._deep = deep
        self._check = check
        self._options = {
            "text": len(check.text) > 0,
            "states": len(check.state) > 0,
        }
        self._stopSearching = False
        self._nextIndex = 0
        self._parentAccs = []
        self._parentAcc = self.device.getAccessible(self.selectedItemPath(), 0)
        self._parentItem = self._pathItem(self._parentAcc.path)
        self._lastDisplayedItem = self._parentItem
        self._remainingItems = {}

        self._parentItem.takeChildren()
        if self._parentAcc.count:
            self._parentItem.setExpanded(True)
        self._responseFind()
예제 #4
0
    def _startTests(self):
        '''
        Starts execution of tests.
        '''
        log.debug("Starting tests")
        self._actionStart.setVisible(False)
        devices = self._devices.getChecked()
        if not devices:
            runWarning("Select some devices first")
            self._actionStart.setVisible(True)
            return
        tests = self._tests.getCheckedTests()
        if not tests:
            self._actionStart.setVisible(True)
            return
        if sum([test.count() for test in tests]) == 0:
            runWarning("Selected test suites do not contain any test cases")
            self._actionStart.setVisible(True)
            return

        self._suiteRuns = 0
        self._todoSuites = len(tests)
        self._testResult = testresult.TestResult()
        self._testRunner = TestRunner(devices, tests, self._testResult)
        self._devices.deviceChecked.connect(self._testRunner.addDevice)
        self._devices.deviceUnchecked.connect(self._testRunner.removeDevice)
        self._devices.setWarning(True)

        self._testRunner.start()

        self._actionStop.setVisible(True)
        self._actionPause.setVisible(True)
예제 #5
0
 def _openDialog(self):
     '''
     Opens selected files containing test results in tabs.
     '''
     log.debug("Opening result file")
     readableChannels = {}
     for c in [
             c for c in channels.get()
             if isinstance(c, channels.TestResultFileChannel)
     ]:
         desc = "%s (*.%s)" % (c.name, c.fileExt().strip("."))
         readableChannels[desc] = c
     if not readableChannels:
         dialogs.runWarning("There are no readable channels available")
         return
     dialog = QtGui.QFileDialog(self.view)
     dialog.setFileMode(QtGui.QFileDialog.ExistingFiles)
     dialog.setFilter(";;".join(readableChannels))
     if not dialog.exec_():
         log.debug("Opening result file was cancelled")
         return
     channel = readableChannels[dialog.selectedFilter()]
     for path in dialog.selectedFiles():
         try:
             self.addTab(channel.read(path),
                         os.path.split(path)[1],
                         tooltip=path)
             self._updateRecentFiles(path)
         except Exception, ex:
             dialogs.runError("Error occurred while loading result file "
                              "'%s':\n%s" % (path, ex))
예제 #6
0
파일: testview.py 프로젝트: mlyko/tadek-ui
    def _startTests(self):
        '''
        Starts execution of tests.
        '''
        log.debug("Starting tests")
        self._actionStart.setVisible(False)
        devices = self._devices.getChecked()
        if not devices:
            runWarning("Select some devices first")
            self._actionStart.setVisible(True)
            return
        tests = self._tests.getCheckedTests()
        if not tests:
            self._actionStart.setVisible(True)
            return
        if sum([test.count() for test in tests]) == 0:
            runWarning("Selected test suites do not contain any test cases")
            self._actionStart.setVisible(True)
            return

        self._suiteRuns = 0
        self._todoSuites = len(tests)
        self._testResult = testresult.TestResult()
        self._testRunner = TestRunner(devices, tests, self._testResult)
        self._devices.deviceChecked.connect(self._testRunner.addDevice)
        self._devices.deviceUnchecked.connect(self._testRunner.removeDevice)
        self._devices.setWarning(True)

        self._testRunner.start()

        self._actionStop.setVisible(True)
        self._actionPause.setVisible(True)
예제 #7
0
 def _openDialog(self):
     '''
     Opens selected files containing test results in tabs.
     '''
     log.debug("Opening result file")
     readableChannels = {}
     for c in [c for c in channels.get()
                 if isinstance(c, channels.TestResultFileChannel)]:
         desc = "%s (*.%s)" % (c.name, c.fileExt().strip("."))
         readableChannels[desc] = c
     if not readableChannels:
         dialogs.runWarning("There are no readable channels available")
         return
     dialog = QtGui.QFileDialog(self.view)
     dialog.setFileMode(QtGui.QFileDialog.ExistingFiles)
     dialog.setFilter(";;".join(readableChannels))
     if not dialog.exec_():
         log.debug("Opening result file was cancelled")
         return
     channel = readableChannels[dialog.selectedFilter()]
     for path in dialog.selectedFiles():
         try:
             self.addTab(channel.read(path), os.path.split(path)[1],
                         tooltip=path)
             self._updateRecentFiles(path)
         except Exception, ex:
             dialogs.runError("Error occurred while loading result file "
                              "'%s':\n%s" % (path, ex))
예제 #8
0
    def _openRecent(self):
        '''
        Opens a recent file containing test results in tabs.
        '''
        log.debug("Opening recent result file")

        path = self.sender().data()
        ext = os.path.splitext(path)[1]
        channel = None
        for c in channels.get():
            if (isinstance(c, channels.TestResultFileChannel)
                    and c.fileExt() == ext):
                channel = c
                break
        if not channel:
            dialogs.runWarning("There are no readable channels accepting "
                               "'%s' files" % ext)
            return
        try:
            self.addTab(channel.read(path),
                        os.path.split(path)[1],
                        tooltip=path)
        except Exception, ex:
            dialogs.runError("Error occurred while loading result file:\n%s" %
                             str(ex))
예제 #9
0
파일: device.py 프로젝트: mlyko/tadek-ui
    def find(self, check, deep):
        '''
        Initiates the searching process.
        '''
        if not self._active:
            dialogs.runWarning("Device is disconnected")
            self.searchingStopped.emit()
            return
        log.info("Searching started for name: \"%s\", role: \"%s\", state: "
                 "\"%s\", text: \"%s\", with deep option set to %s)"
                 % (check.name, check.role, check.state, check.text, deep))
        self._manualExpand = True
        self._manualSelect = True
        self._deep = deep
        self._check = check
        self._options = {
            "text":  len(check.text) > 0,
            "states":  len(check.state) > 0,
        }
        self._stopSearching = False
        self._nextIndex = 0
        self._parentAccs = []
        self._parentAcc = self.device.getAccessible(
            self.selectedItemPath(), 0)
        self._parentItem = self._pathItem(self._parentAcc.path)
        self._lastDisplayedItem = self._parentItem
        self._remainingItems = {}

        self._parentItem.takeChildren()
        if self._parentAcc.count:
            self._parentItem.setExpanded(True)
        self._responseFind()
예제 #10
0
    def _startSearching(self):
        '''
        Starts the searching process.
        '''
        self.buttonNext.setVisible(True)
        self.buttonNext.setEnabled(False)
        self.buttonSearch.setVisible(False)
        self.buttonStop.setEnabled(True)

        explorerDev = self._view.deviceTabAtIndex()
        if explorerDev is None:
            runWarning("No device is connected.", "Search unavailable")
            self.searchingStoppedUpdateState()
            return

        currentPath = explorerDev.selectedItemPath()
        if currentPath:
            if not explorerDev.itemExists(currentPath):
                self.searchingStoppedUpdateState()
                return
        else:
            runInformation("No item is selected.", "Search unavailable")
            self.searchingStoppedUpdateState()
            log.warning("Search cannot be performed since no reference item"
                        " is selected")
            return

        self._explorerDev = explorerDev
        self._explorerDev.startItemChanged.connect(self._startItemChanged)
        self._explorerDev.itemFound.connect(self.itemFoundUpdateState)
        self._explorerDev.itemNotFound.connect(self.itemNotFoundUpdateState)
        self._explorerDev.searchingStopped.connect(self._stopSearching)
        self._searching = True

        criteria = {
            'name': self._name,
            'role': self._role,
            'state': self._state,
            'text': self._text,
            'matchType': self._matchType,
            'caseSensitiveMatch': self._caseSensitiveMatch
        }
        deep = False
        if self._method == self._DEEP_METHOD:
            deep = True
        try:
            explorerDev.find(self.Check(criteria), deep)
            self._lastNames.add(self._name)
            if self._role:
                self._lastRoles.add(self._role)
            if self._state:
                self._lastStates.add(self._state)
            self._manualUpdate = True
            self._refreshCompleters()
            self._manualUpdate = False
            self._saveState()
        except:
            self._stopSearching()
예제 #11
0
파일: search.py 프로젝트: mlyko/tadek-ui
    def _startSearching(self):
        '''
        Starts the searching process.
        '''
        self.buttonNext.setVisible(True)
        self.buttonNext.setEnabled(False)
        self.buttonSearch.setVisible(False)
        self.buttonStop.setEnabled(True)

        explorerDev = self._view.deviceTabAtIndex()
        if explorerDev is None:
            runWarning("No device is connected.", "Search unavailable")
            self.searchingStoppedUpdateState()
            return

        currentPath = explorerDev.selectedItemPath()
        if currentPath:
            if not explorerDev.itemExists(currentPath):
                self.searchingStoppedUpdateState()
                return
        else:
            runInformation("No item is selected.", "Search unavailable")
            self.searchingStoppedUpdateState()
            log.warning("Search cannot be performed since no reference item"
                " is selected")
            return

        self._explorerDev = explorerDev
        self._explorerDev.startItemChanged.connect(self._startItemChanged)
        self._explorerDev.itemFound.connect(self.itemFoundUpdateState)
        self._explorerDev.itemNotFound.connect(self.itemNotFoundUpdateState)
        self._explorerDev.searchingStopped.connect(self._stopSearching)
        self._searching = True

        criteria = {
            'name': self._name,
            'role': self._role,
            'state': self._state,
            'text': self._text,
            'matchType': self._matchType,
            'caseSensitiveMatch': self._caseSensitiveMatch
        }
        deep = False
        if self._method == self._DEEP_METHOD:
            deep = True
        try:
            explorerDev.find(self.Check(criteria), deep)
            self._lastNames.add(self._name)
            if self._role:
                self._lastRoles.add(self._role)
            if self._state:
                self._lastStates.add(self._state)
            self._manualUpdate = True
            self._refreshCompleters()
            self._manualUpdate = False
            self._saveState()
        except:
            self._stopSearching()
예제 #12
0
 def _closeTabOfIndex(self, index):
     '''
     Closes a tab with test results of given index.
     '''
     title = self._tabWidget.tabText(index)
     if self._tabs[title].isClosable():
         log.debug("Closing result tab '%s'" % title)
         self._tabWidget.removeTab(index)
         del self._tabs[title]
     else:
         dialogs.runWarning("Result tab cannot be closed until the execution"
                            " of test cases is finished")
예제 #13
0
 def findNext(self):
     '''
     Runs the searching process again after a match was found.
     '''
     if not self._active:
         dialogs.runWarning("Device is disconnected")
         self.searchingStopped.emit()
         return
     log.info("Searching for next match")
     self._manualExpand = True
     self._manualSelect = True
     self._responseFind()
예제 #14
0
파일: device.py 프로젝트: mlyko/tadek-ui
 def findNext(self):
     '''
     Runs the searching process again after a match was found.
     '''
     if not self._active:
         dialogs.runWarning("Device is disconnected")
         self.searchingStopped.emit()
         return
     log.info("Searching for next match")
     self._manualExpand = True
     self._manualSelect = True
     self._responseFind()
예제 #15
0
파일: search.py 프로젝트: mlyko/tadek-ui
 def _compileExpression(self, pattern, flags, toLog):
     '''
     Compiles regular expression provided as pattern to check its
     correctness (and remembers it) and logs a message on failure.
     '''
     msg = "Regular expression \"%s\" is incorrect"
     msgToLog = "Regular expression for %s is incorrect"
     try:
         return re.compile(pattern, flags)
     except:
         runWarning(msg % pattern[:-1], "Incorrect expression")
         log.warning(msgToLog, toLog)
         raise
예제 #16
0
 def _compileExpression(self, pattern, flags, toLog):
     '''
     Compiles regular expression provided as pattern to check its
     correctness (and remembers it) and logs a message on failure.
     '''
     msg = "Regular expression \"%s\" is incorrect"
     msgToLog = "Regular expression for %s is incorrect"
     try:
         return re.compile(pattern, flags)
     except:
         runWarning(msg % pattern[:-1], "Incorrect expression")
         log.warning(msgToLog, toLog)
         raise
예제 #17
0
 def _closeTabOfIndex(self, index):
     '''
     Closes a tab with test results of given index.
     '''
     title = self._tabWidget.tabText(index)
     if self._tabs[title].isClosable():
         log.debug("Closing result tab '%s'" % title)
         self._tabWidget.removeTab(index)
         del self._tabs[title]
     else:
         dialogs.runWarning(
             "Result tab cannot be closed until the execution"
             " of test cases is finished")
예제 #18
0
 def addLocation(self):
     '''
     Adds an item to locations tree and enables it. A warning is displayed
     if path is invalid.
     '''
     path = QtGui.QFileDialog.getExistingDirectory(window())
     if not path:
         return
     log.debug("Adding test path '%s'" % path)
     message = self._addLocation(path)
     if message is not None:
         runWarning(message)
         return
     self._locItems[path].setCheckState(0, QtCore.Qt.Checked)
예제 #19
0
파일: tests.py 프로젝트: mlyko/tadek-ui
 def addLocation(self):
     '''
     Adds an item to locations tree and enables it. A warning is displayed
     if path is invalid.
     '''
     path = QtGui.QFileDialog.getExistingDirectory(window())
     if not path:
         return
     log.debug("Adding test path '%s'" % path)
     message = self._addLocation(path)
     if message is not None:
         runWarning(message)
         return
     self._locItems[path].setCheckState(0, QtCore.Qt.Checked)
예제 #20
0
 def _execute(self):
     '''
     Executes keyboard event based on key code and modifiers.
     '''
     log.info('Executing mouse event')
     path = self._deviceTab.selectedItemPath()
     if path is None:
         dialogs.runWarning("No accessible item is selected."
                            "Mouse events unavailable")
     else:
         x = int(self._x.value())
         y = int(self._y.value())
         button = self._buttons[self._button.checkedButton()]
         event = self._events[self._event.checkedButton()]
         self._deviceTab.device.requestDevice("requestMouseEvent",
                                              path, x, y, button, event)
예제 #21
0
 def _execute(self):
     '''
     Executes keyboard event based on key code and modifiers.
     '''
     log.info('Executing keyboard event')
     path = self._deviceTab.selectedItemPath()
     if path is None:
         dialogs.runWarning("No accessible item is selected. ",
                            "Keyboard events unavailable")
     else:
         keycode = int(self._keycode.text())
         items = self._modifiers.findItems('', QtCore.Qt.MatchContains)
         mods = [self._itemData(item)[1] for item in items
                                 if item.checkState() == QtCore.Qt.Checked]
         self._deviceTab.device.requestDevice("requestKeyboardEvent",
                                              path, keycode, mods)
예제 #22
0
 def _execute(self):
     '''
     Executes keyboard event based on key code and modifiers.
     '''
     log.info('Executing mouse event')
     path = self._deviceTab.selectedItemPath()
     if path is None:
         dialogs.runWarning("No accessible item is selected."
                            "Mouse events unavailable")
     else:
         x = int(self._x.value())
         y = int(self._y.value())
         button = self._buttons[self._button.checkedButton()]
         event = self._events[self._event.checkedButton()]
         self._deviceTab.device.requestDevice("requestMouseEvent", path, x,
                                              y, button, event)
예제 #23
0
 def _execute(self):
     '''
     Executes keyboard event based on key code and modifiers.
     '''
     log.info('Executing keyboard event')
     path = self._deviceTab.selectedItemPath()
     if path is None:
         dialogs.runWarning("No accessible item is selected. ",
                            "Keyboard events unavailable")
     else:
         keycode = int(self._keycode.text())
         items = self._modifiers.findItems('', QtCore.Qt.MatchContains)
         mods = [
             self._itemData(item)[1] for item in items
             if item.checkState() == QtCore.Qt.Checked
         ]
         self._deviceTab.device.requestDevice("requestKeyboardEvent", path,
                                              keycode, mods)
예제 #24
0
 def _addModifier(self, name, code):
     '''
     Adds modifier to the list.
     '''
     selected = self._modifiers.selectedItems()
     if name in self._MODIFIERS:
         dialogs.runWarning("Default modifier '%s' cannot be redefined"
                            % name)
         return
     if selected:
         self._setItemData(selected[0], name, code)
     elif name in self._userModifiers:
         if dialogs.runQuestion("Modifier '%s' already exists. Do you "
                                "want to update it?" % name):
             item = self._modifiers.findItems(name,
                                              QtCore.Qt.MatchExactly)[0]
             self._setItemData(item, name, code)
         else:
             return
     else:
         self._userModifiers.append(name)
         self._modifiers.scrollToItem(self._createItem(name, code))
     config.set(self._CONFIG_NAME, self._CONFIG_SECTION, name, code)
예제 #25
0
 def _addModifier(self, name, code):
     '''
     Adds modifier to the list.
     '''
     selected = self._modifiers.selectedItems()
     if name in self._MODIFIERS:
         dialogs.runWarning("Default modifier '%s' cannot be redefined" %
                            name)
         return
     if selected:
         self._setItemData(selected[0], name, code)
     elif name in self._userModifiers:
         if dialogs.runQuestion("Modifier '%s' already exists. Do you "
                                "want to update it?" % name):
             item = self._modifiers.findItems(name,
                                              QtCore.Qt.MatchExactly)[0]
             self._setItemData(item, name, code)
         else:
             return
     else:
         self._userModifiers.append(name)
         self._modifiers.scrollToItem(self._createItem(name, code))
     config.set(self._CONFIG_NAME, self._CONFIG_SECTION, name, code)
예제 #26
0
    def _openRecent(self):
        '''
        Opens a recent file containing test results in tabs.
        '''
        log.debug("Opening recent result file")

        path = self.sender().data()
        ext = os.path.splitext(path)[1]
        channel = None
        for c in channels.get():
            if (isinstance(c, channels.TestResultFileChannel) and
                c.fileExt() == ext):
                channel = c
                break
        if not channel:
            dialogs.runWarning("There are no readable channels accepting "
                               "'%s' files" % ext)
            return
        try:
            self.addTab(channel.read(path), os.path.split(path)[1],
                        tooltip=path)
        except Exception, ex:
            dialogs.runError("Error occurred while loading result file:\n%s"
                             % str(ex))