diff --git a/mozilla/embedding/qa/testembed/Makefile.in b/mozilla/embedding/qa/testembed/Makefile.in index e6a0c7d9e79..f4853c9cfdd 100644 --- a/mozilla/embedding/qa/testembed/Makefile.in +++ b/mozilla/embedding/qa/testembed/Makefile.in @@ -1,147 +1,154 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: Mozilla-sample-code 1.0 -# -# Copyright (c) 2002 Netscape Communications Corporation and -# other contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this Mozilla sample software and associated documentation files -# (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject to the -# following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -# Contributor(s): -# Ashish Bhatt -# -# ***** END LICENSE BLOCK ***** - -DEPTH = ../../.. -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -PROGRAM = testembed$(BIN_SUFFIX) -RESFILE = testembed.res - -MODULE = testEmbed -REQUIRES = \ - xpcom \ - string \ - necko \ - webbrwsr \ - webBrowser_core \ - widget \ - docshell \ - dom \ - uriloader \ - embed_base \ - webshell \ - shistory \ - appcomps \ - pref \ - profile \ - find \ - gfx \ - windowwatcher \ - layout \ - history \ - helperAppDlg \ - content \ - webbrowserpersist \ - xpinstall \ - composer \ - commandhandler \ - $(NULL) - -CPPSRCS = \ - TestEmbed.cpp \ - BrowserFrm.cpp \ - BrowserFrameGlue.cpp \ - BrowserView.cpp \ - BrowserImpl.cpp \ - BrowserImplWebPrgrsLstnr.cpp \ - BrowserImplHistoryLstnr.cpp \ - BrowserImplCtxMenuLstnr.cpp \ - Dialogs.cpp \ - ProfileMgr.cpp \ - ProfilesDlg.cpp \ - winEmbedFileLocProvider.cpp \ - MostRecentUrls.cpp \ - PrintProgressDialog.cpp \ - Preferences.cpp \ - StdAfx.cpp \ - UrlDialog.cpp \ - QaUtils.cpp \ - Tests.cpp \ - nsirequest.cpp \ - nsihistory.cpp \ - nsiwebnav.cpp \ - nsiDirServ.cpp \ - domwindow.cpp \ - selection.cpp \ - nsProfile.cpp \ - nsIClipBoardCmd.cpp \ - nsIObserServ.cpp \ - nsIFile.cpp \ - nsIWebBrow.cpp \ - nsIWebProg.cpp \ - nsIWebBrowFind.cpp \ - QaFindDlg.cpp \ - WebProgDlg.cpp \ - $(NULL) - -EXTRA_DSO_LIBS = embed_base_s gkgfx testEmbedComponents - -LIBS = \ - $(EXTRA_DSO_LIBS) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -OS_LIBS += \ - ole32.lib \ - comdlg32.lib \ - shell32.lib \ - version.lib \ - $(NULL) - -LOCAL_INCLUDES = -I$(srcdir)/components - -# -# Control the default heap size. -# This is the heap returned by GetProcessHeap(). -# As we use the CRT heap, the default size is too large and wastes VM. -# -# The default heap size is 1MB on Win32. -# The heap will grow if need be. -# -# Set it to 256k. See bug 127069. -# -LDFLAGS += /HEAP:0x40000 - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON" -LDFLAGS += -SUBSYSTEM:windows - -libs:: testembed.htm - $(INSTALL) $^ $(DIST)/bin - -install:: testembed.htm - $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir) - +# ***** BEGIN LICENSE BLOCK ***** +# Version: Mozilla-sample-code 1.0 +# +# Copyright (c) 2002 Netscape Communications Corporation and +# other contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this Mozilla sample software and associated documentation files +# (the "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the +# following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# Contributor(s): +# Ashish Bhatt +# +# ***** END LICENSE BLOCK ***** + +DEPTH = ../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +PROGRAM = testembed$(BIN_SUFFIX) +RESFILE = testembed.res + +MODULE = testEmbed + +REQUIRES = \ + xpcom \ + string \ + necko \ + webbrwsr \ + webBrowser_core \ + widget \ + docshell \ + dom \ + uriloader \ + embed_base \ + webshell \ + shistory \ + appcomps \ + pref \ + profile \ + find \ + gfx \ + windowwatcher \ + layout \ + history \ + helperAppDlg \ + content \ + webbrowserpersist \ + xpinstall \ + composer \ + commandhandler \ + editor \ + $(NULL) + +CPPSRCS = \ + TestEmbed.cpp \ + BrowserFrm.cpp \ + BrowserFrameGlue.cpp \ + BrowserView.cpp \ + BrowserImpl.cpp \ + BrowserImplWebPrgrsLstnr.cpp \ + BrowserImplHistoryLstnr.cpp \ + BrowserImplCtxMenuLstnr.cpp \ + Dialogs.cpp \ + ProfileMgr.cpp \ + ProfilesDlg.cpp \ + winEmbedFileLocProvider.cpp \ + MostRecentUrls.cpp \ + PrintProgressDialog.cpp \ + Preferences.cpp \ + StdAfx.cpp \ + UrlDialog.cpp \ + QaUtils.cpp \ + Tests.cpp \ + nsirequest.cpp \ + nsihistory.cpp \ + nsiwebnav.cpp \ + nsiDirServ.cpp \ + domwindow.cpp \ + selection.cpp \ + nsProfile.cpp \ + nsIClipBoardCmd.cpp \ + nsIObserServ.cpp \ + nsIFile.cpp \ + nsIWebBrow.cpp \ + nsIWebProg.cpp \ + nsIWebBrowFind.cpp \ + QaFindDlg.cpp \ + WebProgDlg.cpp \ + nsIEditSession.cpp \ + nsICommandMgr.cpp \ + $(NULL) + +EXTRA_DSO_LIBS = embed_base_s gkgfx testEmbedComponents + +LIBS = \ + $(EXTRA_DSO_LIBS) \ + $(XPCOM_LIBS) \ + $(NSPR_LIBS) \ + $(NULL) + +OS_LIBS += \ + ole32.lib \ + comdlg32.lib \ + shell32.lib \ + version.lib \ + $(NULL) + +LOCAL_INCLUDES = -I$(srcdir)/components + +# +# Control the default heap size. +# This is the heap returned by GetProcessHeap(). +# As we use the CRT heap, the default size is too large and wastes VM. +# +# The default heap size is 1MB on Win32. +# The heap will grow if need be. +# +# Set it to 256k. See bug 127069. +# + +LDFLAGS += /HEAP:0x40000 + +include $(topsrcdir)/config/rules.mk + +CXXFLAGS += /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON" +LDFLAGS += -SUBSYSTEM:windows + +libs:: testembed.htm + $(INSTALL) $^ $(DIST)/bin + +install:: testembed.htm + $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir) + + + diff --git a/mozilla/embedding/qa/testembed/QaUtils.cpp b/mozilla/embedding/qa/testembed/QaUtils.cpp index 444550feee6..5b5095915c2 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.cpp +++ b/mozilla/embedding/qa/testembed/QaUtils.cpp @@ -248,6 +248,18 @@ void WebProgDOMWindowTest(nsIWebProgress *progress, const char *inString, RvTestResult(rv, totalStr2.get(), displayMethod); } +nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *webBrowser) +{ + nsCOMPtr theDOMWindow; + + webBrowser->GetContentDOMWindow(getter_AddRefs(theDOMWindow)); + if (!theDOMWindow) { + QAOutput("Didn't get a DOM Window."); + return nsnull; + } + return (theDOMWindow); +} + void GetTheUri(nsIURI *theUri, int displayMethod) { nsresult rv; diff --git a/mozilla/embedding/qa/testembed/QaUtils.h b/mozilla/embedding/qa/testembed/QaUtils.h index ea3f592d563..cd2cd33079a 100644 --- a/mozilla/embedding/qa/testembed/QaUtils.h +++ b/mozilla/embedding/qa/testembed/QaUtils.h @@ -62,6 +62,7 @@ extern void FormatAndPrintOutput(const char *, nsCAutoString, int); extern void FormatAndPrintOutput(const char *, int, int); extern void RequestName(nsIRequest *, nsCString &, int displayMethod=1); extern void WebProgDOMWindowTest(nsIWebProgress *, const char *,int displayMethod=1); +extern nsIDOMWindow * GetTheDOMWindow(nsIWebBrowser *); extern void GetTheUri(nsIURI *theUri, int displayMethod=1); extern void onStateChangeString(char *, char *, nsCString, PRUint32, int displayMethod=1); extern nsresult rv; diff --git a/mozilla/embedding/qa/testembed/StdAfx.h b/mozilla/embedding/qa/testembed/StdAfx.h index 6a29996cabd..f14dc6ebc2d 100644 --- a/mozilla/embedding/qa/testembed/StdAfx.h +++ b/mozilla/embedding/qa/testembed/StdAfx.h @@ -131,7 +131,9 @@ #include "nsIURILoader.h" #include "nsCURILoader.h" -//#include "nsIURIContentListener.h" +#include "nsIEditingSession.h" +#include "nsICommandManager.h" +#include "nsICommandParams.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 844f22ce1ec..b083c977c9b 100644 --- a/mozilla/embedding/qa/testembed/Tests.cpp +++ b/mozilla/embedding/qa/testembed/Tests.cpp @@ -65,6 +65,8 @@ #include "nsIWebBrow.h" #include "nsIWebProg.h" #include "nsIWebBrowFind.h" +#include "nsIEditSession.h" +#include "nsICommandMgr.h" #include "QaUtils.h" #include @@ -245,6 +247,21 @@ BEGIN_MESSAGE_MAP(CTests, CWnd) ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETSEARCHFRAMES, OnInterfacesNsiwebbrowfind) ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETSEARCHFRAMES, OnInterfacesNsiwebbrowfind) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_INIT, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW, OnInterfacesNsieditingsession) + ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW, OnInterfacesNsieditingsession) + + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ADDCOMMANDOBSERVER, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_REMOVECOMMANDOBSERVER, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE, OnInterfacesNsicommandmgr) + ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND, OnInterfacesNsicommandmgr) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -632,14 +649,14 @@ void CTests::OnInterfacesNsiwebnav() void CTests::OnInterfacesNsiclipboardcommands() { - CNsIClipBoardCmd oClipCmd(qaWebBrowser) ; + CNsIClipBoardCmd oClipCmd(qaWebBrowser); oClipCmd.OnStartTests(nCommandID); } void CTests::OnInterfacesNsiobserverservice() { - CnsIObserServ oObserv ; + CnsIObserServ oObserv; oObserv.OnStartTests(nCommandID); } @@ -666,4 +683,16 @@ void CTests::OnInterfacesNsiwebbrowfind() { CNsIWebBrowFind oWebBrowFind(qaWebBrowser, qaBrowserImpl); oWebBrowFind.OnStartTests(nCommandID); +} + +void CTests::OnInterfacesNsieditingsession() +{ + CnsIEditSession oEditSession(qaWebBrowser); + oEditSession.OnStartTests(nCommandID); +} + +void CTests::OnInterfacesNsicommandmgr() +{ + CnsICommandMgr oCommandMgr(qaWebBrowser); + oCommandMgr.OnStartTests(nCommandID); } \ No newline at end of file diff --git a/mozilla/embedding/qa/testembed/Tests.h b/mozilla/embedding/qa/testembed/Tests.h index e7b9d0dbe9d..61cc3d28417 100644 --- a/mozilla/embedding/qa/testembed/Tests.h +++ b/mozilla/embedding/qa/testembed/Tests.h @@ -137,6 +137,8 @@ protected: afx_msg void OnInterfacesNsiwebbrowser(); afx_msg void OnInterfacesNsiwebprogress(); afx_msg void OnInterfacesNsiwebbrowfind(); + afx_msg void OnInterfacesNsieditingsession(); + afx_msg void OnInterfacesNsicommandmgr(); //}}AFX_MSG diff --git a/mozilla/embedding/qa/testembed/nsICommandMgr.cpp b/mozilla/embedding/qa/testembed/nsICommandMgr.cpp new file mode 100644 index 00000000000..24fc7ea43d5 --- /dev/null +++ b/mozilla/embedding/qa/testembed/nsICommandMgr.cpp @@ -0,0 +1,186 @@ +// nsICommandMgr.cpp : implementation file +// +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Epstein + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// File Overview.... +// +// nsICommandMgr.cpp : test implementations for nsICommandManager interface +// +#include "stdafx.h" +#include "testembed.h" +#include "nsICommandMgr.h" +#include "QaUtils.h" +#include "BrowserFrm.h" +#include "BrowserImpl.h" +#include "BrowserView.h" +#include "Tests.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// nsICommandMgr + +CnsICommandMgr::CnsICommandMgr(nsIWebBrowser *mWebBrowser) +{ + qaWebBrowser = mWebBrowser; +} + +CnsICommandMgr::~CnsICommandMgr() +{ +} + + +nsICommandManager * CnsICommandMgr::GetCommandMgrObject() +{ + nsCOMPtr cmdMgrObj = do_GetInterface(qaWebBrowser, &rv); + RvTestResult(rv, "GetCommandMgrObject() test", 1); + if (!cmdMgrObj) { + QAOutput("Didn't get nsICommandManager object."); + return nsnull; + } + return cmdMgrObj; +} + +nsICommandManager * CnsICommandMgr::GetCommandMgrWithContractIDObject() +{ + nsCOMPtr cmdMgrObj = do_CreateInstance(NS_COMMAND_MANAGER_CONTRACTID, &rv); + RvTestResult(rv, "GetCommandMgrWithContractIDObject() test", 1); + if (!cmdMgrObj) { + QAOutput("Didn't get nsICommandManager object."); + return nsnull; + } + return cmdMgrObj; +} + +nsICommandParams * CnsICommandMgr::GetCommandParamsObject() +{ + nsCOMPtr cmdParamsObj = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID,&rv); + RvTestResult(rv, "GetCommandParamsObject() test", 1); + if (!cmdParamsObj) { + QAOutput("Didn't get nsICommandParams object."); + return nsnull; + } + nsICommandParams *retVal = cmdParamsObj; + NS_ADDREF(retVal); + return retVal; +} + +void CnsICommandMgr::IsCommandSupportedTest(const char *aCommandName) +{ + PRBool isSupported; + + cmdMgrObj = GetCommandMgrObject(); + rv = cmdMgrObj->IsCommandSupported(aCommandName, &isSupported); + RvTestResult(rv, "IsCommandSupported() test", 2); + FormatAndPrintOutput("isSupported boolean = ", isSupported, 2); +} + +void CnsICommandMgr::IsCommandEnabledTest(const char *aCommandName) +{ + PRBool isEnabled; + + cmdMgrObj = GetCommandMgrObject(); + rv = cmdMgrObj->IsCommandEnabled(aCommandName, &isEnabled); + RvTestResult(rv, "IsCommandEnabled() test", 2); + FormatAndPrintOutput("isEnabled boolean = ", isEnabled, 2); +} + +void CnsICommandMgr::GetCommandStateTest(const char *aCommandName, const char *aParameter) +{ + PRBool enabled = PR_FALSE; + + cmdMgrObj = GetCommandMgrObject(); + cmdParamObj = GetCommandParamsObject(); + rv = cmdMgrObj->GetCommandState(aCommandName, cmdParamObj); + RvTestResult(rv, "GetCommandState() test", 2); + cmdParamObj->GetBooleanValue(aParameter, &enabled); + FormatAndPrintOutput("isEnabled boolean = ", enabled, 2); +} + +void CnsICommandMgr::DoCommandTest(const char *aCommandName, const char *value) +{ + cmdMgrObj = GetCommandMgrObject(); + cmdParamObj = GetCommandParamsObject(); + rv = cmdMgrObj->DoCommand(aCommandName, cmdParamObj); + RvTestResult(rv, "DoCommand() test", 2); + cmdParamObj->SetCStringValue("state_attribute", value); +} + +void CnsICommandMgr::OnStartTests(UINT nMenuID) +{ + switch(nMenuID) + { + case ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS : + RunAllTests(); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_ADDCOMMANDOBSERVER : + QAOutput("Not implemented yet.", 2); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_REMOVECOMMANDOBSERVER : + QAOutput("Not implemented yet.", 2); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED : + IsCommandSupportedTest("cmd_bold"); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED : + IsCommandEnabledTest("cmd_bold"); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE : + GetCommandStateTest("cmd_bold", "state_enabled"); + break; + case ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND : + nsCAutoString value; + DoCommandTest("cmd_bold", value.get()); + break; + } +} + +void CnsICommandMgr::RunAllTests() +{ + QAOutput("Not implemented yet.", 2); +} + + +///////////////////////////////////////////////////////////////////////////// +// CnsICommandMgr message handlers diff --git a/mozilla/embedding/qa/testembed/nsICommandMgr.h b/mozilla/embedding/qa/testembed/nsICommandMgr.h new file mode 100644 index 00000000000..9fde827e6dc --- /dev/null +++ b/mozilla/embedding/qa/testembed/nsICommandMgr.h @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Epstein + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// File Overview.... +// +// header file for nsIEditingSession interface tests +// +#if !defined(AFX_NSICOMMANDMGR_H__574F7B4A_B175_11D6_9BE0_00C04FA02BE6__INCLUDED_) +#define AFX_NSICOMMANDMGR_H__574F7B4A_B175_11D6_9BE0_00C04FA02BE6__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// nsICommandMgr.h : header file +// + +#include "BrowserView.h" +#include "BrowserImpl.h" +#include "StdAfx.h" +#include "Tests.h" + +///////////////////////////////////////////////////////////////////////////// +// nsICommandMgr window + +class CnsICommandMgr// : public nsIObserver, public nsSupportsWeakReference +{ +// Construction +public: + CnsICommandMgr(nsIWebBrowser *mWebBrowser); + + nsCOMPtr qaWebBrowser; + nsCOMPtr cmdMgrObj; + nsCOMPtr cmdParamObj; + // test methods +public: + nsICommandManager * GetCommandMgrObject(); + nsICommandManager * GetCommandMgrWithContractIDObject(); + nsICommandParams * GetCommandParamsObject(); + void IsCommandSupportedTest(const char *); + void IsCommandEnabledTest(const char *); + void GetCommandStateTest(const char *, const char *); + void DoCommandTest(const char *, const char *); + void OnStartTests(UINT nMenuID); + void RunAllTests(); +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CnsICommandMgr) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CnsICommandMgr(); + + // Generated message map functions +protected: + +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_NSICOMMANDMGR_H__574F7B4A_B175_11D6_9BE0_00C04FA02BE6__INCLUDED_) diff --git a/mozilla/embedding/qa/testembed/nsIEditSession.cpp b/mozilla/embedding/qa/testembed/nsIEditSession.cpp new file mode 100644 index 00000000000..0d0d734d638 --- /dev/null +++ b/mozilla/embedding/qa/testembed/nsIEditSession.cpp @@ -0,0 +1,200 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Epstein + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// File Overview.... +// +// nsIEditSession.cpp : test implementations for nsIEditingSession interface +// + +#include "stdafx.h" +#include "testembed.h" +#include "nsIEditSession.h" +#include "QaUtils.h" +#include "BrowserFrm.h" +#include "BrowserImpl.h" +#include "BrowserView.h" +#include "Tests.h" +#include "nsIEditor.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// nsIEditSession + +CnsIEditSession::CnsIEditSession(nsIWebBrowser *mWebBrowser) +{ + qaWebBrowser = mWebBrowser; +} + +CnsIEditSession::~CnsIEditSession() +{ +} + +nsIEditingSession * CnsIEditSession::GetEditSessionObject() +{ + editingSession = do_GetInterface(qaWebBrowser); + if (!editingSession) { + QAOutput("Didn't get nsIEditingSession object."); + return nsnull; + } + + return (editingSession); +} + +void CnsIEditSession::InitTest() +{ + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv = editingSession->Init(domWindow); + RvTestResult(rv, "Init() test", 2); + } + else + QAOutput("Didn't get object(s) for InitTest() test. Test failed.", 1); +} + +void CnsIEditSession::MakeWinEditTest(PRBool afterUriLoad) +{ + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv= editingSession->MakeWindowEditable(domWindow, afterUriLoad); + RvTestResult(rv, "MakeWindowEditable() test", 2); + } + else + QAOutput("Didn't get object(s) for MakeWindowEditable() test. Test failed.", 1); +} + +void CnsIEditSession::WinIsEditTest(PRBool outIsEditable) +{ + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv = editingSession->WindowIsEditable(domWindow, &outIsEditable); + RvTestResult(rv, "WindowIsEditable() test", 2); + FormatAndPrintOutput("the outIsEditable boolean = ", outIsEditable, 2); + } + else + QAOutput("Didn't get object(s) for WinIsEditTest() test. Test failed.", 1); +} + +void CnsIEditSession::GetEditorWinTest() +{ + nsCOMPtr theEditor; +// nsIEditor *theEditor = nsnull; + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv = editingSession->GetEditorForWindow(domWindow, getter_AddRefs(theEditor)); + RvTestResult(rv, "GetEditorForWindow() test", 2); + if (!theEditor) + QAOutput("Didn't get the Editor object."); + } + else + QAOutput("Didn't get object(s) for WinIsEditTest() test. Test failed.", 1); +} + +void CnsIEditSession::SetEditorWinTest() +{ + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv = editingSession->SetupEditorOnWindow(domWindow); + RvTestResult(rv, "SetupEditorOnWindow() test", 2); + } + else + QAOutput("Didn't get object(s) for SetEditorWinTest() test. Test failed.", 1); +} + +void CnsIEditSession::TearEditorWinTest() +{ + editingSession = GetEditSessionObject(); + domWindow = GetTheDOMWindow(qaWebBrowser); + if (domWindow && editingSession) { + rv = editingSession->TearDownEditorOnWindow(domWindow); + RvTestResult(rv, "TearDownEditorOnWindow() test", 2); + } + else + QAOutput("Didn't get object(s) for TearEditorWinTest() test. Test failed.", 1); +} + +void CnsIEditSession::OnStartTests(UINT nMenuID) +{ + switch(nMenuID) + { + case ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS : + RunAllTests(); + break; + case ID_INTERFACES_NSIEDITINGSESSION_INIT : + InitTest(); + break; + case ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE : + MakeWinEditTest(PR_FALSE); + break; + case ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE : + WinIsEditTest(PR_TRUE); + break; + case ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW : + GetEditorWinTest(); + break; + case ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW : + SetEditorWinTest(); + break; + case ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW : + TearEditorWinTest(); + break; + } +} + +void CnsIEditSession::RunAllTests() +{ + InitTest(); + MakeWinEditTest(PR_FALSE); + WinIsEditTest(PR_TRUE); + GetEditorWinTest(); +// SetEditorWinTest(); + TearEditorWinTest(); +} + +///////////////////////////////////////////////////////////////////////////// +// CnsIEditSession message handlers diff --git a/mozilla/embedding/qa/testembed/nsIEditSession.h b/mozilla/embedding/qa/testembed/nsIEditSession.h new file mode 100644 index 00000000000..1f7c2ff274b --- /dev/null +++ b/mozilla/embedding/qa/testembed/nsIEditSession.h @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Epstein + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// File Overview.... +// +// header file for nsIEditingSession interface tests +// + +#if !defined(AFX_NSIEDITSESSION_H__4C854323_B0B8_11D6_9BE0_00C04FA02BE6__INCLUDED_) +#define AFX_NSIEDITSESSION_H__4C854323_B0B8_11D6_9BE0_00C04FA02BE6__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// nsIEditSession.h : header file +// + +#include "BrowserView.h" +#include "BrowserImpl.h" +#include "StdAfx.h" +#include "Tests.h" + +///////////////////////////////////////////////////////////////////////////// +// nsIEditSession window + +class CnsIEditSession +{ +// Construction +public: + CnsIEditSession(nsIWebBrowser *mWebBrowser); + + nsCOMPtr qaWebBrowser; +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CnsIEditSession) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CnsIEditSession(); + + // local methods for nsIEditingSession tests + nsIEditingSession * GetEditSessionObject(); + void InitTest(void); + void MakeWinEditTest(PRBool); + void WinIsEditTest(PRBool); + void SetEditorWinTest(void); + void GetEditorWinTest(void); + void TearEditorWinTest(void); + void OnStartTests(UINT nMenuID); + void RunAllTests(void); + + nsCOMPtr editingSession; + nsCOMPtr domWindow; + // Generated message map functions +protected: + +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_NSIEDITSESSION_H__4C854323_B0B8_11D6_9BE0_00C04FA02BE6__INCLUDED_) diff --git a/mozilla/embedding/qa/testembed/nsIObserServ.cpp b/mozilla/embedding/qa/testembed/nsIObserServ.cpp index 4d107b312d3..34758f18bb3 100644 --- a/mozilla/embedding/qa/testembed/nsIObserServ.cpp +++ b/mozilla/embedding/qa/testembed/nsIObserServ.cpp @@ -221,8 +221,6 @@ void CnsIObserServ::EnumerateObserversTest() RvTestResult(rv, "nsIObserver() test", 1); // compare 'this' with observer object - // if (this ==(CnsIObserServ *)observer) - if( this == NS_REINTERPRET_CAST(CnsIObserServ*,NS_REINTERPRET_CAST(void*, observer.get()))) { QAOutput("observers match. Test passes."); diff --git a/mozilla/embedding/qa/testembed/resource.h b/mozilla/embedding/qa/testembed/resource.h index d1009875670..c9cb74d9942 100644 --- a/mozilla/embedding/qa/testembed/resource.h +++ b/mozilla/embedding/qa/testembed/resource.h @@ -233,6 +233,20 @@ #define ID_INTERFACES_NSIWEBBROWSERFIND_GETMATCHCASE 32962 #define ID_INTERFACES_NSIWEBBROWSERFIND_SETSEARCHFRAMES 32963 #define ID_INTERFACES_NSIWEBBROWSERFIND_GETSEARCHFRAMES 32964 +#define ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS 32966 +#define ID_INTERFACES_NSIEDITINGSESSION_INIT 32967 +#define ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE 32968 +#define ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE 32969 +#define ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW 32970 +#define ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW 32971 +#define ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW 32972 +#define ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS 32973 +#define ID_INTERFACES_NSICOMMANDMANAGER_ADDCOMMANDOBSERVER 32974 +#define ID_INTERFACES_NSICOMMANDMANAGER_REMOVECOMMANDOBSERVER 32975 +#define ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED 32976 +#define ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED 32977 +#define ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE 32978 +#define ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND 32979 #define ID_CLIPBOARDCMD_PASTE 42789 #define ID_CLIPBOARDCMD_COPYSELECTION 42790 #define ID_CLIPBOARDCMD_SELECTALL 42791 @@ -249,7 +263,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 153 -#define _APS_NEXT_COMMAND_VALUE 32965 +#define _APS_NEXT_COMMAND_VALUE 32980 #define _APS_NEXT_CONTROL_VALUE 1033 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/mozilla/embedding/qa/testembed/testembed.aps b/mozilla/embedding/qa/testembed/testembed.aps index 1d43a9214b1..9390153adb9 100644 Binary files a/mozilla/embedding/qa/testembed/testembed.aps and b/mozilla/embedding/qa/testembed/testembed.aps differ diff --git a/mozilla/embedding/qa/testembed/testembed.dsp b/mozilla/embedding/qa/testembed/testembed.dsp index f0cc924a68f..c6748b33489 100644 --- a/mozilla/embedding/qa/testembed/testembed.dsp +++ b/mozilla/embedding/qa/testembed/testembed.dsp @@ -126,6 +126,10 @@ SOURCE=.\DomWindow.cpp # End Source File # Begin Source File +SOURCE=.\EditingSession.cpp +# End Source File +# Begin Source File + SOURCE=.\MostRecentUrls.cpp # End Source File # Begin Source File @@ -138,6 +142,10 @@ SOURCE=.\nsiDirServ.cpp # End Source File # Begin Source File +SOURCE=.\nsIEditSession.cpp +# End Source File +# Begin Source File + SOURCE=.\nsiHistory.cpp # End Source File # Begin Source File @@ -242,6 +250,10 @@ SOURCE=.\DomWindow.h # End Source File # Begin Source File +SOURCE=.\EditingSession.h +# End Source File +# Begin Source File + SOURCE=.\IBrowserFrameGlue.h # End Source File # Begin Source File @@ -258,6 +270,10 @@ SOURCE=.\nsiDirServ.h # End Source File # Begin Source File +SOURCE=.\nsIEditSession.h +# End Source File +# Begin Source File + SOURCE=.\nsIFile.h # End Source File # Begin Source File diff --git a/mozilla/embedding/qa/testembed/testembed.rc b/mozilla/embedding/qa/testembed/testembed.rc index 1af8876105b..7cc6a988814 100644 --- a/mozilla/embedding/qa/testembed/testembed.rc +++ b/mozilla/embedding/qa/testembed/testembed.rc @@ -434,7 +434,6 @@ BEGIN MENUITEM "RemoveObservers", ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS END - POPUP "nsIWebBrowser" BEGIN MENUITEM "", ID_INTERFACES_NSIWEBBROWSER @@ -503,6 +502,43 @@ BEGIN MENUITEM "GetSearchFrames", ID_INTERFACES_NSIWEBBROWSERFIND_GETSEARCHFRAMES END + POPUP "nsIEditingSession" + BEGIN + MENUITEM "RunAllTests", ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS + + MENUITEM SEPARATOR + MENUITEM "Init", ID_INTERFACES_NSIEDITINGSESSION_INIT + + MENUITEM "MakeWindowEditable", ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE + + MENUITEM "WindowIsEditable", ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE + + MENUITEM "GetEditorForWindow", ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW + + MENUITEM "SetupEditorOnWindow", ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW + + MENUITEM "TearDownEditorOnWindow", ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW + + END + POPUP "nsICommandManager" + BEGIN + MENUITEM "Run All Tests", ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS + + MENUITEM SEPARATOR + MENUITEM "AddCommandObserver", ID_INTERFACES_NSICOMMANDMANAGER_ADDCOMMANDOBSERVER + + MENUITEM "RemoveCommandObserver", ID_INTERFACES_NSICOMMANDMANAGER_REMOVECOMMANDOBSERVER + + MENUITEM SEPARATOR + MENUITEM "IsCommandeSupported", ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED + + MENUITEM "IsCOmmandEnabled", ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED + + MENUITEM "GetCommandState", ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE + + MENUITEM "DoCOmmand", ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND + + END END POPUP "T&ools" BEGIN