-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into one_button_ESC_key_handling
- Loading branch information
Showing
6 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ matrix: | |
env: | ||
- LLVM_VERSION=3.8 | ||
- TRAVIS_CONFIG=linux | ||
dist: precise | ||
sudo: false | ||
cache: | ||
apt: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
"""QGIS Unit tests for QgsFieldComboBox | ||
.. note:: This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
""" | ||
__author__ = 'Nyall Dawson' | ||
__date__ = '20/07/2017' | ||
__copyright__ = 'Copyright 2017, The QGIS Project' | ||
# This will get replaced with a git SHA1 when you do a git archive | ||
__revision__ = '$Format:%H$' | ||
|
||
import qgis # NOQA | ||
|
||
from qgis.core import QgsFields, QgsVectorLayer, QgsFieldProxyModel | ||
from qgis.gui import QgsFieldComboBox | ||
from qgis.PyQt.QtCore import QVariant, Qt | ||
|
||
from qgis.testing import start_app, unittest | ||
|
||
start_app() | ||
|
||
|
||
def create_layer(): | ||
layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer&field=fldint2:integer", | ||
"addfeat", "memory") | ||
assert layer.isValid() | ||
return layer | ||
|
||
|
||
def create_model(): | ||
l = create_layer() | ||
m = QgsFieldModel() | ||
m.setLayer(l) | ||
return l, m | ||
|
||
|
||
class TestQgsFieldComboBox(unittest.TestCase): | ||
|
||
def testGettersSetters(self): | ||
""" test combobox getters/setters """ | ||
l = create_layer() | ||
w = QgsFieldComboBox() | ||
w.setLayer(l) | ||
self.assertEqual(w.layer(), l) | ||
|
||
w.setField('fldint') | ||
self.assertEqual(w.currentField(), 'fldint') | ||
|
||
def testFilter(self): | ||
""" test setting field with filter """ | ||
l = create_layer() | ||
w = QgsFieldComboBox() | ||
w.setLayer(l) | ||
w.setFilters(QgsFieldProxyModel.Int) | ||
self.assertEqual(w.layer(), l) | ||
|
||
w.setField('fldint') | ||
self.assertEqual(w.currentField(), 'fldint') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |