Changeset View
Changeset View
Standalone View
Standalone View
autotests/kplugininfotest.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 48 | { | |||
---|---|---|---|---|---|
78 | QVERIFY(compatJsonFile.open(QFile::ReadOnly)); | 78 | QVERIFY(compatJsonFile.open(QFile::ReadOnly)); | ||
79 | QJsonObject compatJson = QJsonDocument::fromJson(compatJsonFile.readAll(), &jsonError).object(); | 79 | QJsonObject compatJson = QJsonDocument::fromJson(compatJsonFile.readAll(), &jsonError).object(); | ||
80 | QCOMPARE(jsonError.error, QJsonParseError::NoError); | 80 | QCOMPARE(jsonError.error, QJsonParseError::NoError); | ||
81 | QVERIFY(!compatJson.isEmpty()); | 81 | QVERIFY(!compatJson.isEmpty()); | ||
82 | 82 | | |||
83 | // for most constructors translations are performed when the object is constructed and not at runtime! | 83 | // for most constructors translations are performed when the object is constructed and not at runtime! | ||
84 | QLocale::setDefault(QLocale::c()); | 84 | QLocale::setDefault(QLocale::c()); | ||
85 | KPluginInfo info(fakepluginDesktop); | 85 | KPluginInfo info(fakepluginDesktop); | ||
86 | #if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) | ||||
86 | KService::Ptr fakepluginService(new KService(fakepluginDesktop)); | 87 | KService::Ptr fakepluginService(new KService(fakepluginDesktop)); | ||
87 | KPluginInfo infoFromService(fakepluginService); | 88 | KPluginInfo infoFromService(fakepluginService); | ||
89 | #endif | ||||
88 | KPluginInfo compatJsonInfo(KPluginMetaData(compatJson, pluginName)); | 90 | KPluginInfo compatJsonInfo(KPluginMetaData(compatJson, pluginName)); | ||
89 | QLocale::setDefault(QLocale(QLocale::German, QLocale::Germany)); | 91 | QLocale::setDefault(QLocale(QLocale::German, QLocale::Germany)); | ||
90 | KPluginInfo infoGerman(fakepluginDesktop); | 92 | KPluginInfo infoGerman(fakepluginDesktop); | ||
93 | #if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) | ||||
91 | KService::Ptr fakepluginServiceGerman(new KService(fakepluginDesktop)); | 94 | KService::Ptr fakepluginServiceGerman(new KService(fakepluginDesktop)); | ||
92 | KPluginInfo infoFromServiceGerman(fakepluginServiceGerman); | 95 | KPluginInfo infoFromServiceGerman(fakepluginServiceGerman); | ||
96 | #endif | ||||
93 | KPluginInfo compatJsonInfoGerman(KPluginMetaData(compatJson, pluginName)); | 97 | KPluginInfo compatJsonInfoGerman(KPluginMetaData(compatJson, pluginName)); | ||
94 | QLocale::setDefault(QLocale::c()); | 98 | QLocale::setDefault(QLocale::c()); | ||
95 | 99 | | |||
96 | QTest::ignoreMessage(QtWarningMsg, "\"/this/path/does/not/exist.desktop\" has no desktop group, cannot construct a KPluginInfo object from it."); | 100 | QTest::ignoreMessage(QtWarningMsg, "\"/this/path/does/not/exist.desktop\" has no desktop group, cannot construct a KPluginInfo object from it."); | ||
97 | QVERIFY(!KPluginInfo(QStringLiteral("/this/path/does/not/exist.desktop")).isValid()); | 101 | QVERIFY(!KPluginInfo(QStringLiteral("/this/path/does/not/exist.desktop")).isValid()); | ||
98 | 102 | | |||
99 | QTest::newRow("from .desktop") << fakepluginDesktop << info << infoGerman << QVariant() << false; | 103 | QTest::newRow("from .desktop") << fakepluginDesktop << info << infoGerman << QVariant() << false; | ||
100 | QTest::newRow("with custom property") << info.libraryPath() << withCustomProperty(info) | 104 | QTest::newRow("with custom property") << info.libraryPath() << withCustomProperty(info) | ||
101 | << withCustomProperty(infoGerman) << QVariant("Baz") << false; | 105 | << withCustomProperty(infoGerman) << QVariant("Baz") << false; | ||
106 | #if KSERVICE_ENABLE_DEPRECATED_SINCE(5, 0) | ||||
102 | QTest::newRow("from KService::Ptr") << fakepluginDesktop << infoFromService | 107 | QTest::newRow("from KService::Ptr") << fakepluginDesktop << infoFromService | ||
103 | << infoFromServiceGerman << QVariant() << true; | 108 | << infoFromServiceGerman << QVariant() << true; | ||
104 | QTest::newRow("from KService::Ptr + custom property") << pluginName | 109 | QTest::newRow("from KService::Ptr + custom property") << pluginName | ||
105 | << withCustomProperty(infoFromService) << withCustomProperty(infoFromServiceGerman) | 110 | << withCustomProperty(infoFromService) << withCustomProperty(infoFromServiceGerman) | ||
106 | << QVariant("Baz") << true; | 111 | << QVariant("Baz") << true; | ||
112 | #endif | ||||
107 | QTest::newRow("from JSON file") << pluginName << jsonInfo << jsonInfo << QVariant() << false; | 113 | QTest::newRow("from JSON file") << pluginName << jsonInfo << jsonInfo << QVariant() << false; | ||
108 | QTest::newRow("from JSON file + custom property") << pluginName | 114 | QTest::newRow("from JSON file + custom property") << pluginName | ||
109 | << withCustomProperty(jsonInfo) << withCustomProperty(jsonInfo) << QVariant("Baz") << false; | 115 | << withCustomProperty(jsonInfo) << withCustomProperty(jsonInfo) << QVariant("Baz") << false; | ||
110 | QTest::newRow("from JSON file (compatibility)") << pluginName | 116 | QTest::newRow("from JSON file (compatibility)") << pluginName | ||
111 | << compatJsonInfo << compatJsonInfoGerman << QVariant() << true; | 117 | << compatJsonInfo << compatJsonInfoGerman << QVariant() << true; | ||
112 | QTest::newRow("from JSON file (compatibility) + custom property") << pluginName | 118 | QTest::newRow("from JSON file (compatibility) + custom property") << pluginName | ||
113 | << withCustomProperty(compatJsonInfo) << withCustomProperty(compatJsonInfoGerman) | 119 | << withCustomProperty(compatJsonInfo) << withCustomProperty(compatJsonInfoGerman) | ||
114 | << QVariant("Baz") << true; | 120 | << QVariant("Baz") << true; | ||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |