]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/uris/uris.cpp
@wxsince -> @since in Doxygen docs
[wxWidgets.git] / tests / uris / uris.cpp
index 4067550da7df67f2f6836e4b9ada0d8f19fbb0d3..8ea7438debddef925e027119ba9f8d56ac7d1ea7 100644 (file)
@@ -49,9 +49,10 @@ private:
         CPPUNIT_TEST( Assignment );
         CPPUNIT_TEST( Comparison );
         CPPUNIT_TEST( Unescaping );
+        CPPUNIT_TEST( FileScheme );
 #if TEST_URL
         CPPUNIT_TEST( URLCompat );
-#if wxUSE_PROTOCOL_HTTP
+#if 0 && wxUSE_PROTOCOL_HTTP
         CPPUNIT_TEST( URLProxy  );
 #endif
 #endif
@@ -68,10 +69,13 @@ private:
     void Assignment();
     void Comparison();
     void Unescaping();
+    void FileScheme();
 
 #if TEST_URL
     void URLCompat();
+#if 0 && wxUSE_PROTOCOL_HTTP
     void URLProxy();
+#endif
 #endif
 
     DECLARE_NO_COPY_CLASS(URITestCase)
@@ -300,8 +304,31 @@ void URITestCase::Unescaping()
 
 }
 
+void URITestCase::FileScheme()
+{
+    //file:// variety (NOT CONFORMANT TO THE RFC)
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file://e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("e:/wxcode/script1.xml") );
+
+    //file:/// variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:///e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("/e:/wxcode/script1.xml") );
+
+    //file:/ variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:/e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("/e:/wxcode/script1.xml") );
+
+    //file: variety
+    CPPUNIT_ASSERT(wxURI(wxString(wxT("file:e:/wxcode/script1.xml"))).GetPath() 
+                    == wxT("e:/wxcode/script1.xml") );
+}
+
 #if TEST_URL
 
+const wxChar* pszProblemUrls[] = { wxT("http://www.csdn.net"),
+                                   wxT("http://www.163.com"),
+                                   wxT("http://www.sina.com.cn") };
+
 #include "wx/url.h"
 #include "wx/file.h"
 
@@ -331,9 +358,6 @@ void URITestCase::URLCompat()
     CPPUNIT_ASSERT( uricopy == url );
     CPPUNIT_ASSERT( uricopy == urlcopy );
     CPPUNIT_ASSERT( uricopy == uri );
-#if WXWIN_COMPATIBILITY_2_4
-    CPPUNIT_ASSERT( wxURL::ConvertFromURI(wxT("%20%41%20")) == wxT(" A ") );
-#endif
     CPPUNIT_ASSERT( wxURI::Unescape(wxT("%20%41%20")) == wxT(" A ") );
 
     wxURI test(wxT("file:\"myf\"ile.txt"));
@@ -341,15 +365,51 @@ void URITestCase::URLCompat()
     CPPUNIT_ASSERT( test.BuildURI() == wxT("file:%22myf%22ile.txt") );
     CPPUNIT_ASSERT( test.GetScheme() == wxT("file") );
     CPPUNIT_ASSERT( test.GetPath() == wxT("%22myf%22ile.txt") );
+
+    // 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...)
+    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(_T("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
 }
 
-#if wxUSE_PROTOCOL_HTTP
+// 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
-