63 void UT_LogsServiceHandler::testConstructor() |
68 void UT_LogsServiceHandler::testConstructor() |
64 { |
69 { |
65 QVERIFY( mService ); |
70 QVERIFY( mService ); |
66 QVERIFY( !mService->mIsAppStartedUsingService ); |
71 QVERIFY( !mService->mIsAppStartedUsingService ); |
67 QVERIFY( !mService->isStartedUsingService() ); |
72 QVERIFY( !mService->isStartedUsingService() ); |
|
73 |
|
74 QVERIFY( mServiceOld ); |
|
75 QVERIFY( !mServiceOld->mIsAppStartedUsingService ); |
|
76 QVERIFY( !mServiceOld->isStartedUsingService() ); |
|
77 |
68 |
78 |
69 QtHighwayStubHelper::setIsService(true); |
79 QtHighwayStubHelper::setIsService(true); |
70 LogsServiceHandler serviceHandler(*mMainWindow); |
80 LogsServiceHandler serviceHandler(*mMainWindow); |
71 QVERIFY( serviceHandler.mIsAppStartedUsingService ); |
81 QVERIFY( serviceHandler.mIsAppStartedUsingService ); |
72 QVERIFY( serviceHandler.isStartedUsingService() ); |
82 QVERIFY( serviceHandler.isStartedUsingService() ); |
73 |
83 |
|
84 LogsServiceHandlerOld serviceHandlerOld(*mMainWindow); |
|
85 QVERIFY( serviceHandlerOld.mIsAppStartedUsingService ); |
|
86 QVERIFY( serviceHandlerOld.isStartedUsingService() ); |
74 } |
87 } |
75 |
88 |
76 void UT_LogsServiceHandler::testStart() |
89 void UT_LogsServiceHandler::testStart() |
77 { |
90 { |
78 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
91 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
79 QSignalSpy spy(mService, SIGNAL(activateView(LogsServices::LogsView, bool))); |
92 QSignalSpy spy(mServiceOld, SIGNAL(activateView(LogsServices::LogsView, bool))); |
80 |
93 |
81 // Wrong view |
94 // Wrong view |
82 QVERIFY( mService->start( 9999, true ) != 0 ); |
95 QVERIFY( mServiceOld->start( 9999, true ) != 0 ); |
83 QVERIFY( spy.count() == 0 ); |
96 QVERIFY( spy.count() == 0 ); |
84 |
97 |
85 // Correct view |
98 // Correct view |
86 mService->mMainWindow.mForeground = false; |
99 mServiceOld->mMainWindow.mForeground = false; |
87 QVERIFY( mService->start( (int)LogsServices::ViewReceived, true ) == 0 ); |
100 QVERIFY( mServiceOld->start( (int)LogsServices::ViewReceived, true ) == 0 ); |
88 QVERIFY( spy.count() == 1 ); |
101 QVERIFY( spy.count() == 1 ); |
89 LogsServices::LogsView view = |
102 LogsServices::LogsView view = |
90 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
103 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
91 QVERIFY( view == LogsServices::ViewReceived ); |
104 QVERIFY( view == LogsServices::ViewReceived ); |
92 QVERIFY( mService->currentlyActivatedView() == LogsServices::ViewReceived ); |
105 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
93 QVERIFY( mService->mMainWindow.mForeground ); |
|
94 } |
106 } |
95 |
107 |
96 void UT_LogsServiceHandler::testStartWithNum() |
108 void UT_LogsServiceHandler::testStartWithNum() |
97 { |
109 { |
98 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
110 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
99 QSignalSpy spy2(mService, SIGNAL(activateView(QString))); |
111 QSignalSpy spy2(mServiceOld, SIGNAL(activateView(QString))); |
100 |
112 |
101 mService->mMainWindow.mForeground = false; |
113 mServiceOld->mMainWindow.mForeground = false; |
102 QVERIFY( mService->startWithNum( (int)LogsServices::ViewReceived, true, |
114 QVERIFY( mServiceOld->startWithNum( (int)LogsServices::ViewReceived, true, |
103 QString("+123456") ) == 0 ); |
115 QString("+123456") ) == 0 ); |
104 QVERIFY( spy2.count() == 1 ); |
116 QVERIFY( spy2.count() == 1 ); |
105 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
117 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
106 QVERIFY( mService->mMainWindow.mForeground ); |
118 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
107 } |
119 } |
|
120 |
|
121 void UT_LogsServiceHandler::testShow() |
|
122 { |
|
123 qRegisterMetaType< LogsServices::LogsView >("LogsServices::LogsView"); |
|
124 QSignalSpy spy(mService, SIGNAL(activateView(LogsServices::LogsView, bool))); |
|
125 QSignalSpy spy2(mService, SIGNAL(activateView(QString))); |
|
126 QVariantMap map; |
|
127 |
|
128 // Wrong view |
|
129 map.insert(logsViewIndexParam, QVariant(9999)); |
|
130 QVERIFY( mService->show(map) != 0 ); |
|
131 QVERIFY( spy.count() == 0 ); |
|
132 QVERIFY( spy2.count() == 0 ); |
|
133 |
|
134 // Correct view, dialpad text is empty |
|
135 map.clear(); |
|
136 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
|
137 mService->mMainWindow.mForeground = false; |
|
138 QVERIFY( mService->show(map) == 0 ); |
|
139 QVERIFY( spy.count() == 1 ); |
|
140 QVERIFY( spy2.count() == 0 ); |
|
141 LogsServices::LogsView view = |
|
142 qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
|
143 QVERIFY( view == LogsServices::ViewReceived ); |
|
144 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
145 |
|
146 // Correct view, dialpad text not empty |
|
147 spy.clear(); |
|
148 map.clear(); |
|
149 map.insert(logsViewIndexParam, QVariant((int)LogsServices::ViewReceived)); |
|
150 map.insert(logsDialpadTextParam, QVariant(QString("+123456"))); |
|
151 mService->mMainWindow.mForeground = false; |
|
152 QVERIFY( mService->show(map) == 0 ); |
|
153 QVERIFY( spy.count() == 0 ); |
|
154 QVERIFY( spy2.count() == 1 ); |
|
155 QVERIFY( spy2.at(0).at(0).toString() == QString("+123456")); |
|
156 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
157 |
|
158 // Some completly dummy parameters or no params at all |
|
159 spy.clear(); |
|
160 spy2.clear(); |
|
161 map.clear(); |
|
162 map.insert("dummy_param", QVariant(666)); |
|
163 mService->mMainWindow.mForeground = false; |
|
164 QVERIFY( mService->show(map) == 0 ); |
|
165 QVERIFY( spy.count() == 1 ); |
|
166 QVERIFY( spy2.count() == 0 ); |
|
167 view = qvariant_cast< LogsServices::LogsView >(spy.at(0).at(0)); |
|
168 QVERIFY( view == LogsServices::ViewAll ); |
|
169 QVERIFY( mServiceOld->mMainWindow.mForeground ); |
|
170 } |