|
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 MpMediaWallDocumentLoader |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <qnamespace.h> |
|
19 #include <hbtoolbutton.h> |
|
20 |
|
21 #include "stub/inc/hgmediawall.h" |
|
22 #include "unittest_mpmediawalldocumentloader.h" |
|
23 |
|
24 |
|
25 |
|
26 // Do this so we can access all member variables. |
|
27 #define private public |
|
28 #include "mpmediawalldocumentloader.h" |
|
29 #undef private |
|
30 |
|
31 /*! |
|
32 Make our test case a stand-alone executable that runs all the test functions. |
|
33 */ |
|
34 int main(int argc, char *argv[]) |
|
35 { |
|
36 QApplication app(argc, argv); |
|
37 TestMpMediaWallDocumentLoader tv; |
|
38 |
|
39 if ( argc > 1 ) { |
|
40 return QTest::qExec( &tv, argc, argv); |
|
41 } |
|
42 else { |
|
43 char *pass[3]; |
|
44 pass[0] = argv[0]; |
|
45 pass[1] = "-o"; |
|
46 pass[2] = "c:\\data\\unittest_mpmediawalldocumentloader.txt"; |
|
47 |
|
48 return QTest::qExec(&tv, 3, pass); |
|
49 } |
|
50 } |
|
51 |
|
52 TestMpMediaWallDocumentLoader::TestMpMediaWallDocumentLoader() |
|
53 : mTest(0) |
|
54 { |
|
55 } |
|
56 |
|
57 TestMpMediaWallDocumentLoader::~TestMpMediaWallDocumentLoader() |
|
58 { |
|
59 delete mTest; |
|
60 } |
|
61 |
|
62 /*! |
|
63 Called before the first testfunction is executed. |
|
64 */ |
|
65 void TestMpMediaWallDocumentLoader::initTestCase() |
|
66 { |
|
67 } |
|
68 |
|
69 /*! |
|
70 Called after the last testfunction was executed. |
|
71 */ |
|
72 void TestMpMediaWallDocumentLoader::cleanupTestCase() |
|
73 { |
|
74 } |
|
75 |
|
76 /*! |
|
77 Called before each testfunction is executed. |
|
78 */ |
|
79 void TestMpMediaWallDocumentLoader::init() |
|
80 { |
|
81 mTest = new MpMediaWallDocumentLoader(); |
|
82 } |
|
83 |
|
84 /*! |
|
85 Called after every testfunction. |
|
86 */ |
|
87 void TestMpMediaWallDocumentLoader::cleanup() |
|
88 { |
|
89 delete mTest; |
|
90 mTest = 0; |
|
91 } |
|
92 |
|
93 /*! |
|
94 Tests the correct creation of HgMediawall. |
|
95 */ |
|
96 void TestMpMediaWallDocumentLoader::testCreateHgMediawall() |
|
97 { |
|
98 cleanup(); |
|
99 init(); |
|
100 QObject *theObject; |
|
101 theObject = mTest->createObject(QString("HgMediawall"),QString("myHgMediawall")); |
|
102 QCOMPARE(theObject->metaObject()->className(),"HgMediawall"); |
|
103 QCOMPARE(theObject->objectName(),QString("myHgMediawall")); |
|
104 QVERIFY(qobject_cast<HgMediawall*>(theObject)); |
|
105 delete theObject; |
|
106 |
|
107 } |
|
108 |
|
109 /*! |
|
110 Tests the correct creation of HbToolButton. |
|
111 */ |
|
112 void TestMpMediaWallDocumentLoader::testCreateHbToolButton() |
|
113 { |
|
114 cleanup(); |
|
115 init(); |
|
116 QObject *theObject; |
|
117 theObject = mTest->createObject(QString("HbToolButton"),QString("myHbToolButton")); |
|
118 QCOMPARE(theObject->metaObject()->className(),"HbToolButton"); |
|
119 QCOMPARE(theObject->objectName(),QString("myHbToolButton")); |
|
120 QVERIFY(qobject_cast<HbToolButton*>(theObject)); |
|
121 delete theObject; |
|
122 |
|
123 } |
|
124 |
|
125 /*! |
|
126 Tests the correct creation of QObject, this should be pased to the |
|
127 base class and base class should return a named object. |
|
128 */ |
|
129 void TestMpMediaWallDocumentLoader::testCreateQObject() |
|
130 { |
|
131 cleanup(); |
|
132 init(); |
|
133 QObject *theObject; |
|
134 theObject = mTest->createObject(QString("QObject"),QString("myQObject")); |
|
135 QCOMPARE(theObject->metaObject()->className(),"QObject"); |
|
136 QCOMPARE(theObject->objectName(),QString("myQObject")); |
|
137 delete theObject; |
|
138 } |
|
139 |
|
140 // End of file |