Esempio n. 1
0
    def _resetItem(self, item, applyToAllChildren=False):
        item.setText(1, "")
        if variantToPyValue(item.data(1, QtCore.Qt.UserRole)):
            item.setData(1, QtCore.Qt.UserRole, 0)

        if applyToAllChildren:
            for i in range(item.childCount()):
                self._resetItem(item.child(i), applyToAllChildren)
Esempio n. 2
0
 def onSingleTestStop(self, testId, endTime):
     _, testId = self._testManager.parseParameterizedTestId(testId)
     item = self._findItemById(testId)
     if item:
         startTime = variantToPyValue(item.data(1, QtCore.Qt.UserRole))
         item.setData(1, QtCore.Qt.UserRole + 1, endTime)
         rep = "%.3f s" % (endTime - startTime)
         item.setText(1, rep)
Esempio n. 3
0
 def showResultOnItemByTestId(self, testId, state):
     _, testId = self._testManager.parseParameterizedTestId(testId)
     item = self._findItemById(testId)
     if item:
         # For parameterized test, some might succeed but others might failed, we make sure
         # we set failed for this situation.
         if state == constants.TEST_RESULT_SKIP or state > variantToPyValue(
             self._stateOfItem(item)
         ):
             self._setItemIconState(item, state)
Esempio n. 4
0
 def onSingleTestStart(self, testId, startTime):
     isParameterized, testId = self._testManager.parseParameterizedTestId(testId)
     item = self._findItemById(testId)
     if item:
         self.focusItem(item)
         self._setTestIconStateToAncestors(item, constants.TEST_RESULT_RUNNING)
         if not isParameterized or not variantToPyValue(
             item.data(1, QtCore.Qt.UserRole)
         ):
             item.setData(1, QtCore.Qt.UserRole, startTime)
             item.setText(1, "running...")
Esempio n. 5
0
    def _calculateAncestorItemStates(self, item, updatedIds):
        cId = self.testIdOfItem(item)
        if cId in updatedIds:
            return

        updatedIds.add(cId)
        stateToSet = constants.TEST_RESULT_NONE
        for i in range(item.childCount()):
            cState = variantToPyValue(item.child(i).data(0, QtCore.Qt.UserRole + 1))
            stateToSet = max(stateToSet, cState)

        self._setItemIconState(item, stateToSet)

        if item is self._rootTestItem:
            return

        self._calculateAncestorItemStates(item.parent(), updatedIds)
Esempio n. 6
0
    def _onTestRunnerSwitched(self):
        act = self.sender()
        if not act:
            return

        runnerMode = variantToPyValue(act.data())
        self._testManager.setRunnerMode(runnerMode)
        runner = self._testManager.getRunner()
        self._updateConfigButton(runner)

        self._uiStream.write(
            ">> Switch to unittest runner <b>{}</b>.<br>".format(
                runner.name()))

        self._onReloadUiButtonClicked()
        appsettings.get().saveSimpleConfig(
            constants.CONFIG_KEY_LAST_RUNNER_MODE, runnerMode)
        for act in self._testRunnerActions:
            self._updateLabelOfTestRunnerAct(act, runnerMode)
Esempio n. 7
0
    def _itemMatchs(self, item, keywords):
        state = variantToPyValue(item.data(0, QtCore.Qt.UserRole + 1))
        stateMatch = False
        txtMatch = True
        lbl = self.testIdOfItem(item).lower()
        hasFilter = False
        for each in keywords:
            if not each.startswith(":"):
                if each not in lbl:
                    return False

            if each.startswith(":"):
                hasFilter = True
                if not stateMatch:
                    desiredState = constants.TEST_RESULT_NONE
                    if each in constants.KEYWORD_TEST_STATES:
                        desiredState = constants.KEYWORD_TEST_STATES[each]
                    if desiredState < 0:
                        stateMatch = state > 0
                    else:
                        stateMatch = state == desiredState

        stateMatch = stateMatch or not hasFilter
        return stateMatch and txtMatch
Esempio n. 8
0
 def simpleConfigValue(self, key, defaultValue=None):
     value = self._qsettings().value(key, defaultValue)
     return variantToPyValue(value)
Esempio n. 9
0
 def _setSelectedItemsLevel(self):
     level = variantToPyValue(self.sender().data())
     loggingutils.setLoggingLevel(level, *self.selectedTestIds())
Esempio n. 10
0
 def _stateOfItem(self, item):
     return variantToPyValue(item.data(0, QtCore.Qt.UserRole + 1))
Esempio n. 11
0
 def _categoryOfItem(self, item):
     return variantToPyValue(item.data(0, QtCore.Qt.UserRole))
Esempio n. 12
0
 def _updateLabelOfTestRunnerAct(self, act, currentMode):
     runnerMode = variantToPyValue(act.data())
     runner = self._testManager.getRunnerByMode(runnerMode)
     suffix = " [actived]" if runnerMode == currentMode else ""
     lbl = runner.name() + suffix
     act.setText(lbl)