Ejemplo n.º 1
0
    def test_createGUI_accept(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)
        rank = self.__rnd.randint(1, 6)
        lengths = [str(self.__rnd.randint(1, 100)) for r in range(rank)]
        form = DimensionsDlg()
        form.rank = rank
        form.lengths = lengths
        self.assertEqual(form.rank, rank)
        self.assertEqual(form.lengths, lengths)
        self.assertEqual(form.subItems, ["dim"])
        self.assertTrue(isinstance(form.ui, Ui_DimensionsDlg))

        self.assertEqual(form.createGUI(), None)
        form.show()

        form.accept()
        self.assertEqual(form.result(), 1)

        self.assertEqual(form.rank, rank)
        self.assertEqual(form.lengths, lengths)
        self.assertEqual(form.ui.rankSpinBox.value(), rank)
        self.assertEqual(form.ui.dimTableWidget.columnCount(), 1)
        self.assertEqual(form.ui.dimTableWidget.rowCount(), rank)
        for r in range(rank):
            it = form.ui.dimTableWidget.item(r, 0)
            self.assertEqual(it.text(), str(lengths[r]))
Ejemplo n.º 2
0
    def test_constructor(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)
        form = DimensionsDlg()
        self.assertEqual(form.rank, 0)
        self.assertEqual(form.lengths, [])
        self.assertEqual(form.subItems, ["dim"])
        self.assertTrue(isinstance(form.ui, Ui_DimensionsDlg))

        self.assertEqual(form.result(), 0)
Ejemplo n.º 3
0
    def test_createGUI_doc_ui_text(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)
        rank = self.__rnd.randint(1, 6)
        lengths = [self.__rnd.randint(1, 100) for r in range(rank)]
        form = DimensionsDlg()
        self.assertEqual(form.rank, 0)
        self.assertEqual(form.lengths, [])
        self.assertEqual(form.subItems, ["dim"])
        self.assertTrue(isinstance(form.ui, Ui_DimensionsDlg))

        self.assertEqual(form.createGUI(), None)
        form.show()

        #        QTest.keyClicks(form.ui.rankSpinBox, str(rank))
        form.ui.rankSpinBox.setValue(rank)

        self.assertEqual(form.ui.rankSpinBox.value(), rank)
        self.assertEqual(form.ui.dimTableWidget.columnCount(), 1)
        self.assertEqual(form.ui.dimTableWidget.rowCount(), rank)

        for r in range(rank):
            it = form.ui.dimTableWidget.item(r, 0)
            self.assertEqual(it.text(), '')

        cancelWidget = form.ui.buttonBox.button(form.ui.buttonBox.Cancel)
        QTest.mouseClick(cancelWidget, Qt.LeftButton)

        self.assertEqual(form.result(), 0)

        self.assertEqual(form.rank, rank)
        self.assertEqual(form.lengths, [None] * rank)
Ejemplo n.º 4
0
    def test_createGUI_len_ui_text_err_2(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)
        rank = self.__rnd.randint(1, 6)
        lengths = [str(self.__rnd.randint(1, 100)) for r in range(rank)]
        form = DimensionsDlg()
        self.assertEqual(form.rank, 0)
        self.assertEqual(form.lengths, [])
        self.assertEqual(form.subItems, ["dim"])
        self.assertTrue(isinstance(form.ui, Ui_DimensionsDlg))

        self.assertEqual(form.createGUI(), None)
        form.show()

        form.ui.rankSpinBox.setValue(rank)
        #        QTest.keyClicks(form.ui.rankSpinBox, str(rank))

        self.assertEqual(form.ui.rankSpinBox.value(), rank)
        self.assertEqual(form.ui.dimTableWidget.columnCount(), 1)
        self.assertEqual(form.ui.dimTableWidget.rowCount(), rank)

        for r in range(rank):
            it = form.ui.dimTableWidget.item(r, 0)
            self.assertEqual(it.text(), '')

        for r in range(rank):
            form.ui.dimTableWidget.setCurrentCell(r, 0)
            it = QTableWidgetItem(unicode(lengths[r]))
            form.ui.dimTableWidget.setItem(r, 0, it)

        for r in range(rank):
            QTimer.singleShot(10, self.checkMessageBox)
            form.ui.dimTableWidget.setCurrentCell(r, 0)
            #            QTest.keyClicks(form.ui.dimTableWidget, str(lengths[r]))
            it = QTableWidgetItem("blew")
            form.ui.dimTableWidget.setItem(r, 0, it)
            self.assertEqual(self.text, 'Wrong value of the edited length')

        okWidget = form.ui.buttonBox.button(form.ui.buttonBox.Ok)
        QTest.mouseClick(okWidget, Qt.LeftButton)

        self.assertEqual(form.result(), 1)

        self.assertEqual(form.rank, rank)
        self.assertEqual(form.lengths, lengths)
Ejemplo n.º 5
0
    def test_createGUI(self):
        fun = sys._getframe().f_code.co_name
        print "Run: %s.%s() " % (self.__class__.__name__, fun)
        form = DimensionsDlg()
        self.assertEqual(form.rank, 0)
        self.assertEqual(form.lengths, [])
        self.assertEqual(form.subItems, ["dim"])
        self.assertTrue(isinstance(form.ui, Ui_DimensionsDlg))

        self.assertEqual(form.createGUI(), None)
        form.show()

        self.assertEqual(form.result(), 0)

        self.assertEqual(form.rank, 0)
        self.assertEqual(form.lengths, [])
        self.assertEqual(form.ui.rankSpinBox.value(), 0)
        self.assertEqual(form.ui.dimTableWidget.columnCount(), 1)
        self.assertEqual(form.ui.dimTableWidget.rowCount(), 0)