| 45 | |
| 46 | class MetaComponentParseTest : public QObject { |
| 47 | Q_OBJECT |
| 48 | |
| 49 | void doTest(QString name) |
| 50 | { |
| 51 | QString source = QFINDTESTDATA("testdata/MetaComponentParse"); |
| 52 | |
| 53 | QString comp_rp = FS::PathCombine(source, name); |
| 54 | |
| 55 | QFile file; |
| 56 | file.setFileName(comp_rp); |
| 57 | QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); |
| 58 | QString data = file.readAll(); |
| 59 | file.close(); |
| 60 | |
| 61 | QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8()); |
| 62 | QJsonObject obj = doc.object(); |
| 63 | |
| 64 | QJsonValue description_json = obj.value("description"); |
| 65 | QJsonValue expected_json = obj.value("expected_output"); |
| 66 | |
| 67 | QVERIFY(!description_json.isUndefined()); |
| 68 | QVERIFY(expected_json.isString()); |
| 69 | |
| 70 | QString expected = expected_json.toString(); |
| 71 | |
| 72 | QString processed = ResourcePackUtils::processComponent(description_json); |
| 73 | |
| 74 | QCOMPARE(processed, expected); |
| 75 | } |
| 76 | |
| 77 | private slots: |
| 78 | void test_parseComponentBasic() { doTest("component_basic.json"); } |
nothing calls this directly
no test coverage detected