~ubuntu-branches/ubuntu/saucy/qgis/saucy

« back to all changes in this revision

Viewing changes to tests/src/core/regression992.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-04-24 15:12:20 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120424151220-r88g00af5fpn5fc3
Tags: 1.7.4+1.7.5~20120320-1
The "Sometimes they come back" release.

* Branching from Qgis tree and adapting to current Debian Policy and
  standards. The target tree is currently set to release-1.7.
  (closes: #661491, #606304, #615683, #616182, #600308)
* Policy bumped to 3.9.3.
* Moving to debhelper compatibility level 9.
* Source format is now 3.0 with quilt support.
* Merged with 2bf42287 upstream git snapshot.
* Migrated to dh_python2 instead of python-central.
  (closes: #617048)
* Snapshot in qgis.org release-1.7: c936d031
* Added an automagic creation of a lintian override for sqlite embedding.
  This is required for uploading currently.
* Added missing ${misc:Depends} to make lintian happy.
* Copyright notes updated and debian/copyright moved to format 1.0.
* More licenses notices now reported in debian/copyright. Thanks ftpmasters.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
 
30
30
//qgis includes...
31
 
#include <qgsrasterlayer.h> 
32
 
#include <qgsrasterbandstats.h> 
33
 
#include <qgsmaplayerregistry.h> 
 
31
#include <qgsrasterlayer.h>
 
32
#include <qgsrasterbandstats.h>
 
33
#include <qgsmaplayerregistry.h>
34
34
#include <qgsapplication.h>
35
 
#include <qgsmaprenderer.h> 
 
35
#include <qgsmaprenderer.h>
36
36
 
37
37
//qgis unit test includes
38
38
#include <qgsrenderchecker.h>
43
43
 */
44
44
class Regression992: public QObject
45
45
{
46
 
  Q_OBJECT;
 
46
    Q_OBJECT;
47
47
  private slots:
48
48
    void initTestCase();// will be called before the first testfunction is executed.
49
49
    void cleanupTestCase();// will be called after the last testfunction was executed.
50
 
    void init(){};// will be called before each testfunction is executed.
51
 
    void cleanup(){};// will be called after every testfunction.
 
50
    void init() {};// will be called before each testfunction is executed.
 
51
    void cleanup() {};// will be called after every testfunction.
52
52
 
53
53
    void regression992();
54
54
  private:
55
 
    bool render(QString theFileName);
 
55
    bool render( QString theFileName );
56
56
    QString mTestDataDir;
57
57
    QgsRasterLayer * mpRasterLayer;
58
58
    QgsMapRenderer * mpMapRenderer;
63
63
void Regression992::initTestCase()
64
64
{
65
65
  // init QGIS's paths - true means that all path will be inited from prefix
66
 
  QString qgisPath = QCoreApplication::applicationDirPath ();
67
 
  QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
 
66
  QString qgisPath = QCoreApplication::applicationDirPath();
 
67
  QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
68
68
  QgsApplication::showSettings();
69
69
  //create some objects that will be used in all tests...
70
70
  //create a raster layer that will be used in all tests...
71
 
  mTestDataDir = QString(TEST_DATA_DIR) + QDir::separator(); //defined in CMakeLists.txt
 
71
  mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CMakeLists.txt
72
72
  QString myFileName = mTestDataDir + "rgbwcmyk01_YeGeo.jp2";
73
 
  QFileInfo myRasterFileInfo ( myFileName );
74
 
  mpRasterLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(),
75
 
            myRasterFileInfo.completeBaseName() );
 
73
  QFileInfo myRasterFileInfo( myFileName );
 
74
  mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(),
 
75
                                      myRasterFileInfo.completeBaseName() );
76
76
  // Register the layer with the registry
77
 
  QgsMapLayerRegistry::instance()->addMapLayer(mpRasterLayer);
 
77
  QgsMapLayerRegistry::instance()->addMapLayer( mpRasterLayer );
78
78
  // add the test layer to the maprender
79
79
  mpMapRenderer = new QgsMapRenderer();
80
80
  QStringList myLayers;
81
 
  myLayers << mpRasterLayer->getLayerID();
82
 
  mpMapRenderer->setLayerSet(myLayers);
 
81
  myLayers << mpRasterLayer->id();
 
82
  mpMapRenderer->setLayerSet( myLayers );
83
83
  mReport += "<h1>Regression 992 Test</h1>\n";
84
84
  mReport += "<p>See <a href=\"https://trac.osgeo.org/qgis/ticket/992\">"
85
 
    "trac ticket 992</a> for more details.</p>";
 
85
             "trac ticket 992</a> for more details.</p>";
86
86
}
87
87
//runs after all tests
88
88
void Regression992::cleanupTestCase()
89
89
{
90
90
  QString myReportFile = QDir::tempPath() + QDir::separator() + "regression992.html";
91
 
  QFile myFile ( myReportFile);
92
 
  if ( myFile.open ( QIODevice::WriteOnly ) )
 
91
  QFile myFile( myReportFile );
 
92
  if ( myFile.open( QIODevice::WriteOnly ) )
93
93
  {
94
 
    QTextStream myQTextStream ( &myFile );
 
94
    QTextStream myQTextStream( &myFile );
95
95
    myQTextStream << mReport;
96
96
    myFile.close();
97
 
    QDesktopServices::openUrl("file://"+myReportFile);
 
97
    QDesktopServices::openUrl( "file://" + myReportFile );
98
98
  }
99
99
}
100
100
 
101
101
void Regression992::regression992()
102
102
{
103
 
  QVERIFY ( mpRasterLayer->isValid() );
104
 
  mpMapRenderer->setExtent(mpRasterLayer->extent());
105
 
  QString myDataDir (TEST_DATA_DIR); //defined in CmakeLists.txt
 
103
  QVERIFY( mpRasterLayer->isValid() );
 
104
  mpMapRenderer->setExtent( mpRasterLayer->extent() );
 
105
  QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
106
106
  QString myTestDataDir = myDataDir + QDir::separator();
107
107
  QgsRenderChecker myChecker;
108
 
  myChecker.setExpectedImage ( myTestDataDir + "expected_rgbwcmyk01_YeGeo.jp2.png" );
109
 
  myChecker.setMapRenderer ( mpMapRenderer );
110
 
  bool myResultFlag = myChecker.runTest("regression992");
 
108
  myChecker.setExpectedImage( myTestDataDir + "expected_rgbwcmyk01_YeGeo.jp2.png" );
 
109
  myChecker.setMapRenderer( mpMapRenderer );
 
110
  bool myResultFlag = myChecker.runTest( "regression992" );
111
111
  mReport += "\n\n\n" + myChecker.report();
112
 
  QVERIFY(myResultFlag);
 
112
  QVERIFY( myResultFlag );
113
113
}
114
114
 
115
 
QTEST_MAIN(Regression992)
 
115
QTEST_MAIN( Regression992 )
116
116
#include "moc_regression992.cxx"
117
117