24 #include "logsviewmanager.h" |
24 #include "logsviewmanager.h" |
25 #include "logsmainwindow.h" |
25 #include "logsmainwindow.h" |
26 #include "logscomponentrepository.h" |
26 #include "logscomponentrepository.h" |
27 #include "logsmatchesview.h" |
27 #include "logsmatchesview.h" |
28 #include "logsdefs.h" |
28 #include "logsdefs.h" |
|
29 #include <xqaiwdecl.h> |
29 |
30 |
30 //SYSTEM |
31 //SYSTEM |
31 #include <QtTest/QtTest> |
32 #include <QtTest/QtTest> |
32 |
33 |
33 Q_DECLARE_METATYPE(LogsServices::LogsView) |
34 Q_DECLARE_METATYPE(XQService::LogsViewIndex) |
34 |
35 |
35 void UT_LogsServiceHandler::initTestCase() |
36 void UT_LogsServiceHandler::initTestCase() |
36 { |
37 { |
37 } |
38 } |
38 |
39 |
86 QVERIFY( serviceHandlerOld.isStartedUsingService() ); |
87 QVERIFY( serviceHandlerOld.isStartedUsingService() ); |
87 } |
88 } |
88 |
89 |
89 void UT_LogsServiceHandler::testStart() |
90 void UT_LogsServiceHandler::testStart() |
90 { |
91 { |
91 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
92 qRegisterMetaType< XQService::LogsViewIndex >("XQService::LogsViewIndex"); |
92 QSignalSpy spy(mServiceOld, SIGNAL(activateView(LogsServices::LogsView, bool, QString))); |
93 QSignalSpy spy(mServiceOld, SIGNAL(activateView(XQService::LogsViewIndex, bool, QString))); |
93 |
94 |
94 // Wrong view |
95 // Wrong view |
95 QVERIFY( mServiceOld->start( 9999, true ) != 0 ); |
96 QVERIFY( mServiceOld->start( 9999, true ) != 0 ); |
96 QVERIFY( spy.count() == 0 ); |
97 QVERIFY( spy.count() == 0 ); |
97 |
98 |
98 // Correct view |
99 // Correct view |
99 QVERIFY( mServiceOld->start( (int)LogsServices::ViewReceived, true ) == 0 ); |
100 QVERIFY( mServiceOld->start( (int)XQService::LogsViewReceived, true ) == 0 ); |
100 QVERIFY( spy.count() == 1 ); |
101 QVERIFY( spy.count() == 1 ); |
101 LogsServices::LogsView view = |
102 XQService::LogsViewIndex view = |
102 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
103 qvariant_cast< XQService::LogsViewIndex >(spy.at(0).at(0)); |
103 QVERIFY( view == LogsServices::ViewReceived ); |
104 QVERIFY( view == XQService::LogsViewReceived ); |
104 } |
105 } |
105 |
106 |
106 void UT_LogsServiceHandler::testStartWithNum() |
107 void UT_LogsServiceHandler::testStartWithNum() |
107 { |
108 { |
108 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
109 qRegisterMetaType< XQService::LogsViewIndex >("XQService::LogsViewIndex"); |
109 QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString))); |
110 QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString))); |
110 |
111 |
111 QVERIFY( mServiceOld->startWithNum( (int)LogsServices::ViewReceived, true, |
112 QVERIFY( mServiceOld->startWithNum( (int)XQService::LogsViewReceived, true, |
112 QString("+123456") ) == 0 ); |
113 QString("+123456") ) == 0 ); |
113 QVERIFY( spy2.count() == 1 ); |
114 QVERIFY( spy2.count() == 1 ); |
114 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
115 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
115 } |
116 } |
116 |
117 |
117 void UT_LogsServiceHandler::testShow() |
118 void UT_LogsServiceHandler::testShow() |
118 { |
119 { |
119 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
120 qRegisterMetaType< XQService::LogsViewIndex >("XQService::LogsViewIndex"); |
120 QSignalSpy spy(mService, SIGNAL(activateView(LogsServices::LogsView, bool, QString))); |
121 QSignalSpy spy(mService, SIGNAL(activateView(XQService::LogsViewIndex, bool, QString))); |
121 QSignalSpy spy2(mService, SIGNAL(activateView(QString))); |
122 QSignalSpy spy2(mService, SIGNAL(activateView(QString))); |
122 QVariantMap map; |
123 QVariantMap map; |
123 |
124 |
124 // Wrong view |
125 // Wrong view |
125 map.insert(logsViewIndexParam, QVariant(9999)); |
126 map.insert(logsViewIndexParam, QVariant(9999)); |
127 QVERIFY( spy.count() == 0 ); |
128 QVERIFY( spy.count() == 0 ); |
128 QVERIFY( spy2.count() == 0 ); |
129 QVERIFY( spy2.count() == 0 ); |
129 |
130 |
130 // Correct view, dialpad text is empty |
131 // Correct view, dialpad text is empty |
131 map.clear(); |
132 map.clear(); |
132 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
133 map.insert(logsViewIndexParam, QVariant((int)XQService::LogsViewReceived)); |
133 map.insert(logsShowDialpadParam, QVariant(true)); |
134 map.insert(logsShowDialpadParam, QVariant(true)); |
134 QVERIFY( mService->show(map) == 0 ); |
135 QVERIFY( mService->show(map) == 0 ); |
135 QVERIFY( spy.count() == 1 ); |
136 QVERIFY( spy.count() == 1 ); |
136 QVERIFY( spy2.count() == 0 ); |
137 QVERIFY( spy2.count() == 0 ); |
137 LogsServices::LogsView view = |
138 XQService::LogsViewIndex view = |
138 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
139 qvariant_cast< XQService::LogsViewIndex >(spy.at(0).at(0)); |
139 QCOMPARE( view, LogsServices::ViewReceived ); |
140 QCOMPARE( view, XQService::LogsViewReceived ); |
140 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
141 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
141 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
142 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
142 |
143 |
143 // Correct view, dialpad text not empty |
144 // Correct view, dialpad text not empty |
144 spy.clear(); |
145 spy.clear(); |
145 map.clear(); |
146 map.clear(); |
146 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
147 map.insert(logsViewIndexParam, QVariant((int)XQService::LogsViewReceived)); |
147 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
148 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
148 QVERIFY( mService->show(map) == 0 ); |
149 QVERIFY( mService->show(map) == 0 ); |
149 QVERIFY( spy.count() == 0 ); |
150 QVERIFY( spy.count() == 0 ); |
150 QVERIFY( spy2.count() == 1 ); |
151 QVERIFY( spy2.count() == 1 ); |
151 QCOMPARE( spy2.at(0).at(0).toString(), QString("+123456")); |
152 QCOMPARE( spy2.at(0).at(0).toString(), QString("+123456")); |
156 map.clear(); |
157 map.clear(); |
157 map.insert("dummy_param", QVariant(666)); |
158 map.insert("dummy_param", QVariant(666)); |
158 QVERIFY( mService->show(map) == 0 ); |
159 QVERIFY( mService->show(map) == 0 ); |
159 QVERIFY( spy.count() == 1 ); |
160 QVERIFY( spy.count() == 1 ); |
160 QVERIFY( spy2.count() == 0 ); |
161 QVERIFY( spy2.count() == 0 ); |
161 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
162 view = qvariant_cast< XQService::LogsViewIndex >(spy.at(0).at(0)); |
162 QCOMPARE( view, LogsServices::ViewAll ); |
163 QCOMPARE( view, XQService::LogsViewAll ); |
163 QCOMPARE( spy.at(0).at(1).toBool(), false ); |
164 QCOMPARE( spy.at(0).at(1).toBool(), false ); |
164 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
165 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
165 |
166 |
166 // Both new and deprecated params present, new params will be used |
167 // Both new and deprecated params present, new params will be used |
167 spy.clear(); |
168 spy.clear(); |
168 map.clear(); |
169 map.clear(); |
169 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
170 map.insert(logsViewIndexParam, QVariant((int)XQService::LogsViewReceived)); |
170 map.insert(logsShowDialpadParam, QVariant(false)); |
171 map.insert(logsShowDialpadParam, QVariant(false)); |
171 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
172 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
172 |
173 |
173 map.insert(logsViewIndexParamNew, QVariant((int)LogsServices::ViewCalled)); |
174 map.insert(XQLOGS_VIEW_INDEX, QVariant((int)XQService::LogsViewCalled)); |
174 map.insert(logsShowDialpadParamNew, QVariant(true)); |
175 map.insert(XQLOGS_SHOW_DIALPAD, QVariant(true)); |
175 map.insert(logsDialpadTextParamNew, QVariant(QString(""))); |
176 map.insert(XQLOGS_DIALPAD_TEXT, QVariant(QString(""))); |
176 QVERIFY( mService->show(map) == 0 ); |
177 QVERIFY( mService->show(map) == 0 ); |
177 QVERIFY( spy.count() == 1 ); |
178 QVERIFY( spy.count() == 1 ); |
178 QVERIFY( spy2.count() == 0 ); |
179 QVERIFY( spy2.count() == 0 ); |
179 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
180 view = qvariant_cast< XQService::LogsViewIndex >(spy.at(0).at(0)); |
180 QCOMPARE( view, LogsServices::ViewCalled ); |
181 QCOMPARE( view, XQService::LogsViewCalled ); |
181 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
182 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
182 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
183 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
183 } |
184 } |