MCPcopy Create free account
hub / github.com/Skycoder42/QtAutoUpdater / testUpdateCheck

Method testUpdateCheck

tests/auto/plugins/testlib/plugintest.cpp:78–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78void PluginTest::testUpdateCheck()
79{
80 QFETCH(QVersionNumber, installedVersion);
81 QFETCH(QVersionNumber, updateVersion);
82 QFETCH(int, abortLevel);
83 QFETCH(bool, success);
84
85 if (abortLevel > 0) {
86 if (!canAbort(abortLevel == 2)) {
87 QEXPECT_FAIL("", "Backend does not support given abort level", Abort);
88 QVERIFY(false);
89 }
90 }
91
92 QVERIFY(simulateInstall(installedVersion));
93 QVERIFY(prepareUpdate(updateVersion));
94 const auto updates = abortLevel > 0 ?
95 QList<UpdateInfo>{} :
96 createInfos(installedVersion, updateVersion);
97
98 sptr updater { loadBackend() };
99 if (!updater)
100 return;
101
102 QSignalSpy doneSpy{updater.data(), &UpdaterBackend::checkDone};
103 QVERIFY(doneSpy.isValid());
104
105 //start the check updates
106 updater->checkForUpdates();
107
108 if (abortLevel > 0) {
109 if (!doneSpy.wait(0)) {
110 updater->abort(abortLevel == 2);
111 QVERIFY(doneSpy.wait(60000));
112 }
113 } else //wait max 1 min for the process to finish
114 QVERIFY(doneSpy.wait(60000));
115
116 //check if the finished signal is without error
117 QCOMPARE(doneSpy.size(), 1);
118 QCOMPARE(doneSpy[0][0].toBool(), success);
119 if (!updates.isEmpty()) {
120 qDebug() << updates[0];
121 qDebug() << doneSpy[0][1].value<QList<UpdateInfo>>()[0];
122 }
123 QCOMPARE(doneSpy[0][1].value<QList<UpdateInfo>>(), updates);
124}
125
126void PluginTest::testTriggerInstall()
127{

Callers

nothing calls this directly

Calls 3

dataMethod · 0.45
checkForUpdatesMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected