QFileInfo myFileInfo(const QString &fn){ QStringList nf; nf << myFileName(fn); QDir dir(myDirName(fn)); QFileInfoList fil = dir.entryInfoList(nf); if (fil.size()) return fil.at(0); else return QFileInfo(); };
void TestQgsMapLayer::init() { //create some objects that will be used in all tests... //create a map layer that will be used in all tests... QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt myFileName = myFileName + "/points.shp"; QFileInfo myMapFileInfo( myFileName ); mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), "ogr" ); }
void TestQgsOfflineEditing::init() { QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt QString myTempDirName = tempDir.path(); QFile::copy( myFileName + "/points.shp", myTempDirName + "/points.shp" ); QFile::copy( myFileName + "/points.shx", myTempDirName + "/points.shx" ); QFile::copy( myFileName + "/points.dbf", myTempDirName + "/points.dbf" ); QString myTempFileName = myTempDirName + "/points.shp"; QFileInfo myMapFileInfo( myTempFileName ); mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), QStringLiteral( "ogr" ) ); QgsProject::instance()->addMapLayer( mpLayer ); numberOfFeatures = mpLayer->featureCount(); numberOfFields = mpLayer->fields().size(); layerIds.append( mpLayer->id() ); }
void TestQgsMapLayer::initTestCase() { // // Runs once before any tests are run // // init QGIS's paths - true means that all path will be inited from prefix QgsApplication::init(); QgsApplication::initQgis(); QgsApplication::showSettings(); //create some objects that will be used in all tests... //create a map layer that will be used in all tests... QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt myFileName = myFileName + "/points.shp"; QFileInfo myMapFileInfo( myFileName ); mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), "ogr" ); }