Use wxSocketInitializer in the unit tests
Prefer using this RAII wrapper to explicit function calls, this is shorter and more robust.
This commit is contained in:
parent
cc07a0fd9b
commit
1afcac9ca5
5 changed files with 9 additions and 41 deletions
|
|
@ -46,12 +46,7 @@ TEST_CASE("FTP", "[net][.]")
|
|||
const wxString user = wxGetenv("WX_FTP_TEST_USER");
|
||||
const wxString password = wxGetenv("WX_FTP_TEST_PASS");
|
||||
|
||||
class SocketInit
|
||||
{
|
||||
public:
|
||||
SocketInit() { wxSocketBase::Initialize(); }
|
||||
~SocketInit() { wxSocketBase::Shutdown(); }
|
||||
} socketInit;
|
||||
wxSocketInitializer socketInit;
|
||||
|
||||
// wxFTP cannot be a static variable as its ctor needs to access
|
||||
// wxWidgets internals after it has been initialized
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@
|
|||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class URLTestCase : public CppUnit::TestCase
|
||||
class URLTestCase : public CppUnit::TestCase, private wxSocketInitializer
|
||||
{
|
||||
public:
|
||||
URLTestCase();
|
||||
~URLTestCase();
|
||||
URLTestCase() = default;
|
||||
~URLTestCase() = default;
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( URLTestCase );
|
||||
|
|
@ -52,16 +52,6 @@ CPPUNIT_TEST_SUITE_REGISTRATION( URLTestCase );
|
|||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( URLTestCase, "URLTestCase" );
|
||||
|
||||
|
||||
URLTestCase::URLTestCase()
|
||||
{
|
||||
wxSocketBase::Initialize();
|
||||
}
|
||||
|
||||
URLTestCase::~URLTestCase()
|
||||
{
|
||||
wxSocketBase::Shutdown();
|
||||
}
|
||||
|
||||
void URLTestCase::GetInputStream()
|
||||
{
|
||||
if (!IsNetworkAvailable()) // implemented in test.cpp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue