示例#1
0
class TestInfoObject(unittest.TestCase):

    def setUp(self):
        self._instance = InfoObject()

    def testConstructor(self):
        self.assertTrue(InfoObject())

    def testConstructorWithParent(self):
        self.assertTrue(InfoObject(QObject()))

    def testConstructorInvalidParameter(self):
        with self.assertRaises(TypeError):
            InfoObject(str(''))

    def testEqualOperator(self):
        sameInfoObject = self._instance
        self.assertTrue(sameInfoObject == self._instance)

    def testInequalityOperator(self):
        newInfoObject = InfoObject()
        self.assertTrue(newInfoObject != self._instance)

    def testPropertiesAcessorsOneProperty(self):
        self._instance.setProperties({"test": "test"})
        self.assertEqual(self._instance.properties(), {"test": "test"})

    def testPropertiesAcessorsSetProperties(self):
        self._instance.setProperties({"test": "test", "test1": 1})
        self.assertEqual(self._instance.properties(), {"test": "test", "test1": 1})

    def testPropertySlotsString(self):
        self._instance.setProperty("key", "value")
        self.assertEqual(self._instance.property("key"), "value")

    def testPropertySlotsInvalidKey(self):
        self._instance.setProperty("key", "value")
        self.assertEqual(self._instance.property("keys"), None)
示例#2
0
    def options(self, asInfoObject=False):
        """Return current options

        If `asInfoObject` is True, return a InfoObject otherwise a dictionary
        """
        if asInfoObject:
            color=self.pbBgColor.color()

            returned=InfoObject()
            returned.setProperty('compression', self.hsCompressionLevel.value())
            returned.setProperty('indexed', self.cbIndexed.isChecked())
            returned.setProperty('interlaced', self.cbInterlacing.isChecked())
            returned.setProperty('saveSRGBProfile', self.cbSaveICCProfile.isChecked())
            returned.setProperty('forceSRGB', self.cbForceConvertsRGB.isChecked())
            returned.setProperty('alpha', self.rbStoreAlpha.isChecked())
            returned.setProperty('transparencyFillcolor', [color.red(), color.green(), color.blue()])
        else:
            returned={
                'compression': self.hsCompressionLevel.value(),
                'indexed': self.cbIndexed.isChecked(),
                'interlaced': self.cbInterlacing.isChecked(),
                'saveSRGBProfile': self.cbSaveICCProfile.isChecked(),
                'forceSRGB': self.cbForceConvertsRGB.isChecked(),
                'alpha': self.rbStoreAlpha.isChecked(),
                'transparencyFillcolor': self.pbBgColor.color()
            }

        return returned
示例#3
0
    def options(self, asInfoObject=False):
        """Return current options

        If `asInfoObject` is True, return a InfoObject otherwise a dictionary
        """
        if asInfoObject:
            color=self.pbBgColor.color()

            returned=InfoObject()
            returned.setProperty('quality', self.hsQuality.value())
            returned.setProperty('smoothing', self.hsSmoothing.value())
            returned.setProperty('subsampling', self.cbxSubsampling.currentIndex())
            returned.setProperty('progressive', self.cbProgressive.isChecked())
            returned.setProperty('optimize', self.cbOptimize.isChecked())
            returned.setProperty('saveProfile', self.cbSaveICCProfile.isChecked())
            returned.setProperty('transparencyFillcolor', [color.red(), color.green(), color.blue()])
        else:
            returned={
                'quality': self.hsQuality.value(),
                'smoothing': self.hsSmoothing.value(),
                'subsampling': self.cbxSubsampling.currentIndex(),
                'progressive': self.cbProgressive.isChecked(),
                'optimize': self.cbOptimize.isChecked(),
                'saveProfile': self.cbSaveICCProfile.isChecked(),
                'transparencyFillcolor': self.pbBgColor.color()
            }

        return returned