33// SPDX-License-Identifier: GPL-3.0-or-later
44
55#include < QTest>
6- #include < QLoggingCategory>
76
8- #include " ../src/utils/ categoryutils.h"
7+ #include " categoryutils.h"
98
109namespace {
11- Q_LOGGING_CATEGORY (logTest, " dde.launchpad.test" )
1210
1311using C = CategoryUtils::Categorytype;
1412}
@@ -47,7 +45,6 @@ private slots:
4745
4846void TestCategoryUtils::parseDDECategoryStringKnown ()
4947{
50- qCInfo (logTest) << " parseDDECategoryString should map the known DDE category names" ;
5148 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" music" ))), int (C::CategoryMusic));
5249 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" internet" ))), int (C::CategoryInternet));
5350 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" development" ))), int (C::CategoryDevelopment));
@@ -56,22 +53,19 @@ void TestCategoryUtils::parseDDECategoryStringKnown()
5653
5754void TestCategoryUtils::parseDDECategoryStringUnknown ()
5855{
59- qCInfo (logTest) << " Unknown DDE category strings should yield CategoryErr" ;
6056 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" unknown" ))), int (C::CategoryErr));
6157 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" Music" ))), int (C::CategoryErr)); // case sensitive
6258}
6359
6460void TestCategoryUtils::parseXdgCategoryStringSingle ()
6561{
66- qCInfo (logTest) << " parseXdgCategoryString should map single-valued XDG categories" ;
6762 const auto result = CategoryUtils::parseXdgCategoryString (QStringLiteral (" webbrowser" ));
6863 QCOMPARE (result.size (), 1 );
6964 QVERIFY (result.contains (C::CategoryInternet));
7065}
7166
7267void TestCategoryUtils::parseXdgCategoryStringMultiValued ()
7368{
74- qCInfo (logTest) << " audiovideo should map to both music and video" ;
7569 const auto result = CategoryUtils::parseXdgCategoryString (QStringLiteral (" audiovideo" ));
7670 QCOMPARE (result.size (), 2 );
7771 QVERIFY (result.contains (C::CategoryMusic));
@@ -80,61 +74,52 @@ void TestCategoryUtils::parseXdgCategoryStringMultiValued()
8074
8175void TestCategoryUtils::parseXdgCategoryStringUnknown ()
8276{
83- qCInfo (logTest) << " Unknown XDG category strings should yield an empty list" ;
8477 const auto result = CategoryUtils::parseXdgCategoryString (QStringLiteral (" totally-unknown-category" ));
8578 QVERIFY (result.isEmpty ());
8679}
8780
8881void TestCategoryUtils::bestMatchedSingleCategory ()
8982{
90- qCInfo (logTest) << " A single matching category should win" ;
9183 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" music" )})), int (C::CategoryMusic));
9284 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" network" )})), int (C::CategoryInternet));
9385 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" spreadsheet" )})), int (C::CategoryOffice));
9486}
9587
9688void TestCategoryUtils::bestMatchedEmptyReturnsOthers ()
9789{
98- qCInfo (logTest) << " An empty category list should be classified as others" ;
9990 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({})), int (C::CategoryOthers));
10091}
10192
10293void TestCategoryUtils::bestMatchedOthersOnlyReturnsOthers ()
10394{
104- qCInfo (logTest) << " An only-others list should be classified as others" ;
10595 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" others" )})), int (C::CategoryOthers));
10696}
10797
10898void TestCategoryUtils::bestMatchedMusicVideoTiePrefersVideo ()
10999{
110- qCInfo (logTest) << " A music/video tie should prefer video" ;
111100 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" music" ), QStringLiteral (" video" )})),
112101 int (C::CategoryVideo));
113102}
114103
115104void TestCategoryUtils::bestMatchedPlayerMapsToVideo ()
116105{
117- qCInfo (logTest) << " player (maps to music+video) should resolve to video" ;
118106 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" player" )})), int (C::CategoryVideo));
119107}
120108
121109void TestCategoryUtils::bestMatchedMaxCountWins ()
122110{
123- qCInfo (logTest) << " The category with the highest count should win" ;
124111 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" game" ), QStringLiteral (" game" ), QStringLiteral (" music" )})),
125112 int (C::CategoryGame));
126113}
127114
128115void TestCategoryUtils::bestMatchedMultipleInternet ()
129116{
130- qCInfo (logTest) << " Several internet categories should aggregate into internet" ;
131117 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" webbrowser" ), QStringLiteral (" email" )})),
132118 int (C::CategoryInternet));
133119}
134120
135121void TestCategoryUtils::parseDDECategoryStringAllKnown ()
136122{
137- qCInfo (logTest) << " parseDDECategoryString should map all known DDE category names" ;
138123 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" chat" ))), int (C::CategoryChat));
139124 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" video" ))), int (C::CategoryVideo));
140125 QCOMPARE (int (CategoryUtils::parseDDECategoryString (QStringLiteral (" graphics" ))), int (C::CategoryGraphics));
@@ -146,7 +131,6 @@ void TestCategoryUtils::parseDDECategoryStringAllKnown()
146131
147132void TestCategoryUtils::parseXdgCategoryStringMultipleDistinctCategories ()
148133{
149- qCInfo (logTest) << " parseXdgCategoryString for several distinct known categories" ;
150134 // Each call returns the list for that single string; verify a batch of them
151135 QCOMPARE (CategoryUtils::parseXdgCategoryString (QStringLiteral (" ide" )).size (), 1 );
152136 QVERIFY (CategoryUtils::parseXdgCategoryString (QStringLiteral (" ide" )).contains (C::CategoryDevelopment));
@@ -164,15 +148,13 @@ void TestCategoryUtils::parseXdgCategoryStringMultipleDistinctCategories()
164148
165149void TestCategoryUtils::parseXdgCategoryStringAudioMapsToMusic ()
166150{
167- qCInfo (logTest) << " audio should map to music" ;
168151 const auto result = CategoryUtils::parseXdgCategoryString (QStringLiteral (" audio" ));
169152 QCOMPARE (result.size (), 1 );
170153 QVERIFY (result.contains (C::CategoryMusic));
171154}
172155
173156void TestCategoryUtils::bestMatchedDDECategoryWinsOverXdg ()
174157{
175- qCInfo (logTest) << " A DDE category name should be matched before falling to XDG parsing" ;
176158 // 'music' is a DDE name -> CategoryMusic (via parseDDECategoryString)
177159 // 'audio' is an XDG name -> CategoryMusic (via parseXdgCategoryString)
178160 // mixing them should still yield Music
@@ -182,7 +164,6 @@ void TestCategoryUtils::bestMatchedDDECategoryWinsOverXdg()
182164
183165void TestCategoryUtils::bestMatchedGameVariants ()
184166{
185- qCInfo (logTest) << " Various game XDG categories should aggregate into game" ;
186167 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" actiongame" ), QStringLiteral (" arcadegame" )})),
187168 int (C::CategoryGame));
188169 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" boardgame" ), QStringLiteral (" cardgame" ), QStringLiteral (" puzzlegame" )})),
@@ -191,7 +172,6 @@ void TestCategoryUtils::bestMatchedGameVariants()
191172
192173void TestCategoryUtils::bestMatchedDevelopmentVariants ()
193174{
194- qCInfo (logTest) << " Development XDG categories should aggregate into development" ;
195175 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" ide" ), QStringLiteral (" debugger" )})),
196176 int (C::CategoryDevelopment));
197177 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" building" ), QStringLiteral (" revisioncontrol" )})),
@@ -200,14 +180,12 @@ void TestCategoryUtils::bestMatchedDevelopmentVariants()
200180
201181void TestCategoryUtils::bestMatchedReadingVariants ()
202182{
203- qCInfo (logTest) << " Reading XDG categories should aggregate into reading" ;
204183 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" news" ), QStringLiteral (" translation" )})),
205184 int (C::CategoryReading));
206185}
207186
208187void TestCategoryUtils::bestMatchedSystemVariants ()
209188{
210- qCInfo (logTest) << " System XDG categories should aggregate into system" ;
211189 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" desktopsettings" ), QStringLiteral (" packagemanager" )})),
212190 int (C::CategorySystem));
213191 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" terminalemulator" ), QStringLiteral (" filemanager" )})),
@@ -216,7 +194,6 @@ void TestCategoryUtils::bestMatchedSystemVariants()
216194
217195void TestCategoryUtils::bestMatchedGraphicsVariants ()
218196{
219- qCInfo (logTest) << " Graphics XDG categories should aggregate into graphics" ;
220197 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" 2dgraphics" ), QStringLiteral (" rastergraphics" )})),
221198 int (C::CategoryGraphics));
222199 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" photography" ), QStringLiteral (" viewer" )})),
@@ -225,14 +202,12 @@ void TestCategoryUtils::bestMatchedGraphicsVariants()
225202
226203void TestCategoryUtils::bestMatchedChatVariants ()
227204{
228- qCInfo (logTest) << " Chat XDG categories should aggregate into chat" ;
229205 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" instantmessaging" ), QStringLiteral (" contactmanagement" )})),
230206 int (C::CategoryChat));
231207}
232208
233209void TestCategoryUtils::bestMatchedOfficeVariants ()
234210{
235- qCInfo (logTest) << " Office XDG categories should aggregate into office" ;
236211 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" spreadsheet" ), QStringLiteral (" presentation" )})),
237212 int (C::CategoryOffice));
238213 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" science" ), QStringLiteral (" math" )})),
@@ -241,7 +216,6 @@ void TestCategoryUtils::bestMatchedOfficeVariants()
241216
242217void TestCategoryUtils::bestMatchedMixedUnknownAndKnown ()
243218{
244- qCInfo (logTest) << " Unknown categories mixed with known ones should ignore unknowns" ;
245219 // 'totally-unknown' yields CategoryErr from DDE and empty from XDG -> ignored
246220 // 'music' yields CategoryMusic -> should win
247221 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" totally-unknown" ), QStringLiteral (" music" )})),
@@ -250,14 +224,12 @@ void TestCategoryUtils::bestMatchedMixedUnknownAndKnown()
250224
251225void TestCategoryUtils::bestMatchedAudioVideoEditingTie ()
252226{
253- qCInfo (logTest) << " audiovideoediting maps to both music and video -> tie -> video" ;
254227 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" audiovideoediting" )})),
255228 int (C::CategoryVideo));
256229}
257230
258231void TestCategoryUtils::bestMatchedRecorderTie ()
259232{
260- qCInfo (logTest) << " recorder maps to both music and video -> tie -> video" ;
261233 QCOMPARE (int (CategoryUtils::parseBestMatchedCategory ({QStringLiteral (" recorder" )})),
262234 int (C::CategoryVideo));
263235}
0 commit comments