void TestQgsProject::testProjectUnits() { //test setting and retrieving project units // DISTANCE //first set a default QGIS distance unit QgsSettings s; s.setValue( QStringLiteral( "/qgis/measure/displayunits" ), QgsUnitTypes::encodeUnit( QgsUnitTypes::DistanceFeet ) ); QgsProject *prj = new QgsProject; // new project should inherit QGIS default distance unit prj->clear(); QCOMPARE( prj->distanceUnits(), QgsUnitTypes::DistanceFeet ); //changing default QGIS unit should not affect existing project s.setValue( QStringLiteral( "/qgis/measure/displayunits" ), QgsUnitTypes::encodeUnit( QgsUnitTypes::DistanceNauticalMiles ) ); QCOMPARE( prj->distanceUnits(), QgsUnitTypes::DistanceFeet ); //test setting new units for project prj->setDistanceUnits( QgsUnitTypes::DistanceNauticalMiles ); QCOMPARE( prj->distanceUnits(), QgsUnitTypes::DistanceNauticalMiles ); // AREA //first set a default QGIS area unit s.setValue( QStringLiteral( "/qgis/measure/areaunits" ), QgsUnitTypes::encodeUnit( QgsUnitTypes::AreaSquareYards ) ); // new project should inherit QGIS default area unit prj->clear(); QCOMPARE( prj->areaUnits(), QgsUnitTypes::AreaSquareYards ); //changing default QGIS unit should not affect existing project s.setValue( QStringLiteral( "/qgis/measure/areaunits" ), QgsUnitTypes::encodeUnit( QgsUnitTypes::AreaAcres ) ); QCOMPARE( prj->areaUnits(), QgsUnitTypes::AreaSquareYards ); //test setting new units for project prj->setAreaUnits( QgsUnitTypes::AreaAcres ); QCOMPARE( prj->areaUnits(), QgsUnitTypes::AreaAcres ); delete prj; }