Better error checking for NS objects. not part of the build.

This commit is contained in:
depstein%netscape.com 2002-10-04 07:26:37 +00:00
Родитель 0703286f2b
Коммит 98532636b4
3 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -309,12 +309,16 @@ nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *webBrowser)
return (theDOMWindow);
}
nsCAutoString GetTheUri(nsIURI *theUri, int displayMethod)
nsCAutoString GetTheUri(nsIURI *theURI, int displayMethod)
{
nsresult rv;
nsCAutoString uriString;
rv = theUri->GetSpec(uriString);
if (!theURI) {
QAOutput("nsIURI object is null. return failure.");
return nsnull;
}
rv = theURI->GetSpec(uriString);
RvTestResult(rv, "nsIURI::GetSpec() test", displayMethod);
FormatAndPrintOutput("the uri = ", uriString, displayMethod);

Просмотреть файл

@ -541,6 +541,7 @@ void CTests::OnTestsAddUriContentListenerByOpenUri()
theStr = myDialog.m_urlfield;
rv = NS_NewURI(getter_AddRefs(theURI), theStr);
RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 1);
FormatAndPrintOutput("theStr = ", theStr, 1);
GetTheUri(theURI, 1);
rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
RvTestResult(rv, "For OpenURI(): NS_NewChannel() test", 1);
@ -573,11 +574,18 @@ void CTests::OnTestsNSNewChannelAndAsyncOpen()
rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
RvTestResult(rv, "NS_NewChannel() test", 2);
if (!theChannel)
{
QAOutput("We didn't get the Channel for AsyncOpen(). Test failed.", 1);
return;
}
QAOutput("AynchOpen() test.", 2);
nsCOMPtr<nsIStreamListener> listener(NS_STATIC_CAST(nsIStreamListener*, qaBrowserImpl));
nsCOMPtr<nsIWeakReference> thisListener(dont_AddRef(NS_GetWeakReference(listener)));
qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener));
if (!listener)
QAOutput("listener object is null for AsyncOpen().", 1);
// this calls nsIStreamListener::OnDataAvailable()
rv = theChannel->AsyncOpen(listener, nsnull);
RvTestResult(rv, "AsyncOpen()", 2);
@ -720,6 +728,11 @@ void CTests::OnToolsRemoveAllGH()
void CTests::OnToolsTestYourMethod()
{
// place your test code here
if (myDialog.DoModal() == IDOK)
{
rv = qaWebNav->GetCurrentURI(getter_AddRefs(theURI));
GetTheUri(theURI, 1);
}
}
// ***********************************************************************

Просмотреть файл

@ -229,7 +229,7 @@ nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
if (!theURI)
{
QAOutput("We didn't get the URI. Test failed.", 1);
return NULL;
return nsnull;
}
else {
retURI = GetTheUri(theURI, 1);
@ -246,7 +246,7 @@ nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
if (!theChannel)
{
QAOutput("We didn't get the Channel. Test failed.", 1);
return NULL;
return nsnull;
}
else {
RvTestResult(rv, "NS_NewChannel", 1);
@ -257,6 +257,10 @@ nsIChannel * CNsIRequest::GetTheChannel(int i, nsILoadGroup *theLoadGroup)
nsCOMPtr<nsIWeakReference> thisListener(dont_AddRef(NS_GetWeakReference(listener)));
qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener));
if (!listener) {
QAOutput("We didn't get the listener for AsyncOpen(). Test failed.", 1);
return nsnull;
}
// this calls nsIStreamListener::OnDataAvailable()
rv = theChannel->AsyncOpen(listener, nsnull);
RvTestResult(rv, "AsyncOpen()", 1);