Skip to content
Permalink
Browse files

Add test case for backgroundColor serialization

  • Loading branch information
elpaso committed Feb 25, 2019
1 parent e63b2ef commit 94b5fed57ae337500d3fecca9c87aba42f5ba102
Showing with 21 additions and 3 deletions.
  1. +21 −3 tests/src/python/test_qgseditformconfig.py
@@ -20,11 +20,14 @@
QgsVectorLayer,
QgsReadWriteContext,
QgsEditFormConfig,
QgsFetchedContent)
QgsFetchedContent,
QgsAttributeEditorContainer,
)
from qgis.gui import QgsGui

from qgis.testing import start_app, unittest
from qgis.PyQt.QtXml import QDomDocument, QDomElement
from qgis.PyQt.QtGui import QColor
from utilities import unitTestDataPath
import socketserver
import threading
@@ -84,14 +87,16 @@ def testFormUi(self):
config.setLayout(QgsEditFormConfig.GeneratedLayout)
self.assertEqual(config.layout(), QgsEditFormConfig.GeneratedLayout)

uiLocal = os.path.join(unitTestDataPath(), '/qgis_local_server/layer_attribute_form.ui')
uiLocal = os.path.join(
unitTestDataPath(), '/qgis_local_server/layer_attribute_form.ui')
config.setUiForm(uiLocal)
self.assertEqual(config.layout(), QgsEditFormConfig.UiFileLayout)

config.setLayout(QgsEditFormConfig.GeneratedLayout)
self.assertEqual(config.layout(), QgsEditFormConfig.GeneratedLayout)

uiUrl = 'http://localhost:' + str(self.port) + '/qgis_local_server/layer_attribute_form.ui'
uiUrl = 'http://localhost:' + \
str(self.port) + '/qgis_local_server/layer_attribute_form.ui'
config.setUiForm(uiUrl)
self.assertEqual(config.layout(), QgsEditFormConfig.UiFileLayout)
content = QgsApplication.networkContentFetcherRegistry().fetch(uiUrl)
@@ -140,6 +145,19 @@ def testLabelOnTop(self):
self.assertFalse(config.labelOnTop(0))
self.assertFalse(config.labelOnTop(1))

def test_backgroundColorSerialize(self):
"""Test backgroundColor serialization"""

layer = self.createLayer()
config = layer.editFormConfig()
color_name = '#ff00ff'
container = QgsAttributeEditorContainer('container name', None, QColor('#ff00ff'))
doc = QDomDocument()
element = container.toDomElement(doc)
config = QgsEditFormConfig()
container2 = config.attributeEditorElementFromDomElement(element, None, self.layer.id())
self.assertEqual(container2.backgroundColor().name(), color_name)


if __name__ == '__main__':
unittest.main()

0 comments on commit 94b5fed

Please sign in to comment.
You can’t perform that action at this time.