From 54ddf1590e98ed57267fe09f5805d7adede13e0a Mon Sep 17 00:00:00 2001 From: "depstein%netscape.com" Date: Wed, 22 Jan 2003 04:11:05 +0000 Subject: [PATCH] updated nsIHttpChannel response tests. more flexible parameter passing. not part of the build. git-svn-id: svn://10.0.0.236/trunk@136798 18797224-902f-48f8-a5cc-f745e15eee43 --- .../qa/testembed/nsichanneltests.cpp | 18 +----- .../qa/testembed/nsihttpchanneltests.cpp | 61 ++++++++++++------ .../qa/testembed/nsihttpchanneltests.h | 8 +-- mozilla/embedding/qa/testembed/testembed.aps | Bin 718 -> 2746 bytes 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/mozilla/embedding/qa/testembed/nsichanneltests.cpp b/mozilla/embedding/qa/testembed/nsichanneltests.cpp index 5de9121f116..53ec651cb8d 100644 --- a/mozilla/embedding/qa/testembed/nsichanneltests.cpp +++ b/mozilla/embedding/qa/testembed/nsichanneltests.cpp @@ -219,8 +219,6 @@ void CnsIChannelTests::GetSecurityInfoTest(nsIChannel *theChannel, PRInt16 displ } rv = theChannel->GetSecurityInfo(getter_AddRefs(theSupports)); RvTestResult(rv, "GetSecurityInfo", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "GetSecurityInfo"); if (!theSupports) QAOutput("Didn't get nsISupports object for GetSecurityInfoTest.", displayMode); } @@ -228,9 +226,7 @@ void CnsIChannelTests::GetSecurityInfoTest(nsIChannel *theChannel, PRInt16 displ void CnsIChannelTests::SetContentTypeTest(nsIChannel *theChannel, PRInt16 displayMode) { rv = theChannel->SetContentType(NS_LITERAL_CSTRING("text/plain")); - RvTestResult(rv, "SetContentType", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "SetContentType"); + RvTestResult(rv, "SetContentType", displayMode); } void CnsIChannelTests::GetContentTypeTest(nsIChannel *theChannel, PRInt16 displayMode) @@ -239,8 +235,6 @@ void CnsIChannelTests::GetContentTypeTest(nsIChannel *theChannel, PRInt16 displa rv = theChannel->GetContentType(contentType); RvTestResult(rv, "GetContentType", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "GetContentType"); FormatAndPrintOutput("the content type = ", contentType, displayMode); } @@ -250,8 +244,6 @@ void CnsIChannelTests::SetContentCharsetTest(nsIChannel *theChannel, PRInt16 dis rv = theChannel->SetContentCharset(NS_LITERAL_CSTRING("ISO-8859-1")); RvTestResult(rv, "SetContentCharset", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "SetContentCharset"); } void CnsIChannelTests::GetContentCharsetTest(nsIChannel *theChannel, PRInt16 displayMode) @@ -260,8 +252,6 @@ void CnsIChannelTests::GetContentCharsetTest(nsIChannel *theChannel, PRInt16 dis rv = theChannel->GetContentCharset(charsetType); RvTestResult(rv, "GetContentCharset", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "GetContentCharset"); FormatAndPrintOutput("the charset type = ", charsetType, displayMode); } @@ -272,8 +262,6 @@ void CnsIChannelTests::SetContentLengthTest(nsIChannel *theChannel, PRInt16 disp contentLength = 10000; rv = theChannel->SetContentLength(contentLength); RvTestResult(rv, "SetContentLength", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "SetContentLength"); } void CnsIChannelTests::GetContentLengthTest(nsIChannel *theChannel, PRInt16 displayMode) @@ -282,8 +270,6 @@ void CnsIChannelTests::GetContentLengthTest(nsIChannel *theChannel, PRInt16 disp rv = theChannel->GetContentLength(&contentLength); RvTestResult(rv, "GetContentLength", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "GetContentLength"); FormatAndPrintOutput("the content length = ", contentLength, displayMode); } @@ -291,8 +277,6 @@ void CnsIChannelTests::OpenTest(nsIChannel *theChannel, PRInt16 displayMode) { rv = theChannel->Open(getter_AddRefs(theInputStream)); RvTestResult(rv, "OpenTest", displayMode); - if (displayMode == 1) - RvTestResultDlg(rv, "OpenTest"); if (!theInputStream) QAOutput("Didn't get theInputStream object. OpenTest failed.", displayMode); } diff --git a/mozilla/embedding/qa/testembed/nsihttpchanneltests.cpp b/mozilla/embedding/qa/testembed/nsihttpchanneltests.cpp index cdffbe9c2a8..15ed365fe89 100644 --- a/mozilla/embedding/qa/testembed/nsihttpchanneltests.cpp +++ b/mozilla/embedding/qa/testembed/nsihttpchanneltests.cpp @@ -68,22 +68,22 @@ void CnsIHttpChannelTests::OnStartTests(UINT nMenuID) RunAllTests(); break ; case ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTMETHOD : - SetRequestMethodTest(theHttpChannel, 2); + SetRequestMethodTest(theHttpChannel, "PUT", 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTMETHOD : GetRequestMethodTest(theHttpChannel, 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_SETREFERRER : - SetReferrerTest(theHttpChannel, 2); + SetReferrerTest(theHttpChannel, "https://www.sun.com", 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_GETREFERRER : GetReferrerTest(theHttpChannel, 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTHEADER : - SetRequestHeaderTest(theHttpChannel, 2); + SetRequestHeaderTest(theHttpChannel, "Content-Type", "text/html", 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTHEADER : - GetRequestHeaderTest(theHttpChannel, 2); + GetRequestHeaderTest(theHttpChannel, "Content-Type", 2); break ; case ID_INTERFACES_NSIHTTPCHANNEL_VISITREQUESTHEADERS : VisitRequestHeadersTest(theHttpChannel, 2); @@ -121,13 +121,19 @@ void CnsIHttpChannelTests::RunAllTests() QAOutput("Didn't get nsIHttpChannel object. RunAllTests not run.", 1); return; } - - SetRequestMethodTest(theHttpChannel, 1); + QAOutput(" nsIHttpChannel request tests:"); + SetRequestMethodTest(theHttpChannel, "POST", 1); GetRequestMethodTest(theHttpChannel, 1); - SetReferrerTest(theHttpChannel, 1); + SetRequestMethodTest(theHttpChannel, "HEAD", 1); + GetRequestMethodTest(theHttpChannel, 1); + SetReferrerTest(theHttpChannel, "http://www.cisco.com", 1); GetReferrerTest(theHttpChannel, 1); - SetRequestHeaderTest(theHttpChannel, 1); - GetRequestHeaderTest(theHttpChannel, 1); + SetRequestHeaderTest(theHttpChannel, "Cookie", "TheCookie", 1); + GetRequestHeaderTest(theHttpChannel, "Cookie", 1); + SetRequestHeaderTest(theHttpChannel, "Content-Type", "text/xml", 1); + GetRequestHeaderTest(theHttpChannel, "Content-Type", 1); + SetRequestHeaderTest(theHttpChannel, "Content-Length", "10000", 1); + GetRequestHeaderTest(theHttpChannel, "Content-Length", 1); VisitRequestHeadersTest(theHttpChannel, 1); SetAllowPipeliningTest(theHttpChannel, PR_FALSE, 1); SetAllowPipeliningTest(theHttpChannel, PR_TRUE, 1); @@ -144,12 +150,14 @@ void CnsIHttpChannelTests::RunAllTests() } void CnsIHttpChannelTests::SetRequestMethodTest(nsIHttpChannel *theHttpChannel, + const char * requestType, PRInt16 displayMode) { // SetRequestMethod // try "GET", "PUT", "HEAD", or "POST" - rv = theHttpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST")); + rv = theHttpChannel->SetRequestMethod(nsDependentCString(requestType)); RvTestResult(rv, "SetRequestMethod()", displayMode); + RvTestResultDlg(rv, "SetRequestMethod() test", true); } void CnsIHttpChannelTests::GetRequestMethodTest(nsIHttpChannel *theHttpChannel, @@ -159,22 +167,25 @@ void CnsIHttpChannelTests::GetRequestMethodTest(nsIHttpChannel *theHttpChannel, nsCAutoString method; rv = theHttpChannel->GetRequestMethod(method); RvTestResult(rv, "GetRequestMethod()", displayMode); + RvTestResultDlg(rv, "GetRequestMethod() test"); // if (method.Equals("POST") FormatAndPrintOutput("GetRequestMethod method = ", method, displayMode); } void CnsIHttpChannelTests::SetReferrerTest(nsIHttpChannel *theHttpChannel, + const char *theUrl, PRInt16 displayMode) { // SetReferrer nsCAutoString theSpec; - theSpec = "http://www.cisco.com"; + theSpec = theUrl; NS_NewURI(getter_AddRefs(theURI), theSpec); if (!theURI) QAOutput("Didn't get URI object. Test failed.", 2); rv = theHttpChannel->SetReferrer(theURI); RvTestResult(rv, "SetReferrer()", displayMode); + RvTestResultDlg(rv, "SetReferrer() test"); } void CnsIHttpChannelTests::GetReferrerTest(nsIHttpChannel *theHttpChannel, @@ -182,8 +193,10 @@ void CnsIHttpChannelTests::GetReferrerTest(nsIHttpChannel *theHttpChannel, { // GetReferrer nsCAutoString theSpec; + rv = theHttpChannel->GetReferrer(getter_AddRefs(theURI)); RvTestResult(rv, "GetReferrer()", displayMode); + RvTestResultDlg(rv, "GetReferrer() test"); if (!theURI) QAOutput("Didn't get nsIURI object. Test failed.", displayMode); else { @@ -193,26 +206,30 @@ void CnsIHttpChannelTests::GetReferrerTest(nsIHttpChannel *theHttpChannel, } void CnsIHttpChannelTests::SetRequestHeaderTest(nsIHttpChannel *theHttpChannel, + const char *requestType, + const char *headerVal, PRInt16 displayMode) { // SetRequestHeader // try {"Content-Type","text/xml"}, {"Content-Length", 10000}, and // {"Accept"), NS_LITERAL_CSTRING("text/xml,application/xml,application/xhtml+xml,*/*;q=0.1"), - const char *headerVal = "TheCookie"; - rv = theHttpChannel->SetRequestHeader(NS_LITERAL_CSTRING("Cookie"), + rv = theHttpChannel->SetRequestHeader(nsDependentCString(requestType), nsDependentCString(headerVal), PR_FALSE); RvTestResult(rv, "SetRequestHeader()", displayMode); + RvTestResultDlg(rv, "SetRequestHeader() test"); } void CnsIHttpChannelTests::GetRequestHeaderTest(nsIHttpChannel *theHttpChannel, + const char *requestType, PRInt16 displayMode) { // GetRequestHeader nsCAutoString header; // could be set to "referrer" - rv = theHttpChannel->GetRequestHeader(NS_LITERAL_CSTRING("Cookie"), header); + rv = theHttpChannel->GetRequestHeader(nsDependentCString(requestType), header); RvTestResult(rv, "GetRequestHeader()", displayMode); + RvTestResultDlg(rv, "GetRequestHeader() test"); FormatAndPrintOutput("GetRequestHeader type = ", header, displayMode); } @@ -226,6 +243,7 @@ void CnsIHttpChannelTests::VisitRequestHeadersTest(nsIHttpChannel *theHttpChann rv = theHttpChannel->VisitRequestHeaders(theVisitor); RvTestResult(rv, "VisitRequestHeaders()", displayMode); + RvTestResultDlg(rv, "VisitRequestHeaders() test"); } void CnsIHttpChannelTests::SetAllowPipeliningTest(nsIHttpChannel *theHttpChannel, @@ -234,6 +252,7 @@ void CnsIHttpChannelTests::SetAllowPipeliningTest(nsIHttpChannel *theHttpChanne { rv = theHttpChannel->SetAllowPipelining(mAllowPipelining); RvTestResult(rv, "SetAllowPipelining()", displayMode); + RvTestResultDlg(rv, "SetAllowPipelining() test"); FormatAndPrintOutput("SetAllowPipelining value = ", mAllowPipelining, displayMode); rv = theHttpChannel->GetAllowPipelining(&mAllowPipelining); @@ -247,6 +266,7 @@ void CnsIHttpChannelTests::GetAllowPipeliningTest(nsIHttpChannel *theHttpChanne rv = theHttpChannel->GetAllowPipelining(&mAllowPipelining); RvTestResult(rv, "GetAllowPipelining()", displayMode); + RvTestResultDlg(rv, "GetAllowPipelining() test"); FormatAndPrintOutput("GetAllowPipelining value = ", mAllowPipelining, displayMode); } @@ -256,6 +276,7 @@ void CnsIHttpChannelTests::SetRedirectionLimitTest(nsIHttpChannel *theHttpChann { rv = theHttpChannel->SetRedirectionLimit(mRedirectionLimit); RvTestResult(rv, "SetRedirectionLimit()", displayMode); + RvTestResultDlg(rv, "SetRedirectionLimit() test"); } void CnsIHttpChannelTests::GetRedirectionLimitTest(nsIHttpChannel *theHttpChannel, @@ -265,6 +286,7 @@ void CnsIHttpChannelTests::GetRedirectionLimitTest(nsIHttpChannel *theHttpChann rv = theHttpChannel->GetRedirectionLimit(&mRedirectionLimit); RvTestResult(rv, "GetRedirectionLimit()", displayMode); + RvTestResultDlg(rv, "GetRedirectionLimit() test"); FormatAndPrintOutput("GetRedirectionLimit value = ", mRedirectionLimit, displayMode); } @@ -277,9 +299,10 @@ void CnsIHttpChannelTests::CallResponseTests(nsIHttpChannel *theHttpChannel, GetResponseStatusTest(theHttpChannel, displayMode); GetResponseStatusTextTest(theHttpChannel, displayMode); GetRequestSucceededTest(theHttpChannel, displayMode); - SetResponseHeaderTest(theHttpChannel, "Refresh", "", PR_TRUE, displayMode); + GetResponseHeaderTest(theHttpChannel, "Set-Cookie", displayMode); + SetResponseHeaderTest(theHttpChannel, "Refresh", "1001", PR_TRUE, displayMode); GetResponseHeaderTest(theHttpChannel, "Refresh", displayMode); - SetResponseHeaderTest(theHttpChannel, "Set-Cookie", "", PR_FALSE, displayMode); + SetResponseHeaderTest(theHttpChannel, "Set-Cookie", "MyCookie", PR_TRUE, displayMode); GetResponseHeaderTest(theHttpChannel, "Set-Cookie", displayMode); SetResponseHeaderTest(theHttpChannel, "Cache-control", "no-cache", PR_FALSE, displayMode); GetResponseHeaderTest(theHttpChannel, "Cache-control", displayMode); @@ -324,7 +347,7 @@ void CnsIHttpChannelTests::GetResponseHeaderTest(nsIHttpChannel *theHttpChannel, { nsCAutoString mResponse; - rv = theHttpChannel->GetResponseHeader(NS_LITERAL_CSTRING(responseType), mResponse); + rv = theHttpChannel->GetResponseHeader(nsDependentCString(responseType), mResponse); RvTestResult(rv, "GetResponseHeader()", displayMode); FormatAndPrintOutput("GetResponseHeader = ", mResponse, displayMode); FormatAndPrintOutput("GetResponseHeader response type = ", responseType, displayMode); @@ -335,8 +358,8 @@ void CnsIHttpChannelTests::SetResponseHeaderTest(nsIHttpChannel *theHttpChannel, const char * value, PRBool merge, PRInt16 displayMode) { // Refresh - rv = theHttpChannel->SetResponseHeader(NS_LITERAL_CSTRING(responseType), - NS_LITERAL_CSTRING(value), merge); + rv = theHttpChannel->SetResponseHeader(nsDependentCString(responseType), + nsDependentCString(value), merge); RvTestResult(rv, "SetResponseHeader()", displayMode); FormatAndPrintOutput("SetResponseHeader value = ", value, displayMode); FormatAndPrintOutput("SetResponseHeader response type = ", responseType, displayMode); diff --git a/mozilla/embedding/qa/testembed/nsihttpchanneltests.h b/mozilla/embedding/qa/testembed/nsihttpchanneltests.h index ff5b2ff1588..722a4c90cc5 100644 --- a/mozilla/embedding/qa/testembed/nsihttpchanneltests.h +++ b/mozilla/embedding/qa/testembed/nsihttpchanneltests.h @@ -23,12 +23,12 @@ public: nsIHttpChannel * GetHttpChannelObject(nsCAutoString); void OnStartTests(UINT nMenuID); void RunAllTests(); - void SetRequestMethodTest(nsIHttpChannel *, PRInt16); + void SetRequestMethodTest(nsIHttpChannel *, const char *, PRInt16); void GetRequestMethodTest(nsIHttpChannel *, PRInt16); - void SetReferrerTest(nsIHttpChannel *, PRInt16); + void SetReferrerTest(nsIHttpChannel *, const char *, PRInt16); void GetReferrerTest(nsIHttpChannel *, PRInt16); - void SetRequestHeaderTest(nsIHttpChannel *, PRInt16); - void GetRequestHeaderTest(nsIHttpChannel *, PRInt16); + void SetRequestHeaderTest(nsIHttpChannel *, const char *, const char *, PRInt16); + void GetRequestHeaderTest(nsIHttpChannel *, const char *, PRInt16); void VisitRequestHeadersTest(nsIHttpChannel *, PRInt16); void SetAllowPipeliningTest(nsIHttpChannel *, PRBool, PRInt16); void GetAllowPipeliningTest(nsIHttpChannel *, PRInt16); diff --git a/mozilla/embedding/qa/testembed/testembed.aps b/mozilla/embedding/qa/testembed/testembed.aps index 924f893a00330692e0592a34c6e92ea0233bd2ea..037297ebceabb6d99601cd8d60d92288f7b4a733 100644 GIT binary patch literal 2746 zcmc&#Jx?P?7#=tm4j^NtNIeHBI95_y?os=X=HX$z*6lP>e%CyDZ5l?iwZHpYeb+L( zmQ;+m}wZcyi#&1^2o5f1?*Rdosi_JaySk*C>L@R0e8q@VB^z@XD z8>?%TQmweL{Y1pUKx?noH@;q((bqOg+iRsFeenf-KC^h-sqY`vX`^kJwd4A}x%7PH z+ZDu^Ed%AAJxiiStBIw&v%4z`6mGQDZhiT4v(agH+j|!MrP)2HAJW3pr_?l>mTAy* zJG*FSVq-cDq(}gnwyb)~sCNwXbadQqnJo)3vK{Q-H8z@JgW~wn?MWTq^(EMZeHA!G zk^`&`2Q-u55`rIbT}AK(OZxpjs4$2tBS@?WzUmeU`XLySta5Ql56lpGq(bEFNl_|z zBoz^~fGm%qYr!Nk$z3ZpN;K!Lu)-cGkJK*_g_l%~Xg0~GJR)*_mBja4m4}Pgq6kew zk&C$ORftj{dmhRWpy0_&!%*2HHPbK*g~AoJ;UPpQ&Q&j2C5B7okW+^!>lW5}q-N4%9uk|N4o0kOvB%^d7k2-w!VC04zB3 zlHd#Wzug0QJLL5sxhq2OlZd@hd=3;Cy&Fh;7srEnV1Is)BlCl~uuou}!*LN_VE`I| z;ygrx&|_w%LAe_3)$eo62yNxYSq2)rbVRk`PATocOKH(5bAw`7>& zIhVzJjbAt#zJS!vFPCiFvC)g~aN916gdX=qe=^q1O2VxnPKv`|W+jg??FJFHEPo*# zW|RKPkUYz=9M7?=A?H1`ap}VuO5vFJc`$L$i#-P@{cbqd&ft>FJIWWwH(n3egu-$Q zaxrXv>iCyu2htC&%Bm?cCU}l-U2qE;R88}Zd!;;@ligui-lqMfwsGqH{`a4TRN!Q1 P$1M~5ei+JCzE%GVv9zI` literal 718 zcmZ9J$xg#C6h$u*^E?kbkXWOnO`)(sPUDt{48?KOf+|_1M1a&Xw6I~xm+(3KRk7oi z5F$P0`P?htXBzj{N>2s5#249~OsGPNW&mWK7Zd(lc zopIkvdbi2l-Q&}J>$Tl_O9pQ#$hxC`2Y7k?pYfe;Z6M1yNXY^E$>90D-${-hAO~?B zM-V%Vxg9oP8V05mW5OqHP-VoYFbic&k6?I1eVbp`6+Oj_rWM}wX%Gu1ti-b6FpCCe z^P1-dmy(;9%X3bf%3r{Ip1VG&$&g|Z3rcWAorQj#3&$m1Sd)T<#hg$lQPc>TlQ~LQ z$~oeQGUdt~$5{S#R9%loa^DlI