|
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 tests for ParserRecognizer. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtTest/QtTest> |
|
19 |
|
20 //#include <hbglobal_p.h> |
|
21 #include "xqservicerequest.h" |
|
22 #include "parserrecognizer.h" |
|
23 #include "pevirtualengine.h" |
|
24 |
|
25 QString apiString; |
|
26 QString methodString; |
|
27 bool sendCalled; |
|
28 |
|
29 class TestParserRecognizer : public QObject |
|
30 { |
|
31 Q_OBJECT |
|
32 public: |
|
33 TestParserRecognizer(); |
|
34 virtual ~TestParserRecognizer(); |
|
35 |
|
36 public slots: |
|
37 void initTestCase (); |
|
38 void cleanupTestCase (); |
|
39 void init (); |
|
40 void cleanup (); |
|
41 |
|
42 private slots: |
|
43 void testActivateRfsDeep(); |
|
44 void testActivateRfsNormal(); |
|
45 void testActivateWarrantyMode(); |
|
46 void testShowBTDeviceAddress(); |
|
47 void testShowBTLoopback(); |
|
48 void testActivateBTDebugMode(); |
|
49 void testShowIMEI(); |
|
50 void testShowVersion(); |
|
51 void testShowWLANMacAddress(); |
|
52 void testSSRequestFailed(); |
|
53 |
|
54 private: |
|
55 ParserRecognizer *parserRecognizer; // class under test |
|
56 }; |
|
57 |
|
58 XQServiceRequest::XQServiceRequest(QString const& api, QString const& method, bool const& sync) |
|
59 { |
|
60 Q_UNUSED(sync); |
|
61 apiString = api; |
|
62 methodString = method; |
|
63 } |
|
64 |
|
65 bool XQServiceRequest::send(QVariant& retValue) |
|
66 { |
|
67 Q_UNUSED(retValue); |
|
68 sendCalled = true; |
|
69 return true; |
|
70 } |
|
71 |
|
72 XQServiceRequest::~XQServiceRequest() |
|
73 { |
|
74 } |
|
75 |
|
76 TestParserRecognizer::TestParserRecognizer () |
|
77 { |
|
78 } |
|
79 |
|
80 TestParserRecognizer::~TestParserRecognizer () |
|
81 { |
|
82 } |
|
83 |
|
84 void TestParserRecognizer::initTestCase () |
|
85 { |
|
86 } |
|
87 |
|
88 void TestParserRecognizer::cleanupTestCase () |
|
89 { |
|
90 } |
|
91 |
|
92 void TestParserRecognizer::init () |
|
93 { |
|
94 apiString = ""; |
|
95 methodString = ""; |
|
96 sendCalled = false; |
|
97 parserRecognizer = new ParserRecognizer; |
|
98 } |
|
99 |
|
100 void TestParserRecognizer::cleanup () |
|
101 { |
|
102 delete parserRecognizer; |
|
103 } |
|
104 |
|
105 void TestParserRecognizer::testActivateRfsDeep() |
|
106 { |
|
107 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageActivateRfsDeep, 0); |
|
108 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
109 QCOMPARE(methodString, QString("activateDeepRestoreFactorySettings()")); |
|
110 QCOMPARE(sendCalled, true); |
|
111 } |
|
112 |
|
113 void TestParserRecognizer::testActivateRfsNormal() |
|
114 { |
|
115 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageActivateRfsNormal, 0); |
|
116 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
117 QCOMPARE(methodString, QString("activateNormalRestoreFactorySettings()")); |
|
118 QCOMPARE(sendCalled, true); |
|
119 } |
|
120 |
|
121 void TestParserRecognizer::testActivateWarrantyMode() |
|
122 { |
|
123 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageActivateWarrantyMode, 0); |
|
124 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
125 QCOMPARE(methodString, QString("activateWarrantyMode()")); |
|
126 QCOMPARE(sendCalled, true); |
|
127 } |
|
128 |
|
129 void TestParserRecognizer::testShowBTDeviceAddress() |
|
130 { |
|
131 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowBTDeviceAddress, 0); |
|
132 QCOMPARE(apiString, QString("com.nokia.services.bluetooth")); |
|
133 QCOMPARE(methodString, QString("showBluetoothDeviceAddress()")); |
|
134 QCOMPARE(sendCalled, true); |
|
135 } |
|
136 |
|
137 void TestParserRecognizer::testShowBTLoopback() |
|
138 { |
|
139 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowBTLoopback, 0); |
|
140 QCOMPARE(apiString, QString("com.nokia.services.bluetooth")); |
|
141 QCOMPARE(methodString, QString("showBluetoothLoopback()")); |
|
142 QCOMPARE(sendCalled, true); |
|
143 } |
|
144 |
|
145 void TestParserRecognizer::testActivateBTDebugMode() |
|
146 { |
|
147 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageBTDebugMode, 0); |
|
148 QCOMPARE(apiString, QString("com.nokia.services.bluetooth")); |
|
149 QCOMPARE(methodString, QString("activateBluetoothDebugMode()")); |
|
150 QCOMPARE(sendCalled, true); |
|
151 } |
|
152 |
|
153 void TestParserRecognizer::testShowIMEI() |
|
154 { |
|
155 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowIMEI, 0); |
|
156 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
157 QCOMPARE(methodString, QString("showIMEICode()")); |
|
158 QCOMPARE(sendCalled, true); |
|
159 } |
|
160 |
|
161 void TestParserRecognizer::testShowVersion() |
|
162 { |
|
163 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowVersion, 0); |
|
164 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
165 QCOMPARE(methodString, QString("showVersionNumber()")); |
|
166 QCOMPARE(sendCalled, true); |
|
167 } |
|
168 |
|
169 void TestParserRecognizer::testShowWLANMacAddress() |
|
170 { |
|
171 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageShowWlanMacAddress, 0); |
|
172 QCOMPARE(apiString, QString("com.nokia.services.wlan")); |
|
173 QCOMPARE(methodString, QString("showWLANMacAddress()")); |
|
174 QCOMPARE(sendCalled, true); |
|
175 } |
|
176 |
|
177 void TestParserRecognizer::testSSRequestFailed() |
|
178 { |
|
179 parserRecognizer->sendMessage(MEngineMonitor::EPEMessageSSRequestFailed, 0); |
|
180 QCOMPARE(apiString, QString("com.nokia.services.telephony")); |
|
181 QCOMPARE(methodString, QString("supplementaryServiceRequestFailed()")); |
|
182 QCOMPARE(sendCalled, true); |
|
183 } |
|
184 |
|
185 QTEST_MAIN(TestParserRecognizer) |
|
186 #include "unit_tests.moc" |