diff options
-rw-r--r-- | tests/runtime/tst_runtime.cpp | 22 | ||||
-rw-r--r-- | tests/yaml/tst_yaml.cpp | 9 |
2 files changed, 18 insertions, 13 deletions
diff --git a/tests/runtime/tst_runtime.cpp b/tests/runtime/tst_runtime.cpp index d64014e2..73a2f7a9 100644 --- a/tests/runtime/tst_runtime.cpp +++ b/tests/runtime/tst_runtime.cpp @@ -110,10 +110,10 @@ tst_Runtime::tst_Runtime() void tst_Runtime::factory() { - RuntimeFactory *rf = RuntimeFactory::instance(); + QScopedPointer<RuntimeFactory> rf { RuntimeFactory::instance() }; QVERIFY(rf); - QVERIFY(rf == RuntimeFactory::instance()); + QVERIFY(rf.get() == RuntimeFactory::instance()); QVERIFY(rf->runtimeIds().isEmpty()); QVERIFY(rf->registerRuntime(new TestRuntimeManager(qSL("foo"), qApp))); @@ -136,20 +136,22 @@ void tst_Runtime::factory() QCOMPARE(temp.write(yaml), yaml.size()); temp.close(); - Application *a = nullptr; + QScopedPointer<Application> a; + QScopedPointer<PackageInfo> pi; + QScopedPointer<Package> p; try { - PackageInfo *pi = PackageInfo::fromManifest(temp.fileName()); + pi.reset(PackageInfo::fromManifest(temp.fileName())); QVERIFY(pi); - Package *p = new Package(pi); - a = new Application(pi->applications().first(), p); + p.reset(new Package(pi.get())); + a.reset(new Application(pi->applications().constFirst(), p.get())); } catch (const Exception &e) { QVERIFY2(false, qPrintable(e.errorString())); } QVERIFY(a); - AbstractRuntime *r = rf->create(nullptr, a); + QScopedPointer<AbstractRuntime> r { rf->create(nullptr, a.get()) }; QVERIFY(r); - QVERIFY(r->application() == a); + QVERIFY(r->application() == a.get()); QVERIFY(r->manager()->inProcess()); QVERIFY(r->state() == Am::NotRunning); QVERIFY(r->applicationProcessId() == 0); @@ -166,10 +168,6 @@ void tst_Runtime::factory() r->stop(); QVERIFY(r->state() == Am::NotRunning); QVERIFY(!r->securityToken().isEmpty()); - - delete r; - delete rf; - delete a; } QTEST_MAIN(tst_Runtime) diff --git a/tests/yaml/tst_yaml.cpp b/tests/yaml/tst_yaml.cpp index 8d7f022a..db0e4d86 100644 --- a/tests/yaml/tst_yaml.cpp +++ b/tests/yaml/tst_yaml.cpp @@ -309,6 +309,9 @@ void tst_Yaml::cache() QVERIFY(ct2); QCOMPARE(ct2->name, "cache2"); QCOMPARE(ct2->file, ":/data/cache2.yaml"); + + delete ct1; + delete ct2; } catch (const Exception &e) { QVERIFY2(false, e.what()); } @@ -361,6 +364,8 @@ void tst_Yaml::mergedCache() QVERIFY(ct); QCOMPARE(ct->name, QFileInfo(files.last()).baseName()); QCOMPARE(ct->file, files.join(qSL(","))); + + delete ct; } catch (const Exception &e) { QVERIFY2(false, e.what()); } @@ -382,7 +387,9 @@ void tst_Yaml::mergedCache() QTest::ignoreMessage(QtWarningMsg, "Failed to read Cache: cached file checksums do not match"); brokenCache.parse(); QVERIFY(brokenCache.parseReadFromCache()); - QCOMPARE(brokenCache.takeMergedResult()->value, qSL("foobar")); + CacheTest *ct = brokenCache.takeMergedResult(); + QCOMPARE(ct->value, qSL("foobar")); + delete ct; } class YamlRunnable : public QRunnable |