本文整理汇总了Python中qgis.PyQt.QtTest.QTest类的典型用法代码示例。如果您正苦于以下问题:Python QTest类的具体用法?Python QTest怎么用?Python QTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testPublishLayersDialog
def testPublishLayersDialog(self):
# test the content of the GUI
for idx, ws in enumerate(self.cat.get_workspaces()):
if ws.name == WORKSPACE:
wsIdx = idx
if ws.name == WORKSPACEB:
wsIdxB = idx
dialog = PublishLayersDialog(self.cat)
self.assertEquals(5, dialog.table.columnCount())
self.assertEquals(8, dialog.table.rowCount())
# test that cancel return an empty list of layer to publish
dialog = PublishLayersDialog(self.cat)
cancelWidget = dialog.buttonBox.button(dialog.buttonBox.Cancel)
QTest.mouseClick(cancelWidget, Qt.LeftButton)
self.assertIsNone(dialog.topublish)
# check that returned layers in the correct workspaces
# step 1: set first two layer to publish
dialog.table.item(0,0).setCheckState(Qt.Checked)
dialog.table.item(1,0).setCheckState(Qt.Checked)
# step 2: set WS where to publish
dialog.table.cellWidget(0,1).setCurrentIndex(wsIdx)
dialog.table.cellWidget(1,1).setCurrentIndex(wsIdxB)
# step 3: press ok
okWidget = dialog.buttonBox.button(dialog.buttonBox.Ok)
QTest.mouseClick(okWidget, Qt.LeftButton)
# step 4: last check
self.assertIsNotNone(dialog.topublish)
self.assertEquals(WORKSPACE, dialog.topublish[0][1].name)
self.assertEquals(WORKSPACEB, dialog.topublish[1][1].name)
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:31,代码来源:guitests.py
示例2: test_mouse_drag
def test_mouse_drag(self):
"""Test setting extents by dragging works.
This currently fails as QTest does not properly do the mouse
interactions with the canvas.
"""
# Imported here because it is not available in OSX QGIS bundle
# pylint: disable=redefined-outer-name
from qgis.PyQt.QtTest import QTest
# Click the capture button
QTest.mouseClick(self.dialog.capture_button, Qt.LeftButton)
# drag a rect on the canvas
QTest.mousePress(CANVAS, Qt.LeftButton, pos=QPoint(0, 0), delay=500)
QTest.mouseRelease(
CANVAS, Qt.LeftButton,
pos=QPoint(300, 300),
delay=-1)
# on drag the extents selector windows should appear again
QTest.qWaitForWindowExposed(self.dialog)
# Click ok to dispose of the window again
ok = self.dialog.button_box.button(QtWidgets.QDialogButtonBox.Ok)
QTest.mouseClick(ok, Qt.LeftButton)
# Check the extent emitted on closing teh dialog is correct
expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0)
self.assertEqual(self.extent.toString(), expected_extent.toString())
开发者ID:inasafe,项目名称:inasafe,代码行数:30,代码来源:test_extent_selector.py
示例3: testSelectAllButton
def testSelectAllButton(self):
dialog = LayerGroupDialog(self.cat)
QTest.mouseClick(dialog.selectAllButton, Qt.LeftButton)
for i in range(dialog.table.rowCount()):
self.assertTrue(dialog.table.cellWidget(i, 0).isChecked())
QTest.mouseClick(dialog.selectAllButton, Qt.LeftButton)
for i in range(dialog.table.rowCount()):
self.assertFalse(dialog.table.cellWidget(i, 0).isChecked())
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:8,代码来源:guitests.py
示例4: test_100_auth_db
def test_100_auth_db(self):
for kind in self.config_list():
config = self.config_obj(kind, base=False)
msg = 'Could not store {0} config'.format(kind)
self.assertTrue(self.authm.storeAuthenticationConfig(config), msg)
msg = 'Could not store a sample of all configs in auth db'
self.assertTrue(
(len(self.authm.configIds()) == len(self.config_list())), msg)
msg = 'Could not retrieve available configs from auth db'
self.assertTrue(len(self.authm.availableAuthMethodConfigs()) > 0, msg)
backup = None
resetpass, backup = self.authm.resetMasterPassword(
'newpass', self.mpass, True, backup)
msg = 'Could not reset master password and/or re-encrypt configs'
self.assertTrue(resetpass, msg)
# qDebug('Backup db path: {0}'.format(backup))
msg = 'Could not retrieve backup path for reset master password op'
self.assertIsNotNone(backup)
self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg)
msg = 'Could not verify reset master password'
self.assertTrue(self.authm.setMasterPassword('newpass', True), msg)
msg = 'Could not remove all configs from auth db'
self.assertTrue(self.authm.removeAllAuthenticationConfigs(), msg)
msg = 'Configs were not removed from auth db'
self.assertTrue(len(self.authm.configIds()) == 0, msg)
msg = 'Auth db does not exist'
self.assertTrue(os.path.exists(self.authm.authenticationDatabasePath()), msg)
QTest.qSleep(1000) # necessary for new backup to have different name
msg = 'Could not erase auth db'
backup = None
reserase, backup = \
self.authm.eraseAuthenticationDatabase(True, backup)
self.assertTrue(reserase, msg)
# qDebug('Erase db backup db path: {0}'.format(backup))
msg = 'Could not retrieve backup path for erase db op'
self.assertIsNotNone(backup)
self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg)
msg = 'Master password not erased from auth db'
self.assertTrue(not self.authm.masterPasswordIsSet() and
not self.authm.masterPasswordHashInDatabase(), msg)
self.set_master_password()
开发者ID:ndavid,项目名称:QGIS,代码行数:55,代码来源:test_qgsauthsystem.py
示例5: testCreateCatalogDialogUsingExistingName
def testCreateCatalogDialogUsingExistingName(self):
self.explorer.catalogs()["name"] = self.cat
dialog = DefineCatalogDialog(self.explorer.catalogs())
dialog.nameBox.setText("name")
okWidget = dialog.buttonBox.button(dialog.buttonBox.Ok)
QTest.mouseClick(okWidget, Qt.LeftButton)
self.assertEquals("name_2", dialog.name)
settings = QSettings()
settings.beginGroup("/GeoServer/Catalogs/name")
settings.remove("")
settings.endGroup()
settings.beginGroup("/GeoServer/Catalogs/name_2")
settings.remove("")
settings.endGroup()
del self.explorer.catalogs()["name"]
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:15,代码来源:guitests.py
示例6: setUp
def setUp(self):
"""Runs before each test."""
self.extent = QgsRectangle(10.0, 10.0, 20.0, 20.0)
self.crs = QgsCoordinateReferenceSystem('EPSG:4326')
CANVAS.setExtent(self.extent)
self.dialog = ExtentSelectorDialog(
IFACE,
PARENT,
self.extent,
self.crs)
self.signal_received = False
self.dialog.extent_defined.connect(self.extent_defined)
self.dialog.show()
QTest.qWaitForWindowExposed(self.dialog)
开发者ID:inasafe,项目名称:inasafe,代码行数:16,代码来源:test_extent_selector.py
示例7: testCreateCatalogDialogWithUrlWithoutProtocol
def testCreateCatalogDialogWithUrlWithoutProtocol(self):
dialog = DefineCatalogDialog(self.explorer.catalogs())
dialog.nameBox.setText("name")
dialog.urlBox.setText(geoserverLocation()+"/geoserver")
dialog.passwordBox.setText("password")
dialog.usernameBox.setText("username")
okWidget = dialog.buttonBox.button(dialog.buttonBox.Ok)
QTest.mouseClick(okWidget, Qt.LeftButton)
self.assertTrue(dialog.ok)
self.assertEquals("username", dialog.username)
self.assertEquals("password", dialog.password)
self.assertEquals("name", dialog.name)
self.assertEquals("http://"+geoserverLocation()+"/geoserver/rest", dialog.url)
settings = QSettings()
settings.endGroup()
settings.beginGroup("/GeoServer/Catalogs/name")
settings.remove("")
settings.endGroup()
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:18,代码来源:guitests.py
示例8: testLastCatalogNameIsShownByDefault
def testLastCatalogNameIsShownByDefault(self):
dialog = DefineCatalogDialog(self.explorer.catalogs())
dialog.nameBox.setText("catalogname")
dialog.urlBox.setText("localhost:8081/geoserver")
okWidget = dialog.buttonBox.button(dialog.buttonBox.Ok)
QTest.mouseClick(okWidget, Qt.LeftButton)
self.assertTrue(dialog.ok)
self.assertEquals("catalogname", dialog.name)
self.assertEquals("http://localhost:8081/geoserver/rest", dialog.url)
dialog = DefineCatalogDialog(self.explorer.catalogs())
self.assertEquals("catalogname", dialog.nameBox.text())
self.assertEquals("localhost:8081/geoserver", dialog.urlBox.text())
okWidget = dialog.buttonBox.button(dialog.buttonBox.Ok)
QTest.mouseClick(okWidget, Qt.LeftButton)
settings = QSettings()
settings.endGroup()
settings.beginGroup("/GeoServer/Catalogs/catalogname")
settings.remove("")
settings.endGroup()
开发者ID:GeoCat,项目名称:qgis-geoserver-plugin,代码行数:19,代码来源:guitests.py
示例9: test_spinboxes
def test_spinboxes(self):
"""Test validate extent method."""
self.dialog.x_maximum.clear()
self.dialog.extent_defined.connect(self.extent_defined)
QTest.mouseClick(self.dialog.x_maximum, Qt.LeftButton)
QTest.keyClick(self.dialog.x_maximum, '3')
QTest.keyClick(self.dialog.x_maximum, '0')
ok = self.dialog.button_box.button(QtWidgets.QDialogButtonBox.Ok)
QTest.mouseClick(ok, Qt.LeftButton)
expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0)
self.assertEqual(self.extent.toString(), expected_extent.toString())
开发者ID:inasafe,项目名称:inasafe,代码行数:12,代码来源:test_extent_selector.py
示例10: test
def test(self):
# Skip if GDAL python bindings are not available
try:
from osgeo import gdal, ogr
except:
return
version_num = int(gdal.VersionInfo('VERSION_NUM'))
if version_num < GDAL_COMPUTE_VERSION(1, 11, 0):
return
dialog = QgsNewGeoPackageLayerDialog()
dialog.setProperty("hideDialogs", True)
mDatabase = dialog.findChild(QgsFileWidget, "mDatabase")
buttonBox = dialog.findChild(QDialogButtonBox, "buttonBox")
ok_button = buttonBox.button(QDialogButtonBox.Ok)
mTableNameEdit = dialog.findChild(QLineEdit, "mTableNameEdit")
mLayerIdentifierEdit = dialog.findChild(QLineEdit, "mLayerIdentifierEdit")
mLayerDescriptionEdit = dialog.findChild(QLineEdit, "mLayerDescriptionEdit")
mFeatureIdColumnEdit = dialog.findChild(QLineEdit, "mFeatureIdColumnEdit")
mGeometryTypeBox = dialog.findChild(QComboBox, "mGeometryTypeBox")
mGeometryColumnEdit = dialog.findChild(QLineEdit, "mGeometryColumnEdit")
mFieldNameEdit = dialog.findChild(QLineEdit, "mFieldNameEdit")
mFieldTypeBox = dialog.findChild(QComboBox, "mFieldTypeBox")
mFieldLengthEdit = dialog.findChild(QLineEdit, "mFieldLengthEdit")
mAddAttributeButton = dialog.findChild(QToolButton, "mAddAttributeButton")
mRemoveAttributeButton = dialog.findChild(QToolButton, "mRemoveAttributeButton")
mAttributeView = dialog.findChild(QTreeWidget, "mAttributeView")
dialog.accepted.connect(self.accepted_slot)
mGeometryTypeBox.setCurrentIndex(mGeometryTypeBox.findData(ogr.wkbPoint))
self.assertEqual(mGeometryTypeBox.currentText(), "Point")
self.assertFalse(ok_button.isEnabled())
dbname = os.path.join(self.basetestpath, 'test.gpkg')
mDatabase.setFilePath(dbname)
self.assertEqual(mTableNameEdit.text(), 'test')
self.assertEqual(mLayerIdentifierEdit.text(), 'test')
self.assertTrue(ok_button.isEnabled())
mGeometryColumnEdit.setText('my_geom')
mFeatureIdColumnEdit.setText('my_fid')
self.assertFalse(mAddAttributeButton.isEnabled())
self.assertFalse(mRemoveAttributeButton.isEnabled())
mFieldNameEdit.setText('strfield')
self.assertTrue(mAddAttributeButton.isEnabled())
mFieldLengthEdit.setText('10')
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
mFieldNameEdit.setText('intfield')
mFieldTypeBox.setCurrentIndex(mFieldTypeBox.findData('integer'))
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
mFieldNameEdit.setText('realfield')
mFieldTypeBox.setCurrentIndex(mFieldTypeBox.findData('real'))
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
mFieldNameEdit.setText('datefield')
mFieldTypeBox.setCurrentIndex(mFieldTypeBox.findData('date'))
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
mFieldNameEdit.setText('datetimefield')
mFieldTypeBox.setCurrentIndex(mFieldTypeBox.findData('datetime'))
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
if version_num >= GDAL_COMPUTE_VERSION(2, 0, 0):
mFieldNameEdit.setText('int64field')
mFieldTypeBox.setCurrentIndex(mFieldTypeBox.findData('integer64'))
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
# Add and remove field
mFieldNameEdit.setText('dummy')
self.assertFalse(mFieldLengthEdit.isEnabled())
QTest.mouseClick(mAddAttributeButton, Qt.LeftButton)
index = mAttributeView.model().index(mAttributeView.model().rowCount() - 1, 0)
mAttributeView.setCurrentIndex(index)
QTest.mouseClick(mRemoveAttributeButton, Qt.LeftButton)
self.accepted = False
QTest.mouseClick(ok_button, Qt.LeftButton)
self.assertTrue(self.accepted)
layers = QgsProject.instance().mapLayers()
self.assertEqual(len(layers), 1)
layer = layers[list(layers.keys())[0]]
self.assertEqual(layer.name(), 'test')
self.assertEqual(layer.geometryType(), QgsWkbTypes.PointGeometry)
QgsProject.instance().removeAllMapLayers()
#.........这里部分代码省略.........
开发者ID:jonnyforestGIS,项目名称:QGIS,代码行数:101,代码来源:test_qgsnewgeopackagelayerdialog.py
示例11: test
def test(self):
# This test is quite fragile as it depends on windows manager behaviour
# regarding focus, so not surprising it doesn't pass
# on other platforms than Linux.
#if 'TRAVIS_OS_NAME' in os.environ and os.environ['TRAVIS_OS_NAME'] == 'osx':
# return
main_dialog = QgsProviderRegistry.instance().selectWidget("WFS")
main_dialog.setProperty("hideDialogs", True)
self.assertIsNotNone(main_dialog)
# Create new connection
btnNew = main_dialog.findChild(QWidget, "btnNew")
self.assertIsNotNone(btnNew)
QTest.mouseClick(btnNew, Qt.LeftButton)
new_conn = find_window('QgsNewHttpConnectionBase')
self.assertIsNotNone(new_conn)
txtName = new_conn.findChild(QLineEdit, "txtName")
self.assertIsNotNone(txtName)
txtName.setText("test_connection")
txtUrl = new_conn.findChild(QLineEdit, "txtUrl")
self.assertIsNotNone(txtUrl)
txtUrl.setText("test_url")
new_conn.accept()
# Wait for object to be destroyed
new_conn = self.wait_object_destruction(new_conn)
# Try to connect
btnConnect = main_dialog.findChild(QWidget, "btnConnect")
self.assertIsNotNone(btnConnect)
QTest.mouseClick(btnConnect, Qt.LeftButton)
# Depends on asynchronous signal
QApplication.processEvents()
error_box = find_window('WFSCapabilitiesErrorBox')
self.assertIsNotNone(error_box)
# Close error box
error_box.accept()
# Wait for object to be destroyed
error_box = self.wait_object_destruction(error_box)
# Edit connection
btnEdit = main_dialog.findChild(QWidget, "btnEdit")
self.assertIsNotNone(btnEdit)
QTest.mouseClick(btnEdit, Qt.LeftButton)
new_conn = find_window('QgsNewHttpConnectionBase',)
self.assertIsNotNone(new_conn)
txtName = new_conn.findChild(QLineEdit, "txtName")
self.assertIsNotNone(txtName)
txtName.setText("test_connection")
txtUrl = new_conn.findChild(QLineEdit, "txtUrl")
self.assertIsNotNone(txtUrl)
endpoint = self.basetestpath + '/fake_qgis_http_endpoint'
expected_endpoint = endpoint
if sys.platform == 'win32' and expected_endpoint[1] == ':':
expected_endpoint = expected_endpoint[0] + expected_endpoint[2:]
with open(sanitize(endpoint, '?SERVICE=WFS?REQUEST=GetCapabilities?ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0'), 'wb') as f:
f.write("""
<wfs:WFS_Capabilities version="2.0.0" xmlns="http://www.opengis.net/wfs/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://schemas.opengis.net/gml/3.2" xmlns:fes="http://www.opengis.net/fes/2.0">
<FeatureTypeList>
<FeatureType>
<Name>my:typename</Name>
<Title>Title</Title>
<Abstract>Abstract</Abstract>
<DefaultCRS>urn:ogc:def:crs:EPSG::4326</DefaultCRS>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-71.123 66.33</ows:LowerCorner>
<ows:UpperCorner>-65.32 78.3</ows:UpperCorner>
</ows:WGS84BoundingBox>
</FeatureType>
</FeatureTypeList>
<fes:Filter_Capabilities>
<fes:Spatial_Capabilities>
<fes:GeometryOperands>
<fes:GeometryOperand name="gml:Envelope"/>
<fes:GeometryOperand name="gml:Point"/>
<fes:GeometryOperand name="gml:MultiPoint"/>
<fes:GeometryOperand name="gml:LineString"/>
<fes:GeometryOperand name="gml:MultiLineString"/>
<fes:GeometryOperand name="gml:Polygon"/>
<fes:GeometryOperand name="gml:MultiPolygon"/>
<fes:GeometryOperand name="gml:MultiGeometry"/>
</fes:GeometryOperands>
<fes:SpatialOperators>
<fes:SpatialOperator name="Disjoint"/>
<fes:SpatialOperator name="Equals"/>
<fes:SpatialOperator name="DWithin"/>
<fes:SpatialOperator name="Beyond"/>
<fes:SpatialOperator name="Intersects"/>
<fes:SpatialOperator name="Touches"/>
<fes:SpatialOperator name="Crosses"/>
<fes:SpatialOperator name="Within"/>
<fes:SpatialOperator name="Contains"/>
<fes:SpatialOperator name="Overlaps"/>
<fes:SpatialOperator name="BBOX"/>
</fes:SpatialOperators>
#.........这里部分代码省略.........
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:101,代码来源:test_provider_wfs_gui.py
注:本文中的qgis.PyQt.QtTest.QTest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论