tsrc/common/phoneuitestmain.h
changeset 76 cfea66083b62
equal deleted inserted replaced
74:d1c62c765e48 76:cfea66083b62
       
     1 /*
       
     2 * Copyright (c) 2010 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef PHONEUITESTMAIN
       
    19 #define PHONEUITESTMAIN
       
    20 
       
    21 #include <hbapplication.h>
       
    22 #include <hbmainwindow.h>
       
    23 
       
    24 char *new_argv[3];
       
    25 HbMainWindow *mainWindow;
       
    26 #define PHONE_UITEST_MAIN(TestObject) \
       
    27 int main(int argc, char *argv[]) \
       
    28 { \
       
    29 HbApplication *app = new HbApplication(argc, argv); \
       
    30 QString str = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + ".log"; \
       
    31 QByteArray   bytes  = str.toAscii(); \
       
    32 \
       
    33 char arg1[] = "-o"; \
       
    34 \
       
    35 new_argv[0] = argv[0]; \
       
    36 new_argv[1] = arg1; \
       
    37 new_argv[2] = bytes.data(); \
       
    38 \
       
    39 TestObject tc; \
       
    40 QResource::registerResource("../hbcore.rcc"); \
       
    41 mainWindow = new HbMainWindow;\
       
    42 mainWindow->show(); \
       
    43 int ret = QTest::qExec(&tc, 3, new_argv); \
       
    44 /* Core dump if HbIconLoader instance is not destroyed before the application instance. */ \
       
    45 /* HbIconLoader uses QCoreApplication::aboutToQuit() signal to destroy itself. */ \
       
    46 /* app.exec() where the signal is normally emitted is not called here. */ \
       
    47 /* So, invoking the signal explicitly. */ \
       
    48 QMetaObject::invokeMethod(app, "aboutToQuit", Qt::DirectConnection); \
       
    49 delete mainWindow; \
       
    50 delete app; \
       
    51 return ret; \
       
    52 }
       
    53 
       
    54 #endif