зеркало из https://github.com/mozilla/pjs.git
Cleaned up nsIChannel tests and running AsyncOpen() from the Tests menu. Added additional nsIProtocolHandler tests to Tests > nsIProtocolHandler->NewURI() for tracking some values. Will spin off into separate Test Interface in the future.
This commit is contained in:
Родитель
81b340cc56
Коммит
0ed0e66552
|
@ -535,18 +535,20 @@ NS_IMETHODIMP CBrowserImpl::OnStartRequest(nsIRequest *request,
|
|||
nsCString stringMsg;
|
||||
|
||||
QAOutput("\n");
|
||||
QAOutput("##### BEGIN: nsIRequestObserver::OnStartRequest() #####");
|
||||
QAOutput("##### BEGIN: nsIRequestObserver::OnStartRequest() #####");
|
||||
|
||||
if (!ctxt)
|
||||
QAOutput("We did NOT get the context object.\n");
|
||||
|
||||
RequestName(request, stringMsg, 1);
|
||||
|
||||
// these are for nsIChannel tests found in nsichanneltests.cpp (post AsyncOpen() tests)
|
||||
// they will only be run if a nsISupports context was passed to AsyncOpen()
|
||||
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
|
||||
CBrowserImpl *aBrowserImpl = new CBrowserImpl();
|
||||
CnsIChannelTests *channelTests = new CnsIChannelTests(mWebBrowser, aBrowserImpl);
|
||||
CnsIHttpChannelTests *httpChannelTests = new CnsIHttpChannelTests(mWebBrowser, aBrowserImpl);
|
||||
if (channelTests && ctxt && channel) {
|
||||
if (channelTests && channel) {
|
||||
QAOutput("\n Start nsIChannel PostAsyncOpenTests tests:");
|
||||
channelTests->PostAsyncOpenTests(channel, 1);
|
||||
}
|
||||
|
|
|
@ -623,16 +623,10 @@ void CTests::OnTestsNSNewChannelAndAsyncOpen()
|
|||
}
|
||||
|
||||
QAOutput("AynchOpen() test:", 2);
|
||||
nsCOMPtr<nsIStreamListener> listener(NS_STATIC_CAST(nsIStreamListener*, qaBrowserImpl));
|
||||
nsCOMPtr<nsIWeakReference> thisListener(do_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);
|
||||
// this calls nsIStreamListener::OnDataAvailable()
|
||||
CnsIChannelTests *channelTests = new CnsIChannelTests(qaWebBrowser, qaBrowserImpl);
|
||||
channelTests->AsyncOpenTest(theChannel, 2);;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,7 +673,8 @@ void CTests::OnTestsProtocolHandlerNewURI()
|
|||
{
|
||||
nsCAutoString theStr, retStr;
|
||||
nsCOMPtr<nsIURI> theOriginalURI;
|
||||
nsIURI *theReturnURI = nsnull;
|
||||
nsIURI *theReturnURI = nsnull;
|
||||
nsIChannel *theReturnChannel = nsnull;
|
||||
const char *theProtocol;
|
||||
|
||||
nsCOMPtr<nsIProtocolHandler> protocolHandler;
|
||||
|
@ -708,7 +703,42 @@ void CTests::OnTestsProtocolHandlerNewURI()
|
|||
if (strcmp(myDialog.m_urlfield, retStr.get()) == 0)
|
||||
QAOutput("The in/out URIs MATCH.", 1);
|
||||
else
|
||||
QAOutput("The in/out URIs don't MATCH.", 1);
|
||||
QAOutput("The in/out URIs don't MATCH.", 1);
|
||||
|
||||
// other protocol handler tests:
|
||||
|
||||
// GetScheme() test
|
||||
nsCAutoString theScheme;
|
||||
rv = protocolHandler->GetScheme(theScheme);
|
||||
RvTestResult(rv, "protocolHandler->GetScheme() test", 1);
|
||||
FormatAndPrintOutput("GetScheme() = ", theScheme, 1);
|
||||
|
||||
// GetDefaultPort() test
|
||||
PRInt32 theDefaultPort;
|
||||
rv = protocolHandler->GetDefaultPort(&theDefaultPort);
|
||||
RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
|
||||
FormatAndPrintOutput("GetDefaultPort() = ", theDefaultPort, 1);
|
||||
|
||||
// GetProtocolFlags() test
|
||||
PRUint32 theProtocolFlags;
|
||||
rv = protocolHandler->GetProtocolFlags(&theProtocolFlags);
|
||||
RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
|
||||
FormatAndPrintOutput("GetProtocolFlags() = ", theProtocolFlags, 1);
|
||||
|
||||
// NewChannel() test
|
||||
rv = protocolHandler->NewChannel(theReturnURI, &theReturnChannel);
|
||||
RvTestResult(rv, "protocolHandler->NewChannel() test", 1);
|
||||
if (!theReturnChannel)
|
||||
QAOutput("We didn't get the returned nsIChannel object.", 1);
|
||||
|
||||
|
||||
// AllowPort() test
|
||||
PRBool retPort;
|
||||
rv = protocolHandler->AllowPort(theDefaultPort, "http", &retPort);
|
||||
RvTestResult(rv, "protocolHandler->AllowPort() test", 1);
|
||||
FormatAndPrintOutput("AllowPort() boolean = ", retPort, 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -369,6 +369,12 @@ void CnsIChannelTests::AsyncOpenTest(nsIChannel *theChannel, PRInt16 displayMode
|
|||
theSupports = do_QueryInterface(theChannel);
|
||||
if (!theSupports)
|
||||
QAOutput("Didn't get the nsISupports object. AsyncOpen() failed.", displayMode);
|
||||
|
||||
if (theSupports == theChannel)
|
||||
QAOutput("Supports = Channel.", displayMode);
|
||||
else
|
||||
QAOutput("Supports != Channel.", displayMode);
|
||||
|
||||
|
||||
rv = theChannel->AsyncOpen(listener, theSupports);
|
||||
RvTestResult(rv, "AsyncOpen()", displayMode);
|
||||
|
@ -489,8 +495,7 @@ void CnsIChannelTests::RunAllTests()
|
|||
SetNotificationsTest(theChannel, 1);
|
||||
GetNotificationsTest(theChannel, 1);
|
||||
AsyncOpenTest(theChannel, 1);
|
||||
// PostAsyncOpenTests() called from nsIRequestObservor::OnStartRequest (in BrowserImpl.cpp)
|
||||
OpenTest(theChannel, 1);
|
||||
// PostAsyncOpenTests() called from nsIRequestObserver::OnStartRequest (in BrowserImpl.cpp)
|
||||
QAOutput("\n");
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче