kaboutdatatest.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /*
  2. SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
  3. SPDX-FileCopyrightText: 2017 Harald Sitter <sitter@kde.org>
  4. SPDX-License-Identifier: LGPL-2.0-only
  5. */
  6. // test object
  7. #include <kaboutdata.h>
  8. // Qt
  9. #include <QFile>
  10. #include <QLatin1String>
  11. #include <QObject>
  12. #include <QTest>
  13. #include <QTextStream>
  14. #ifndef Q_OS_WIN
  15. void initLocale()
  16. {
  17. qputenv("LC_ALL", "en_US.utf-8");
  18. }
  19. Q_CONSTRUCTOR_FUNCTION(initLocale)
  20. #endif
  21. class KAboutDataTest : public QObject
  22. {
  23. Q_OBJECT
  24. private Q_SLOTS:
  25. void testLongFormConstructorWithDefaults();
  26. void testLongFormConstructor();
  27. void testShortFormConstructor();
  28. void testSetAddLicense();
  29. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  30. void testSetProgramIconName();
  31. #endif
  32. void testSetDesktopFileName();
  33. void testCopying();
  34. void testKAboutDataOrganizationDomain();
  35. void testLicenseSPDXID();
  36. void testLicenseOrLater();
  37. void testProductName();
  38. };
  39. static const char AppName[] = "app";
  40. static const char ProgramName[] = "ProgramName";
  41. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  42. static const char ProgramIconName[] = "program-icon";
  43. #endif
  44. static const char Version[] = "Version";
  45. static const char ShortDescription[] = "ShortDescription";
  46. static const char CopyrightStatement[] = "CopyrightStatement";
  47. static const char Text[] = "Text";
  48. static const char HomePageAddress[] = "http://test.no.where/";
  49. static const char HomePageSecure[] = "https://test.no.where/";
  50. static const char OrganizationDomain[] = "no.where";
  51. static const char BugsEmailAddress[] = "bugs@no.else";
  52. static const char LicenseText[] = "free to write, reading forbidden";
  53. static const char LicenseFileName[] = "testlicensefile";
  54. static const char LicenseFileText[] = "free to write, reading forbidden, in the file";
  55. void KAboutDataTest::testLongFormConstructorWithDefaults()
  56. {
  57. KAboutData aboutData(QString::fromLatin1(AppName),
  58. QLatin1String(ProgramName),
  59. QString::fromLatin1(Version),
  60. QLatin1String(ShortDescription),
  61. KAboutLicense::Unknown);
  62. QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName));
  63. QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
  64. QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
  65. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  66. QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName));
  67. #endif
  68. QCOMPARE(aboutData.programLogo(), QVariant());
  69. QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org"));
  70. QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
  71. QCOMPARE(aboutData.homepage(), QString());
  72. QCOMPARE(aboutData.bugAddress(), QString::fromLatin1("submit@bugs.kde.org"));
  73. QVERIFY(aboutData.authors().isEmpty());
  74. QVERIFY(aboutData.credits().isEmpty());
  75. QVERIFY(aboutData.translators().isEmpty());
  76. QCOMPARE(aboutData.otherText(), QString());
  77. QCOMPARE(aboutData.licenses().count(), 1);
  78. // We don't know the default text, do we?
  79. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
  80. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
  81. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
  82. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
  83. // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
  84. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  85. QCOMPARE(aboutData.copyrightStatement(), QString());
  86. QCOMPARE(aboutData.shortDescription(), (QLatin1String(ShortDescription)));
  87. QCOMPARE(aboutData.customAuthorPlainText(), QString());
  88. QCOMPARE(aboutData.customAuthorRichText(), QString());
  89. QVERIFY(!aboutData.customAuthorTextEnabled());
  90. QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
  91. QCOMPARE(aboutData.internalVersion(), Version);
  92. QCOMPARE(aboutData.internalProgramName(), ProgramName);
  93. QCOMPARE(aboutData.internalBugAddress(), "submit@bugs.kde.org");
  94. QCOMPARE(aboutData.internalProductName(), nullptr);
  95. }
  96. void KAboutDataTest::testLongFormConstructor()
  97. {
  98. KAboutData aboutData(QString::fromLatin1(AppName),
  99. QLatin1String(ProgramName),
  100. QString::fromLatin1(Version),
  101. QLatin1String(ShortDescription),
  102. KAboutLicense::Unknown,
  103. QLatin1String(CopyrightStatement),
  104. QLatin1String(Text),
  105. QString::fromLatin1(HomePageAddress),
  106. QString::fromLatin1(BugsEmailAddress));
  107. QCOMPARE(aboutData.componentName(), QLatin1String(AppName));
  108. QCOMPARE(aboutData.productName(), QLatin1String(AppName));
  109. QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
  110. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  111. QCOMPARE(aboutData.programIconName(), QLatin1String(AppName));
  112. #endif
  113. QCOMPARE(aboutData.programLogo(), QVariant());
  114. QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1(OrganizationDomain));
  115. QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
  116. QCOMPARE(aboutData.homepage(), QString::fromLatin1(HomePageAddress));
  117. QCOMPARE(aboutData.bugAddress(), QString::fromLatin1(BugsEmailAddress));
  118. QVERIFY(aboutData.authors().isEmpty());
  119. QVERIFY(aboutData.credits().isEmpty());
  120. QVERIFY(aboutData.translators().isEmpty());
  121. QCOMPARE(aboutData.otherText(), QLatin1String(Text));
  122. QCOMPARE(aboutData.licenses().count(), 1);
  123. // We don't know the default text, do we?
  124. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
  125. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
  126. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
  127. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
  128. // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
  129. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  130. QCOMPARE(aboutData.copyrightStatement(), QLatin1String(CopyrightStatement));
  131. QCOMPARE(aboutData.shortDescription(), QLatin1String(ShortDescription));
  132. QCOMPARE(aboutData.customAuthorPlainText(), QString());
  133. QCOMPARE(aboutData.customAuthorRichText(), QString());
  134. QVERIFY(!aboutData.customAuthorTextEnabled());
  135. QCOMPARE(aboutData.desktopFileName(), QStringLiteral("where.no.app"));
  136. QCOMPARE(aboutData.internalVersion(), Version);
  137. QCOMPARE(aboutData.internalProgramName(), ProgramName);
  138. QCOMPARE(aboutData.internalBugAddress(), BugsEmailAddress);
  139. QCOMPARE(aboutData.internalProductName(), nullptr);
  140. // We support http and https protocols on the homepage address, ensure they
  141. // give the same org. domain and desktop file name.
  142. KAboutData aboutDataSecure(QString::fromLatin1(AppName),
  143. QLatin1String(ProgramName),
  144. QString::fromLatin1(Version),
  145. QLatin1String(ShortDescription),
  146. KAboutLicense::Unknown,
  147. QLatin1String(CopyrightStatement),
  148. QLatin1String(Text),
  149. QString::fromLatin1(HomePageSecure),
  150. QString::fromLatin1(BugsEmailAddress));
  151. QCOMPARE(aboutDataSecure.componentName(), QLatin1String(AppName));
  152. QCOMPARE(aboutDataSecure.productName(), QLatin1String(AppName));
  153. QCOMPARE(aboutDataSecure.organizationDomain(), QString::fromLatin1(OrganizationDomain));
  154. QCOMPARE(aboutDataSecure.desktopFileName(), QStringLiteral("where.no.app"));
  155. }
  156. void KAboutDataTest::testShortFormConstructor()
  157. {
  158. KAboutData aboutData(QString::fromLatin1(AppName), QLatin1String(ProgramName), QString::fromLatin1(Version));
  159. QCOMPARE(aboutData.componentName(), QString::fromLatin1(AppName));
  160. QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
  161. QCOMPARE(aboutData.displayName(), QLatin1String(ProgramName));
  162. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  163. QCOMPARE(aboutData.programIconName(), QString::fromLatin1(AppName));
  164. #endif
  165. QCOMPARE(aboutData.programLogo(), QVariant());
  166. QCOMPARE(aboutData.organizationDomain(), QString::fromLatin1("kde.org"));
  167. QCOMPARE(aboutData.version(), QString::fromLatin1(Version));
  168. QCOMPARE(aboutData.homepage(), QString());
  169. QCOMPARE(aboutData.bugAddress(), QString::fromLatin1("submit@bugs.kde.org"));
  170. QVERIFY(aboutData.authors().isEmpty());
  171. QVERIFY(aboutData.credits().isEmpty());
  172. QVERIFY(aboutData.translators().isEmpty());
  173. QCOMPARE(aboutData.otherText(), QString());
  174. QCOMPARE(aboutData.licenses().count(), 1);
  175. // We don't know the default text, do we?
  176. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
  177. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
  178. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
  179. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
  180. // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
  181. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  182. QCOMPARE(aboutData.copyrightStatement(), QString());
  183. QCOMPARE(aboutData.shortDescription(), QString());
  184. QCOMPARE(aboutData.customAuthorPlainText(), QString());
  185. QCOMPARE(aboutData.customAuthorRichText(), QString());
  186. QVERIFY(!aboutData.customAuthorTextEnabled());
  187. QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
  188. QCOMPARE(aboutData.internalVersion(), Version);
  189. QCOMPARE(aboutData.internalProgramName(), ProgramName);
  190. QCOMPARE(aboutData.internalBugAddress(), "submit@bugs.kde.org");
  191. QCOMPARE(aboutData.internalProductName(), nullptr);
  192. }
  193. void KAboutDataTest::testKAboutDataOrganizationDomain()
  194. {
  195. KAboutData data(QString::fromLatin1("app"),
  196. QLatin1String("program"),
  197. QString::fromLatin1("version"),
  198. QLatin1String("description"),
  199. KAboutLicense::LGPL,
  200. QLatin1String("copyright"),
  201. QLatin1String("hello world"),
  202. QStringLiteral("http://www.koffice.org"));
  203. QCOMPARE(data.organizationDomain(), QString::fromLatin1("koffice.org"));
  204. QCOMPARE(data.desktopFileName(), QStringLiteral("org.koffice.app"));
  205. KAboutData data2(QString::fromLatin1("app"),
  206. QLatin1String("program"),
  207. QString::fromLatin1("version"),
  208. QLatin1String("description"),
  209. KAboutLicense::LGPL,
  210. QString::fromLatin1("copyright"),
  211. QLatin1String("hello world"),
  212. QStringLiteral("app"));
  213. QCOMPARE(data2.organizationDomain(), QString::fromLatin1("kde.org"));
  214. QCOMPARE(data2.desktopFileName(), QStringLiteral("org.kde.app"));
  215. }
  216. void KAboutDataTest::testSetAddLicense()
  217. {
  218. // prepare a file with a license text
  219. QFile licenseFile(QString::fromLatin1(LicenseFileName));
  220. licenseFile.open(QIODevice::WriteOnly);
  221. QTextStream licenseFileStream(&licenseFile);
  222. licenseFileStream << LicenseFileText;
  223. licenseFile.close();
  224. const QString copyrightStatement = QLatin1String(CopyrightStatement);
  225. const QString lineFeed = QString::fromLatin1("\n\n");
  226. KAboutData aboutData(QString::fromLatin1(AppName),
  227. QLatin1String(ProgramName),
  228. QString::fromLatin1(Version),
  229. QLatin1String(ShortDescription),
  230. KAboutLicense::Unknown,
  231. QLatin1String(CopyrightStatement),
  232. QLatin1String(Text),
  233. QString::fromLatin1(HomePageAddress),
  234. QString::fromLatin1(BugsEmailAddress));
  235. // set to GPL2
  236. aboutData.setLicense(KAboutLicense::GPL_V2);
  237. QCOMPARE(aboutData.licenses().count(), 1);
  238. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2"));
  239. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2"));
  240. // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL2Text) );
  241. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  242. // set to Unknown again
  243. aboutData.setLicense(KAboutLicense::Unknown);
  244. QCOMPARE(aboutData.licenses().count(), 1);
  245. // We don't know the default text, do we?
  246. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString(WarningText) );
  247. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::ShortName).isEmpty());
  248. // QCOMPARE( aboutData.licenses().at(0).name(KAboutLicense::FullName), QString(WarningText) );
  249. QVERIFY(!aboutData.licenses().at(0).name(KAboutLicense::FullName).isEmpty());
  250. // QCOMPARE( aboutData.licenses().at(0).text(), QString(WarningText) );
  251. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  252. // add GPL3
  253. aboutData.addLicense(KAboutLicense::GPL_V3);
  254. QCOMPARE(aboutData.licenses().count(), 1);
  255. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3"));
  256. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3"));
  257. // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) );
  258. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  259. // add GPL2, Custom and File
  260. aboutData.addLicense(KAboutLicense::GPL_V2);
  261. aboutData.addLicenseText(QLatin1String(LicenseText));
  262. aboutData.addLicenseTextFile(QLatin1String(LicenseFileName));
  263. QCOMPARE(aboutData.licenses().count(), 4);
  264. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v3"));
  265. QCOMPARE(aboutData.licenses().at(0).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 3"));
  266. // QCOMPARE( aboutData.licenses().at(0).text(), QString(GPL3Text) );
  267. QVERIFY(!aboutData.licenses().at(0).text().isEmpty());
  268. QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::ShortName), QString::fromLatin1("GPL v2"));
  269. QCOMPARE(aboutData.licenses().at(1).name(KAboutLicense::FullName), QString::fromLatin1("GNU General Public License Version 2"));
  270. // QCOMPARE( aboutData.licenses().at(1).text(), QString(GPL2Text) );
  271. QVERIFY(!aboutData.licenses().at(1).text().isEmpty());
  272. QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::ShortName), QString::fromLatin1("Custom"));
  273. QCOMPARE(aboutData.licenses().at(2).name(KAboutLicense::FullName), QString::fromLatin1("Custom"));
  274. QCOMPARE(aboutData.licenses().at(2).text(), QLatin1String(LicenseText));
  275. QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::ShortName), QString::fromLatin1("Custom"));
  276. QCOMPARE(aboutData.licenses().at(3).name(KAboutLicense::FullName), QString::fromLatin1("Custom"));
  277. QCOMPARE(aboutData.licenses().at(3).text(), QString(copyrightStatement + lineFeed + QLatin1String(LicenseFileText)));
  278. }
  279. #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 2)
  280. void KAboutDataTest::testSetProgramIconName()
  281. {
  282. const QString programIconName(QString::fromLatin1(ProgramIconName));
  283. KAboutData aboutData(QString::fromLatin1(AppName),
  284. QLatin1String(ProgramName),
  285. QString::fromLatin1(Version),
  286. QLatin1String(ShortDescription),
  287. KAboutLicense::Unknown,
  288. QLatin1String(CopyrightStatement),
  289. QLatin1String(Text),
  290. QString::fromLatin1(HomePageAddress),
  291. QString::fromLatin1(BugsEmailAddress));
  292. // Deprecated, still want to test this though. Silence GCC warnings.
  293. #pragma GCC diagnostic push
  294. #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
  295. // set different iconname
  296. aboutData.setProgramIconName(programIconName);
  297. #pragma GCC diagnostic pop
  298. QCOMPARE(aboutData.programIconName(), programIconName);
  299. }
  300. #endif
  301. void KAboutDataTest::testCopying()
  302. {
  303. KAboutData aboutData(QString::fromLatin1(AppName),
  304. QLatin1String(ProgramName),
  305. QString::fromLatin1(Version),
  306. QLatin1String(ShortDescription),
  307. KAboutLicense::GPL_V2);
  308. {
  309. KAboutData aboutData2(QString::fromLatin1(AppName),
  310. QLatin1String(ProgramName),
  311. QString::fromLatin1(Version),
  312. QLatin1String(ShortDescription),
  313. KAboutLicense::GPL_V3);
  314. aboutData2.addLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions);
  315. aboutData = aboutData2;
  316. }
  317. QList<KAboutLicense> licenses = aboutData.licenses();
  318. QCOMPARE(licenses.count(), 2);
  319. QCOMPARE(licenses.at(0).key(), KAboutLicense::GPL_V3);
  320. QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-3.0"));
  321. // check it doesn't crash
  322. QVERIFY(!licenses.at(0).text().isEmpty());
  323. QCOMPARE(licenses.at(1).key(), KAboutLicense::GPL_V2);
  324. QCOMPARE(aboutData.licenses().at(1).spdx(), QStringLiteral("GPL-2.0+"));
  325. // check it doesn't crash
  326. QVERIFY(!licenses.at(1).text().isEmpty());
  327. }
  328. void KAboutDataTest::testSetDesktopFileName()
  329. {
  330. KAboutData aboutData(QString::fromLatin1(AppName),
  331. QLatin1String(ProgramName),
  332. QString::fromLatin1(Version),
  333. QLatin1String(ShortDescription),
  334. KAboutLicense::Unknown);
  335. QCOMPARE(aboutData.desktopFileName(), QStringLiteral("org.kde.app"));
  336. // set different desktopFileName
  337. aboutData.setDesktopFileName(QStringLiteral("foo.bar.application"));
  338. QCOMPARE(aboutData.desktopFileName(), QStringLiteral("foo.bar.application"));
  339. }
  340. void KAboutDataTest::testLicenseSPDXID()
  341. {
  342. // Input with + should output with +.
  343. auto license = KAboutLicense::byKeyword(QStringLiteral("GPLv2+"));
  344. QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0+"));
  345. // Input without should output without.
  346. license = KAboutLicense::byKeyword(QStringLiteral("GPLv2"));
  347. QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0"));
  348. // Input of spdx with or-later should also work
  349. license = KAboutLicense::byKeyword(QStringLiteral("GPL-2.0-or-later"));
  350. QCOMPARE(license.spdx(), QStringLiteral("GPL-2.0+")); // TODO: should not return the deprecatd version
  351. // we should be able to match by spdx too
  352. // create a KAboutLicense from enum, then make sure going to spdx and back gives the same enum
  353. for (int i = 1; i <= KAboutLicense::LGPL_V2_1; ++i) { /*current highest enum value*/
  354. KAboutData aboutData(QString::fromLatin1(AppName),
  355. QLatin1String(ProgramName),
  356. QString::fromLatin1(Version),
  357. QLatin1String(ShortDescription),
  358. KAboutLicense::GPL_V2);
  359. aboutData.setLicense(KAboutLicense::LicenseKey(i));
  360. QVERIFY(aboutData.licenses().count() == 1);
  361. const auto license = aboutData.licenses().constFirst();
  362. auto licenseFromKeyword = KAboutLicense::byKeyword(license.spdx());
  363. QCOMPARE(license.key(), licenseFromKeyword.key());
  364. }
  365. }
  366. void KAboutDataTest::testLicenseOrLater()
  367. {
  368. // For kaboutdata we can replace the license with an orLater version. Or add a second one.
  369. KAboutData aboutData(QString::fromLatin1(AppName),
  370. QLatin1String(ProgramName),
  371. QString::fromLatin1(Version),
  372. QLatin1String(ShortDescription),
  373. KAboutLicense::GPL_V2);
  374. QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0"));
  375. aboutData.setLicense(KAboutLicense::GPL_V2, KAboutLicense::OrLaterVersions);
  376. QCOMPARE(aboutData.licenses().at(0).spdx(), QStringLiteral("GPL-2.0+"));
  377. aboutData.addLicense(KAboutLicense::LGPL_V3, KAboutLicense::OrLaterVersions);
  378. bool foundLGPL = false;
  379. const QList<KAboutLicense> licenses = aboutData.licenses();
  380. for (const auto &license : licenses) {
  381. if (license.key() == KAboutLicense::LGPL_V3) {
  382. QCOMPARE(license.spdx(), QStringLiteral("LGPL-3.0+"));
  383. foundLGPL = true;
  384. break;
  385. }
  386. }
  387. QCOMPARE(foundLGPL, true);
  388. }
  389. void KAboutDataTest::testProductName()
  390. {
  391. KAboutData aboutData(QString::fromLatin1(AppName), QString::fromLatin1(ProgramName));
  392. QCOMPARE(aboutData.productName(), QString::fromLatin1(AppName));
  393. QCOMPARE(aboutData.internalProductName(), nullptr);
  394. aboutData.setProductName("frameworks-kcoreaddons/aboutdata");
  395. QCOMPARE(aboutData.productName(), QString::fromLatin1("frameworks-kcoreaddons/aboutdata"));
  396. QCOMPARE(aboutData.internalProductName(), "frameworks-kcoreaddons/aboutdata");
  397. }
  398. QTEST_MAIN(KAboutDataTest)
  399. #include "kaboutdatatest.moc"