diff --git a/mozilla/embedding/qa/testembed/BrowserImpl.cpp b/mozilla/embedding/qa/testembed/BrowserImpl.cpp index 626f078bb41..9d53b2fe898 100644 --- a/mozilla/embedding/qa/testembed/BrowserImpl.cpp +++ b/mozilla/embedding/qa/testembed/BrowserImpl.cpp @@ -398,12 +398,11 @@ NS_IMETHODIMP CBrowserImpl::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *input, PRUint32 offset, PRUint32 count) { - CQaUtils::QAOutput("Inside OnDataAvailable()."); + CQaUtils::QAOutput("***** nsIRequest async tests inside nsIStreamListener::OnDataAvailable(). *****"); CTests::IsPendingReqTest(request); CTests::GetStatusReqTest(request); CTests::SuspendReqTest(request); - CQaUtils::QAOutput("nsIRequest: Between Suspend and Resume."); CTests::ResumeReqTest(request); // CTests::CancelReqTest(request); diff --git a/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp b/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp index 5994c0dfb45..3754579b83e 100644 --- a/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp +++ b/mozilla/embedding/qa/testembed/BrowserImplWebPrgrsLstnr.cpp @@ -154,6 +154,7 @@ NS_IMETHODIMP CBrowserImpl::OnStateChange(nsIWebProgress *progress, nsIRequest * strcpy(theStateType, "STATE_START"); // a few nsIRequest tests + CQaUtils::QAOutput("Some nsIRequest tests thru web prog lstnr: "); CTests::IsPendingReqTest(request); CTests::GetStatusReqTest(request); @@ -285,10 +286,10 @@ CBrowserImpl::OnStatusChange(nsIWebProgress* aWebProgress, CQaUtils::RequestName(aRequest, stringMsg); // status result test - CQaUtils::RvTestResult(aStatus, "OnStatusChange(): status result test", 2); + CQaUtils::FormatAndPrintOutput("OnStatusChange(): Status = ", aStatus, 1); // web progress DOMWindow test - CQaUtils::WebProgDOMWindowTest(aWebProgress, "OnStatusChange()", 1); + CQaUtils::WebProgDOMWindowTest(aWebProgress, "OnStatusChange(): web prog DOM window test", 1); m_pBrowserFrameGlue->UpdateStatusBarText(aMessage); diff --git a/mozilla/embedding/qa/testembed/QaUtils.cpp b/mozilla/embedding/qa/testembed/QaUtils.cpp index e0b34c7b2bd..5d8e98eca52 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.cpp +++ b/mozilla/embedding/qa/testembed/QaUtils.cpp @@ -56,7 +56,7 @@ CQaUtils::~CQaUtils() } // *********************************************************************** -// ***************** Local QA Methods ****************** +// ********************* Local QA Methods ********************* // *********************************************************************** @@ -65,7 +65,7 @@ void CQaUtils::RvTestResult(nsresult rv, const char *pLine, int displayMethod) // note: default displayMethod = 1 in .h file CString strLine = pLine; - char theOutputLine[100]; + char theOutputLine[200]; if (NS_FAILED(rv)) strLine += " failed."; diff --git a/mozilla/embedding/qa/testembed/QaUtils.h b/mozilla/embedding/qa/testembed/QaUtils.h index 268d339d250..d44ad08930b 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.h +++ b/mozilla/embedding/qa/testembed/QaUtils.h @@ -53,6 +53,8 @@ public: void static WebProgDOMWindowTest(nsIWebProgress *, const char *, int displayMethod=1); + nsresult rv; + // Some helper methods // Generated message map functions diff --git a/mozilla/embedding/qa/testembed/StdAfx.h b/mozilla/embedding/qa/testembed/StdAfx.h index 238aa859f3b..c54d6e428f2 100644 --- a/mozilla/embedding/qa/testembed/StdAfx.h +++ b/mozilla/embedding/qa/testembed/StdAfx.h @@ -99,7 +99,7 @@ #include "nsIDOMDocument.h" #include "nsIDOMDocumentType.h" #include "nsIURIContentListener.h" - +#include "nsIHelperAppLauncherDialog.h" //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/mozilla/embedding/qa/testembed/Tests.cpp b/mozilla/embedding/qa/testembed/Tests.cpp index 4c17f79b701..d2ad828742a 100644 --- a/mozilla/embedding/qa/testembed/Tests.cpp +++ b/mozilla/embedding/qa/testembed/Tests.cpp @@ -64,6 +64,7 @@ BEGIN_MESSAGE_MAP(CTests, CWnd) ON_COMMAND(ID_TOOLS_REMOVEALLGH, OnToolsRemoveAllGH) ON_COMMAND(ID_TOOLS_TESTYOURMETHOD, OnToolsTestYourMethod) ON_COMMAND(ID_TOOLS_TESTYOURMETHOD2, OnToolsTestYourMethod2) + ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228) ON_COMMAND(ID_CLIPBOARDCMD_PASTE, OnPasteTest) ON_COMMAND(ID_CLIPBOARDCMD_COPYSELECTION, OnCopyTest) ON_COMMAND(ID_CLIPBOARDCMD_SELECTALL, OnSelectAllTest) @@ -972,68 +973,101 @@ void CTests::GetSHTest() // *********************************************************************** // nsIRequest iface +// table columns corrsp to: pending, status, suspend, resume, cancel, +// setLoadGroup & getLoadGroup tests respectively. + +Element UrlTable[] = { + {"http://www.netscape.com", 1, 1, 0, 0, 0, 1, 1}, + {"http://www.yahoo.com", 0, 0, 1, 1, 0, 0, 0}, + {"http://www.cisco.com", 0, 0, 0, 0, 1, 0, 0}, + {"http://www.sun.com", 0, 0, 0, 0, 0, 1, 1}, + {"http://www.intel.com", 1, 1, 1, 0, 0, 0, 0}, + {"http://www.aol.com", 0, 1, 0, 0, 0, 1, 1} +}; void CTests::OnInterfacesNsirequest() { - // note: individual nsIRequest tests are called in: - // 1) BrowserImplWebProgLstner.cpp, nsIWebProgressListener::OnStateChange(). - // 2) BrowserImpl.cpp, nsIStreamListener::OnDataAvailable() + // note: nsIRequest tests are called: + // 1) in BrowserImpl.cpp, nsIStreamListener::OnDataAvailable() + // 2) as individual tests below nsCString theSpec; nsCOMPtr theURI; nsCOMPtr theChannel; nsCOMPtr theLoadGroup(do_CreateInstance(NS_LOADGROUP_CONTRACTID)); - nsCOMPtr theDefaultRequest; + + int i=0; CQaUtils::QAOutput("Start nsIRequest tests.", 2); - theSpec = "http://www.netscape.com"; - CQaUtils::FormatAndPrintOutput("the uri spec = ", theSpec, 2); - - rv = NS_NewURI(getter_AddRefs(theURI), theSpec); - if (!theURI) +// theSpec = "http://www.netscape.com"; + for (i=0; i<6; i++) { - CQaUtils::QAOutput("We didn't get the URI. Test failed.", 1); - return; - } - else - CQaUtils::RvTestResult(rv, "NS_NewURI", 1); + theSpec = UrlTable[i].theUrl; + CQaUtils::FormatAndPrintOutput("the uri spec = ", theSpec, 2); - rv = NS_OpenURI(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); - if (!theChannel) - { - CQaUtils::QAOutput("We didn't get the Channel. Test failed.", 1); - return; - } - else if (!theLoadGroup) - { - CQaUtils::QAOutput("We didn't get the Load Group. Test failed.", 2); - return; - } - else - CQaUtils::RvTestResult(rv, "NS_OpenURI", 1); -/* - IsPendingReqTest(theChannel); - GetStatusReqTest(theChannel); + rv = NS_NewURI(getter_AddRefs(theURI), theSpec); + if (!theURI) + { + CQaUtils::QAOutput("We didn't get the URI. Test failed.", 1); + return; + } + else + CQaUtils::RvTestResult(rv, "NS_NewURI", 1); - SuspendReqTest(theChannel); - CQaUtils::QAOutput("nsIRequest: Between Suspend and Resume."); - ResumeReqTest(theChannel); + rv = NS_OpenURI(getter_AddRefs(theChannel), theURI, nsnull, theLoadGroup); + if (!theChannel) + { + CQaUtils::QAOutput("We didn't get the Channel. Test failed.", 1); + return; + } + else if (!theLoadGroup) + { + CQaUtils::QAOutput("We didn't get the Load Group. Test failed.", 2); + return; + } + else + CQaUtils::RvTestResult(rv, "NS_OpenURI", 1); -// CancelReqTest(theChannel); + nsCOMPtr listener(NS_STATIC_CAST(nsIStreamListener*, qaBrowserImpl)); + nsCOMPtr thisListener(dont_AddRef(NS_GetWeakReference(listener))); + qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener)); - SetLoadGroupTest(theChannel, theLoadGroup); - GetLoadGroupTest(theChannel); -*/ + // this calls nsIStreamListener::OnDataAvailable() + rv = theChannel->AsyncOpen(listener, nsnull); + CQaUtils::RvTestResult(rv, "AsyncOpen()", 1); - nsCOMPtr sListener(NS_STATIC_CAST(nsIStreamListener*, qaBrowserImpl)); - nsCOMPtr thisListener(dont_AddRef(NS_GetWeakReference(sListener))); - qaWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsIStreamListener)); + // nsIRequest individual tests - rv = theChannel->AsyncOpen(sListener, nsnull); - CQaUtils::RvTestResult(rv, "AsyncOpen()", 1); + CQaUtils::QAOutput("***** Individual nsIRequest test begins. *****"); + nsCOMPtr theRequest = do_QueryInterface(theChannel); + + if (UrlTable[i].reqPend == TRUE) + IsPendingReqTest(theRequest); + + if (UrlTable[i].reqStatus == TRUE) + GetStatusReqTest(theRequest); + + if (UrlTable[i].reqSuspend == TRUE) + SuspendReqTest(theRequest); + + if (UrlTable[i].reqResume == TRUE) + ResumeReqTest(theRequest); + + if (UrlTable[i].reqCancel == TRUE) + CancelReqTest(theRequest); + + if (UrlTable[i].reqSetLoadGroup == TRUE) + SetLoadGroupTest(theRequest, theLoadGroup); + + if (UrlTable[i].reqGetLoadGroup == TRUE) + GetLoadGroupTest(theRequest); + + CQaUtils::QAOutput("- - - - - - - - - - - - - - - - - - - - -", 1); + } // end for loop + CQaUtils::QAOutput("End nsIRequest tests.", 2); } void CTests::IsPendingReqTest(nsIRequest *request) @@ -1110,83 +1144,6 @@ void CTests::GetLoadGroupTest(nsIRequest *request) CQaUtils::RvTestResult(rv, "nsIRequest:: LoadGroups' GetRequests() rv test", 1); } -// *********** 2nd set of implementations for nsIRequest methods ********* -// ******************* Using nsIChannel as the impl object *************** - -void CTests::IsPendingReqTest(nsIChannel *channel) -{ - PRBool reqPending; - nsresult rv; - - rv = channel->IsPending(&reqPending); - CQaUtils::RvTestResult(rv, "nsIRequest::IsPending() rv test", 1); - - if (!reqPending) - CQaUtils::QAOutput("Pending request = false.", 1); - else - CQaUtils::QAOutput("Pending request = true.", 1); -} - -void CTests::GetStatusReqTest(nsIChannel *channel) -{ - nsresult theStatusError; - nsresult rv; - - rv = channel->GetStatus(&theStatusError); - CQaUtils::RvTestResult(rv, "nsIRequest::GetStatus() test", 1); - CQaUtils::RvTestResult(rv, "the returned status error test", 1); - -} - -void CTests::SuspendReqTest(nsIChannel *channel) -{ - nsresult rv; - - rv = channel->Suspend(); - CQaUtils::RvTestResult(rv, "nsIRequest::Suspend() test", 1); -} - -void CTests::ResumeReqTest(nsIChannel *channel) -{ - nsresult rv; - - rv = channel->Resume(); - CQaUtils::RvTestResult(rv, "nsIRequest::Resume() test", 1); -} - -void CTests::CancelReqTest(nsIChannel *channel) -{ - nsresult rv; - nsresult status = NS_BINDING_ABORTED; - - rv = channel->Cancel(status); - CQaUtils::RvTestResult(rv, "nsIRequest::Cancel() rv test", 1); - CQaUtils::RvTestResult(status, "nsIRequest::Cancel() status test", 1); -} - -void CTests::SetLoadGroupTest(nsIChannel *channel, - nsILoadGroup *theLoadGroup) -{ - nsresult rv; - nsCOMPtr theSimpEnum; - - rv = channel->SetLoadGroup(theLoadGroup); - CQaUtils::RvTestResult(rv, "nsIRequest::SetLoadGroup() rv test", 1); -} - -void CTests::GetLoadGroupTest(nsIChannel *channel) -{ - nsCOMPtr theLoadGroup; - nsresult rv; - nsCOMPtr theSimpEnum; - - rv = channel->GetLoadGroup(getter_AddRefs(theLoadGroup)); - CQaUtils::RvTestResult(rv, "nsIRequest::GetLoadGroup() rv test", 1); - - rv = theLoadGroup->GetRequests(getter_AddRefs(theSimpEnum)); - CQaUtils::RvTestResult(rv, "nsIRequest:: LoadGroups' GetRequests() rv test", 1); -} - // *********************************************************************** //DHARMA - nsIClipboardCommands // Checking the paste() method. @@ -1340,27 +1297,18 @@ void CTests::canPasteTest() void CTests::OnVerifybugs70228() { - CQaUtils::QAOutput("Not implemented yet.", 0); -/* - nsCOMPtr - myHALD(do_GetService(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID)); - if (!myHALD) - CQaUtils::QAOutput("Object not created. It's NOT a service!", 2); - else - CQaUtils::QAOutput("Object is created. But should it?! It's NOT a service!", 2); - nsCOMPtr myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID)); if (!myHALD) CQaUtils::QAOutput("Object not created. It should be. It's a component!", 2); else CQaUtils::QAOutput("Object is created. It's a component!", 2); -*/ + /* nsCOMPtr myHAL(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID)); - rv = myHALD->show(myHal, mySupp); + rv = myHALD->show(myHal, nsnull); */ } diff --git a/mozilla/embedding/qa/testembed/Tests.h b/mozilla/embedding/qa/testembed/Tests.h index 352c586c354..f4940a02b00 100644 --- a/mozilla/embedding/qa/testembed/Tests.h +++ b/mozilla/embedding/qa/testembed/Tests.h @@ -34,6 +34,8 @@ #include "BrowserView.h" #include "BrowserImpl.h" +#include "StdAfx.h" + ///////////////////////////////////////////////////////////////////////////// // CTESTS class @@ -66,7 +68,7 @@ public: nsresult rv; CString strMsg; char theUrl[200]; - char * uriSpec; + char *uriSpec; PRBool exists; PRInt32 numEntries; PRInt32 theIndex; @@ -159,14 +161,20 @@ public: void static CancelReqTest(nsIRequest *); void static SetLoadGroupTest(nsIRequest *, nsILoadGroup *); void static GetLoadGroupTest(nsIRequest *); - - void static IsPendingReqTest(nsIChannel *); - void static GetStatusReqTest(nsIChannel *); - void static SuspendReqTest(nsIChannel *); - void static ResumeReqTest(nsIChannel *); - void static CancelReqTest(nsIChannel *); - void static SetLoadGroupTest(nsIChannel *, nsILoadGroup *); - void static GetLoadGroupTest(nsIChannel *); }; -#endif //_TESTS_H + +typedef struct +{ + char theUrl[1024]; + bool reqPend; + bool reqStatus; + bool reqSuspend; + bool reqResume; + bool reqCancel; + bool reqSetLoadGroup; + bool reqGetLoadGroup; +} Element; + + +#endif //_TESTS_H \ No newline at end of file