]> git.saurik.com Git - wxWidgets.git/blame - tests/uris/url.cpp
fixing text matrix (dataview custom renderer showed problems) and reordering SaveGState
[wxWidgets.git] / tests / uris / url.cpp
CommitLineData
1f51673b
FM
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/uris/url.cpp
3// Purpose: wxURL unit test
4// Author: Francesco Montorsi
5// Created: 2009-5-31
6// RCS-ID: $Id: uris.cpp 58272 2009-01-21 17:02:11Z VZ $
7// Copyright: (c) 2009 Francesco Montorsi
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17 #pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21 #include "wx/wx.h"
22#endif // WX_PRECOMP
23
24#include "wx/url.h"
25#include "wx/mstream.h"
26
27// ----------------------------------------------------------------------------
28// test class
29// ----------------------------------------------------------------------------
30
31class URLTestCase : public CppUnit::TestCase
32{
33public:
34 URLTestCase();
35 ~URLTestCase();
36
37private:
38 CPPUNIT_TEST_SUITE( URLTestCase );
39 CPPUNIT_TEST( GetInputStream );
40 CPPUNIT_TEST_SUITE_END();
41
42 void GetInputStream();
43
44 DECLARE_NO_COPY_CLASS(URLTestCase)
45};
46
47// register in the unnamed registry so that these tests are run by default
48CPPUNIT_TEST_SUITE_REGISTRATION( URLTestCase );
49
50// also include in it's own registry so that these tests can be run alone
51CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( URLTestCase, "URLTestCase" );
52
53
54URLTestCase::URLTestCase()
55{
56 wxSocketBase::Initialize();
57}
58
59URLTestCase::~URLTestCase()
60{
61 wxSocketBase::Shutdown();
62}
63
64void URLTestCase::GetInputStream()
65{
66 if (!IsNetworkAvailable()) // implemented in test.cpp
67 {
68 wxLogWarning("No network connectivity; skipping the URLTestCase::GetInputStream test unit.");
69 return;
70 }
71
72 wxURL url("http://wxwidgets.org/logo9.jpg");
73 CPPUNIT_ASSERT_EQUAL(wxURL_NOERR, url.GetError());
74
75 wxInputStream *in_stream = url.GetInputStream();
76 CPPUNIT_ASSERT(in_stream && in_stream->IsOk());
77
78 wxMemoryOutputStream ostream;
79 CPPUNIT_ASSERT(in_stream->Read(ostream).GetLastError() == wxSTREAM_EOF);
80
81 // wx logo image currently is 13219 bytes
82 CPPUNIT_ASSERT(ostream.GetSize() == 13219);
83}
84