Skip to content
Permalink
Browse files

additional test enable-state in multi-selection in valueRelation

  • Loading branch information
signedav committed Jan 24, 2019
1 parent 727bca9 commit 237e0bcb4a19f6e9539a7a5e0fb1962ad72a847c
Showing with 20 additions and 2 deletions.
  1. +20 −2 tests/src/python/test_qgseditwidgets.py
@@ -18,8 +18,8 @@
from qgis.gui import QgsGui

from qgis.testing import start_app, unittest
from qgis.PyQt.QtCore import QVariant
from qgis.PyQt.QtWidgets import QTextEdit
from qgis.PyQt.QtCore import Qt, QVariant
from qgis.PyQt.QtWidgets import QTextEdit, QTableWidgetItem

start_app()

@@ -108,6 +108,24 @@ def test_enableDisable(self):
wrapper.setEnabled(True)
self.assertTrue(widget.isEnabled())

def test_enableDisableOnTableWidget(self):
reg = QgsGui.editorWidgetRegistry()
layer = QgsVectorLayer("none?field=number:integer", "layer", "memory")
wrapper = reg.create('ValueRelation', layer, 0, {'AllowMulti': 'True'}, None, None)

widget = wrapper.widget()
item = QTableWidgetItem('first item')
widget.setItem(0, 0, item)

# does not change the state the whole widget but the single items instead
wrapper.setEnabled(False)
# widget still true, but items false
self.assertTrue(widget.isEnabled())
self.assertNotEqual(widget.item(0, 0).flags(), widget.item(0, 0).flags() | Qt.ItemIsEnabled)
wrapper.setEnabled(True)
self.assertTrue(widget.isEnabled())
self.assertEqual(widget.item(0, 0).flags(), widget.item(0, 0).flags() | Qt.ItemIsEnabled)


class TestQgsValueMapEditWidget(unittest.TestCase):
VALUEMAP_NULL_TEXT = "{2839923C-8B7D-419E-B84B-CA2FE9B80EC7}"

0 comments on commit 237e0bc

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