Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

omguitest.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Tim Sutton   *
00003  *   tim@linfiniti.com   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include <QtTest/QtTest>
00021 #include <omgui.h>
00022 #include <omgexperiment.h>
00023 #include <QImage>
00024 #include <QList>
00025 
00026 class OmguiTest: public QObject
00027 {
00028   Q_OBJECT;
00029   private slots:
00030   void regression1728367(); //regression test for bug 1728367
00031   void regression1711409(); //regression test for not finding ai grid layers
00032   void initTestCase();// will be called before the first testfunction is executed.
00033   void cleanupTestCase();// will be called after the last testfunction was executed.
00034   void init(){};// will be called before each testfunction is executed.
00035   void cleanup(){};// will be called after every testfunction.
00036   private:
00037   QString mOriginalWorkDir;
00038 };
00039 
00040 void OmguiTest::initTestCase()
00041 {
00042   QCoreApplication::setOrganizationName("openModeller");
00043   QCoreApplication::setOrganizationDomain("openmodeller.sf.net");
00044   QCoreApplication::setApplicationName("OpenModellerGui");
00045   QSettings mySettings;
00046   mOriginalWorkDir = mySettings.value("dataDirs/dataDir","/tmp").toString();
00047   mySettings.setValue("dataDirs/dataDir","/tmp");
00048   //qDebug("Data dir setting stored and set to /tmp");
00049 }
00050 void OmguiTest::cleanupTestCase()
00051 {
00052   QSettings mySettings;
00053   mySettings.setValue("dataDirs/dataDir",mOriginalWorkDir);
00054   //qDebug("Data dir setting restored to \n" + mySettings.value("dataDirs/dataDir").toString().toLocal8Bit());
00055 }
00056 void OmguiTest::regression1728367()
00057 {
00058   QString myFileName;
00059   //@TODO make sure this OS agnostic...
00060   QDir myDir;
00061   if (!myDir.exists("/tmp"))
00062   {
00063     QVERIFY(myDir.mkdir("/tmp"));
00064   }
00065   if (!myDir.exists("/tmp/modelOutputs"))
00066   {
00067     QVERIFY(myDir.mkdir("/tmp/modelOutputs"));
00068   }
00069   if (!myDir.exists("/tmp/modelOutputs/Test 1"))
00070   {
00071     QVERIFY(myDir.mkdir("/tmp/modelOutputs/Test 1"));
00072   }
00073   //create a temporary little experiment
00074   OmgExperiment myExperiment;
00075   myExperiment.setName("Test 1");
00076   myFileName = "/tmp/modelOutputs/Test 1/" + myExperiment.guid() + ".xml";
00077   Omgui::createTextFile( myFileName , myExperiment.toXml());
00078   QFileInfo myInfo(myFileName);
00079   QVERIFY(myInfo.exists());
00080   //now see if omgui can find this experiment...
00081   QStringList myList = Omgui::getExperimentsList();
00082   QVERIFY(myList.count() > 0);
00083   /*
00084   QStringListIterator myIterator(myList);
00085   while (myIterator.hasNext())
00086   {
00087     QString myFileName = myIterator.next();
00088     qDebug("Found");
00089     qDebug(myFileName);
00090   }
00091   */
00092 }
00093 void OmguiTest::regression1711409()
00094 {
00095   //there should be a test aig file in there
00096   QString myDirName (TEST_DATA_DIR); //defined in top CmakeLists.txt
00097   QDir myDir;
00098   if (!myDir.exists("/tmp"))
00099   {
00100     QVERIFY(myDir.mkdir("/tmp"));
00101   }
00102   QString myLayers = Omgui::getLayers(myDirName);
00103   Omgui::createTextFile("/tmp/layerSelectorCache.xml", myLayers);
00104   //check at least one AIG layer was found
00105   QVERIFY(myLayers.contains("Type=\"AIG\""));
00106   
00107 }
00108 
00109 QTEST_MAIN(OmguiTest) 
00110 #include "moc_omguitest.cxx"
00111   
00112 
00113 

Generated on Mon Apr 28 15:09:54 2008 for openModellerDesktop by  doxygen 1.4.1-20050210