+
+void URITestCase::Unescaping()
+{
+ wxString escaped,
+ unescaped;
+
+ escaped = "http://test.com/of/file%3A%2F%2FC%3A%5Curi%5C"
+ "escaping%5Cthat%5Cseems%5Cbroken%5Csadly%5B1%5D.rss";
+
+ unescaped = wxURI(escaped).BuildUnescapedURI();
+
+ CPPUNIT_ASSERT_EQUAL( "http://test.com/of/file://C:\\uri\\"
+ "escaping\\that\\seems\\broken\\sadly[1].rss",
+ unescaped );
+
+ CPPUNIT_ASSERT_EQUAL( unescaped, wxURI::Unescape(escaped) );
+
+
+#if wxUSE_UNICODE
+ escaped = "http://ru.wikipedia.org/wiki/"
+ "%D0%A6%D0%B5%D0%BB%D0%BE%D0%B5_%D1%87%D0%B8%D1%81%D0%BB%D0%BE";
+
+ unescaped = wxURI::Unescape(escaped);
+
+ CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(
+ "http://ru.wikipedia.org/wiki/"
+ "\xD0\xA6\xD0\xB5\xD0\xBB\xD0\xBE\xD0\xB5_"
+ "\xD1\x87\xD0\xB8\xD1\x81\xD0\xBB\xD0\xBE"
+ ),
+ unescaped );
+#endif // wxUSE_UNICODE
+}
+
+void URITestCase::FileScheme()
+{
+ //file:// variety (NOT CONFORMING TO THE RFC)
+ URI_ASSERT_PATH_EQUAL( "file://e:/wxcode/script1.xml",
+ "e:/wxcode/script1.xml" );
+
+ //file:/// variety
+ URI_ASSERT_PATH_EQUAL( "file:///e:/wxcode/script1.xml",
+ "/e:/wxcode/script1.xml" );
+
+ //file:/ variety
+ URI_ASSERT_PATH_EQUAL( "file:/e:/wxcode/script1.xml",
+ "/e:/wxcode/script1.xml" );
+
+ //file: variety
+ URI_ASSERT_PATH_EQUAL( "file:e:/wxcode/script1.xml",
+ "e:/wxcode/script1.xml" );
+}
+
+#if TEST_URL
+
+#include "wx/url.h"
+#include "wx/file.h"
+
+void URITestCase::URLCompat()
+{
+ wxURL url("http://user:password@wxwidgets.org");
+
+ CPPUNIT_ASSERT( url.GetError() == wxURL_NOERR );
+ CPPUNIT_ASSERT( url == wxURL("http://user:password@wxwidgets.org") );
+
+ wxURI uri("http://user:password@wxwidgets.org");
+
+ CPPUNIT_ASSERT( url == uri );
+
+ wxURL urlcopy(uri);
+
+ CPPUNIT_ASSERT( urlcopy == url );
+ CPPUNIT_ASSERT( urlcopy == uri );
+
+ wxURI uricopy(url);
+
+ CPPUNIT_ASSERT( uricopy == url );
+ CPPUNIT_ASSERT( uricopy == urlcopy );
+ CPPUNIT_ASSERT( uricopy == uri );
+ CPPUNIT_ASSERT_EQUAL( " A ", wxURI::Unescape("%20%41%20") );
+
+ wxURI test("file:\"myf\"ile.txt");
+
+ CPPUNIT_ASSERT_EQUAL( "file:%22myf%22ile.txt" , test.BuildURI() );
+ CPPUNIT_ASSERT_EQUAL( "file", test.GetScheme() );
+ CPPUNIT_ASSERT_EQUAL( "%22myf%22ile.txt", test.GetPath() );
+
+ // these could be put under a named registry since they take some
+ // time to complete
+#if 0
+ // Test problem urls (reported not to work some time ago by a user...)
+ const wxChar* pszProblemUrls[] = { "http://www.csdn.net",
+ "http://www.163.com",
+ "http://www.sina.com.cn" };
+
+ for ( size_t i = 0; i < WXSIZEOF(pszProblemUrls); ++i )
+ {
+ wxURL urlProblem(pszProblemUrls[i]);
+ CPPUNIT_ASSERT(urlProblem.GetError() == wxURL_NOERR);
+
+ wxInputStream* is = urlProblem.GetInputStream();
+ CPPUNIT_ASSERT(is != NULL);
+
+ wxFile fOut(wxT("test.html"), wxFile::write);
+ wxASSERT(fOut.IsOpened());
+
+ char buf[1001];
+ for( ;; )
+ {
+ is->Read(buf, 1000);
+ size_t n = is->LastRead();
+ if ( n == 0 )
+ break;
+ buf[n] = 0;
+ fOut.Write(buf, n);
+ }
+
+ delete is;
+ }
+#endif
+}
+
+// the purpose of this test is unclear, it seems to be unfinished so disabling
+// it for now
+#if 0 && wxUSE_PROTOCOL_HTTP
+void URITestCase::URLProxy()
+{
+ wxURL url(wxT("http://www.asite.com/index.html"));
+ url.SetProxy(wxT("pserv:3122"));
+
+ wxURL::SetDefaultProxy(wxT("fol.singnet.com.sg:8080"));
+ wxURL url2(wxT("http://server-name/path/to/file?query_data=value"));
+ wxInputStream *data = url2.GetInputStream();
+ CPPUNIT_ASSERT(data != NULL);
+}
+#endif // wxUSE_PROTOCOL_HTTP
+
+#endif // TEST_URL