Esempio n. 1
0
void CTests::OnTestsNSNewChannelAndAsyncOpen()
{
	nsCOMPtr<nsIChannel> theChannel;
	nsCOMPtr<nsILoadGroup> theLoadGroup(do_CreateInstance(NS_LOADGROUP_CONTRACTID));

	if (myDialog.DoModal() == IDOK)
	{
		nsCAutoString theStr;

		theStr = myDialog.m_urlfield;

		rv = NS_NewURI(getter_AddRefs(theURI), theStr);
		RvTestResult(rv, "NS_NewURI() test", 2);
		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);

		// this calls nsIStreamListener::OnDataAvailable()
		CnsIChannelTests  *channelTests = new CnsIChannelTests(qaWebBrowser, qaBrowserImpl);
		channelTests->AsyncOpenTest(theChannel, 2);;
	}
}
void CNsIRequest::RunIndividualTests(UINT nMenuID, int reqTotal)
{
	nsCOMPtr<nsIChannel> theChannel;
	nsCOMPtr<nsILoadGroup> theLoadGroup(do_CreateInstance(NS_LOADGROUP_CONTRACTID));
	nsCOMPtr<nsIURI> theURI;
	if (!theLoadGroup)
	{
		QAOutput("We didn't get the Load Group. Test failed.", 2);
		return;
	}
	int i=0;

    QAOutput("Start selected nsIRequest test.", 2);	

	for (i=0; i<reqTotal; i++)
	{
		// nsIRequest individual tests

		QAOutput("********** Individual nsIRequest test begins. **********");

		theChannel = GetTheChannel(i, theLoadGroup);
		nsCOMPtr<nsIRequest> theRequest = do_QueryInterface(theChannel);

		switch(nMenuID)
		{
			
		case ID_INTERFACES_NSIREQUEST_GETNAME :
			break;
		case ID_INTERFACES_NSIREQUEST_ISPENDING :
			IsPendingReqTest(theRequest);
			break;
		case ID_INTERFACES_NSIREQUEST_GETSTATUS :
			GetStatusReqTest(theRequest);
			break;
		case ID_INTERFACES_NSIREQUEST_CANCEL :
			CancelReqTest(theRequest);	
			break;
		case ID_INTERFACES_NSIREQUEST_SUSPEND :
			SuspendReqTest(theRequest);	
			break;
		case ID_INTERFACES_NSIREQUEST_RESUME :
			ResumeReqTest(theRequest);	
			break;
		case ID_INTERFACES_NSIREQUEST_GETLOADGROUP :
			GetLoadGroupTest(theRequest);
			break;
		case ID_INTERFACES_NSIREQUEST_SETLOADGROUP :
			SetLoadGroupTest(theRequest, theLoadGroup);	
			break;
		case ID_INTERFACES_NSIREQUEST_GETLOADFLAGS :
			break;
		case ID_INTERFACES_NSIREQUEST_SETLOADFLAGS :
			break;
		}

	} // end for loop
}
void CNsIRequest::RunAllTests(int reqTotal) 
{
	// note: nsIRequest tests are called:
	// 1) in BrowserImpl.cpp, nsIStreamListener::OnDataAvailable()
	// 2) as individual tests below

	nsCOMPtr<nsIChannel> theChannel;
	nsCOMPtr<nsILoadGroup> theLoadGroup(do_CreateInstance(NS_LOADGROUP_CONTRACTID));
	if (!theLoadGroup)
	{
		QAOutput("We didn't get the Load Group. Test failed.", 2);
		return;
	}

	int i=0;

    QAOutput("Start nsIRequest tests.", 1);	

	for (i=0; i<reqTotal; i++)
	{
		// nsIRequest individual tests

		QAOutput("********** Individual nsIRequest test begins. **********");

		theChannel = GetTheChannel(i, theLoadGroup);
		nsCOMPtr<nsIRequest> theRequest = do_QueryInterface(theChannel);

		if (ReqTable[i].reqPend == TRUE)
			IsPendingReqTest(theRequest);

		if (ReqTable[i].reqStatus == TRUE)
			GetStatusReqTest(theRequest);

		if (ReqTable[i].reqSuspend == TRUE)
			SuspendReqTest(theRequest);	

		if (ReqTable[i].reqResume == TRUE)
			ResumeReqTest(theRequest);	

		if (ReqTable[i].reqCancel == TRUE)
			CancelReqTest(theRequest);	

		if (ReqTable[i].reqSetLoadGroup == TRUE)
			SetLoadGroupTest(theRequest, theLoadGroup);	

		if (ReqTable[i].reqGetLoadGroup == TRUE)
			GetLoadGroupTest(theRequest);

		QAOutput("- - - - - - - - - - - - - - - - - - - - -", 1);
	} // end for loop
    QAOutput("End nsIRequest tests.", 1);
}