|         |      1 /* | 
|         |      2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|         |      3  * All rights reserved. | 
|         |      4  * This component and the accompanying materials are made available | 
|         |      5  * under the terms of "Eclipse Public License v1.0" | 
|         |      6  * which accompanies this distribution, and is available | 
|         |      7  * at the URL "http://www.eclipse.org/legal/epl-v10.html". | 
|         |      8  * | 
|         |      9  * Initial Contributors: | 
|         |     10  * Nokia Corporation - initial contribution. | 
|         |     11  * | 
|         |     12  * Contributors: | 
|         |     13  *  | 
|         |     14  * Description: main class for msgapptestsuite. | 
|         |     15  */ | 
|         |     16  | 
|         |     17 #include <QtTest/QtTest> | 
|         |     18 #include "testconversationengine.h" | 
|         |     19  | 
|         |     20 //out put directory for test results. | 
|         |     21 QString OUTPUTDIRECTORY = "c:/logs/messagingtestsuite"; | 
|         |     22 //o/p directory for data to be written on temp file. | 
|         |     23 QString TEMPDIR = "c:/logs/messagingtestsuite/testdata"; | 
|         |     24 //test result O/P file name. | 
|         |     25 QString RESULTFILE = "c:/logs/messagingtestsuite/result_%1.txt"; | 
|         |     26 // folder named UID3 of msgapptestsuite inside private folder. | 
|         |     27 const QString PRIVATE_DIR("C:/private/2001fe76"); | 
|         |     28  | 
|         |     29 //factory method to create objects. | 
|         |     30 QObject* getObject(QString className) | 
|         |     31 { | 
|         |     32     if(className == "TConversationEngine" ) | 
|         |     33     { | 
|         |     34         return new TConversationEngine(); | 
|         |     35     } | 
|         |     36  	else | 
|         |     37 	{ | 
|         |     38 		return 0; | 
|         |     39 	} | 
|         |     40 } | 
|         |     41  | 
|         |     42 //creating o/p directory. | 
|         |     43 void createOutPutDirectory() | 
|         |     44     { | 
|         |     45     QDir dir; | 
|         |     46     //o/p dir | 
|         |     47     dir.mkdir(OUTPUTDIRECTORY); | 
|         |     48     //tmp dir | 
|         |     49     dir.mkdir(TEMPDIR); | 
|         |     50     // dir inside private folder. | 
|         |     51     dir.mkdir(PRIVATE_DIR); | 
|         |     52     } | 
|         |     53  | 
|         |     54 //main entry point | 
|         |     55 int main(int argc, char *argv[]) | 
|         |     56     {  | 
|         |     57     int ret = -1; | 
|         |     58     QCoreApplication app(argc, argv);     | 
|         |     59      | 
|         |     60     //creating output directory. | 
|         |     61     createOutPutDirectory(); | 
|         |     62      | 
|         |     63     //the configuration file. | 
|         |     64     QFile data("c:/msgapptestsuite.cfg"); | 
|         |     65  | 
|         |     66     if (data.open(QFile::ReadOnly))  | 
|         |     67         { | 
|         |     68         QTextStream in(&data); | 
|         |     69         while(!in.atEnd()) | 
|         |     70             { | 
|         |     71             QStringList args; | 
|         |     72             QString appName = argv[0]; | 
|         |     73             args << appName; | 
|         |     74  | 
|         |     75             QString option  = "-o"; | 
|         |     76             args << option; | 
|         |     77  | 
|         |     78             QString outFile = RESULTFILE; | 
|         |     79             QString name = in.readLine(); | 
|         |     80             outFile = outFile.arg(name); | 
|         |     81             args << outFile; | 
|         |     82  | 
|         |     83             QObject* tc = getObject(name); | 
|         |     84  | 
|         |     85             if(tc) | 
|         |     86                 { | 
|         |     87  | 
|         |     88                 ret =  QTest::qExec(tc, args);  | 
|         |     89                 delete tc; | 
|         |     90                 } | 
|         |     91             } | 
|         |     92         }     | 
|         |     93     data.close(); | 
|         |     94     return ret; | 
|         |     95     } |