Ejemplo n.º 1
0
class TestQtGuiWithDpi:

    @classmethod
    def setup_class(cls):
        ''' Initializes a QtGui.QApplication '''
        cls.app = QApplication([])

    @classmethod
    def teardown_class(cls):
        ''' Destruct the QtGui.QApplication '''
        cls.app.deleteLater()

    def setup(self):
        ''' Construct a tested class '''
        self.tested_cls = QtGuiWithDpi()

    def test_set_width_with_dpi(self):
        assert self.tested_cls.set_width_with_dpi(300) == round(300 * 1.5)

    def test_set_height_with_dpi(self):
        assert self.tested_cls.set_height_with_dpi(300) == round(300 * 1.25)

    def test_adjust_dpi(self):
        assert self.tested_cls.adjust_dpi(100, 40) == QSize(round(100 * 1.5), round(40 * 1.25))
        assert self.tested_cls.adjust_dpi(QSize(40, 100)) == QSize(round(40 * 1.5), round(100 * 1.25))

    def test_qspacer_item_with_dpi(self):
        dummy_qspace_item = self.tested_cls.qspacer_item_with_dpi(100, 100)
        assert dummy_qspace_item.sizeHint() == QSize(round(100 * 1.5), round(100 * 1.25))

    def test_qrect_with_dpi(self):
        dummy_qrect = self.tested_cls.qrect_with_dpi(10, 10, 100, 100)
        assert dummy_qrect.topLeft() == QPoint(round(10 * 1.5), round(10 * 1.25))
        assert dummy_qrect.size() == QSize(round(100 * 1.5), round(100 * 1.25))
Ejemplo n.º 2
0
 def setup(self):
     ''' Construct a tested class '''
     self.tested_cls = QtGuiWithDpi()