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

omgexperimentprintertest.cpp

Go to the documentation of this file.
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 <QPrinter>
00022 #include <omgexperiment.h>
00023 #include <omgexperimentprinter.h>
00024 
00025 class OmgExerimentPrinterTest: public QObject
00026 {
00027   Q_OBJECT;
00028       private slots:
00029       void run();
00030 };
00031 
00032 void OmgExerimentPrinterTest::run()
00033 {
00034   //TEST_DATA_DIR is a compiler define set by cmake
00035   QString myFileName(QString(TEST_DATA_DIR) + "/experiment.xml");
00036   //we need to replace [PREFIX] in teh file paths in the 
00037   //model we just loaded so our test can actually find the model 
00038   //data. To do that I temporarily get the xml for the model
00039   //search and replace the xml and then reinstate the model
00040   //from the updated xml...
00041   OmgExperiment myExperiment;
00042   myExperiment.fromXmlFile(myFileName);
00043   QString myExperimentXml = myExperiment.toXml();
00044   myExperimentXml.replace("[PREFIX]",TEST_DATA_DIR);
00045   OmgExperiment myExperiment2;
00046   myExperiment2.fromXml(myExperimentXml);
00047   QVERIFY(myExperiment2.name()=="Test");
00048   myExperiment2.setWorkDir("/tmp");
00049   //
00050   // Note omgexperimentprinter can run in its
00051   // own thread (using start()) but in this test
00052   // I am only validating in a non threaded
00053   // way
00054   //
00055   QPrinter myPrinter;
00056   myPrinter.setOutputFormat(QPrinter::PdfFormat);
00057   myPrinter.setOutputFileName("/tmp/experimentprintertest.pdf");
00058   myPrinter.setDocName("openModellerDesktopExperimentReport");
00059   OmgExperimentPrinter myExperimentPrinter ;
00060   myExperimentPrinter.setExperiment(&myExperiment2);
00061   myExperimentPrinter.setPrinter(myPrinter);
00062   //mpExperimentPrinter.start(); //see note above
00063   myExperimentPrinter.run();
00064 }
00065 
00066 QTEST_MAIN(OmgExerimentPrinterTest) 
00067 #include "moc_omgexperimentprintertest.cxx"
00068   

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