Merge pull request #876 from Scrumplex/revert-updater-stuff
Revert "fix: remove updater if it is not used"
This commit is contained in:
commit
3b187b5246
@ -154,7 +154,6 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
QString getIdealPlatform(QString currentPlatform) {
|
QString getIdealPlatform(QString currentPlatform) {
|
||||||
auto info = Sys::getKernelInfo();
|
auto info = Sys::getKernelInfo();
|
||||||
switch(info.kernelType) {
|
switch(info.kernelType) {
|
||||||
@ -193,7 +192,6 @@ QString getIdealPlatform(QString currentPlatform) {
|
|||||||
}
|
}
|
||||||
return currentPlatform;
|
return currentPlatform;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,7 +756,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
qDebug() << "<> Translations loaded.";
|
qDebug() << "<> Translations loaded.";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
// initialize the updater
|
// initialize the updater
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
{
|
{
|
||||||
@ -768,7 +765,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||||
qDebug() << "<> Updater started.";
|
qDebug() << "<> Updater started.";
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Instance icons
|
// Instance icons
|
||||||
{
|
{
|
||||||
@ -1414,9 +1410,7 @@ MainWindow* Application::showMainWindow(bool minimized)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mainWindow->checkInstancePathForProblems();
|
m_mainWindow->checkInstancePathForProblems();
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged);
|
connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged);
|
||||||
#endif
|
|
||||||
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
|
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
|
||||||
m_openWindows++;
|
m_openWindows++;
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
#include <updater/GoUpdate.h>
|
#include <updater/GoUpdate.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <BaseInstance.h>
|
#include <BaseInstance.h>
|
||||||
|
|
||||||
|
@ -149,23 +149,15 @@ set(LAUNCH_SOURCES
|
|||||||
launch/LogModel.h
|
launch/LogModel.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Launcher_UPDATER_BASE)
|
# Old update system
|
||||||
set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_WITH_UPDATER ${Launcher_APP_BINARY_DEFS}")
|
set(UPDATE_SOURCES
|
||||||
# Old update system
|
updater/GoUpdate.h
|
||||||
set(UPDATE_SOURCES
|
updater/GoUpdate.cpp
|
||||||
updater/GoUpdate.h
|
updater/UpdateChecker.h
|
||||||
updater/GoUpdate.cpp
|
updater/UpdateChecker.cpp
|
||||||
updater/UpdateChecker.h
|
updater/DownloadTask.h
|
||||||
updater/UpdateChecker.cpp
|
updater/DownloadTask.cpp
|
||||||
updater/DownloadTask.h
|
)
|
||||||
updater/DownloadTask.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
ecm_add_test(updater/UpdateChecker_test.cpp LINK_LIBRARIES Launcher_logic Qt5::Test
|
|
||||||
TEST_NAME UpdateChecker)
|
|
||||||
ecm_add_test(updater/DownloadTask_test.cpp LINK_LIBRARIES Launcher_logic Qt5::Test
|
|
||||||
TEST_NAME DownloadTask)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Backend for the news bar... there's usually no news.
|
# Backend for the news bar... there's usually no news.
|
||||||
set(NEWS_SOURCES
|
set(NEWS_SOURCES
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "LauncherPartLaunch.h"
|
#include "LauncherPartLaunch.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
#include "launch/LaunchTask.h"
|
#include "launch/LaunchTask.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
@ -44,8 +44,6 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHttpPart>
|
|
||||||
#include <QUrlQuery>
|
|
||||||
|
|
||||||
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
|
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
|
||||||
{{"0x0.st", "https://0x0.st", ""},
|
{{"0x0.st", "https://0x0.st", ""},
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
@ -1024,7 +1024,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
{
|
{
|
||||||
bool updatesAllowed = APPLICATION->updatesAreAllowed();
|
bool updatesAllowed = APPLICATION->updatesAreAllowed();
|
||||||
@ -1043,7 +1042,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false);
|
updater->checkForUpdate(APPLICATION->settings()->get("UpdateChannel").toString(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
|
setSelectedInstanceById(APPLICATION->settings()->get("SelectedInstance").toString());
|
||||||
|
|
||||||
@ -1355,7 +1353,6 @@ void MainWindow::repopulateAccountsMenu()
|
|||||||
ui->profileMenu->addAction(ui->actionManageAccounts);
|
ui->profileMenu->addAction(ui->actionManageAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void MainWindow::updatesAllowedChanged(bool allowed)
|
void MainWindow::updatesAllowedChanged(bool allowed)
|
||||||
{
|
{
|
||||||
if(!BuildConfig.UPDATER_ENABLED)
|
if(!BuildConfig.UPDATER_ENABLED)
|
||||||
@ -1364,7 +1361,6 @@ void MainWindow::updatesAllowedChanged(bool allowed)
|
|||||||
}
|
}
|
||||||
ui->actionCheckUpdate->setEnabled(allowed);
|
ui->actionCheckUpdate->setEnabled(allowed);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assumes the sender is a QAction
|
* Assumes the sender is a QAction
|
||||||
@ -1470,7 +1466,6 @@ void MainWindow::updateNewsLabel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void MainWindow::updateAvailable(GoUpdate::Status status)
|
void MainWindow::updateAvailable(GoUpdate::Status status)
|
||||||
{
|
{
|
||||||
if(!APPLICATION->updatesAreAllowed())
|
if(!APPLICATION->updatesAreAllowed())
|
||||||
@ -1496,7 +1491,6 @@ void MainWindow::updateNotAvailable()
|
|||||||
UpdateDialog dlg(false, this);
|
UpdateDialog dlg(false, this);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QList<int> stringToIntList(const QString &string)
|
QList<int> stringToIntList(const QString &string)
|
||||||
{
|
{
|
||||||
@ -1518,7 +1512,6 @@ QString intListToString(const QList<int> &list)
|
|||||||
return slist.join(',');
|
return slist.join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void MainWindow::downloadUpdates(GoUpdate::Status status)
|
void MainWindow::downloadUpdates(GoUpdate::Status status)
|
||||||
{
|
{
|
||||||
if(!APPLICATION->updatesAreAllowed())
|
if(!APPLICATION->updatesAreAllowed())
|
||||||
@ -1552,7 +1545,6 @@ void MainWindow::downloadUpdates(GoUpdate::Status status)
|
|||||||
CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void MainWindow::onCatToggled(bool state)
|
void MainWindow::onCatToggled(bool state)
|
||||||
{
|
{
|
||||||
@ -1865,7 +1857,6 @@ void MainWindow::on_actionConfig_Folder_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void MainWindow::checkForUpdates()
|
void MainWindow::checkForUpdates()
|
||||||
{
|
{
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
@ -1878,7 +1869,6 @@ void MainWindow::checkForUpdates()
|
|||||||
qWarning() << "Updater not set up. Cannot check for updates.";
|
qWarning() << "Updater not set up. Cannot check for updates.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void MainWindow::on_actionSettings_triggered()
|
void MainWindow::on_actionSettings_triggered()
|
||||||
{
|
{
|
||||||
|
@ -78,9 +78,7 @@ public:
|
|||||||
|
|
||||||
void checkInstancePathForProblems();
|
void checkInstancePathForProblems();
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void updatesAllowedChanged(bool allowed);
|
void updatesAllowedChanged(bool allowed);
|
||||||
#endif
|
|
||||||
|
|
||||||
void droppedURLs(QList<QUrl> urls);
|
void droppedURLs(QList<QUrl> urls);
|
||||||
signals:
|
signals:
|
||||||
@ -126,9 +124,7 @@ private slots:
|
|||||||
|
|
||||||
void on_actionViewCentralModsFolder_triggered();
|
void on_actionViewCentralModsFolder_triggered();
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
#endif
|
|
||||||
|
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
|
|
||||||
@ -197,11 +193,9 @@ private slots:
|
|||||||
|
|
||||||
void startTask(Task *task);
|
void startTask(Task *task);
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void updateAvailable(GoUpdate::Status status);
|
void updateAvailable(GoUpdate::Status status);
|
||||||
|
|
||||||
void updateNotAvailable();
|
void updateNotAvailable();
|
||||||
#endif
|
|
||||||
|
|
||||||
void defaultAccountChanged();
|
void defaultAccountChanged();
|
||||||
|
|
||||||
@ -211,12 +205,10 @@ private slots:
|
|||||||
|
|
||||||
void updateNewsLabel();
|
void updateNewsLabel();
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
/*!
|
/*!
|
||||||
* Runs the DownloadTask and installs updates.
|
* Runs the DownloadTask and installs updates.
|
||||||
*/
|
*/
|
||||||
void downloadUpdates(GoUpdate::Status status);
|
void downloadUpdates(GoUpdate::Status status);
|
||||||
#endif
|
|
||||||
|
|
||||||
void konamiTriggered();
|
void konamiTriggered();
|
||||||
|
|
||||||
|
@ -78,7 +78,6 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
|
|||||||
m_languageModel = APPLICATION->translations();
|
m_languageModel = APPLICATION->translations();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
if(BuildConfig.UPDATER_ENABLED)
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
{
|
{
|
||||||
QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList);
|
QObject::connect(APPLICATION->updateChecker().get(), &UpdateChecker::channelListLoaded, this, &LauncherPage::refreshUpdateChannelList);
|
||||||
@ -91,9 +90,11 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch
|
|||||||
{
|
{
|
||||||
APPLICATION->updateChecker()->updateChanList(false);
|
APPLICATION->updateChecker()->updateChanList(false);
|
||||||
}
|
}
|
||||||
ui->updateSettingsBox->setHidden(false);
|
|
||||||
}
|
}
|
||||||
#endif
|
else
|
||||||
|
{
|
||||||
|
ui->updateSettingsBox->setHidden(true);
|
||||||
|
}
|
||||||
connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview()));
|
connect(ui->fontSizeBox, SIGNAL(valueChanged(int)), SLOT(refreshFontPreview()));
|
||||||
connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview()));
|
connect(ui->consoleFont, SIGNAL(currentFontChanged(QFont)), SLOT(refreshFontPreview()));
|
||||||
}
|
}
|
||||||
@ -188,7 +189,6 @@ void LauncherPage::on_metadataDisableBtn_clicked()
|
|||||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
void LauncherPage::refreshUpdateChannelList()
|
void LauncherPage::refreshUpdateChannelList()
|
||||||
{
|
{
|
||||||
// Stop listening for selection changes. It's going to change a lot while we update it and
|
// Stop listening for selection changes. It's going to change a lot while we update it and
|
||||||
@ -260,7 +260,6 @@ void LauncherPage::refreshUpdateChannelDesc()
|
|||||||
m_currentUpdateChannel = selected.id;
|
m_currentUpdateChannel = selected.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void LauncherPage::applySettings()
|
void LauncherPage::applySettings()
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,6 @@ slots:
|
|||||||
void on_iconsDirBrowseBtn_clicked();
|
void on_iconsDirBrowseBtn_clicked();
|
||||||
void on_metadataDisableBtn_clicked();
|
void on_metadataDisableBtn_clicked();
|
||||||
|
|
||||||
#ifdef LAUNCHER_WITH_UPDATER
|
|
||||||
/*!
|
/*!
|
||||||
* Updates the list of update channels in the combo box.
|
* Updates the list of update channels in the combo box.
|
||||||
*/
|
*/
|
||||||
@ -101,13 +100,13 @@ slots:
|
|||||||
*/
|
*/
|
||||||
void refreshUpdateChannelDesc();
|
void refreshUpdateChannelDesc();
|
||||||
|
|
||||||
void updateChannelSelectionChanged(int index);
|
|
||||||
#endif
|
|
||||||
/*!
|
/*!
|
||||||
* Updates the font preview
|
* Updates the font preview
|
||||||
*/
|
*/
|
||||||
void refreshFontPreview();
|
void refreshFontPreview();
|
||||||
|
|
||||||
|
void updateChannelSelectionChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LauncherPage *ui;
|
Ui::LauncherPage *ui;
|
||||||
|
|
||||||
|
@ -50,9 +50,6 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Update Settings</string>
|
<string>Update Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoUpdateCheckBox">
|
<widget class="QCheckBox" name="autoUpdateCheckBox">
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QIdentityProxyModel>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QItemSelection>
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include "ui/pages/BasePage.h"
|
#include "ui/pages/BasePage.h"
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
|
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
|
static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
|
|
||||||
#include "tools/MCEditTool.h"
|
#include "tools/MCEditTool.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
@ -46,8 +46,6 @@
|
|||||||
|
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
|
|
||||||
#include <net/NetJob.h>
|
|
||||||
|
|
||||||
namespace LegacyFTB {
|
namespace LegacyFTB {
|
||||||
|
|
||||||
FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
|
FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
|
|
||||||
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
#include "modplatform/modrinth/ModrinthPackManifest.h"
|
||||||
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
|
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
|
||||||
#include "net/NetJob.h"
|
|
||||||
|
|
||||||
class ModPage;
|
class ModPage;
|
||||||
class Version;
|
class Version;
|
||||||
|
@ -1,204 +0,0 @@
|
|||||||
#include <QTest>
|
|
||||||
#include <QSignalSpy>
|
|
||||||
|
|
||||||
#include "updater/GoUpdate.h"
|
|
||||||
#include "updater/DownloadTask.h"
|
|
||||||
#include "updater/UpdateChecker.h"
|
|
||||||
#include <FileSystem.h>
|
|
||||||
|
|
||||||
using namespace GoUpdate;
|
|
||||||
|
|
||||||
FileSourceList encodeBaseFile(const char *suffix)
|
|
||||||
{
|
|
||||||
auto base = QDir::currentPath();
|
|
||||||
QUrl localFile = QUrl::fromLocalFile(base + suffix);
|
|
||||||
QString localUrlString = localFile.toString(QUrl::FullyEncoded);
|
|
||||||
auto item = FileSource("http", localUrlString);
|
|
||||||
return FileSourceList({item});
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VersionFileList)
|
|
||||||
Q_DECLARE_METATYPE(Operation)
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const FileSource &f)
|
|
||||||
{
|
|
||||||
dbg.nospace() << "FileSource(type=" << f.type << " url=" << f.url
|
|
||||||
<< " comp=" << f.compressionType << ")";
|
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const VersionFileEntry &v)
|
|
||||||
{
|
|
||||||
dbg.nospace() << "VersionFileEntry(path=" << v.path << " mode=" << v.mode
|
|
||||||
<< " md5=" << v.md5 << " sources=" << v.sources << ")";
|
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Operation::Type &t)
|
|
||||||
{
|
|
||||||
switch (t)
|
|
||||||
{
|
|
||||||
case Operation::OP_REPLACE:
|
|
||||||
dbg << "OP_COPY";
|
|
||||||
break;
|
|
||||||
case Operation::OP_DELETE:
|
|
||||||
dbg << "OP_DELETE";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Operation &u)
|
|
||||||
{
|
|
||||||
dbg.nospace() << "Operation(type=" << u.type << " file=" << u.source
|
|
||||||
<< " dest=" << u.destination << " mode=" << u.destinationMode << ")";
|
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
class DownloadTaskTest : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private
|
|
||||||
slots:
|
|
||||||
void initTestCase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void cleanupTestCase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_parseVersionInfo_data()
|
|
||||||
{
|
|
||||||
QFile f1(QFINDTESTDATA("testdata/1.json"));
|
|
||||||
f1.open(QFile::ReadOnly);
|
|
||||||
QByteArray data1 = f1.readAll();
|
|
||||||
f1.close();
|
|
||||||
|
|
||||||
QFile f2(QFINDTESTDATA("testdata/2.json"));
|
|
||||||
f2.open(QFile::ReadOnly);
|
|
||||||
QByteArray data2 = f2.readAll();
|
|
||||||
f2.close();
|
|
||||||
|
|
||||||
QTest::addColumn<QByteArray>("data");
|
|
||||||
QTest::addColumn<VersionFileList>("list");
|
|
||||||
QTest::addColumn<QString>("error");
|
|
||||||
QTest::addColumn<bool>("ret");
|
|
||||||
|
|
||||||
QTest::newRow("one")
|
|
||||||
<< data1
|
|
||||||
<< (VersionFileList()
|
|
||||||
<< VersionFileEntry{"fileOne",
|
|
||||||
493,
|
|
||||||
encodeBaseFile("/data/fileOneA"),
|
|
||||||
"9eb84090956c484e32cb6c08455a667b"}
|
|
||||||
<< VersionFileEntry{"fileTwo",
|
|
||||||
644,
|
|
||||||
encodeBaseFile("/data/fileTwo"),
|
|
||||||
"38f94f54fa3eb72b0ea836538c10b043"}
|
|
||||||
<< VersionFileEntry{"fileThree",
|
|
||||||
750,
|
|
||||||
encodeBaseFile("/data/fileThree"),
|
|
||||||
"f12df554b21e320be6471d7154130e70"})
|
|
||||||
<< QString() << true;
|
|
||||||
QTest::newRow("two")
|
|
||||||
<< data2
|
|
||||||
<< (VersionFileList()
|
|
||||||
<< VersionFileEntry{"fileOne",
|
|
||||||
493,
|
|
||||||
encodeBaseFile("/data/fileOneB"),
|
|
||||||
"42915a71277c9016668cce7b82c6b577"}
|
|
||||||
<< VersionFileEntry{"fileTwo",
|
|
||||||
644,
|
|
||||||
encodeBaseFile("/data/fileTwo"),
|
|
||||||
"38f94f54fa3eb72b0ea836538c10b043"})
|
|
||||||
<< QString() << true;
|
|
||||||
}
|
|
||||||
void test_parseVersionInfo()
|
|
||||||
{
|
|
||||||
QFETCH(QByteArray, data);
|
|
||||||
QFETCH(VersionFileList, list);
|
|
||||||
QFETCH(QString, error);
|
|
||||||
QFETCH(bool, ret);
|
|
||||||
|
|
||||||
VersionFileList outList;
|
|
||||||
QString outError;
|
|
||||||
bool outRet = parseVersionInfo(data, outList, outError);
|
|
||||||
QCOMPARE(outRet, ret);
|
|
||||||
QCOMPARE(outList, list);
|
|
||||||
QCOMPARE(outError, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_processFileLists_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<QString>("tempFolder");
|
|
||||||
QTest::addColumn<VersionFileList>("currentVersion");
|
|
||||||
QTest::addColumn<VersionFileList>("newVersion");
|
|
||||||
QTest::addColumn<OperationList>("expectedOperations");
|
|
||||||
|
|
||||||
QTemporaryDir tempFolderObj;
|
|
||||||
QString tempFolder = tempFolderObj.path();
|
|
||||||
// update fileOne, keep fileTwo, remove fileThree
|
|
||||||
QTest::newRow("test 1")
|
|
||||||
<< tempFolder << (VersionFileList()
|
|
||||||
<< VersionFileEntry{
|
|
||||||
QFINDTESTDATA("testdata/fileOne"), 493,
|
|
||||||
FileSourceList()
|
|
||||||
<< FileSource(
|
|
||||||
"http", "http://host/path/fileOne-1"),
|
|
||||||
"9eb84090956c484e32cb6c08455a667b"}
|
|
||||||
<< VersionFileEntry{
|
|
||||||
QFINDTESTDATA("testdata/fileTwo"), 644,
|
|
||||||
FileSourceList()
|
|
||||||
<< FileSource(
|
|
||||||
"http", "http://host/path/fileTwo-1"),
|
|
||||||
"38f94f54fa3eb72b0ea836538c10b043"}
|
|
||||||
<< VersionFileEntry{
|
|
||||||
QFINDTESTDATA("testdata/fileThree"), 420,
|
|
||||||
FileSourceList()
|
|
||||||
<< FileSource(
|
|
||||||
"http", "http://host/path/fileThree-1"),
|
|
||||||
"f12df554b21e320be6471d7154130e70"})
|
|
||||||
<< (VersionFileList()
|
|
||||||
<< VersionFileEntry{
|
|
||||||
QFINDTESTDATA("testdata/fileOne"), 493,
|
|
||||||
FileSourceList()
|
|
||||||
<< FileSource("http",
|
|
||||||
"http://host/path/fileOne-2"),
|
|
||||||
"42915a71277c9016668cce7b82c6b577"}
|
|
||||||
<< VersionFileEntry{
|
|
||||||
QFINDTESTDATA("testdata/fileTwo"), 644,
|
|
||||||
FileSourceList()
|
|
||||||
<< FileSource("http",
|
|
||||||
"http://host/path/fileTwo-2"),
|
|
||||||
"38f94f54fa3eb72b0ea836538c10b043"})
|
|
||||||
<< (OperationList()
|
|
||||||
<< Operation::DeleteOp(QFINDTESTDATA("testdata/fileThree"))
|
|
||||||
<< Operation::CopyOp(
|
|
||||||
FS::PathCombine(tempFolder,
|
|
||||||
QFINDTESTDATA("data/fileOne").replace("/", "_")),
|
|
||||||
QFINDTESTDATA("data/fileOne"), 493));
|
|
||||||
}
|
|
||||||
void test_processFileLists()
|
|
||||||
{
|
|
||||||
QFETCH(QString, tempFolder);
|
|
||||||
QFETCH(VersionFileList, currentVersion);
|
|
||||||
QFETCH(VersionFileList, newVersion);
|
|
||||||
QFETCH(OperationList, expectedOperations);
|
|
||||||
|
|
||||||
OperationList operations;
|
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> network = new QNetworkAccessManager();
|
|
||||||
processFileLists(currentVersion, newVersion, QDir::currentPath(), tempFolder, new NetJob("Dummy", network), operations);
|
|
||||||
qDebug() << (operations == expectedOperations);
|
|
||||||
qDebug() << operations;
|
|
||||||
qDebug() << expectedOperations;
|
|
||||||
QCOMPARE(operations, expectedOperations);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
QTEST_GUILESS_MAIN(DownloadTaskTest)
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "DownloadTask_test.moc"
|
|
@ -1,148 +0,0 @@
|
|||||||
#include <QTest>
|
|
||||||
#include <QSignalSpy>
|
|
||||||
|
|
||||||
#include "updater/UpdateChecker.h"
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(UpdateChecker::ChannelListEntry)
|
|
||||||
|
|
||||||
bool operator==(const UpdateChecker::ChannelListEntry &e1, const UpdateChecker::ChannelListEntry &e2)
|
|
||||||
{
|
|
||||||
qDebug() << e1.url << "vs" << e2.url;
|
|
||||||
return e1.id == e2.id &&
|
|
||||||
e1.name == e2.name &&
|
|
||||||
e1.description == e2.description &&
|
|
||||||
e1.url == e2.url;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const UpdateChecker::ChannelListEntry &c)
|
|
||||||
{
|
|
||||||
dbg.nospace() << "ChannelListEntry(id=" << c.id << " name=" << c.name << " description=" << c.description << " url=" << c.url << ")";
|
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString findTestDataUrl(const char *file)
|
|
||||||
{
|
|
||||||
return QUrl::fromLocalFile(QFINDTESTDATA(file)).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateCheckerTest : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private
|
|
||||||
slots:
|
|
||||||
void initTestCase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void cleanupTestCase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_ChannelListParsing_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<QString>("channel");
|
|
||||||
QTest::addColumn<QString>("channelUrl");
|
|
||||||
QTest::addColumn<bool>("hasChannels");
|
|
||||||
QTest::addColumn<bool>("valid");
|
|
||||||
QTest::addColumn<QList<UpdateChecker::ChannelListEntry> >("result");
|
|
||||||
|
|
||||||
QTest::newRow("garbage")
|
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("testdata/garbageChannels.json")
|
|
||||||
<< false
|
|
||||||
<< false
|
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
|
||||||
QTest::newRow("errors")
|
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("testdata/errorChannels.json")
|
|
||||||
<< false
|
|
||||||
<< true
|
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
|
||||||
QTest::newRow("no channels")
|
|
||||||
<< QString()
|
|
||||||
<< findTestDataUrl("testdata/noChannels.json")
|
|
||||||
<< false
|
|
||||||
<< true
|
|
||||||
<< QList<UpdateChecker::ChannelListEntry>();
|
|
||||||
QTest::newRow("one channel")
|
|
||||||
<< QString("develop")
|
|
||||||
<< findTestDataUrl("testdata/oneChannel.json")
|
|
||||||
<< true
|
|
||||||
<< true
|
|
||||||
<< (QList<UpdateChecker::ChannelListEntry>() << UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", "http://example.org/stuff"});
|
|
||||||
QTest::newRow("several channels")
|
|
||||||
<< QString("develop")
|
|
||||||
<< findTestDataUrl("testdata/channels.json")
|
|
||||||
<< true
|
|
||||||
<< true
|
|
||||||
<< (QList<UpdateChecker::ChannelListEntry>()
|
|
||||||
<< UpdateChecker::ChannelListEntry{"develop", "Develop", "The channel called \"develop\"", findTestDataUrl("testdata")}
|
|
||||||
<< UpdateChecker::ChannelListEntry{"stable", "Stable", "It's stable at least", findTestDataUrl("testdata")}
|
|
||||||
<< UpdateChecker::ChannelListEntry{"42", "The Channel", "This is the channel that is going to answer all of your questions", "https://dent.me/tea"});
|
|
||||||
}
|
|
||||||
void tst_ChannelListParsing()
|
|
||||||
{
|
|
||||||
|
|
||||||
QFETCH(QString, channel);
|
|
||||||
QFETCH(QString, channelUrl);
|
|
||||||
QFETCH(bool, hasChannels);
|
|
||||||
QFETCH(bool, valid);
|
|
||||||
QFETCH(QList<UpdateChecker::ChannelListEntry>, result);
|
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
|
||||||
UpdateChecker checker(nam, channelUrl, channel, 0);
|
|
||||||
|
|
||||||
QSignalSpy channelListLoadedSpy(&checker, SIGNAL(channelListLoaded()));
|
|
||||||
QVERIFY(channelListLoadedSpy.isValid());
|
|
||||||
|
|
||||||
checker.updateChanList(false);
|
|
||||||
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
QVERIFY(channelListLoadedSpy.wait());
|
|
||||||
QCOMPARE(channelListLoadedSpy.size(), 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
channelListLoadedSpy.wait();
|
|
||||||
QCOMPARE(channelListLoadedSpy.size(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QCOMPARE(checker.hasChannels(), hasChannels);
|
|
||||||
QCOMPARE(checker.getChannelList(), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_UpdateChecking()
|
|
||||||
{
|
|
||||||
QString channel = "develop";
|
|
||||||
QString channelUrl = findTestDataUrl("testdata/channels.json");
|
|
||||||
int currentBuild = 2;
|
|
||||||
|
|
||||||
shared_qobject_ptr<QNetworkAccessManager> nam = new QNetworkAccessManager();
|
|
||||||
UpdateChecker checker(nam, channelUrl, channel, currentBuild);
|
|
||||||
|
|
||||||
QSignalSpy updateAvailableSpy(&checker, SIGNAL(updateAvailable(GoUpdate::Status)));
|
|
||||||
QVERIFY(updateAvailableSpy.isValid());
|
|
||||||
QSignalSpy channelListLoadedSpy(&checker, SIGNAL(channelListLoaded()));
|
|
||||||
QVERIFY(channelListLoadedSpy.isValid());
|
|
||||||
|
|
||||||
checker.updateChanList(false);
|
|
||||||
QVERIFY(channelListLoadedSpy.wait());
|
|
||||||
|
|
||||||
qDebug() << "CWD:" << QDir::current().absolutePath();
|
|
||||||
checker.m_channels[0].url = findTestDataUrl("testdata/");
|
|
||||||
checker.checkForUpdate(channel, false);
|
|
||||||
|
|
||||||
QVERIFY(updateAvailableSpy.wait());
|
|
||||||
|
|
||||||
auto status = updateAvailableSpy.first().first().value<GoUpdate::Status>();
|
|
||||||
QCOMPARE(checker.m_channels[0].url, status.newRepoUrl);
|
|
||||||
QCOMPARE(3, status.newVersionId);
|
|
||||||
QCOMPARE(currentBuild, status.currentVersionId);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(UpdateCheckerTest)
|
|
||||||
|
|
||||||
#include "UpdateChecker_test.moc"
|
|
BIN
launcher/updater/testdata/1.json
vendored
BIN
launcher/updater/testdata/1.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/2.json
vendored
BIN
launcher/updater/testdata/2.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/channels.json
vendored
BIN
launcher/updater/testdata/channels.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/errorChannels.json
vendored
BIN
launcher/updater/testdata/errorChannels.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/fileOneA
vendored
BIN
launcher/updater/testdata/fileOneA
vendored
Binary file not shown.
BIN
launcher/updater/testdata/fileOneB
vendored
BIN
launcher/updater/testdata/fileOneB
vendored
Binary file not shown.
BIN
launcher/updater/testdata/fileThree
vendored
BIN
launcher/updater/testdata/fileThree
vendored
Binary file not shown.
BIN
launcher/updater/testdata/fileTwo
vendored
BIN
launcher/updater/testdata/fileTwo
vendored
Binary file not shown.
BIN
launcher/updater/testdata/garbageChannels.json
vendored
BIN
launcher/updater/testdata/garbageChannels.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/index.json
vendored
BIN
launcher/updater/testdata/index.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/noChannels.json
vendored
BIN
launcher/updater/testdata/noChannels.json
vendored
Binary file not shown.
BIN
launcher/updater/testdata/oneChannel.json
vendored
BIN
launcher/updater/testdata/oneChannel.json
vendored
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user