Exemplo n.º 1
0
def makeIconButton(icon, parent=None):
    btn = QtWidgets.QPushButton("", parent)
    btn.setIcon(icon)
    btn.setFlat(True)
    btn.setIconSize(QtCore.QSize(20, 20))
    btn.setFixedSize(QtCore.QSize(24, 24))
    return btn
Exemplo n.º 2
0
 def _createIniSettings():
     return QtCore.QSettings(
         QtCore.QSettings.IniFormat,
         QtCore.QSettings.UserScope,
         constants.ORG_MGLAND,
         constants.APP_NAME,
     )
Exemplo n.º 3
0
 def __init__(self, parent=None):
     QtCore.QObject.__init__(self, parent=parent)
     self._lastCmd = None
     self._process = QtCore.QProcess(self)
     self._process.error.connect(self._onGoToCodeError)
     self._process.readyReadStandardError.connect(
         self._onReadyReadStandardError)
Exemplo n.º 4
0
def makeMenuToolButton(icon=None, toolTip="", parent=None):
    btn = QtWidgets.QToolButton(parent)
    if icon:
        btn.setIcon(icon)
    btn.setToolTip(toolTip)
    btn.setContentsMargins(0, 0, 0, 0)
    btn.setIconSize(QtCore.QSize(20, 20))
    btn.setPopupMode(btn.InstantPopup)
    menu = QtWidgets.QMenu(btn)
    btn.setMenu(menu)
    return (btn, menu)
Exemplo n.º 5
0
    def addButton(self, btnId, button, overrideStyle=True):
        existBtn = self._buttons.get(btnId)
        if existBtn:
            return existBtn

        button.setFixedSize(
            QtCore.QSize(self._BUTTON_DIMENTION, self._BUTTON_DIMENTION))
        button.setParent(self)
        if overrideStyle:
            button.setStyleSheet("QAbstractButton{background:transparent;}")
        self._buttons[btnId] = button
        self._refreshButtons()
        return button
Exemplo n.º 6
0
 def _onBrowseBtnClicked(self):
     btmLeft = self._browseBtn.mapToGlobal(
         QtCore.QPoint(0, self._browseBtn.height()))
     self._browseMenu.exec_(btmLeft)
Exemplo n.º 7
0
    def reload(self, keepUiStates=True):
        if keepUiStates:
            self._viewStates.save()

        self._testCases = []
        self._rootTestItem = None
        self._allItemsIdMap = {}
        self.clear()

        startDirOrModule = self._testManager.startDirOrModule()
        if not startDirOrModule:
            return

        self._rootTestItem = QtWidgets.QTreeWidgetItem([startDirOrModule])
        self._rootTestItem.setToolTip(0, startDirOrModule)
        self._rootTestItem.setData(0, QtCore.Qt.UserRole, constants.ITEM_CATEGORY_ALL)
        self._setItemIconState(self._rootTestItem, constants.TEST_RESULT_NONE)
        self.addTopLevelItem(self._rootTestItem)

        self._allItemsIdMap[startDirOrModule] = self._rootTestItem

        isModule = not pathutils.isPath(startDirOrModule)
        headingCount = 0
        heading = ""
        if isModule:
            headingCount = len(startDirOrModule) + 1
            heading = startDirOrModule + "."

        testCount = 0
        for test in self._testManager.iterAllTestIds():
            testCount = testCount + 1
            if isModule and test.startswith(startDirOrModule):
                test = test[headingCount:]
            testPaths = test.split(".")
            cParent = self._rootTestItem
            for i, p in enumerate(testPaths):
                path = heading + ".".join(testPaths[0 : (i + 1)])
                if path in self._allItemsIdMap:
                    cParent = self._allItemsIdMap[path]
                    continue

                item = QtWidgets.QTreeWidgetItem(cParent)
                item.setText(0, p)
                item.setToolTip(0, path)
                item.setSizeHint(0, QtCore.QSize(20, 20))
                self._allItemsIdMap[path] = item
                cParent = item

            testCase = cParent
            testCase.setData(0, QtCore.Qt.UserRole, constants.ITEM_CATEGORY_TEST)
            self._setItemIconState(testCase, constants.TEST_RESULT_NONE)
            self._testCases.append(cParent)

            caseItem = testCase.parent()
            caseItem.setData(0, QtCore.Qt.UserRole, constants.ITEM_CATEGORY_SUITE)
            self._setItemIconState(caseItem, constants.TEST_RESULT_NONE)

            moduleItem = caseItem.parent()
            moduleItem.setData(0, QtCore.Qt.UserRole, constants.ITEM_CATEGORY_MODULE)
            self._setItemIconState(moduleItem, constants.TEST_RESULT_NONE)

            packageItem = moduleItem.parent()
            while packageItem is not self._rootTestItem and packageItem:
                packageItem.setData(
                    0, QtCore.Qt.UserRole, constants.ITEM_CATEGORY_PACKAGE
                )
                self._setItemIconState(packageItem, constants.TEST_RESULT_NONE)
                packageItem = packageItem.parent()

        self._uiStream.write("\n{}\n".format("-" * 20))
        if not self._testManager.hasLastListerError():
            self._uiStream.write("{} tests collected.\n\n".format(testCount))
        else:
            with self._uiStream.resultCtx(constants.TEST_RESULT_ERROR):
                msg = "Error collecting tests from {}.\n\n".format(
                    self._testManager.startDirOrModule()
                )
                self._uiStream.write(msg)

        if keepUiStates:
            self._viewStates.restore()
        else:
            self._resetExpandStates(self._rootTestItem)
Exemplo n.º 8
0
    def __init__(self, startDirOrModule=None, topDir=None, parent=None):
        parent = parent or dcc.findParentWindow()
        QtWidgets.QWidget.__init__(self, parent)
        self._uiStream = uistream.UiStream()

        self._initIcons()

        self._testManager = testmanager.TestManager(self, startDirOrModule,
                                                    topDir)

        self._mainLay = uiutils.makeMainLayout(self)
        self.setContentsMargins(0, 0, 0, 0)

        # Top layout ------------------------------
        self._dirLayout = uiutils.makeMinorHorizontalLayout()
        self._testRunnerActions = []
        self._makeDirWidgets()
        self._mainLay.addLayout(self._dirLayout)

        self._splitter = QtWidgets.QSplitter(self)
        self._mainLay.addWidget(self._splitter, 1)

        # left layout -----------------------------------
        self._leftWidget, leftLay = self._createSplitterContent()

        _topLayout = uiutils.makeMinorHorizontalLayout()
        self._makeTreeTopWidgets(_topLayout)
        leftLay.addLayout(_topLayout)

        self._view = unittesttree.UnitTestTreeView(self)
        self._view.runAllTest.connect(self._runAllTests)
        self._view.runTests.connect(self._runTests)
        self._view.runSetupOnly.connect(self._runTestSetupOnly)
        self._view.runWithoutTearDown.connect(self._runTestWithoutTearDown)
        self._view.searchNeeded.connect(self._prepareTreeSearch)
        self._view.itemSelectionChanged.connect(self._viewSelectionChanged)

        leftLay.addWidget(self._view)

        # right layout -----------------------------------
        self._rightWidget, rightLay = self._createSplitterContent()
        _logTopLayout = uiutils.makeMinorHorizontalLayout()
        self._logBrowser = logbrowser.LogBrowser(self)
        self._logBrowser.searchNeeded.connect(self._prepareLogSearch)
        self._makeLogBrowserTopWidgets(_logTopLayout)
        rightLay.addLayout(_logTopLayout, 0)
        rightLay.addWidget(self._logBrowser, 1)

        self._splitter.setSizes([230, 500])
        self._splitter.setStretchFactor(0, 0)
        self._splitter.setStretchFactor(1, 1)

        # bottom -----------------------------------
        self._statusLbl = statuslabel.StatusLabel(self)
        self._mainLay.addWidget(self._statusLbl)

        _btmLayout = uiutils.makeMinorHorizontalLayout()
        self._makeRunButtons(_btmLayout)
        self._mainLay.addLayout(_btmLayout)

        self.resize(QtCore.QSize(900, 500))
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose,
                          True)  # for reimport convenience.
        self.setTabOrder(self._rootDirLE, self._treeFilterLE)
        self.setTabOrder(self._treeFilterLE, self._view)
        self.setTabOrder(self._view, self._logBrowser)
        self.setWindowIcon(self._iutestIcon)
        self.setWindowFlags(QtCore.Qt.Window)

        self._updateWindowTitle()
        self._loadLastDirsFromSettings()
        self._restorePanelVisState()

        self.resetUiTestManager()

        QtCore.QTimer.singleShot(0, self._initialLoad)