From db136cbcaf9e5d83f887d884efad58252ac79024 Mon Sep 17 00:00:00 2001 From: "depstein%netscape.com" Date: Sat, 16 Mar 2002 02:31:53 +0000 Subject: [PATCH] a=asa for QA checkins that are not part of the default builds. Removed getAdders for GetSpec() and GetPath(). use nsAutoString. git-svn-id: svn://10.0.0.236/trunk@116681 18797224-902f-48f8-a5cc-f745e15eee43 --- .../qa/testembed/BrowserFrameGlue.cpp | 2 +- .../qa/testembed/BrowserImplWebPrgrsLstnr.cpp | 6 ++-- .../embedding/qa/testembed/BrowserView.cpp | 15 +++++---- mozilla/embedding/qa/testembed/QaUtils.cpp | 31 +++++++++++++++++-- mozilla/embedding/qa/testembed/QaUtils.h | 1 + mozilla/embedding/qa/testembed/Tests.cpp | 6 ++-- mozilla/embedding/qa/testembed/nsIWebNav.cpp | 6 ++-- mozilla/embedding/qa/testembed/nsiHistory.cpp | 16 +++++----- mozilla/embedding/qa/testembed/nsirequest.cpp | 5 +-- 9 files changed, 58 insertions(+), 30 deletions(-) diff --git a/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp b/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp index 2ffdd849f07..0baf67e991a 100644 --- a/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp +++ b/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp @@ -112,7 +112,7 @@ void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation) if(aLocation) { nsXPIDLCString uriString; - aLocation->GetSpec(getter_Copies(uriString)); + aLocation->GetSpec(uriString); pThis->m_wndUrlBar.SetCurrentURL(uriString.get()); } diff --git a/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp b/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp index d1da9300a28..a1d93a48eff 100644 --- a/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp +++ b/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp @@ -253,14 +253,14 @@ NS_IMETHODIMP CBrowserImpl::OnLocationChange(nsIWebProgress* aWebProgress, QAOutput("Entering nsIWebProgLstnr::OnLocationChange()."); nsresult rv; - char *uriSpec; - rv = location->GetSpec(&uriSpec); + nsCAutoString uriString; + rv = location->GetSpec(uriString); if (NS_FAILED(rv)) QAOutput("Bad result for GetSpec()."); else QAOutput("Good result for GetSpec()."); - FormatAndPrintOutput("OnLocationChange(): The location url = ", uriSpec, 1); + FormatAndPrintOutput("OnLocationChange(): The location url = ", uriString, 1); // RequestName(aRequest, stringMsg); // because of crash bug bugzilla 86521 diff --git a/mozilla/embedding/qa/testembed/BrowserView.cpp b/mozilla/embedding/qa/testembed/BrowserView.cpp index 93632b36364..32a386e3035 100644 --- a/mozilla/embedding/qa/testembed/BrowserView.cpp +++ b/mozilla/embedding/qa/testembed/BrowserView.cpp @@ -412,7 +412,7 @@ void CBrowserView::OnViewSource() // Get the uri string associated with the nsIURI object nsXPIDLCString uriString; - rv = currentURI->GetSpec(getter_Copies(uriString)); + rv = currentURI->GetSpec(uriString); if(NS_FAILED(rv)) return; @@ -813,11 +813,10 @@ void CBrowserView::OnSaveLinkAs() // Get the "path" portion (see nsIURI.h for more info // on various parts of a URI) - nsXPIDLCString path; - linkURI->GetPath(getter_Copies(path)); + nsCAutoString fileName; + linkURI->GetPath(fileName); // The path may have the "/" char in it - strip those - nsCAutoString fileName(path); fileName.StripChars("\\/"); // Now, use this file name in a File Save As dlg... @@ -859,8 +858,8 @@ void CBrowserView::OnSaveImageAs() // Get the "path" portion (see nsIURI.h for more info // on various parts of a URI) - nsXPIDLCString path; - linkURI->GetPath(getter_Copies(path)); + nsCAutoString path; + linkURI->GetPath(path); // The path may have the "/" char in it - strip those nsCAutoString fileName(path); @@ -991,8 +990,8 @@ void CBrowserView::OnFilePrint() nsresult rv = mWebNav->GetCurrentURI(getter_AddRefs(currentURI)); if(NS_SUCCEEDED(rv) || currentURI) { - nsXPIDLCString path; - currentURI->GetPath(getter_Copies(path)); + nsCAutoString path; + currentURI->GetPath(path); dlg.SetURI(path.get()); } m_bCurrentlyPrinting = TRUE; diff --git a/mozilla/embedding/qa/testembed/QaUtils.cpp b/mozilla/embedding/qa/testembed/QaUtils.cpp index a25af3176c2..626a0ee500d 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.cpp +++ b/mozilla/embedding/qa/testembed/QaUtils.cpp @@ -161,6 +161,31 @@ void FormatAndPrintOutput(const char *theInput, const char *theVar, int outputMo } } +void FormatAndPrintOutput(const char *theInput, nsCAutoString theVar, int outputMode) +{ + nsCString outStr; + CString strMsg; + + outStr = theInput; + outStr += theVar; + + strMsg = outStr.get(); + + switch (outputMode) + { + case 0: + AfxMessageBox(strMsg); + break; + case 1: + WriteToOutputFile(outStr.get()); + break; + case 2: + WriteToOutputFile(outStr.get()); + AfxMessageBox(strMsg); + break; + } +} + void FormatAndPrintOutput(const char *theInput, int theVar, int outputMode) { nsCString outStr; @@ -227,11 +252,11 @@ void WebProgDOMWindowTest(nsIWebProgress *progress, const char *inString, void GetTheUri(nsIURI *theUri, int displayMethod) { nsresult rv; - char *uriSpec; + nsCAutoString uriString; - rv = theUri->GetSpec(&uriSpec); + rv = theUri->GetSpec(uriString); RvTestResult(rv, "nsIURI::GetSpec() test", displayMethod); - FormatAndPrintOutput("the uri = ", uriSpec, displayMethod); + FormatAndPrintOutput("the uri = ", uriString, displayMethod); } // used for web progress listener in BrowserImplWebPrgrsLstnr.cpp diff --git a/mozilla/embedding/qa/testembed/QaUtils.h b/mozilla/embedding/qa/testembed/QaUtils.h index 9ca86b43dd1..64a6a3d2f8a 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.h +++ b/mozilla/embedding/qa/testembed/QaUtils.h @@ -57,6 +57,7 @@ extern void RvTestResult(nsresult, const char *, int displayMethod=1); extern void WriteToOutputFile(const char *); extern void QAOutput(const char *pLine, int displayMethod=1); extern void FormatAndPrintOutput(const char *, const char *, int); +extern void FormatAndPrintOutput(const char *, nsCAutoString, int); extern void FormatAndPrintOutput(const char *, int, int); extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1); extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1); diff --git a/mozilla/embedding/qa/testembed/Tests.cpp b/mozilla/embedding/qa/testembed/Tests.cpp index 910a558f44d..36665d97fd9 100644 --- a/mozilla/embedding/qa/testembed/Tests.cpp +++ b/mozilla/embedding/qa/testembed/Tests.cpp @@ -237,7 +237,7 @@ void CTests::OnTestsChangeUrl() FormatAndPrintOutput("The url = ", theUrl, 2); /* - char *uriSpec; + nsCAutoString uriString; nsCOMPtr pURI; // GetcurrentURI() declared in nsIP3PUI.idl // used with webNav obj in nsP3PObserverHTML.cpp, line 239 @@ -246,12 +246,12 @@ void CTests::OnTestsChangeUrl() if(NS_FAILED(rv) || !pURI) AfxMessageBox("Bad result for GetCurrentURI()."); - rv = pURI->GetSpec(&uriSpec); + rv = pURI->GetSpec(uriString); if (NS_FAILED(rv)) AfxMessageBox("Bad result for GetSpec()."); AfxMessageBox("Start URL validation test()."); - if (strcmp(uriSpec, theUrl) == 0) + if (strcmp(uriString, theUrl) == 0) { QAOutput("Url loaded successfully. Test Passed.", 2); } diff --git a/mozilla/embedding/qa/testembed/nsIWebNav.cpp b/mozilla/embedding/qa/testembed/nsIWebNav.cpp index 86ef4f23955..22e37a478ef 100644 --- a/mozilla/embedding/qa/testembed/nsIWebNav.cpp +++ b/mozilla/embedding/qa/testembed/nsIWebNav.cpp @@ -415,11 +415,11 @@ void CNsIWebNav::GetCurrentURITest() else RvTestResult(rv, "GetCurrentURI() test", 2); - char *uriSpec; - rv = theUri->GetSpec(&uriSpec); + nsCAutoString uriString; + rv = theUri->GetSpec(uriString); RvTestResult(rv, "nsIURI::GetSpec() for nsIWebNav test", 1); - FormatAndPrintOutput("the nsIWebNav uri = ", uriSpec, 2); + FormatAndPrintOutput("the nsIWebNav uri = ", uriString, 2); } void CNsIWebNav::GetSHTest() diff --git a/mozilla/embedding/qa/testembed/nsiHistory.cpp b/mozilla/embedding/qa/testembed/nsiHistory.cpp index 7f9a25336a1..4b410994491 100644 --- a/mozilla/embedding/qa/testembed/nsiHistory.cpp +++ b/mozilla/embedding/qa/testembed/nsiHistory.cpp @@ -361,11 +361,12 @@ void CNsIHistory::GetURIHistTest(nsIHistoryEntry* theHistoryEntry) else { RvTestResult(rv, "GetURI() (URI attribute) test", 1); - rv = theUri->GetSpec(&uriSpec); + nsCAutoString uriString; + rv = theUri->GetSpec(uriString); if (NS_FAILED(rv)) - QAOutput("We didn't get the uriSpec.", 1); + QAOutput("We didn't get the uriString.", 1); else - FormatAndPrintOutput("The SH Url = ", uriSpec, 2); + FormatAndPrintOutput("The SH Url = ", uriString, 2); } } @@ -423,11 +424,12 @@ void CNsIHistory::SimpleEnumTest(nsISimpleEnumerator *theSimpleEnum) if (!nextHistoryEntry) continue; rv = nextHistoryEntry->GetURI(getter_AddRefs(theUri)); - rv = theUri->GetSpec(&uriSpec); - if (!uriSpec) - QAOutput("uriSpec for GetSpec() invalid. Test failed.", 1); + nsCAutoString uriString; + rv = theUri->GetSpec(uriString); + if (NS_FAILED(rv)) + QAOutput("uriString for GetSpec() invalid. Test failed.", 1); else - FormatAndPrintOutput("The SimpleEnum URL = ", uriSpec, 2); + FormatAndPrintOutput("The SimpleEnum URL = ", uriString, 2); } } diff --git a/mozilla/embedding/qa/testembed/nsirequest.cpp b/mozilla/embedding/qa/testembed/nsirequest.cpp index 1563d8a3a43..d47bdbcbe7f 100644 --- a/mozilla/embedding/qa/testembed/nsirequest.cpp +++ b/mozilla/embedding/qa/testembed/nsirequest.cpp @@ -115,6 +115,7 @@ void CNsIRequest::RunIndividualTests(UINT nMenuID) FormatAndPrintOutput("the uri spec = ", theSpec.get(), 2); rv = NS_NewURI(getter_AddRefs(theURI), theSpec.get()); + if (!theURI) { QAOutput("We didn't get the URI. Test failed.", 1); @@ -123,7 +124,7 @@ void CNsIRequest::RunIndividualTests(UINT nMenuID) else RvTestResult(rv, "NS_NewURI", 1); - rv = NS_OpenURI(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); + rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); if (!theChannel) { QAOutput("We didn't get the Channel. Test failed.", 1); @@ -218,7 +219,7 @@ void CNsIRequest::RunAllTests() else RvTestResult(rv, "NS_NewURI", 1); - rv = NS_OpenURI(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); + rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); if (!theChannel) { QAOutput("We didn't get the Channel. Test failed.", 1);