Move plugins to Sol (#5622)
Co-authored-by: Nerixyz <nerixdev@outlook.de> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "common/network/NetworkManager.hpp"
|
||||
#include "common/network/NetworkResult.hpp"
|
||||
#include "NetworkHelpers.hpp"
|
||||
#include "Test.hpp"
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -10,14 +11,6 @@ using namespace chatterino;
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef CHATTERINO_TEST_USE_PUBLIC_HTTPBIN
|
||||
// Not using httpbin.org, since it can be really slow and cause timeouts.
|
||||
// postman-echo has the same API.
|
||||
const char *const HTTPBIN_BASE_URL = "https://postman-echo.com";
|
||||
#else
|
||||
const char *const HTTPBIN_BASE_URL = "http://127.0.0.1:9051";
|
||||
#endif
|
||||
|
||||
QString getStatusURL(int code)
|
||||
{
|
||||
return QString("%1/status/%2").arg(HTTPBIN_BASE_URL).arg(code);
|
||||
@@ -28,46 +21,6 @@ QString getDelayURL(int delay)
|
||||
return QString("%1/delay/%2").arg(HTTPBIN_BASE_URL).arg(delay);
|
||||
}
|
||||
|
||||
class RequestWaiter
|
||||
{
|
||||
public:
|
||||
void requestDone()
|
||||
{
|
||||
{
|
||||
std::unique_lock lck(this->mutex_);
|
||||
ASSERT_FALSE(this->requestDone_);
|
||||
this->requestDone_ = true;
|
||||
}
|
||||
this->condition_.notify_one();
|
||||
}
|
||||
|
||||
void waitForRequest()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
std::unique_lock lck(this->mutex_);
|
||||
bool done = this->condition_.wait_for(lck, 10ms, [this] {
|
||||
return this->requestDone_;
|
||||
});
|
||||
if (done)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents);
|
||||
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::condition_variable condition_;
|
||||
bool requestDone_ = false;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(NetworkRequest, Success)
|
||||
|
||||
Reference in New Issue
Block a user