From 84c2088c56ed034dd584d7184e8926c1df2659e2 Mon Sep 17 00:00:00 2001 From: "depstein%netscape.com" Date: Fri, 13 Sep 2002 02:25:34 +0000 Subject: [PATCH] 1) Updated nsIWebBrowserChrome, nsIEmbeddingSiteWindow, and nsIURIContentListener implementations. 2) Updated nsICommandManager DoCommand() handling for commands with string attribute input. 3) Added additional FormatAndPrintOutput() method for PRUint32 input. a=asa for QA checkins that are not part of the default builds --- embedding/qa/testembed/BrowserImpl.cpp | 94 ++++++++++++++++++++---- embedding/qa/testembed/BrowserImpl.h | 3 + embedding/qa/testembed/QaUtils.cpp | 25 +++++++ embedding/qa/testembed/QaUtils.h | 1 + embedding/qa/testembed/UrlDialog.h | 3 +- embedding/qa/testembed/nsICommandMgr.cpp | 32 +++++--- embedding/qa/testembed/nsIWebNav.cpp | 3 +- 7 files changed, 134 insertions(+), 27 deletions(-) diff --git a/embedding/qa/testembed/BrowserImpl.cpp b/embedding/qa/testembed/BrowserImpl.cpp index 78ca408f927..7a2b3ff8b52 100644 --- a/embedding/qa/testembed/BrowserImpl.cpp +++ b/embedding/qa/testembed/BrowserImpl.cpp @@ -163,23 +163,27 @@ NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr) // NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus) { +// QAOutput("nsIWebBrowserChrome::SetStatus().", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; m_pBrowserFrameGlue->UpdateStatusBarText(aStatus); - //QAOutput("nsIWebBrowserChrome::SetStatus().", 1); return NS_OK; } NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser) { + QAOutput("nsIWebBrowserChrome::GetWebBrowser().", 1); + NS_ENSURE_ARG_POINTER(aWebBrowser); *aWebBrowser = mWebBrowser; + if (!aWebBrowser) + QAOutput("aWebBrowser is null", 1); NS_IF_ADDREF(*aWebBrowser); - QAOutput("nsIWebBrowserChrome::GetWebBrowser().", 1); return NS_OK; } @@ -189,23 +193,38 @@ NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser) // NS_IMETHODIMP CBrowserImpl::SetWebBrowser(nsIWebBrowser* aWebBrowser) { + QAOutput("nsIWebBrowserChrome::SetWebBrowser().", 1); + NS_ENSURE_ARG_POINTER(aWebBrowser); + if (!aWebBrowser) + QAOutput("aWebBrowser is null", 1); + mWebBrowser = aWebBrowser; - QAOutput("nsIWebBrowserChrome::SetWebBrowser().", 1); return NS_OK; } NS_IMETHODIMP CBrowserImpl::GetChromeFlags(PRUint32* aChromeMask) { + QAOutput("nsIWebBrowserChrome::GetChromeFlags().", 1); + *aChromeMask = nsIWebBrowserChrome::CHROME_ALL; + if (!aChromeMask) + QAOutput("aChromeMask is null", 1); return NS_OK; } NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask) { + QAOutput("nsIWebBrowserChrome::SetChromeFlags().", 1); + + if (!aChromeMask) + QAOutput("aChromeMask is null", 1); + + mChromeMask = aChromeMask; + return NS_OK; } @@ -262,18 +281,18 @@ NS_IMETHODIMP CBrowserImpl::DestroyBrowserWindow() // NS_IMETHODIMP CBrowserImpl::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) { + QAOutput("nsIWebBrowserChrome::SizeBrowserTo(): Browser sized.", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; m_pBrowserFrameGlue->SetBrowserFrameSize(aCX, aCY); - QAOutput("nsIWebBrowserChrome::SizeBrowserTo(): Browser sized.", 1); return NS_OK; } NS_IMETHODIMP CBrowserImpl::ShowAsModal(void) { -// return NS_ERROR_NOT_IMPLEMENTED; QAOutput("inside nsIWebBrowserChrome::ShowAsModal()", 2); return NS_OK; @@ -281,6 +300,8 @@ NS_IMETHODIMP CBrowserImpl::ShowAsModal(void) NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval) { + QAOutput("inside nsIWebBrowserChrome::IsWindowModal()", 1); + // We're not modal *retval = PR_FALSE; @@ -289,6 +310,8 @@ NS_IMETHODIMP CBrowserImpl::IsWindowModal(PRBool *retval) NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus) { + QAOutput("inside nsIWebBrowserChrome::ExitModalEventLoop()", 1); + return NS_OK; } @@ -298,12 +321,16 @@ NS_IMETHODIMP CBrowserImpl::ExitModalEventLoop(nsresult aStatus) NS_IMETHODIMP CBrowserImpl::FocusNextElement() { - return NS_ERROR_NOT_IMPLEMENTED; + QAOutput("inside nsIWebBrowserChromeFocus::FocusNextElement()", 1); + + return NS_OK; } NS_IMETHODIMP CBrowserImpl::FocusPrevElement() { - return NS_ERROR_NOT_IMPLEMENTED; + QAOutput("inside nsIWebBrowserChromeFocus::FocusPrevElement()", 1); + + return NS_OK; } //***************************************************************************** @@ -312,6 +339,8 @@ NS_IMETHODIMP CBrowserImpl::FocusPrevElement() NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) { + QAOutput("inside nsIEmbeddingSiteWindow::SetDimensions()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -339,6 +368,8 @@ NS_IMETHODIMP CBrowserImpl::SetDimensions(PRUint32 aFlags, PRInt32 x, PRInt32 y, NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) { + QAOutput("inside nsIEmbeddingSiteWindow::GetDimensions()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -357,6 +388,8 @@ NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 * NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow) { + QAOutput("inside nsIEmbeddingSiteWindow::GetSiteWindow()", 1); + if (!aSiteWindow) return NS_ERROR_NULL_POINTER; @@ -370,6 +403,8 @@ NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow) NS_IMETHODIMP CBrowserImpl::SetFocus() { + QAOutput("inside nsIEmbeddingSiteWindow::SetFocus()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -380,6 +415,8 @@ NS_IMETHODIMP CBrowserImpl::SetFocus() NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle) { + QAOutput("inside nsIEmbeddingSiteWindow::GetTitle()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -390,6 +427,8 @@ NS_IMETHODIMP CBrowserImpl::GetTitle(PRUnichar** aTitle) NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle) { + QAOutput("inside nsIEmbeddingSiteWindow::SetTitle()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -400,6 +439,8 @@ NS_IMETHODIMP CBrowserImpl::SetTitle(const PRUnichar* aTitle) NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility) { + QAOutput("inside nsIEmbeddingSiteWindow::GetVisibility()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -410,6 +451,8 @@ NS_IMETHODIMP CBrowserImpl::GetVisibility(PRBool *aVisibility) NS_IMETHODIMP CBrowserImpl::SetVisibility(PRBool aVisibility) { + QAOutput("inside nsIEmbeddingSiteWindow::SetVisibility()", 1); + if(! m_pBrowserFrameGlue) return NS_ERROR_FAILURE; @@ -487,6 +530,7 @@ NS_IMETHODIMP CBrowserImpl::OnStartURIOpen(nsIURI *aURI, PRBool *_retval) GetTheUri(aURI, 1); *_retval = PR_TRUE; + FormatAndPrintOutput("_retval set to = ", *_retval, 1); return NS_OK; } @@ -503,7 +547,9 @@ NS_IMETHODIMP CBrowserImpl::DoContent(const char *aContentType, PRBool aIsConten // *aContentHandler = nsnull; QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler); - *_retval = PR_TRUE; + *_retval = PR_FALSE; + FormatAndPrintOutput("_retval set to = ", *_retval, 1); + return NS_OK; } NS_IMETHODIMP CBrowserImpl::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval) @@ -514,7 +560,10 @@ NS_IMETHODIMP CBrowserImpl::IsPreferred(const char *aContentType, char **aDesire FormatAndPrintOutput("IsPreferred() content type = ", *aContentType, 1); *aDesiredContentType = nsCRT::strdup("text/html"); + FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1); *_retval = PR_TRUE; + FormatAndPrintOutput("_retval set to = ", *_retval, 1); + return NS_OK; } @@ -525,14 +574,20 @@ NS_IMETHODIMP CBrowserImpl::CanHandleContent(const char *aContentType, PRBool aI FormatAndPrintOutput("CanHandleContent() content type = ", *aContentType, 1); FormatAndPrintOutput("CanHandleContent() preferred content type = ", aIsContentPreferred, 1); *aDesiredContentType = nsCRT::strdup("text/html"); + FormatAndPrintOutput("aDesiredContentType set to = ", *aDesiredContentType, 1); *_retval = PR_TRUE; + FormatAndPrintOutput("_retval set to = ", *_retval, 1); return NS_OK; } -NS_IMETHODIMP CBrowserImpl::GetLoadCookie(nsISupports * *aLoadCookie) +NS_IMETHODIMP CBrowserImpl::GetLoadCookie(nsISupports **aLoadCookie) { QAOutput("nsIURIContentListener->GetLoadCookie()",1); - *aLoadCookie = nsnull; + + if (!aLoadCookie) + QAOutput("aLoadCookie object is null",1); + *aLoadCookie = mLoadCookie; + NS_IF_ADDREF(*aLoadCookie); return NS_OK; } @@ -541,14 +596,23 @@ NS_IMETHODIMP CBrowserImpl::SetLoadCookie(nsISupports * aLoadCookie) { QAOutput("nsIURIContentListener->SetLoadCookie()",1); + if (!aLoadCookie) + QAOutput("aLoadCookie object is null",1); + mLoadCookie = aLoadCookie; + return NS_OK; } -NS_IMETHODIMP CBrowserImpl::GetParentContentListener(nsIURIContentListener * *aParentContentListener) +NS_IMETHODIMP CBrowserImpl::GetParentContentListener(nsIURIContentListener **aParentContentListener) { QAOutput("nsIURIContentListener->GetParentContentListener()",1); -// *aParentContentListener = nsnull; - QueryInterface(NS_GET_IID(nsIURIContentListener), (void **) aParentContentListener); + + if (!aParentContentListener) + QAOutput("aParentContentListener object is null",1); + *aParentContentListener = mParentContentListener; + NS_IF_ADDREF(*aParentContentListener); + +// QueryInterface(NS_GET_IID(nsIURIContentListener), (void **) aParentContentListener); return NS_OK; } @@ -557,6 +621,10 @@ NS_IMETHODIMP CBrowserImpl::SetParentContentListener(nsIURIContentListener * aPa { QAOutput("nsIURIContentListener->SetParentContentListener()",1); + if (!aParentContentListener) + QAOutput("aParentContentListener object is null",1); + mParentContentListener = aParentContentListener; + return NS_OK; } diff --git a/embedding/qa/testembed/BrowserImpl.h b/embedding/qa/testembed/BrowserImpl.h index fc4d3ad4d05..1d8156c4468 100644 --- a/embedding/qa/testembed/BrowserImpl.h +++ b/embedding/qa/testembed/BrowserImpl.h @@ -88,6 +88,9 @@ protected: PBROWSERFRAMEGLUE m_pBrowserFrameGlue; nsCOMPtr mWebBrowser; + nsCOMPtr mLoadCookie; // de: used for nsIURIContentListener + nsCOMPtr mParentContentListener; // de: used for nsIURIContentListener + PRUint32 mChromeMask; }; #endif //_BROWSERIMPL_H diff --git a/embedding/qa/testembed/QaUtils.cpp b/embedding/qa/testembed/QaUtils.cpp index a9f4ec673e3..cb5f40a2fdf 100644 --- a/embedding/qa/testembed/QaUtils.cpp +++ b/embedding/qa/testembed/QaUtils.cpp @@ -238,6 +238,31 @@ void FormatAndPrintOutput(const char *theInput, double theVar, int outputMode) } } +void FormatAndPrintOutput(const char *theInput, PRUint32 theVar, int outputMode) +{ + nsCString outStr; + CString strMsg; + + outStr = theInput; + outStr.AppendFloat(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; + } +} + // stringMsg is returned in case embeddor wishes to use it in the calling method. void RequestName(nsIRequest *request, nsCString &stringMsg, int displayMethod) { diff --git a/embedding/qa/testembed/QaUtils.h b/embedding/qa/testembed/QaUtils.h index aa1ff55f49d..fe918e16b38 100644 --- a/embedding/qa/testembed/QaUtils.h +++ b/embedding/qa/testembed/QaUtils.h @@ -61,6 +61,7 @@ extern void FormatAndPrintOutput(const char *, const char *, int); extern void FormatAndPrintOutput(const char *, nsCAutoString, int); extern void FormatAndPrintOutput(const char *, int, int); extern void FormatAndPrintOutput(const char *, double, int); +extern void FormatAndPrintOutput(const char *, PRUint32, int); extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1); extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1); extern nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *); diff --git a/embedding/qa/testembed/UrlDialog.h b/embedding/qa/testembed/UrlDialog.h index d979d9c4bd8..d2b59f2491b 100644 --- a/embedding/qa/testembed/UrlDialog.h +++ b/embedding/qa/testembed/UrlDialog.h @@ -15,7 +15,8 @@ class CUrlDialog : public CDialog // Construction public: CUrlDialog(CWnd* pParent = NULL); // standard constructor - unsigned long m_flagvalue ; +// unsigned long m_flagvalue ; + PRUint32 m_flagvalue; // Dialog Data //{{AFX_DATA(CUrlDialog) enum { IDD = IDD_URLDIALOG }; diff --git a/embedding/qa/testembed/nsICommandMgr.cpp b/embedding/qa/testembed/nsICommandMgr.cpp index 04b47fe375c..6f168e772a6 100644 --- a/embedding/qa/testembed/nsICommandMgr.cpp +++ b/embedding/qa/testembed/nsICommandMgr.cpp @@ -207,24 +207,32 @@ void CnsICommandMgr::DoCommandTest(const char *aCommandName) cmdMgrObj = GetCommandMgrObject(qaWebBrowser); cmdParamObj = CnsICmdParams::GetCommandParamObject(); if (!cmdMgrObj) { - QAOutput("Didn't get nsICommandManager object."); + QAOutput("Didn't get nsICommandManager object. Tests fail"); return; } - else if (!cmdMgrObj) { - QAOutput("Didn't get nsICommandParam object."); + if (!cmdMgrObj) { + QAOutput("Didn't get nsICommandParam object. Test fail"); return; } - else { - if (strcmp(aCommandName,"cmd_fontColor") == 0 || - strcmp(aCommandName,"cmd_backgroundColor") == 0 || - strcmp(aCommandName,"cmd_fontFace") == 0 || - strcmp(aCommandName,"cmd_align") == 0) - cmdParamObj->SetCStringValue("state_attribute", value.get()); - rv = cmdMgrObj->DoCommand(aCommandName, cmdParamObj); - RvTestResult(rv, "DoCommand() test", 2); + if (strcmp(aCommandName,"cmd_fontColor") == 0 || + strcmp(aCommandName,"cmd_backgroundColor") == 0 || + strcmp(aCommandName,"cmd_fontFace") == 0 || + strcmp(aCommandName,"cmd_align") == 0) + { + if (strcmp(aCommandName,"cmd_fontColor") == 0 || + strcmp(aCommandName,"cmd_backgroundColor") == 0) + value = "#FF0000"; + else if (strcmp(aCommandName,"cmd_fontFace") == 0) + value = "Helvetica, Ariel, san-serif"; + else + value = "left"; + cmdParamObj->SetCStringValue("state_attribute", value.get()); } + rv = cmdMgrObj->DoCommand(aCommandName, cmdParamObj); + RvTestResult(rv, "DoCommand() test", 2); } + void CnsICommandMgr::OnStartTests(UINT nMenuID) { switch(nMenuID) @@ -245,7 +253,7 @@ void CnsICommandMgr::OnStartTests(UINT nMenuID) IsCommandEnabledTest("cmd_bold"); break; case ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE : - GetCommandStateTest("cmd_copy"); + GetCommandStateTest("cmd_charSet"); break; case ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND : DoCommandTest("cmd_fontColor"); diff --git a/embedding/qa/testembed/nsIWebNav.cpp b/embedding/qa/testembed/nsIWebNav.cpp index 93c2d039385..8ab9aa3b4b1 100644 --- a/embedding/qa/testembed/nsIWebNav.cpp +++ b/embedding/qa/testembed/nsIWebNav.cpp @@ -113,7 +113,8 @@ void CNsIWebNav::OnStartTests(UINT nMenuID) GoToIndexTest(); break ; case ID_INTERFACES_NSIWEBNAV_LOADURI : - LoadUriTest(UrlTable[0].theUri, UrlTable[0].theFlag); + LoadUriTest(UrlTable[0].theUri, UrlTable[1].theFlag); + FormatAndPrintOutput("the loadFlag = ", nsIWebNavigation::LOAD_FLAGS_MASK, 2); break ; case ID_INTERFACES_NSIWEBNAV_RELOAD : ReloadTest(nsIWebNavigation::LOAD_FLAGS_NONE);