homescreenapp/hswidgetuninstaller/tsrc/t_hswidgetuninstaller/src/t_hswidgetuninstaller.cpp
changeset 96 458d8c8d9580
equal deleted inserted replaced
92:6727c5d0afc7 96:458d8c8d9580
       
     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 test class for hswidgetuninstaller.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "t_hswidgetuninstaller.h"
       
    20 #include "hswidgetinstallersender.h"
       
    21 #include "hswidgetcomponentparser.h"
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 void t_hswidgetuninstaller::initTestCase()
       
    27 {
       
    28 #ifndef NFT
       
    29     QDir::setCurrent("C:/hsresources/testresources");
       
    30 #else      
       
    31     QDir::setCurrent("Z:/hsresources/testresources");
       
    32 #endif   
       
    33 }
       
    34 
       
    35 void t_hswidgetuninstaller::cleanupTestCase()
       
    36 {
       
    37 }
       
    38 
       
    39 void t_hswidgetuninstaller::testWidgetInstallerSender()
       
    40 {
       
    41     HsWidgetInstallerSender sender;
       
    42     HsWidgetComponentDescriptor widgetDescriptor;
       
    43     QString functionName("widgetUninstalled(QVariantHash)");
       
    44     sender.widgetChanged(functionName, widgetDescriptor);
       
    45     // nothing to verify
       
    46 }
       
    47 
       
    48 void t_hswidgetuninstaller::testWidgetComponentParser_data()
       
    49 {    
       
    50     QTest::addColumn<QString>("filename");
       
    51     QTest::addColumn<QString>("expecteduri");
       
    52     QTest::addColumn<bool>("expectederror");
       
    53     QTest::addColumn<QString>("expectedtranslationfile");
       
    54     QTest::newRow("notfound") << "notfound.manifest" << "" << true << "";
       
    55     QTest::newRow("empty.manifest") << "empty.manifest" << "" << true << "";
       
    56     QTest::newRow("ok_new") << "ok_new.manifest" << "helloworldwidgetplugin" << false << "helloworldtranslation";
       
    57     QTest::newRow("ok_old") << "ok_old.manifest" << "helloworldwidgetplugin" << false << "";
       
    58     QTest::newRow("fail_new.manifest") << "fail_new.manifest" << "" << true << "";
       
    59     QTest::newRow("version10.manifest") << "version10.manifest" << "helloworldwidgetplugin" << false << "";
       
    60     QTest::newRow("version12.manifest") << "version12.manifest" << "" << true << "";
       
    61 }
       
    62 
       
    63 void t_hswidgetuninstaller::testWidgetComponentParser()
       
    64 {
       
    65     QFETCH(QString, filename);
       
    66     QFETCH(QString, expecteduri);
       
    67     QFETCH(bool, expectederror);
       
    68     QFETCH(QString, expectedtranslationfile);
       
    69     HsWidgetComponentParser componentParser(filename);
       
    70     HsWidgetComponentDescriptor widgetDescriptor = componentParser.widgetComponentDescriptor();
       
    71     QCOMPARE(widgetDescriptor.uri(), expecteduri);
       
    72     QCOMPARE(componentParser.error(), expectederror);
       
    73     QCOMPARE(widgetDescriptor.translationFilename(), expectedtranslationfile);
       
    74 }
       
    75 
       
    76 
       
    77 QTEST_MAIN(t_hswidgetuninstaller)