diff --git a/makespec/BUILDVERSION b/makespec/BUILDVERSION index 2c90e46d..721739cb 100644 --- a/makespec/BUILDVERSION +++ b/makespec/BUILDVERSION @@ -1 +1 @@ -6003 +6004 diff --git a/test/Common.hpp b/test/Common.hpp new file mode 100644 index 00000000..2ec115c5 --- /dev/null +++ b/test/Common.hpp @@ -0,0 +1,19 @@ +#include "base/Qv2rayBaseApplication.hpp" +using namespace Qv2ray; +int fakeArgc = 0; +char *fakeArgv[]{}; + +class QvTestApplication + : public QCoreApplication + , public Qv2rayApplicationInterface +{ + public: + explicit QvTestApplication() : QCoreApplication(fakeArgc, fakeArgv), Qv2rayApplicationInterface(){}; + virtual void MessageBoxWarn(QWidget *, const QString &, const QString &, MessageOpt) override{}; + virtual void MessageBoxInfo(QWidget *, const QString &, const QString &, MessageOpt) override{}; + virtual MessageOpt MessageBoxAsk(QWidget *, const QString &, const QString &, const QList &) override + { + return {}; + }; + virtual void OpenURL(const QString &) override{}; +}; diff --git a/test/src/components/latency/TestRealPing.cpp b/test/src/components/latency/TestRealPing.cpp index 1802dd9c..86f731f6 100644 --- a/test/src/components/latency/TestRealPing.cpp +++ b/test/src/components/latency/TestRealPing.cpp @@ -1,26 +1,9 @@ +#include "Common.hpp" #include "src/components/latency/RealPing.hpp" #include "uvw.hpp" #define CATCH_CONFIG_MAIN #include "catch.hpp" -int fakeArgc = 0; -char *fakeArgv[]{}; - -class QvTestApplication - : public QCoreApplication - , public Qv2rayApplicationInterface -{ - public: - explicit QvTestApplication() : QCoreApplication(fakeArgc, fakeArgv), Qv2rayApplicationInterface(){}; - virtual void MessageBoxWarn(QWidget *, const QString &, const QString &, MessageOpt) override{}; - virtual void MessageBoxInfo(QWidget *, const QString &, const QString &, MessageOpt) override{}; - virtual MessageOpt MessageBoxAsk(QWidget *, const QString &, const QString &, const QList &) override - { - return {}; - }; - virtual void OpenURL(const QString &) override{}; -}; - SCENARIO("Test RealPing get proxy address", "[RealPing]") { QvTestApplication app; diff --git a/test/src/core/connection/TestParseSS.cpp b/test/src/core/connection/TestParseSS.cpp index e70de659..2d5186d3 100644 --- a/test/src/core/connection/TestParseSS.cpp +++ b/test/src/core/connection/TestParseSS.cpp @@ -1,4 +1,5 @@ #include "3rdparty/QJsonStruct/QJsonIO.hpp" +#include "Common.hpp" #include "src/core/connection/Serialization.hpp" #define CATCH_CONFIG_MAIN #include "catch.hpp" @@ -6,7 +7,7 @@ using namespace Qv2ray::core::connection::serialization; SCENARIO("Test Parse Shadowsocks url", "[ParseSSUrl]") { - + QvTestApplication app; GIVEN("A shadowsocks server object") { ShadowSocksServerObject s; @@ -50,8 +51,8 @@ SCENARIO("Test Parse Shadowsocks url", "[ParseSSUrl]") } WHEN("the url with sip003 plugin") { - auto c = ss::Deserialize("ss://YmYtY2ZiOnRlc3Q@192.168.100.1:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com", &alias, - &err); + auto c = + ss::Deserialize("ss://YmYtY2ZiOnRlc3Q@192.168.100.1:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com", &alias, &err); s = ShadowSocksServerObject::fromJson(QJsonIO::GetValue(c, "outbounds", 0, "settings", "servers", 0)); REQUIRE(s.address.toStdString() == "192.168.100.1"); REQUIRE(s.port == 8888); @@ -60,8 +61,7 @@ SCENARIO("Test Parse Shadowsocks url", "[ParseSSUrl]") } WHEN("another url with sip003 plugin") { - auto c = - ss::Deserialize("ss://YmYtY2ZiOnRlc3Q@192.168.1.1:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com", &alias, &err); + auto c = ss::Deserialize("ss://YmYtY2ZiOnRlc3Q@192.168.1.1:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com", &alias, &err); s = ShadowSocksServerObject::fromJson(QJsonIO::GetValue(c, "outbounds", 0, "settings", "servers", 0)); REQUIRE(s.address.toStdString() == "192.168.1.1"); REQUIRE(s.port == 8388); @@ -71,8 +71,7 @@ SCENARIO("Test Parse Shadowsocks url", "[ParseSSUrl]") WHEN("the url with sip003 plugin and remarks") { auto c = ss::Deserialize( - "ss://YmYtY2ZiOnRlc3Q@192.168.100.1:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server", &alias, - &err); + "ss://YmYtY2ZiOnRlc3Q@192.168.100.1:8888/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server", &alias, &err); s = ShadowSocksServerObject::fromJson(QJsonIO::GetValue(c, "outbounds", 0, "settings", "servers", 0)); REQUIRE(s.address.toStdString() == "192.168.100.1"); REQUIRE(s.port == 8888); @@ -81,8 +80,8 @@ SCENARIO("Test Parse Shadowsocks url", "[ParseSSUrl]") } WHEN("another url with sip003 plugin and remarks") { - auto c = ss::Deserialize( - "ss://YmYtY2ZiOnRlc3Q@192.168.1.1:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server", &alias, &err); + auto c = ss::Deserialize("ss://YmYtY2ZiOnRlc3Q@192.168.1.1:8388/?plugin=obfs-local%3bobfs%3dhttp%3bobfs-host%3dgoogle.com#example-server", + &alias, &err); s = ShadowSocksServerObject::fromJson(QJsonIO::GetValue(c, "outbounds", 0, "settings", "servers", 0)); REQUIRE(s.address.toStdString() == "192.168.1.1"); REQUIRE(s.port == 8388); diff --git a/test/src/core/connection/TestParseVmess.cpp b/test/src/core/connection/TestParseVmess.cpp index b760b8e8..82312697 100644 --- a/test/src/core/connection/TestParseVmess.cpp +++ b/test/src/core/connection/TestParseVmess.cpp @@ -1,10 +1,12 @@ #include "3rdparty/QJsonStruct/QJsonIO.hpp" +#include "Common.hpp" #include "src/core/connection/Serialization.hpp" #define CATCH_CONFIG_MAIN #include "catch.hpp" SCENARIO("Test Parse VMess V2 url", "[ParseVMessV2]") { + QvTestApplication app; GIVEN("vmess+tcp") { QString _; @@ -48,6 +50,7 @@ SCENARIO("Test Parse VMess V2 url", "[ParseVMessV2]") SCENARIO("Test Parse VMess V1 url", "[ParseVMessV1]") { + QvTestApplication app; GIVEN("vmess+ws") { QString _;