Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 12, 2023
1 parent 3700930 commit 2fe7d96
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/gui/qgscoordinatereferencesystemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ QVariant QgsCoordinateReferenceSystemModel::data( const QModelIndex &index, int
return crsNode->record().description;

case RoleAuthId:
return QStringLiteral( "%1:%2" ).arg( crsNode->record().authName, crsNode->record().authId );
if ( !crsNode->record().authId.isEmpty() )
return QStringLiteral( "%1:%2" ).arg( crsNode->record().authName, crsNode->record().authId );
else
return QVariant();

case RoleDeprecated:
return crsNode->record().deprecated;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsprojectionselectiontreewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste
}
else
{
bool changed = false;
mBlockSignals = true;
mCheckBoxNoProjection->setChecked( false );
mBlockSignals = false;
Expand All @@ -237,6 +236,7 @@ void QgsProjectionSelectionTreeWidget::setCrs( const QgsCoordinateReferenceSyste
else
loadUnknownCrs( crs );

const bool changed = crs != QgsProjectionSelectionTreeWidget::crs();
if ( changed )
{
emit crsSelected();
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/test_qgscoordinatereferencesystemmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def test_model(self):
Qt.DisplayRole))
self.assertEqual(model.data(custom_crs_index,
QgsCoordinateReferenceSystemModel.RoleName), 'Custom CRS')
self.assertFalse(model.data(custom_crs_index,
QgsCoordinateReferenceSystemModel.RoleAuthId))
self.assertFalse(model.data(custom_crs_index,
QgsCoordinateReferenceSystemModel.RoleDeprecated))
# the proj and wkt roles are only available for non-standard CRS
Expand Down
12 changes: 3 additions & 9 deletions tests/src/python/test_qgsprojectionselectionwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ def testSignal(self):
def testTreeWidgetGettersSetters(self):
""" basic tests for QgsProjectionSelectionTreeWidget """
w = QgsProjectionSelectionTreeWidget()
w.show()
self.assertFalse(w.hasValidSelection())
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(w.crs().authid(), 'EPSG:3111')
self.assertTrue(w.hasValidSelection())

def testTreeWidgetUnknownCrs(self):
w = QgsProjectionSelectionTreeWidget()
w.show()
self.assertFalse(w.hasValidSelection())
w.setCrs(QgsCoordinateReferenceSystem.fromWkt('GEOGCS["WGS 84",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'))
crs = QgsCoordinateReferenceSystem.fromWkt('GEOGCS["WGS 84",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]')
self.assertTrue(crs.isValid())
w.setCrs(crs)
self.assertTrue(w.crs().isValid())
self.assertFalse(w.crs().authid())
self.assertTrue(w.hasValidSelection())
Expand All @@ -173,7 +173,6 @@ def testTreeWidgetUnknownCrs(self):
def testTreeWidgetNotSetOption(self):
""" test allowing no projection option for QgsProjectionSelectionTreeWidget """
w = QgsProjectionSelectionTreeWidget()
w.show()
w.setShowNoProjection(True)
self.assertTrue(w.showNoProjection())
w.setShowNoProjection(False)
Expand All @@ -188,14 +187,12 @@ def testTreeWidgetNotSetOption(self):
def testDialogGettersSetters(self):
""" basic tests for QgsProjectionSelectionTreeWidget """
w = QgsProjectionSelectionDialog()
w.show()
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(w.crs().authid(), 'EPSG:3111')

def testDialogNotSetOption(self):
""" test allowing no projection option for QgsProjectionSelectionTreeWidget """
w = QgsProjectionSelectionDialog()
w.show()
w.setShowNoProjection(True)
self.assertTrue(w.showNoProjection())
w.setShowNoProjection(False)
Expand Down Expand Up @@ -235,7 +232,6 @@ def testTreeWidgetDeferredLoad(self):
self.assertFalse(w.hasValidSelection())
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(len(spy), 1)
w.show()
self.assertTrue(w.hasValidSelection())
self.assertEqual(w.crs().authid(), 'EPSG:3111')
self.assertEqual(len(spy), 1)
Expand All @@ -245,7 +241,6 @@ def testTreeWidgetDeferredLoad(self):
self.assertFalse(w.hasValidSelection())
w.setCrs(QgsCoordinateReferenceSystem())
self.assertEqual(len(spy), 1)
w.show()
self.assertTrue(w.hasValidSelection())
self.assertFalse(w.crs().isValid())
self.assertEqual(len(spy), 1)
Expand All @@ -264,7 +259,6 @@ def testTreeWidgetDeferredLoad(self):
self.assertFalse(w.hasValidSelection())
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
w.show()
w.setCrs(QgsCoordinateReferenceSystem('EPSG:3111'))
self.assertEqual(len(spy), 1)
w.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
Expand Down

0 comments on commit 2fe7d96

Please sign in to comment.