示例#1
0
    def testConstructors(self):
        # empty
        frag = QgsTextFragment()
        self.assertFalse(frag.text())

        fragment = QgsTextFragment('ludicrous gibs!')
        self.assertEqual(fragment.text(), 'ludicrous gibs!')
示例#2
0
    def testConstructors(self):
        # empty
        block = QgsTextBlock()
        self.assertEqual(len(block), 0)

        # single fragment block
        fragment = QgsTextFragment('ludicrous gibs!')
        block = QgsTextBlock(fragment)
        self.assertEqual(len(block), 1)
        self.assertEqual(block[0].text(), fragment.text())
示例#3
0
    def testConstructors(self):
        # empty
        doc = QgsTextDocument()
        self.assertEqual(len(doc), 0)

        # single block document
        block = QgsTextBlock()
        doc = QgsTextDocument(block)
        self.assertEqual(len(doc), 1)
        self.assertEqual(len(doc[0]), 0)

        # single fragment document
        fragment = QgsTextFragment('ludicrous gibs!')
        doc = QgsTextDocument(fragment)
        self.assertEqual(len(doc), 1)
        self.assertEqual(len(doc[0]), 1)
        self.assertEqual(doc[0][0].text(), fragment.text())
示例#4
0
 def testSetText(self):
     fragment = QgsTextFragment()
     fragment.setText('ludicrous gibs!')
     self.assertEqual(fragment.text(), 'ludicrous gibs!')
示例#5
0
 def testCapitalize(self):
     fragment = QgsTextFragment('ludicrous gibs!')
     fragment.applyCapitalization(QgsStringUtils.TitleCase)
     self.assertEqual(fragment.text(), 'Ludicrous Gibs!')