diff --git a/src/common/Modes.cpp b/src/common/Modes.cpp index 23c385ec..c0550c00 100644 --- a/src/common/Modes.cpp +++ b/src/common/Modes.cpp @@ -24,6 +24,10 @@ Modes::Modes() { this->isPortable = true; } + else if (line.startsWith("test")) + { + this->test = line.mid(4); + } } } diff --git a/src/common/Modes.hpp b/src/common/Modes.hpp index 6bf5cc25..6b56b96a 100644 --- a/src/common/Modes.hpp +++ b/src/common/Modes.hpp @@ -11,6 +11,7 @@ public: bool isNightly{}; bool isPortable{}; + QString test{}; }; } // namespace chatterino diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index b5fcea2f..b6a6f4ce 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -214,6 +214,15 @@ void Updates::checkForUpdates() NetworkRequest(url) .timeout(60000) .onSuccess([this](auto result) -> Outcome { + if (Modes::getInstance().test == "0") + { + return Success; + } + if (Modes::getInstance().test == "1") + { + return Failure; + } + auto object = result.parseJson(); /// Version available on every platform QJsonValue version_val = object.value("version"); @@ -224,6 +233,10 @@ void Updates::checkForUpdates() qDebug() << "error updating"; return Failure; } + if (Modes::getInstance().test == "2") + { + return Failure; + } #if defined Q_OS_WIN || defined Q_OS_MACOS /// Windows downloads an installer for the new version @@ -235,6 +248,10 @@ void Updates::checkForUpdates() return Failure; } this->updateExe_ = updateExe_val.toString(); + if (Modes::getInstance().test == "3") + { + return Failure; + } /// Windows portable QJsonValue portable_val = object.value("portable_download"); @@ -256,9 +273,19 @@ void Updates::checkForUpdates() return Failure; #endif + if (Modes::getInstance().test == "4") + { + return Failure; + } + /// Current version this->onlineVersion_ = version_val.toString(); + if (Modes::getInstance().test == "5") + { + return Failure; + } + /// Update available :) if (this->currentVersion_ != this->onlineVersion_) { @@ -281,6 +308,16 @@ Updates::Status Updates::getStatus() const bool Updates::shouldShowUpdateButton() const { + if (Modes::getInstance().test == "8") + { + return false; + } + + if (Modes::getInstance().test == "9") + { + return true; + } + switch (this->getStatus()) { case UpdateAvailable: @@ -314,6 +351,12 @@ void Updates::setStatus_(Status status) if (this->status_ != status) { this->status_ = status; + + if (Modes::getInstance().test == "6") + { + return; + } + postToThread([this, status] { this->statusUpdated.invoke(status); }); } }