testfwuis/symbianunittestui/qt/widgettestrunner.cpp
changeset 2 453d490c84a5
equal deleted inserted replaced
1:753e33780645 2:453d490c84a5
       
     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: widget class to run tests.
       
    15  *
       
    16  */
       
    17 
       
    18 #include "widgettestrunner.h"
       
    19 #include "settings.h"
       
    20 #ifdef Q_OS_SYMBIAN
       
    21 #include "testrunner_s60.h"
       
    22 //#else
       
    23 //#include "testrunner_stub.h"
       
    24 #endif
       
    25 
       
    26 WidgetTestRunner::WidgetTestRunner(QWidget* parent) :
       
    27     QWidget(parent)
       
    28     {
       
    29 #ifdef Q_OS_SYMBIAN //Symbian specific compilation
       
    30     QT_TRAP_THROWING(d_ptr = TestRunnerPrivate::NewL(this));
       
    31 //#else
       
    32 //    d_ptr = new TestRunnerPrivate(this);
       
    33 #endif
       
    34     }
       
    35 
       
    36 WidgetTestRunner::~WidgetTestRunner()
       
    37     {
       
    38     delete d_ptr;
       
    39     }
       
    40 
       
    41 void WidgetTestRunner::addTestDllNames(const QStringList& dllNames)
       
    42     {
       
    43     if (d_ptr->SetTestDllNames(dllNames) != 0)
       
    44         {
       
    45         emit this->errorOccurred(tr("Failed to add test dll files."));
       
    46         }
       
    47     }
       
    48 
       
    49 void WidgetTestRunner::addTestCaseNames(const QStringList& caseNames)
       
    50     {
       
    51     if (d_ptr->SetTestCaseNames(caseNames) != 0)
       
    52         {
       
    53         emit this->errorOccurred(tr("Failed to set test cases to run."));
       
    54         }
       
    55     }
       
    56 
       
    57 int WidgetTestRunner::listTestCases(const QString& dllName, QStringList& caseNames)
       
    58     {
       
    59     int err = -1;
       
    60     if (!dllName.isEmpty())
       
    61         {
       
    62         err = d_ptr->ListTestCases(dllName, caseNames);
       
    63         if (err != 0)
       
    64             {
       
    65             emit this->errorOccurred(tr("Failed to list cases in \"") + dllName + tr("\""));
       
    66             }
       
    67         }
       
    68     return err;
       
    69     }
       
    70 
       
    71 void WidgetTestRunner::saveSettings(const Settings* settings)
       
    72     {
       
    73     if (d_ptr->SetOutputFormat(settings->outputFormat) != 0)
       
    74         {
       
    75         emit this->errorOccurred(tr("Failed to set output format."));
       
    76         }
       
    77     d_ptr->SetAllocFailureSimulation(settings->memAllocFailureSim);
       
    78     d_ptr->SetTimeout(settings->timeout);
       
    79     }
       
    80 
       
    81 void WidgetTestRunner::runTests()
       
    82     {
       
    83     d_ptr->RunTests();
       
    84     }