1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/uris/url.cpp
3 // Purpose: wxURL unit test
4 // Author: Francesco Montorsi
6 // RCS-ID: $Id: uris.cpp 58272 2009-01-21 17:02:11Z VZ $
7 // Copyright: (c) 2009 Francesco Montorsi
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
25 #include "wx/mstream.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class URLTestCase
: public CppUnit::TestCase
38 CPPUNIT_TEST_SUITE( URLTestCase
);
39 CPPUNIT_TEST( GetInputStream
);
40 CPPUNIT_TEST_SUITE_END();
42 void GetInputStream();
44 DECLARE_NO_COPY_CLASS(URLTestCase
)
47 // register in the unnamed registry so that these tests are run by default
48 CPPUNIT_TEST_SUITE_REGISTRATION( URLTestCase
);
50 // also include in it's own registry so that these tests can be run alone
51 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( URLTestCase
, "URLTestCase" );
54 URLTestCase::URLTestCase()
56 wxSocketBase::Initialize();
59 URLTestCase::~URLTestCase()
61 wxSocketBase::Shutdown();
64 void URLTestCase::GetInputStream()
66 if (!IsNetworkAvailable()) // implemented in test.cpp
68 wxLogWarning("No network connectivity; skipping the URLTestCase::GetInputStream test unit.");
72 wxURL
url("http://wxwidgets.org/logo9.jpg");
73 CPPUNIT_ASSERT_EQUAL(wxURL_NOERR
, url
.GetError());
75 wxInputStream
*in_stream
= url
.GetInputStream();
76 CPPUNIT_ASSERT(in_stream
&& in_stream
->IsOk());
78 wxMemoryOutputStream ostream
;
79 CPPUNIT_ASSERT(in_stream
->Read(ostream
).GetLastError() == wxSTREAM_EOF
);
81 // wx logo image currently is 13219 bytes
82 CPPUNIT_ASSERT(ostream
.GetSize() == 13219);