Skip to content
Permalink
Browse files

Dont manualy try to delete shp files - use the new call in filewriter…

… class to do this

git-svn-id: http://svn.osgeo.org/qgis/trunk@7682 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Nov 29, 2007
1 parent 013288a commit 7ba55098b38a6f8b000277e1c6401693e0829154
Showing with 10 additions and 59 deletions.
  1. +10 −59 tests/src/core/testqgsvectorfilewriter.cpp
@@ -57,7 +57,6 @@ class TestQgsVectorFileWriter: public QObject
Q_OBJECT;
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase(){};// will be called after the last testfunction was executed.
void init(){};// will be called before each testfunction is executed.
void cleanup(){};// will be called after every testfunction.

@@ -118,9 +117,8 @@ void TestQgsVectorFileWriter::createPoint()
//
// Remove old copies that may be lying around
//
QString myFileBase = "/tmp/testpt";
QVERIFY(cleanupFile(myFileBase));
QString myFileName = myFileBase + ".shp";
QString myFileName = "/tmp/testpt.shp";
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
QgsVectorFileWriter myWriter (myFileName,
mEncoding,
mFields,
@@ -163,9 +161,8 @@ void TestQgsVectorFileWriter::createLine()
//
// Remove old copies that may be lying around
//
QString myFileBase = "/tmp/testln";
QVERIFY(cleanupFile(myFileBase));
QString myFileName = myFileBase + ".shp";
QString myFileName = "/tmp/testln.shp";
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
QgsVectorFileWriter myWriter (myFileName,
mEncoding,
mFields,
@@ -212,9 +209,8 @@ void TestQgsVectorFileWriter::createPolygon()
//
// Remove old copies that may be lying around
//
QString myFileBase = "/tmp/testply";
QVERIFY(cleanupFile(myFileBase));
QString myFileName = myFileBase + ".shp";
QString myFileName = "/tmp/testply.shp";
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
QgsVectorFileWriter myWriter (myFileName,
mEncoding,
mFields,
@@ -263,9 +259,8 @@ void TestQgsVectorFileWriter::polygonGridTest()
//
// Remove old copies that may be lying around
//
QString myFileBase = "/tmp/testgrid";
QVERIFY(cleanupFile(myFileBase));
QString myFileName = myFileBase + ".shp";
QString myFileName = "/tmp/testgrid.shp";
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
QgsVectorFileWriter myWriter (myFileName,
mEncoding,
mFields,
@@ -326,9 +321,8 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
//
// Remove old copies that may be lying around
//
QString myFileBase = "/tmp/testprjgrid";
QVERIFY(cleanupFile(myFileBase));
QString myFileName = myFileBase + ".shp";
QString myFileName = "/tmp/testprjgrid.shp";
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
//
// We are testing projected coordinate
// system vector writing to lets use something fun...
@@ -393,49 +387,6 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
}
}
}
bool TestQgsVectorFileWriter::cleanupFile(QString theFileBase)
{
//
// Remove old copies that may be lying around
//
QFileInfo myInfo(theFileBase + ".shp");
if (myInfo.exists())
{
if(!QFile::remove(theFileBase + ".shp"))
{
qDebug("Removing file failed : " + theFileBase.toLocal8Bit() + ".shp");
return false;
}
}
myInfo.setFile(theFileBase + ".shx");
if (myInfo.exists())
{
if(!QFile::remove(theFileBase + ".shx"))
{
qDebug("Removing file failed : " + theFileBase.toLocal8Bit() + ".shx");
return false;
}
}
myInfo.setFile(theFileBase + ".dbf");
if (myInfo.exists())
{
if(!QFile::remove(theFileBase + ".dbf"))
{
qDebug("Removing file failed : " + theFileBase.toLocal8Bit() + ".dbf");
return false;
}
}
myInfo.setFile(theFileBase + ".prj");
if (myInfo.exists())
{
if(!QFile::remove(theFileBase + ".prj"))
{
qDebug("Removing file failed : " + theFileBase.toLocal8Bit() + ".prj");
return false;
}
}
return true;
}

QTEST_MAIN(TestQgsVectorFileWriter)
#include "moc_testqgsvectorfilewriter.cxx"

0 comments on commit 7ba5509

Please sign in to comment.
You can’t perform that action at this time.