16 */ |
16 */ |
17 #include "ut_logscommondata.h" |
17 #include "ut_logscommondata.h" |
18 #include "logscommondata.h" |
18 #include "logscommondata.h" |
19 #include "logsconfigurationparams.h" |
19 #include "logsconfigurationparams.h" |
20 #include <xqsettingsmanager.h> |
20 #include <xqsettingsmanager.h> |
|
21 #include <hbcolorscheme.h> |
21 |
22 |
22 #include <QtTest/QtTest> |
23 #include <QtTest/QtTest> |
23 |
24 |
24 void UT_LogsCommonData::initTestCase() |
25 void UT_LogsCommonData::initTestCase() |
25 { |
26 { |
135 QVERIFY( LogsCommonData::getInstance().setPredictiveSearch(true) == -1 ); |
136 QVERIFY( LogsCommonData::getInstance().setPredictiveSearch(true) == -1 ); |
136 QVERIFY( LogsCommonData::getInstance().mPredictiveSearchStatus == 2 ); |
137 QVERIFY( LogsCommonData::getInstance().mPredictiveSearchStatus == 2 ); |
137 QVERIFY( XQSettingsManager::mCurrentVal == 2 ); |
138 QVERIFY( XQSettingsManager::mCurrentVal == 2 ); |
138 } |
139 } |
139 |
140 |
|
141 void UT_LogsCommonData::testRefreshData() |
|
142 { |
|
143 // Theme change not pending |
|
144 LogsCommonData& ct = LogsCommonData::getInstance(); |
|
145 QSignalSpy spy( &ct, SIGNAL(commonDataChanged()) ); |
|
146 ct.mCompressed = true; |
|
147 ct.mHighlightColorStart.clear(); |
|
148 ct.refreshData(); |
|
149 QCOMPARE( spy.count(), 0 ); |
|
150 QVERIFY( !ct.mCompressed ); |
|
151 QVERIFY( !ct.mHighlightColorStart.isEmpty() ); |
|
152 |
|
153 // Pending theme change |
|
154 ct.mPendingThemeChange = true; |
|
155 ct.mCompressed = true; |
|
156 ct.mHighlightColorStart.clear(); |
|
157 ct.refreshData(); |
|
158 QCOMPARE( spy.count(), 1 ); |
|
159 QVERIFY( !ct.mCompressed ); |
|
160 QVERIFY( !ct.mHighlightColorStart.isEmpty() ); |
|
161 |
|
162 // No action when already refreshed |
|
163 ct.refreshData(); |
|
164 QCOMPARE( spy.count(), 1 ); |
|
165 QVERIFY( !ct.mCompressed ); |
|
166 QVERIFY( !ct.mHighlightColorStart.isEmpty() ); |
|
167 } |
|
168 |
|
169 void UT_LogsCommonData::testCompressData() |
|
170 { |
|
171 LogsCommonData& ct = LogsCommonData::getInstance(); |
|
172 ct.mCompressed = false; |
|
173 ct.compressData(); |
|
174 QVERIFY( ct.mCompressed ); |
|
175 } |
|
176 |
|
177 void UT_LogsCommonData::testHandleThemeChange() |
|
178 { |
|
179 LogsCommonData& ct = LogsCommonData::getInstance(); |
|
180 QSignalSpy spy( &ct, SIGNAL(commonDataChanged()) ); |
|
181 |
|
182 // Theme changed when not compressed |
|
183 ct.mCompressed = false; |
|
184 ct.mPendingThemeChange = false; |
|
185 ct.handleThemeChange(); |
|
186 QCOMPARE( spy.count(), 1 ); |
|
187 QVERIFY( !ct.mPendingThemeChange ); |
|
188 |
|
189 // Theme changed when compressed |
|
190 spy.clear(); |
|
191 ct.mCompressed = true; |
|
192 ct.handleThemeChange(); |
|
193 QCOMPARE( spy.count(), 0 ); |
|
194 QVERIFY( ct.mPendingThemeChange ); |
|
195 } |
|
196 |
|
197 void UT_LogsCommonData::testHighlightColor() |
|
198 { |
|
199 LogsCommonData& ct = LogsCommonData::getInstance(); |
|
200 QColor highlight = HbColorScheme::color("qtc_lineedit_marker_normal"); |
|
201 QColor color = HbColorScheme::color("qtc_lineedit_selected"); |
|
202 QString start = QString("<span style=\"background-color: %1; color: %2\">") |
|
203 .arg(highlight.name().toUpper()) |
|
204 .arg(color.name().toUpper()); |
|
205 QCOMPARE( ct.highlightStart(), start ); |
|
206 QCOMPARE( ct.highlightEnd(), QString("</span>") ); |
|
207 } |
|
208 |