| Start/ | End/ | |||
| True | False | - | Line | Source |
| 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: Unit Test for mpdetailsview. | |||
| 15 | * | |||
| 16 | */ | |||
| 17 | #include <QSignalSpy> | |||
| 18 | #include <qgraphicswebview> | |||
| 19 | #include <qwebsettings> | |||
| 20 | #include <QGraphicsWidget> | |||
| 21 | #include <QGraphicsLayoutItem> | |||
| 22 | #include <QUrl> | |||
| 23 | #include <QSslError> | |||
| 24 | #include <QDomElement> | |||
| 25 | #include <QWebPage> | |||
| 26 | #include <QWebFrame> | |||
| 27 | #include <QList> | |||
| 28 | #include <QFile> | |||
| 29 | #include <QTranslator> | |||
| 30 | #include <QLocale> | |||
| 31 | ||||
| 32 | #include <hbinstance.h> | |||
| 33 | #include <hbmainwindow.h> | |||
| 34 | #include <hbaction.h> | |||
| 35 | #include <hblabel.h> | |||
| 36 | #include <hbgroupbox.h> | |||
| 37 | #include <hbdocumentloader.h> | |||
| 38 | #include <hbwidget.h> | |||
| 39 | #include <hbpushbutton.h> | |||
| 40 | #include <hbpopup.h> | |||
| 41 | #include <hbdialog.h> | |||
| 42 | #include <hblistwidget.h> | |||
| 43 | #include <hblistwidgetitem.h> | |||
| 44 | #include <HbApplication> | |||
| 45 | ||||
| 46 | #include "unittest_mpdetailsview.h" | |||
| 47 | #include "stub/inc/mpsongdata.h" | |||
| 48 | #include "stub/inc/thumbnailmanager_qt.h" | |||
| 49 | #include "mpcommondefs.h" | |||
| 50 | ||||
| 51 | // Do this so we can access all member variables. | |||
| 52 | #define private public | |||
| 53 | #include "mpdetailsview.h" | |||
| 54 | #undef private | |||
| 55 | ||||
| 56 | ||||
| 57 | ||||
| 58 | /*! | |||
| 59 | Make our test case a stand-alone executable that runs all the test functions. | |||
| 60 | */ | |||
| Top | ||||
| 1 | 0 | 61 | int main(int argc, char *argv[]) | |
| 62 | { | |||
| 63 | HbApplication app(argc, argv); | |||
| 64 | HbMainWindow window; | |||
| 65 | ||||
| 66 | TestMpDetailsView tv; | |||
| 67 | ||||
| 68 | char *pass[3]; | |||
| 69 | pass[0] = argv[0]; | |||
| 70 | pass[1] = "-o"; | |||
| 71 | pass[2] = "c:\\data\\unittest_testmpdetailsview.txt"; | |||
| 72 | ||||
| 73 | int res = QTest::qExec(&tv, 3, pass); | |||
| 74 | ||||
| 1 | 75 | return res; | ||
| 76 | } | |||
| 77 | ||||
| 78 | //Constructor | |||
| Top | ||||
| 1 | 1 | 79 | TestMpDetailsView::TestMpDetailsView() | |
| 80 | : mTest(0) | |||
| 81 | { | |||
| 82 | ||||
| 83 | } | |||
| 84 | ||||
| 85 | //Destructor | |||
| Top | ||||
| 1 | 1 | 86 | TestMpDetailsView::~TestMpDetailsView() | |
| 87 | { | |||
| 88 | delete mTest; | |||
| 89 | } | |||
| 90 | ||||
| 91 | /*! | |||
| 92 | Called before the first testfunction is executed. | |||
| 93 | */ | |||
| Top | ||||
| 1 | 1 | 94 | void TestMpDetailsView::initTestCase() | |
| 95 | { | |||
| 96 | ||||
| 97 | } | |||
| 98 | ||||
| 99 | /*! | |||
| 100 | Called after the last testfunction was executed. | |||
| 101 | */ | |||
| Top | ||||
| 1 | 1 | 102 | void TestMpDetailsView::cleanupTestCase() | |
| 103 | { | |||
| 104 | ||||
| 105 | } | |||
| 106 | ||||
| 107 | /*! | |||
| 108 | Called before each testfunction is executed. | |||
| 109 | */ | |||
| Top | ||||
| 4 | 4 | 110 | void TestMpDetailsView::init() | |
| 111 | { | |||
| 112 | mTest = new MpDetailsView(); | |||
| 113 | mTest->initializeView(); | |||
| 114 | } | |||
| 115 | ||||
| 116 | /*! | |||
| 117 | Called after every testfunction. | |||
| 118 | */ | |||
| Top | ||||
| 4 | 4 | 119 | void TestMpDetailsView::cleanup() | |
| 120 | { | |||
| 121 | delete mTest; | |||
| 122 | mTest = 0; | |||
| 123 | } | |||
| 124 | ||||
| Top | ||||
| 1 | 1 | 125 | void TestMpDetailsView::testactivateView() | |
| 126 | { | |||
| 127 | mTest->activateView(); | |||
| 128 | QVERIFY(mTest->mActivated==true); | |||
| 0 | 1 | - | 128 | if (! QTest::qVerify ( ( mTest -> mActivated.. |
| 0 | - | 128 | return | |
| 128 | while ( 0 ) | |||
| 129 | } | |||
| 130 | ||||
| Top | ||||
| 1 | 1 | 131 | void TestMpDetailsView::testdeactivateView() | |
| 132 | { | |||
| 133 | mTest->deactivateView(); | |||
| 134 | QVERIFY(mTest->mActivated==false); | |||
| 0 | 1 | - | 134 | if (! QTest::qVerify ( ( mTest -> mActivated.. |
| 0 | - | 134 | return | |
| 134 | while ( 0 ) | |||
| 135 | } | |||
| 136 | ||||
| Top | ||||
| 1 | 1 | 137 | void TestMpDetailsView::testbackSlot() { | |
| 138 | connect(this, SIGNAL(back()), mTest->mSoftKeyBack, SIGNAL(triggered())); | |||
| 139 | QSignalSpy spy(mTest, SIGNAL(command(int))); | |||
| 140 | QVERIFY(spy.isValid()); | |||
| 0 | 1 | - | 140 | if (! QTest::qVerify ( ( spy . isValid ( ) ).. |
| 0 | - | 140 | return | |
| 140 | while ( 0 ) | |||
| 141 | QCOMPARE(spy.count(),0); | |||
| 0 | 1 | - | 141 | if (! QTest::qCompare ( spy . count ( ) , 0 .. |
| 0 | - | 141 | return | |
| 141 | while ( 0 ) | |||
| 142 | ||||
| 143 | emit back(); | |||
| 144 | QCOMPARE(spy.count(),1); | |||
| 0 | 1 | - | 144 | if (! QTest::qCompare ( spy . count ( ) , 1 .. |
| 0 | - | 144 | return | |
| 144 | while ( 0 ) | |||
| 145 | } | |||
| 146 | ||||
| 147 | ||||
| ***TER 62% (16/26) of SOURCE FILE unittest_mpdetailsview.cpp | ||||