From a113ddc9e508e51ad58b80362ea902c2f4b52d82 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sat, 6 Jun 2026 12:40:36 +0200 Subject: [PATCH] Add some guards against missing build options --- include/wx/chkconf.h | 9 +++++++++ tests/image/image.cpp | 4 ++++ tests/interactive/input.cpp | 4 +++- tests/net/socket.cpp | 2 ++ tests/streams/socketstream.cpp | 4 ++++ tests/test.cpp | 4 ++++ tests/uris/ftp.cpp | 4 ++++ tests/uris/url.cpp | 4 ++++ tests/xml/xmltest.cpp | 4 ++++ 9 files changed, 38 insertions(+), 1 deletion(-) diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index 5113339f8b..0b5bfa8b05 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -1337,6 +1337,15 @@ # define wxUSE_PROTOCOL 1 # endif # endif + +# if !wxUSE_SOCKETS +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_URL requires wxUSE_SOCKETS" +# else +# undef wxUSE_SOCKETS +# define wxUSE_SOCKETS 1 +# endif +# endif #endif /* wxUSE_URL */ #if wxUSE_PROTOCOL diff --git a/tests/image/image.cpp b/tests/image/image.cpp index 786eb5f4cb..59ed0dbb09 100644 --- a/tests/image/image.cpp +++ b/tests/image/image.cpp @@ -135,6 +135,8 @@ TEST_CASE_METHOD(ImageHandlersInit, "wxImage::LoadFromFile", "[image]") CHECK(img.LoadFile("image/bitfields.bmp", wxBITMAP_TYPE_BMP)); } +#if wxUSE_URL + TEST_CASE_METHOD(ImageHandlersInit, "wxImage::LoadFromSocketStream", "[image]") { // This test doesn't work any more even using the IP address below as the @@ -161,6 +163,8 @@ TEST_CASE_METHOD(ImageHandlersInit, "wxImage::LoadFromSocketStream", "[image]") CHECK( img.LoadFile(*in_stream, wxBITMAP_TYPE_PNG) ); } +#endif // wxUSE_URL + TEST_CASE_METHOD(ImageHandlersInit, "wxImage::LoadFromZipStream", "[image]") { for (unsigned int i=0; iRead(out).GetLastError() ); +#endif } TEST_CASE("wxDatagramSocket::ShortRead", "[socket][dgram]") diff --git a/tests/streams/socketstream.cpp b/tests/streams/socketstream.cpp index 6b4bb2b7ee..0452597fc3 100644 --- a/tests/streams/socketstream.cpp +++ b/tests/streams/socketstream.cpp @@ -11,6 +11,8 @@ #include "testprec.h" +#if wxUSE_SOCKETS + // for all others, include the necessary headers #ifndef WX_PRECOMP #include "wx/log.h" @@ -243,3 +245,5 @@ void socketStream::DoCheckInputStream(wxSocketInputStream& stream_in) // Register the stream sub suite, by using some stream helper macro. STREAM_TEST_SUBSUITE_NAMED_REGISTRATION(socketStream) + +#endif // wxUSE_SOCKETS diff --git a/tests/test.cpp b/tests/test.cpp index 711be77e1f..398dfbb2c7 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -448,6 +448,7 @@ extern void SetProcessEventFunc(ProcessEventFunc func) static bool DoCheckConnection() { +#if wxUSE_SOCKETS // NOTE: we could use wxDialUpManager here if it was in wxNet; since it's in // wxCore we use a simple rough test: @@ -466,6 +467,9 @@ static bool DoCheckConnection() (sock.Write(HTTP_GET, strlen(HTTP_GET)), sock.WaitForRead(1)); return online; +#else + return false; +#endif } extern bool IsNetworkAvailable() diff --git a/tests/uris/ftp.cpp b/tests/uris/ftp.cpp index 28b54ac435..3af5ffea2f 100644 --- a/tests/uris/ftp.cpp +++ b/tests/uris/ftp.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_PROTOCOL_FTP + #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP @@ -134,3 +136,5 @@ TEST_CASE("FTP", "[net][.]") CHECK( ftp.GetLastResult() == "11" ); } } + +#endif // wxUSE_PROTOCOL_FTP diff --git a/tests/uris/url.cpp b/tests/uris/url.cpp index 03c43105c7..c65afe1515 100644 --- a/tests/uris/url.cpp +++ b/tests/uris/url.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_URL + #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP @@ -108,3 +110,5 @@ TEST_CASE("wxURL::CopyAndAssignment", "[url]") puri = new wxURL(); delete puri; } + +#endif // wxUSE_URL diff --git a/tests/xml/xmltest.cpp b/tests/xml/xmltest.cpp index ac9dee4b3c..23844b165c 100644 --- a/tests/xml/xmltest.cpp +++ b/tests/xml/xmltest.cpp @@ -13,6 +13,8 @@ #include "testprec.h" +#if wxUSE_XML + #ifndef WX_PRECOMP #include "wx/wx.h" #endif // WX_PRECOMP @@ -626,3 +628,5 @@ TEST_CASE("XML::Load", "[xml][.]") WARN("Dump of " << file << ":\n" << sos.GetString()); } + +#endif // wxUSE_XML