Files
BiLauncher/tests/common/nettest.h
T
galeon 41599fa82f
tests / linux (push) Failing after 2m18s
tests / windows (push) Skipped
tests / macos (push) Skipped
tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped
new unit tests, hehe 67
Signed-off-by: galeon <dertiellis@gmail.com>
2026-10-12 13:14:08 +03:00

40 lines
1.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
// Помощники для тестов сетевых сервисов.
#include "fakeinternet.h"
#include <QString>
#include <QtTest/QTest>
// В initTestCase(): поднять FakeInternet или пропустить весь тест-класс.
// С BILAUNCHER_REQUIRE_FAKE_INTERNET=1 (так в CI на Linux) недоступность —
// ошибка, а не пропуск: иначе сломанный перехват тихо выключил бы все сетевые тесты.
#define BILAUNCHER_START_FAKE_INTERNET(net) \
do { \
QString startError_; \
if (!(net).start(&startError_)) { \
const QString message_ = QStringLiteral("FakeInternet недоступен: ") + startError_; \
if (qEnvironmentVariableIntValue("BILAUNCHER_REQUIRE_FAKE_INTERNET")) \
QFAIL(qPrintable(message_)); \
QSKIP(qPrintable(message_)); \
} \
} while (false)
// Результат колбэка вида (bool ok, QString warning).
struct CallResult
{
int calls = 0;
bool ok = false;
QString warning;
auto callback()
{
return [this](bool okValue, const QString &warningValue) {
++calls;
ok = okValue;
warning = warningValue;
};
}
};