75 QVERIFY( !mServiceOld->mIsAppStartedUsingService ); |
75 QVERIFY( !mServiceOld->mIsAppStartedUsingService ); |
76 QVERIFY( !mServiceOld->isStartedUsingService() ); |
76 QVERIFY( !mServiceOld->isStartedUsingService() ); |
77 |
77 |
78 |
78 |
79 QtHighwayStubHelper::setIsService(true); |
79 QtHighwayStubHelper::setIsService(true); |
80 LogsServiceHandler serviceHandler(*mMainWindow); |
80 LogsServiceHandler serviceHandler; |
81 QVERIFY( serviceHandler.mIsAppStartedUsingService ); |
81 QVERIFY( serviceHandler.mIsAppStartedUsingService ); |
82 QVERIFY( serviceHandler.isStartedUsingService() ); |
82 QVERIFY( serviceHandler.isStartedUsingService() ); |
83 |
83 |
84 LogsServiceHandlerOld serviceHandlerOld(*mMainWindow); |
84 LogsServiceHandlerOld serviceHandlerOld; |
85 QVERIFY( serviceHandlerOld.mIsAppStartedUsingService ); |
85 QVERIFY( serviceHandlerOld.mIsAppStartedUsingService ); |
86 QVERIFY( serviceHandlerOld.isStartedUsingService() ); |
86 QVERIFY( serviceHandlerOld.isStartedUsingService() ); |
87 } |
87 } |
88 |
88 |
89 void UT_LogsServiceHandler::testStart() |
89 void UT_LogsServiceHandler::testStart() |
94 // Wrong view |
94 // Wrong view |
95 QVERIFY( mServiceOld->start( 9999, true ) != 0 ); |
95 QVERIFY( mServiceOld->start( 9999, true ) != 0 ); |
96 QVERIFY( spy.count() == 0 ); |
96 QVERIFY( spy.count() == 0 ); |
97 |
97 |
98 // Correct view |
98 // Correct view |
99 mServiceOld->mMainWindow.mForeground = false; |
|
100 QVERIFY( mServiceOld->start( (int)LogsServices::ViewReceived, true ) == 0 ); |
99 QVERIFY( mServiceOld->start( (int)LogsServices::ViewReceived, true ) == 0 ); |
101 QVERIFY( spy.count() == 1 ); |
100 QVERIFY( spy.count() == 1 ); |
102 LogsServices::LogsView view = |
101 LogsServices::LogsView view = |
103 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
102 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
104 QVERIFY( view == LogsServices::ViewReceived ); |
103 QVERIFY( view == LogsServices::ViewReceived ); |
105 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
106 } |
104 } |
107 |
105 |
108 void UT_LogsServiceHandler::testStartWithNum() |
106 void UT_LogsServiceHandler::testStartWithNum() |
109 { |
107 { |
110 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
108 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
111 QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString))); |
109 QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString))); |
112 |
110 |
113 mServiceOld->mMainWindow.mForeground = false; |
|
114 QVERIFY( mServiceOld->startWithNum( (int)LogsServices::ViewReceived, true, |
111 QVERIFY( mServiceOld->startWithNum( (int)LogsServices::ViewReceived, true, |
115 QString("+123456") ) == 0 ); |
112 QString("+123456") ) == 0 ); |
116 QVERIFY( spy2.count() == 1 ); |
113 QVERIFY( spy2.count() == 1 ); |
117 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
114 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
118 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
119 } |
115 } |
120 |
116 |
121 void UT_LogsServiceHandler::testShow() |
117 void UT_LogsServiceHandler::testShow() |
122 { |
118 { |
123 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
119 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
132 QVERIFY( spy2.count() == 0 ); |
128 QVERIFY( spy2.count() == 0 ); |
133 |
129 |
134 // Correct view, dialpad text is empty |
130 // Correct view, dialpad text is empty |
135 map.clear(); |
131 map.clear(); |
136 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
132 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
137 mService->mMainWindow.mForeground = false; |
133 map.insert(logsShowDialpadParam, QVariant(true)); |
138 QVERIFY( mService->show(map) == 0 ); |
134 QVERIFY( mService->show(map) == 0 ); |
139 QVERIFY( spy.count() == 1 ); |
135 QVERIFY( spy.count() == 1 ); |
140 QVERIFY( spy2.count() == 0 ); |
136 QVERIFY( spy2.count() == 0 ); |
141 LogsServices::LogsView view = |
137 LogsServices::LogsView view = |
142 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
138 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
143 QVERIFY( view == LogsServices::ViewReceived ); |
139 QCOMPARE( view, LogsServices::ViewReceived ); |
144 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
140 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
|
141 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
145 |
142 |
146 // Correct view, dialpad text not empty |
143 // Correct view, dialpad text not empty |
147 spy.clear(); |
144 spy.clear(); |
148 map.clear(); |
145 map.clear(); |
149 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
146 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
150 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
147 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
151 mService->mMainWindow.mForeground = false; |
|
152 QVERIFY( mService->show(map) == 0 ); |
148 QVERIFY( mService->show(map) == 0 ); |
153 QVERIFY( spy.count() == 0 ); |
149 QVERIFY( spy.count() == 0 ); |
154 QVERIFY( spy2.count() == 1 ); |
150 QVERIFY( spy2.count() == 1 ); |
155 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
151 QCOMPARE( spy2.at(0).at(0).toString(), QString("+123456")); |
156 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
157 |
152 |
158 // Some completly dummy parameters or no params at all |
153 // Some completly dummy parameters or no params at all |
159 spy.clear(); |
154 spy.clear(); |
160 spy2.clear(); |
155 spy2.clear(); |
161 map.clear(); |
156 map.clear(); |
162 map.insert("dummy_param", QVariant(666)); |
157 map.insert("dummy_param", QVariant(666)); |
163 mService->mMainWindow.mForeground = false; |
|
164 QVERIFY( mService->show(map) == 0 ); |
158 QVERIFY( mService->show(map) == 0 ); |
165 QVERIFY( spy.count() == 1 ); |
159 QVERIFY( spy.count() == 1 ); |
166 QVERIFY( spy2.count() == 0 ); |
160 QVERIFY( spy2.count() == 0 ); |
167 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
161 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
168 QVERIFY( view == LogsServices::ViewAll ); |
162 QCOMPARE( view, LogsServices::ViewAll ); |
169 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
163 QCOMPARE( spy.at(0).at(1).toBool(), false ); |
|
164 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
|
165 |
|
166 // Both new and deprecated params present, new params will be used |
|
167 spy.clear(); |
|
168 map.clear(); |
|
169 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
|
170 map.insert(logsShowDialpadParam, QVariant(false)); |
|
171 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
|
172 |
|
173 map.insert(logsViewIndexParamNew, QVariant((int)LogsServices::ViewCalled)); |
|
174 map.insert(logsShowDialpadParamNew, QVariant(true)); |
|
175 map.insert(logsDialpadTextParamNew, QVariant(QString(""))); |
|
176 QVERIFY( mService->show(map) == 0 ); |
|
177 QVERIFY( spy.count() == 1 ); |
|
178 QVERIFY( spy2.count() == 0 ); |
|
179 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
|
180 QCOMPARE( view, LogsServices::ViewCalled ); |
|
181 QCOMPARE( spy.at(0).at(1).toBool(), true ); |
|
182 QCOMPARE( spy.at(0).at(2).toString(), QString("")); |
170 } |
183 } |