00001 /*************************************************************************** 00002 * Copyright (C) 2005 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 <QCoreApplication> 00022 #include <omgexperiment.h> 00023 #include <omgmodellerpluginregistry.h> 00024 #include <omgmodellerplugininterface.h> 00025 #include <omgpluginmessenger.h> 00026 #include <omgui.h> 00027 #include <omglocalitiesmodel.h> 00028 #include <QString> 00029 #include <QDir> 00030 class OmgLocalitiesModelTest: public QObject 00031 { 00032 Q_OBJECT; 00033 private slots: 00034 void rowsAndColumns(); 00035 }; 00036 00037 void OmgLocalitiesModelTest::rowsAndColumns() 00038 { 00039 //TEST_DATA_DIR is a compiler define set by cmake 00040 QString myFileName(QString(TEST_DATA_DIR) + "/model.xml"); 00041 qDebug(myFileName); 00042 OmgModel myModel; 00043 myModel.fromXmlFile(myFileName); 00044 //we need to replace [PREFIX] in teh file paths in the 00045 //model we just loaded so our test can actually find the model 00046 //data. To do that I temporarily get the xml for the model 00047 //search and replace the xml and then reinstate the model 00048 //from the updated xml... 00049 QString myModelXml = myModel.toXml(); 00050 myModelXml.replace("[PREFIX]",TEST_DATA_DIR); 00051 myModel.fromXml(myModelXml); 00052 QString myFileName2 = "/tmp/replacedmodel.xml"; 00053 Omgui::createTextFile( myFileName2 , myModel.toModelCreationXml()); 00054 00055 00056 QStringList myList = OmgModellerPluginRegistry::instance()->names(); 00057 QVERIFY(myList.count() > 0); 00058 myModel.setWorkDir("/tmp"); 00059 00060 OmgModellerPluginInterface * mypModellerPlugin = 00061 OmgModellerPluginRegistry::instance()->getPlugin(); 00062 QVERIFY(!mypModellerPlugin->getName().isEmpty()); 00063 QString myResult = mypModellerPlugin->createModel(&myModel); 00064 QVERIFY(!myResult.isEmpty()); 00065 OmgLocalitiesModel myLocalitiesModel; 00066 myLocalitiesModel.setModel(&myModel); 00067 QVERIFY(myLocalitiesModel.rowCount() > 0); 00068 QVERIFY(myLocalitiesModel.columnCount() > 0); 00069 } 00070 00071 QTEST_MAIN(OmgLocalitiesModelTest) 00072 #include "moc_omglocalitiesmodeltest.cxx"