Back to index

lightning-sunbird  0.9+nobinonly
Tests.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* vim:set ts=4 sw=4 sts=4 cindent noexpandtab: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   David Epstein <depstein@netscape.com>
00025  *   Dharma Sirnapalli <dsirnapalli@netscape.com>
00026  *   Ashish Bhatt <ashishbhatt@netscape.com>
00027  *
00028  * Alternatively, the contents of this file may be used under the terms of
00029  * either the GNU General Public License Version 2 or later (the "GPL"), or
00030  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00031  * in which case the provisions of the GPL or the LGPL are applicable instead
00032  * of those above. If you wish to allow use of your version of this file only
00033  * under the terms of either the GPL or the LGPL, and not to allow others to
00034  * use your version of this file under the terms of the MPL, indicate your
00035  * decision by deleting the provisions above and replace them with the notice
00036  * and other provisions required by the GPL or the LGPL. If you do not delete
00037  * the provisions above, a recipient may use your version of this file under
00038  * the terms of any one of the MPL, the GPL or the LGPL.
00039  *
00040  * ***** END LICENSE BLOCK ***** */
00041 
00042 
00043 // File Overview....
00044 //
00045 // These are QA test case implementations
00046 //
00047 
00048 
00049 #include "stdafx.h"
00050 #include "TestEmbed.h"
00051 #include "BrowserImpl.h"
00052 #include "BrowserFrm.h"
00053 #include "UrlDialog.h"
00054 #include "ProfileMgr.h"
00055 #include "ProfilesDlg.h"
00056 #include "Tests.h"
00057 #include "nsihistory.h"
00058 #include "nsiwebnav.h"
00059 #include "nsirequest.h"
00060 #include "nsidirserv.h"
00061 #include "domwindow.h"
00062 #include "selection.h"
00063 #include "nsProfile.h"
00064 #include "nsIClipboardCmd.h"
00065 #include "nsIObserServ.h"
00066 #include "nsIFile.h"
00067 #include "nsIWebBrow.h"
00068 #include "nsIWebProg.h"
00069 #include "nsIWebBrowFind.h"
00070 #include "nsIEditSession.h"
00071 #include "nsICommandMgr.h"
00072 #include "nsICmdParams.h"
00073 #include "QaUtils.h"
00074 #include "nsIIOService.h"
00075 #include "nsIChannelTests.h"
00076 #include "nsIHttpChannelTests.h"
00077 #include <stdio.h>
00078 
00079 #ifdef _DEBUG
00080 #define new DEBUG_NEW
00081 #undef THIS_FILE
00082 static char THIS_FILE[] = __FILE__;
00083 #endif
00084 
00085 nsresult rv;
00086 
00087 // Register message for FindDialog communication
00088 static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING);
00089 
00090 BEGIN_MESSAGE_MAP(CTests, CWnd)
00091        //{{AFX_MSG_MAP(CTests)
00092        ON_COMMAND(ID_TESTS_CHANGEURL, OnTestsChangeUrl)
00093        ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
00094        ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
00095        ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
00096        ON_COMMAND(ID_TESTS_ADDTOOLTIPLISTENER, OnTestsAddTooltipListener)
00097        ON_COMMAND(ID_TESTS_ADDWEBPROGLISTENER, OnTestsAddWebProgListener)
00098        ON_COMMAND(ID_TESTS_ADDHISTORYLISTENER, OnTestsAddHistoryListener)
00099        ON_COMMAND(ID_TESTS_REMOVEHISTORYLISTENER, OnTestsRemovehistorylistener)
00100        ON_COMMAND(ID_TESTS_ADDURICONTENTLISTENER_ADDFROMNSIWEBBROWSER, OnTestsAddUriContentListenerByWebBrowser)
00101        ON_COMMAND(ID_TESTS_ADDURICONTENTLISTENER_ADDFROMNSIURILOADER, OnTestsAddUriContentListenerByUriLoader)
00102        ON_COMMAND(ID_TESTS_ADDURICONTENTLISTENER_OPENURI, OnTestsAddUriContentListenerByOpenUri)
00103        ON_COMMAND(ID_TESTS_NSNEWCHANNEL, OnTestsNSNewChannelAndAsyncOpen)
00104        ON_COMMAND(ID_TESTS_NSIIOSERVICENEWURI, OnTestsIOServiceNewURI)
00105        ON_COMMAND(ID_TESTS_NSIPROTOCOLHANDLERNEWURI, OnTestsProtocolHandlerNewURI)
00106        ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
00107        ON_COMMAND(ID_TOOLS_REMOVEALLGH, OnToolsRemoveAllGH)
00108        ON_COMMAND(ID_TOOLS_VIEWLOGFILE, OnToolsViewLogfile)
00109        ON_COMMAND(ID_TOOLS_DELETELOGFILE, OnToolsDeleteLogfile)
00110        ON_COMMAND(ID_TOOLS_TESTYOURMETHOD, OnToolsTestYourMethod)
00111        ON_COMMAND(ID_TOOLS_TESTYOURMETHOD2, OnToolsTestYourMethod2)
00112        ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
00113        ON_COMMAND(ID_VERIFYBUGS_90195, OnVerifybugs90195)
00114        ON_COMMAND(ID_VERIFYBUGS_169617, OnVerifybugs169617)
00115        ON_COMMAND(ID_VERIFYBUGS_170274, OnVerifybugs170274)
00116        ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_INIT, OnInterfacesNsidirectoryservice)
00117        ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_REGISTERPROVIDER, OnInterfacesNsidirectoryservice)
00118        ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS, OnInterfacesNsidirectoryservice)
00119        ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER, OnInterfacesNsidirectoryservice)
00120        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_RUNALLTESTS, OnInterfacesNsidomwindow)
00121        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETDOMDOCUMENT, OnInterfacesNsidomwindow)
00122        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETFRAMES, OnInterfacesNsidomwindow)
00123        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETNAME, OnInterfacesNsidomwindow)
00124        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETPARENT, OnInterfacesNsidomwindow)
00125        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCROLLBARS, OnInterfacesNsidomwindow)
00126        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCROLLY, OnInterfacesNsidomwindow)
00127        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCSOLLX, OnInterfacesNsidomwindow)
00128        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSELECTION, OnInterfacesNsidomwindow)
00129        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBY, OnInterfacesNsidomwindow)
00130        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYLINES, OnInterfacesNsidomwindow)
00131        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYPAGES, OnInterfacesNsidomwindow)
00132        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLTO, OnInterfacesNsidomwindow)
00133        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SIZETOCONTENT, OnInterfacesNsidomwindow)
00134        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETTEXTZOOM, OnInterfacesNsidomwindow)
00135        ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SETTEXTZOOM, OnInterfacesNsidomwindow)
00136        ON_COMMAND(ID_INTERFACES_NSISELECTION_RUNALLTESTS, OnInterfacesNsiselection)
00137        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETANCHORNODE, OnInterfacesNsiselection)
00138        ON_COMMAND(ID_INTERFACES_NSISELECTION_ADDRANGE, OnInterfacesNsiselection)
00139        ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSE, OnInterfacesNsiselection)
00140        ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSETOEND, OnInterfacesNsiselection)
00141        ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSETOSTART, OnInterfacesNsiselection)
00142        ON_COMMAND(ID_INTERFACES_NSISELECTION_CONTAINSNODE, OnInterfacesNsiselection)
00143        ON_COMMAND(ID_INTERFACES_NSISELECTION_DELETEFROMDOCUMENT, OnInterfacesNsiselection)
00144        ON_COMMAND(ID_INTERFACES_NSISELECTION_EXTEND, OnInterfacesNsiselection)
00145        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETANCHOROFFSET, OnInterfacesNsiselection)
00146        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETFOCUSNODE, OnInterfacesNsiselection)
00147        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETFOCUSOFFSET, OnInterfacesNsiselection)
00148        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETISCOLLAPSED, OnInterfacesNsiselection)
00149        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETRANGEAT, OnInterfacesNsiselection)
00150        ON_COMMAND(ID_INTERFACES_NSISELECTION_GETRANGECOUNT, OnInterfacesNsiselection)
00151        ON_COMMAND(ID_INTERFACES_NSISELECTION_REMOVEALLRANGES, OnInterfacesNsiselection)
00152        ON_COMMAND(ID_INTERFACES_NSISELECTION_REMOVERANGE, OnInterfacesNsiselection)
00153        ON_COMMAND(ID_INTERFACES_NSISELECTION_SELECTALLCHILDREN, OnInterfacesNsiselection)
00154        ON_COMMAND(ID_INTERFACES_NSISELECTION_SELECTIONLANGUAGECHANGE, OnInterfacesNsiselection)
00155        ON_COMMAND(ID_INTERFACES_NSISELECTION_TOSTRING, OnInterfacesNsiselection)
00156        ON_COMMAND(ID_INTERFACES_NSIPROFILE_RUNALLTESTS, OnInterfacesNsiprofile)
00157        ON_COMMAND(ID_INTERFACES_NSIPROFILE_CLONEPROFILE, OnInterfacesNsiprofile)
00158        ON_COMMAND(ID_INTERFACES_NSIPROFILE_CREATENEWPROFILE, OnInterfacesNsiprofile)
00159        ON_COMMAND(ID_INTERFACES_NSIPROFILE_DELETEPROFILE, OnInterfacesNsiprofile)
00160        ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETCURRENTPROFILE, OnInterfacesNsiprofile)
00161        ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETPROFILECOUNT, OnInterfacesNsiprofile)
00162        ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETPROFILELIST, OnInterfacesNsiprofile)
00163        ON_COMMAND(ID_INTERFACES_NSIPROFILE_PROFILEEXISTS, OnInterfacesNsiprofile)
00164        ON_COMMAND(ID_INTERFACES_NSIPROFILE_RENAMEPROFILE, OnInterfacesNsiprofile)
00165        ON_COMMAND(ID_INTERFACES_NSIPROFILE_SETCURRENTPROFILE, OnInterfacesNsiprofile)
00166        ON_COMMAND(ID_INTERFACES_NSIPROFILE_SHUTDOWNCURRENTPROFILE, OnInterfacesNsiprofile)
00167        ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETCOUNT, OnInterfacesNsishistory)
00168        ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETENTRYATINDEX, OnInterfacesNsishistory)
00169        ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETINDEX, OnInterfacesNsishistory)
00170        ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETMAXLENGTH, OnInterfacesNsishistory)
00171        ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETSHISTORYENUMERATOR, OnInterfacesNsishistory)
00172        ON_COMMAND(ID_INTERFACES_NSISHISTORY_PURGEHISTORY, OnInterfacesNsishistory)
00173        ON_COMMAND(ID_INTERFACES_NSISHISTORY_RUNALLTESTS, OnInterfacesNsishistory)
00174        ON_COMMAND(ID_INTERFACES_NSISHISTORY_SETMAXLENGTH, OnInterfacesNsishistory)
00175        ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETISSUBFRAME, OnInterfacesNsishistory)
00176        ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETTITLE, OnInterfacesNsishistory)
00177        ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETURI, OnInterfacesNsishistory)
00178        ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_RUNALLTESTS, OnInterfacesNsishistory)
00179        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETCANGOBACK, OnInterfacesNsiwebnav)
00180        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETCANGOFORWARD, OnInterfacesNsiwebnav)
00181        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETCURRENTURI, OnInterfacesNsiwebnav)
00182        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETREFERRINGURI, OnInterfacesNsiwebnav)
00183        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETDOCUMENT, OnInterfacesNsiwebnav)
00184        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETSESSIONHISTORY, OnInterfacesNsiwebnav)
00185        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GOBACK, OnInterfacesNsiwebnav)
00186        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GOFORWARD, OnInterfacesNsiwebnav)
00187        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GOTOINDEX, OnInterfacesNsiwebnav)
00188        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_LOADURI, OnInterfacesNsiwebnav)
00189        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_RELOAD, OnInterfacesNsiwebnav)
00190        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_RUNALLTESTS, OnInterfacesNsiwebnav)
00191        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_SETSESSIONHISTORY, OnInterfacesNsiwebnav)
00192        ON_COMMAND(ID_INTERFACES_NSIWEBNAV_STOP, OnInterfacesNsiwebnav)
00193        ON_COMMAND(ID_INTERFACES_NSICHANNEL_RUNALLTESTS, OnInterfacesNsichannel)
00194        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETORIGINALURI, OnInterfacesNsichannel)
00195        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETORIGINALURI, OnInterfacesNsichannel)
00196        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETURI, OnInterfacesNsichannel)
00197        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETOWNER, OnInterfacesNsichannel)
00198        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETOWNER, OnInterfacesNsichannel)
00199        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETNOTIFICATIONS, OnInterfacesNsichannel)
00200        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETNOTIFICATIONS, OnInterfacesNsichannel)
00201        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETSECURITYINFO, OnInterfacesNsichannel)
00202        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETCONTENTTYPE, OnInterfacesNsichannel)
00203        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETCONTENTTYPE, OnInterfacesNsichannel)
00204        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETCONTENTCHARSET, OnInterfacesNsichannel)
00205        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETCONTENTCHARSET, OnInterfacesNsichannel)
00206        ON_COMMAND(ID_INTERFACES_NSICHANNEL_SETCONTENTLENGTH, OnInterfacesNsichannel)
00207        ON_COMMAND(ID_INTERFACES_NSICHANNEL_GETCONTENTLENGTH, OnInterfacesNsichannel)
00208        ON_COMMAND(ID_INTERFACES_NSICHANNEL_OPEN, OnInterfacesNsichannel)
00209        ON_COMMAND(ID_INTERFACES_NSICHANNEL_ASYNCOPEN, OnInterfacesNsichannel)
00210        ON_COMMAND(ID_INTERFACES_NSIREQUEST_GETLOADFLAGS, OnInterfacesNsirequest)
00211        ON_COMMAND(ID_INTERFACES_NSIREQUEST_GETLOADGROUP, OnInterfacesNsirequest)
00212        ON_COMMAND(ID_INTERFACES_NSIREQUEST_GETNAME, OnInterfacesNsirequest)
00213        ON_COMMAND(ID_INTERFACES_NSIREQUEST_GETSTATUS, OnInterfacesNsirequest)
00214        ON_COMMAND(ID_INTERFACES_NSIREQUEST_ISPENDING, OnInterfacesNsirequest)
00215        ON_COMMAND(ID_INTERFACES_NSIREQUEST_CANCEL, OnInterfacesNsirequest)
00216        ON_COMMAND(ID_INTERFACES_NSIREQUEST_RESUME, OnInterfacesNsirequest)
00217        ON_COMMAND(ID_INTERFACES_NSIREQUEST_SETLOADFLAGS, OnInterfacesNsirequest)
00218        ON_COMMAND(ID_INTERFACES_NSIREQUEST_SETLOADGROUP, OnInterfacesNsirequest)
00219        ON_COMMAND(ID_INTERFACES_NSIREQUEST_SUSPEND, OnInterfacesNsirequest)
00220        ON_COMMAND(ID_INTERFACES_NSIREQUEST_RUNALLTESTS, OnInterfacesNsirequest)
00221        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION, OnInterfacesNsiclipboardcommands)
00222        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION, OnInterfacesNsiclipboardcommands)
00223        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANPASTE, OnInterfacesNsiclipboardcommands)
00224        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION, OnInterfacesNsiclipboardcommands)
00225        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYSELECTION, OnInterfacesNsiclipboardcommands)
00226        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION, OnInterfacesNsiclipboardcommands)
00227        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_PASTE, OnInterfacesNsiclipboardcommands)
00228        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTALL, OnInterfacesNsiclipboardcommands)
00229        ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTNONE, OnInterfacesNsiclipboardcommands)
00230        ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS, OnInterfacesNsiobserverservice)
00231        ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS, OnInterfacesNsiobserverservice)
00232        ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_NOTIFYOBSERVERS, OnInterfacesNsiobserverservice)
00233        ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS, OnInterfacesNsiobserverservice)
00234        ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS, OnInterfacesNsiobserverservice)
00235        ON_COMMAND(ID_INTERFACES_NSIFILE_APPENDRELATICEPATH, OnInterfacesNsifile)
00236        ON_COMMAND(ID_INTERFACES_NSIFILE_COPYTO, OnInterfacesNsifile)
00237        ON_COMMAND(ID_INTERFACES_NSIFILE_CREATE, OnInterfacesNsifile)
00238        ON_COMMAND(ID_INTERFACES_NSIFILE_EXISTS, OnInterfacesNsifile)
00239        ON_COMMAND(ID_INTERFACES_NSIFILE_INITWITHPATH, OnInterfacesNsifile)
00240        ON_COMMAND(ID_INTERFACES_NSIFILE_MOVETO, OnInterfacesNsifile)
00241        ON_COMMAND(ID_INTERFACES_NSIFILE_RUNALLTESTS, OnInterfacesNsifile)
00242        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_RUNALLTESTS, OnInterfacesNsiwebbrowser)
00243        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_ADDWEBBROWSERLISTENER, OnInterfacesNsiwebbrowser)
00244        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_REMOVEWEBBROWSERLISTENER, OnInterfacesNsiwebbrowser)
00245        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_GETCONTAINERWINDOW, OnInterfacesNsiwebbrowser)
00246        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_SETCONTAINERWINDOW, OnInterfacesNsiwebbrowser)
00247        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_GETPARENTURICONTENTLISTENER, OnInterfacesNsiwebbrowser)
00248        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_SETPARENTURICONTENTLISTENER, OnInterfacesNsiwebbrowser)
00249        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_GETCONTENTDOMWINDOW, OnInterfacesNsiwebbrowser)
00250        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSER_NSIWBSETUPSETPROPERTY, OnInterfacesNsiwebbrowser)
00251        ON_COMMAND(ID_INTERFACES_NSIWEBPROGRESS_RUNALLTESTS, OnInterfacesNsiwebprogress)
00252        ON_COMMAND(ID_INTERFACES_NSIWEBPROGRESS_ADDPROGRESSLISTENER, OnInterfacesNsiwebprogress)
00253        ON_COMMAND(ID_INTERFACES_NSIWEBPROGRESS_REMOVEPROGRESSLISTENER, OnInterfacesNsiwebprogress)
00254        ON_COMMAND(ID_INTERFACES_NSIWEBPROGRESS_GETDOMWINDOW, OnInterfacesNsiwebprogress)
00255        ON_COMMAND(ID_INTERFACES_NSIWEBPROGRESS_ISLOADINGDOCUMENT, OnInterfacesNsiwebprogress)
00256        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_RUNALLTESTS, OnInterfacesNsiwebbrowfind)
00257        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETSEARCHSTRINGTEST, OnInterfacesNsiwebbrowfind)
00258        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETSEARCHSTRINGTEST, OnInterfacesNsiwebbrowfind)
00259        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_FINDNEXTTEST, OnInterfacesNsiwebbrowfind)
00260        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETFINDBACKWARDSTEST, OnInterfacesNsiwebbrowfind)
00261        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETFINDBACKWARDSTEST, OnInterfacesNsiwebbrowfind)
00262        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETWRAPFINDTEST, OnInterfacesNsiwebbrowfind)
00263        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETWRAPFINDTEST, OnInterfacesNsiwebbrowfind)
00264        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETENTIREWORDTEST, OnInterfacesNsiwebbrowfind)
00265        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETENTIREWORDTEST, OnInterfacesNsiwebbrowfind)
00266        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETMATCHCASE, OnInterfacesNsiwebbrowfind)
00267        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETMATCHCASE, OnInterfacesNsiwebbrowfind)
00268        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_SETSEARCHFRAMES, OnInterfacesNsiwebbrowfind)
00269        ON_COMMAND(ID_INTERFACES_NSIWEBBROWSERFIND_GETSEARCHFRAMES, OnInterfacesNsiwebbrowfind)
00270        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS, OnInterfacesNsieditingsession)
00271        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_INIT, OnInterfacesNsieditingsession)
00272        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_MAKEWINDOWEDITABLE, OnInterfacesNsieditingsession)
00273        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_WINDOWISEDITABLE, OnInterfacesNsieditingsession)
00274        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_GETEDITORFORWINDOW, OnInterfacesNsieditingsession)
00275        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_SETUPEDITORONWINDOW, OnInterfacesNsieditingsession)
00276        ON_COMMAND(ID_INTERFACES_NSIEDITINGSESSION_TEARDOWNEDITORONWINDOW, OnInterfacesNsieditingsession)
00277        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS, OnInterfacesNsicommandmgr)
00278        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ADDCOMMANDOBSERVER, OnInterfacesNsicommandmgr)
00279        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_REMOVECOMMANDOBSERVER, OnInterfacesNsicommandmgr)
00280        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDESUPPORTED, OnInterfacesNsicommandmgr)
00281        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_ISCOMMANDENABLED, OnInterfacesNsicommandmgr)
00282        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_GETCOMMANDSTATE, OnInterfacesNsicommandmgr)
00283        ON_COMMAND(ID_INTERFACES_NSICOMMANDMANAGER_DOCOMMAND, OnInterfacesNsicommandmgr)
00284        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_RUNALLTESTS, OnInterfacesNsicmdparams)
00285        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETVALUETYPE, OnInterfacesNsicmdparams)
00286        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETBOOLEANVALUE, OnInterfacesNsicmdparams)
00287        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETLONGVALUE, OnInterfacesNsicmdparams)
00288        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETDOUBLEVALUE, OnInterfacesNsicmdparams)
00289        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETSTRINGVALUE, OnInterfacesNsicmdparams)
00290        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETCSTRINGVALUE, OnInterfacesNsicmdparams)
00291        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETISUPPORTSVALUE, OnInterfacesNsicmdparams)
00292        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETBOOLEANVALUE, OnInterfacesNsicmdparams)
00293        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETLONGVALUE, OnInterfacesNsicmdparams)
00294        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETDOUBLEVALUE, OnInterfacesNsicmdparams)
00295        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETSTRINGVALUE, OnInterfacesNsicmdparams)
00296        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETCSTRINGVALUE, OnInterfacesNsicmdparams)
00297        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_SETISUPPORTSVALUE, OnInterfacesNsicmdparams)
00298        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_REMOVEVALUE, OnInterfacesNsicmdparams)
00299        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_HASMOREELEMENTS, OnInterfacesNsicmdparams)
00300        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_FIRST, OnInterfacesNsicmdparams)
00301        ON_COMMAND(ID_INTERFACES_NSICOMMANDPARAMS_GETNEXT, OnInterfacesNsicmdparams)
00302        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_RUNALLTESTS ,OnInterfacesNsihttpchannel)
00303        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTMETHOD, OnInterfacesNsihttpchannel)
00304        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTMETHOD, OnInterfacesNsihttpchannel)
00305        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_SETREFERRER, OnInterfacesNsihttpchannel)
00306        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETREFERRER, OnInterfacesNsihttpchannel)
00307        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_SETREQUESTHEADER, OnInterfacesNsihttpchannel)
00308        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETREQUESTHEADER, OnInterfacesNsihttpchannel)
00309        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_VISITREQUESTHEADERS, OnInterfacesNsihttpchannel)
00310        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_SETALLOWPIPELINING, OnInterfacesNsihttpchannel)    
00311        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETALLOWPIPELINING, OnInterfacesNsihttpchannel)    
00312        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_SETREDIRECTIONLIMIT, OnInterfacesNsihttpchannel)
00313        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETREDIRECTIONLIMIT, OnInterfacesNsihttpchannel)
00314        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUS, OnInterfacesNsihttpchannel)
00315        ON_COMMAND(ID_INTERFACES_NSIHTTPCHANNEL_GETRESPONSESTATUSTEXT, OnInterfacesNsihttpchannel)
00316        ON_COMMAND(ID_INTERFACES_RUNALLTESTCASES, OnInterfacesRunalltestcases)
00317        
00318        //}}AFX_MSG_MAP
00319 
00320 END_MESSAGE_MAP()
00321 
00322 //static declarations
00323 //nsCOMPtr<nsIWebBrowser> CTests::qaWebBrowser;
00324 
00325 //end static declarations
00326 
00327 CTests::CTests(nsIWebBrowser* mWebBrowser,
00328                         nsIBaseWindow* mBaseWindow,
00329                         nsIWebNavigation* mWebNav,
00330                         CBrowserImpl *mpBrowserImpl)
00331 {
00332        qaWebBrowser = mWebBrowser;
00333        qaBaseWindow = mBaseWindow;
00334        qaWebNav = mWebNav;
00335        qaBrowserImpl = mpBrowserImpl;
00336 }
00337 
00338 CTests::~CTests()
00339 {
00340 
00341 }
00342 
00343 
00344 // *********************************************************
00345 // depstein: Start QA test cases here
00346 // *********************************************************
00347 
00348 void CTests::OnTestsChangeUrl()
00349 {
00350        if (!qaWebNav)
00351        {
00352               QAOutput("Web navigation object not found. Change URL test not performed.", 2);
00353               return;
00354        }
00355 
00356        if (myDialog.DoModal() == IDOK)
00357        {
00358               QAOutput("Begin Change URL test.", 1);
00359               rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(myDialog.m_urlfield).get(),
00360                                                         myDialog.m_flagvalue, nsnull,nsnull, nsnull);
00361 
00362            RvTestResult(rv, "rv LoadURI() test", 1);
00363               FormatAndPrintOutput("The url = ", myDialog.m_urlfield, 2);
00364               FormatAndPrintOutput("The flag = ", myDialog.m_flagvalue, 1);
00365               QAOutput("End Change URL test.", 1);
00366        }
00367        else
00368               QAOutput("Change URL test not executed.", 1);
00369 }
00370 
00371 // *********************************************************
00372 
00373 void CTests::OnTestsGlobalHistory()
00374 {
00375        // create instance of myHistory object. Call's XPCOM
00376        // service manager to pass the contract ID.
00377 
00378        PRBool theRetVal = PR_FALSE;
00379 
00380        nsCOMPtr<nsIGlobalHistory> myHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
00381 
00382        if (!myHistory)
00383        {
00384               QAOutput("Couldn't find history object. No GH tests performed.", 2);
00385               return;
00386        }
00387 
00388        if (myDialog.DoModal() == IDOK)
00389        {
00390               QAOutput("Begin IsVisited() and AddPage() tests.", 2);
00391               FormatAndPrintOutput("The history url = ", myDialog.m_urlfield, 1);
00392 
00393               // see if url is already in the GH file (pre-AddPage() test)
00394               rv = myHistory->IsVisited(myDialog.m_urlfield, &theRetVal);
00395            RvTestResult(rv, "rv IsVisited() test", 1);
00396               FormatAndPrintOutput("The IsVisited() boolean return value = ", theRetVal, 1);
00397 
00398               if (theRetVal)
00399                      QAOutput("URL has been visited. Won't execute AddPage().", 2);
00400               else
00401               {
00402                      QAOutput("URL hasn't been visited. Will execute AddPage().", 2);
00403 
00404                      // adds a url to the global history file
00405                      rv = myHistory->AddPage(myDialog.m_urlfield);
00406 
00407                      // prints addPage() results to output file
00408                      if (NS_FAILED(rv))
00409                      {
00410                             QAOutput("Invalid results for AddPage(). Url not added. Test failed.", 1);
00411                             return;
00412                      }
00413                      else
00414                             QAOutput("Valid results for AddPage(). Url added. Test passed.", 1);
00415 
00416                      // checks if url was visited (post-AddPage() test)
00417                      myHistory->IsVisited(myDialog.m_urlfield, &theRetVal);
00418 
00419                      if (theRetVal)
00420                             QAOutput("URL is visited; post-AddPage() test. IsVisited() test passed.", 1);
00421                      else
00422                             QAOutput("URL isn't visited; post-AddPage() test. IsVisited() test failed.", 1);
00423               }
00424               QAOutput("End IsVisited() and AddPage() tests.", 2);
00425        }
00426        else
00427               QAOutput("IsVisited() and AddPage() tests not executed.", 1);
00428 }
00429 
00430 
00431 // *********************************************************
00432 
00433 void CTests::OnTestsCreateFile()
00434 {
00435        //nsresult rv;
00436 
00437        PRBool exists;
00438     nsCOMPtr<nsILocalFile> theTestFile(do_GetService(NS_LOCAL_FILE_CONTRACTID));
00439 
00440     if (!theTestFile)
00441        {
00442               QAOutput("File object doesn't exist. No File tests performed.", 2);
00443               return;
00444        }
00445 
00446 
00447        QAOutput("Start Create File test.", 2);
00448 
00449        rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\theFile.txt"));
00450        rv = theTestFile->Exists(&exists);
00451        QAOutput("File (theFile.txt) doesn't exist. We'll create it.\r\n", 1);
00452 
00453        rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
00454        RvTestResult(rv, "File Create() test", 2);
00455 }
00456 
00457 // *********************************************************
00458 
00459 void CTests::OnTestsCreateprofile()
00460 {
00461     CProfilesDlg    myDialog;
00462     nsresult        rv;
00463 
00464        if (myDialog.DoModal() == IDOK)
00465     {
00466               nsCOMPtr<nsIProfile> theProfServ(do_GetService(NS_PROFILE_CONTRACTID,&rv));
00467               if (NS_FAILED(rv))
00468               {
00469                  QAOutput("Didn't get profile service. No profile tests performed.", 2);
00470                  return;
00471               }
00472 
00473           QAOutput("Start Profile switch test.", 2);
00474 
00475           QAOutput("Retrieved profile service.", 2);
00476 
00477        rv = theProfServ->SetCurrentProfile(myDialog.m_SelectedProfile.get());
00478           RvTestResult(rv, "SetCurrentProfile() (profile switching) test", 2);
00479 
00480           QAOutput("End Profile switch test.", 2);
00481     }
00482        else
00483           QAOutput("Profile switch test not executed.", 2);
00484 }
00485 
00486 // *********************************************************
00487 
00488 void CTests::OnTestsAddTooltipListener()
00489 {
00490     nsWeakPtr weakling(
00491         do_GetWeakReference(NS_STATIC_CAST(nsITooltipListener*, qaBrowserImpl)));
00492  
00493        rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsITooltipListener));
00494        RvTestResult(rv, "AddWebBrowserListener(). Add Tooltip Listener test", 2);
00495 }
00496 
00497 // *********************************************************
00498 
00499 void CTests::OnTestsAddWebProgListener()
00500 {
00501     nsWeakPtr weakling(
00502         do_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*, qaBrowserImpl)));
00503  
00504        rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
00505        RvTestResult(rv, "AddWebBrowserListener(). Add Web Prog Lstnr test", 2);
00506 }
00507 
00508 // *********************************************************
00509 
00510 void CTests::OnTestsAddHistoryListener()
00511 {
00512    // addSHistoryListener test
00513 
00514        nsWeakPtr weakling(
00515         do_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, qaBrowserImpl)));
00516 
00517        rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
00518        RvTestResult(rv, "AddWebBrowserListener(). Add History Lstnr test", 2);
00519 }
00520 
00521 // *********************************************************
00522 
00523 void CTests::OnTestsRemovehistorylistener()
00524 {
00525   // RemoveSHistoryListener test
00526 
00527        nsWeakPtr weakling(
00528         do_GetWeakReference(NS_STATIC_CAST(nsISHistoryListener*, qaBrowserImpl)));
00529 
00530        rv = qaWebBrowser->RemoveWebBrowserListener(weakling, NS_GET_IID(nsISHistoryListener));
00531        RvTestResult(rv, "RemoveWebBrowserListener(). Remove History Lstnr test", 2);
00532 }
00533 
00534 // *********************************************************
00535 
00536 void CTests::OnTestsAddUriContentListenerByWebBrowser()
00537 {
00538     nsWeakPtr weakling(
00539         do_GetWeakReference(NS_STATIC_CAST(nsIURIContentListener*, qaBrowserImpl)));
00540 
00541     rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIURIContentListener));
00542        RvTestResult(rv, "AddWebBrowserListener(). add nsIURIContentListener test", 2);
00543 }
00544 
00545 // *********************************************************
00546 
00547 void CTests::OnTestsAddUriContentListenerByUriLoader()
00548 {
00549        nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
00550        RvTestResult(rv, "nsIURILoader() object test", 1);
00551 
00552        if (!myLoader) {
00553               QAOutput("Didn't get urILoader object. test failed", 2);
00554               return;
00555        }
00556 
00557        nsCOMPtr<nsIURIContentListener> cntListener(NS_STATIC_CAST(nsIURIContentListener*, qaBrowserImpl));
00558 
00559        if (!cntListener) {
00560               QAOutput("Didn't get urIContentListener object. test failed", 2);
00561               return;
00562        }
00563        else {
00564               rv = myLoader->RegisterContentListener(cntListener);
00565               RvTestResult(rv, "nsIUriLoader->RegisterContentListener() test", 2);
00566        }
00567 }
00568 
00569 // *********************************************************
00570 
00571 void CTests::OnTestsAddUriContentListenerByOpenUri()
00572 {
00573        nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
00574        RvTestResult(rv, "nsIURILoader() object test", 1);
00575 
00576        if (!myLoader) {
00577               QAOutput("Didn't get urILoader object. test failed", 2);
00578               return;
00579        }
00580 
00581        if (myDialog.DoModal() == IDOK)
00582        {
00583               nsCAutoString theStr;
00584 
00585               theStr = myDialog.m_urlfield;
00586               rv = NS_NewURI(getter_AddRefs(theURI), theStr);
00587               RvTestResult(rv, "For OpenURI(): NS_NewURI() test", 1);
00588               FormatAndPrintOutput("theStr = ", theStr, 1);
00589               GetTheURI(theURI, 1);
00590               rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
00591               RvTestResult(rv, "For OpenURI(): NS_NewChannel() test", 1);
00592        }
00593        else {
00594               QAOutput("Didn't get a url. test failed", 2);
00595               return;
00596        }
00597 
00598        rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
00599        RvTestResult(rv, "nsIUriLoader->OpenURI() test", 2);
00600 }
00601 
00602 // *********************************************************
00603 
00604 void CTests::OnTestsNSNewChannelAndAsyncOpen()
00605 {
00606        nsCOMPtr<nsIChannel> theChannel;
00607        nsCOMPtr<nsILoadGroup> theLoadGroup(do_CreateInstance(NS_LOADGROUP_CONTRACTID));
00608 
00609        if (myDialog.DoModal() == IDOK)
00610        {
00611               nsCAutoString theStr;
00612 
00613               theStr = myDialog.m_urlfield;
00614 
00615               rv = NS_NewURI(getter_AddRefs(theURI), theStr);
00616               RvTestResult(rv, "NS_NewURI() test", 2);
00617               rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
00618               RvTestResult(rv, "NS_NewChannel() test", 2);
00619 
00620               if (!theChannel)
00621               {
00622                  QAOutput("We didn't get the Channel for AsyncOpen(). Test failed.", 1);
00623                  return;
00624               }
00625 
00626               QAOutput("AynchOpen() test:", 2);
00627 
00628               // this calls nsIStreamListener::OnDataAvailable()
00629               CnsIChannelTests  *channelTests = new CnsIChannelTests(qaWebBrowser, qaBrowserImpl);
00630               channelTests->AsyncOpenTest(theChannel, 2);;
00631        }
00632 }
00633 
00634 // *********************************************************
00635 
00636 void CTests::OnTestsIOServiceNewURI()
00637 {
00638        nsCOMPtr<nsIIOService> ioService(do_GetIOService(&rv));
00639        if (!ioService) {
00640               QAOutput("We didn't get the IOService object.", 2);
00641               return;
00642        }
00643 
00644        if (myDialog.DoModal() == IDOK)
00645        {
00646               nsCAutoString theStr, retURI;
00647 
00648               theStr = myDialog.m_urlfield;
00649 
00650               rv = ioService->NewURI(theStr, nsnull, nsnull, getter_AddRefs(theURI));
00651               RvTestResult(rv, "ioService->NewURI() test", 2);
00652 
00653               if (!theURI)
00654                      QAOutput("We didn't get the nsIURI object for IOService test.", 2);
00655               else {
00656                      retURI = GetTheURI(theURI, 1);
00657                      FormatAndPrintOutput("The ioService->NewURI() output uri = ", retURI, 2);
00658               }
00659        }
00660 }
00661 
00662 // *********************************************************
00663 
00664 void CTests::OnTestsProtocolHandlerNewURI()
00665 {
00666        nsCOMPtr<nsIIOService> ioService(do_GetIOService(&rv));
00667 
00668        if (!ioService) {
00669               QAOutput("We didn't get the IOService object.", 2);
00670               return;
00671        }
00672 
00673        if (myDialog.DoModal() == IDOK)
00674        {
00675               nsCAutoString theStr, retStr;
00676               nsCOMPtr<nsIURI> theOriginalURI;
00677               nsIURI *theReturnURI = nsnull;
00678               nsIChannel *theReturnChannel = nsnull;
00679               const char *theProtocol;
00680 
00681               nsCOMPtr<nsIProtocolHandler> protocolHandler;
00682 
00683               theStr = myDialog.m_urlfield;
00684               theProtocol = myDialog.m_protocolvalue;
00685               FormatAndPrintOutput("The protocol scheme = ", theProtocol, 1);
00686               rv = ioService->GetProtocolHandler(theProtocol, getter_AddRefs(protocolHandler));
00687               RvTestResult(rv, "ioService->GetProtocolHandler() test", 2);
00688               rv = qaWebNav->GetCurrentURI(getter_AddRefs(theOriginalURI));
00689               if (!protocolHandler) {
00690                      QAOutput("We didn't get the protocolHandler object.", 2);
00691                      return;
00692               }
00693               rv = protocolHandler->NewURI(theStr, nsnull, theOriginalURI, &theReturnURI);
00694               if (!theOriginalURI)
00695                      QAOutput("We didn't get the original nsIURI object.", 2);
00696               else if (!theReturnURI)
00697                      QAOutput("We didn't get the output nsIURI object.", 2);
00698 
00699               RvTestResult(rv, "protocolHandler->NewURI() test", 2);
00700 
00701            retStr = GetTheURI(theReturnURI, 1);
00702 
00703           // simple string compare to see if input & output URLs match
00704            if (strcmp(myDialog.m_urlfield, retStr.get()) == 0)
00705                  QAOutput("The in/out URIs MATCH.", 1);
00706            else
00707                  QAOutput("The in/out URIs don't MATCH.", 1);
00708 
00709               // other protocol handler tests:
00710 
00711               // GetScheme() test
00712               nsCAutoString theScheme;
00713               rv = protocolHandler->GetScheme(theScheme);
00714               RvTestResult(rv, "protocolHandler->GetScheme() test", 1);
00715               FormatAndPrintOutput("GetScheme() = ", theScheme, 1);
00716 
00717               // GetDefaultPort() test
00718               PRInt32 theDefaultPort;
00719               rv = protocolHandler->GetDefaultPort(&theDefaultPort);
00720               RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
00721               FormatAndPrintOutput("GetDefaultPort() = ", theDefaultPort, 1);
00722 
00723               // GetProtocolFlags() test
00724               PRUint32 theProtocolFlags;
00725               rv = protocolHandler->GetProtocolFlags(&theProtocolFlags);
00726               RvTestResult(rv, "protocolHandler->GetDefaultPort() test", 1);
00727               FormatAndPrintOutput("GetProtocolFlags() = ", theProtocolFlags, 1);
00728 
00729               // NewChannel() test
00730               rv = protocolHandler->NewChannel(theReturnURI, &theReturnChannel);
00731               RvTestResult(rv, "protocolHandler->NewChannel() test", 1);
00732               if (!theReturnChannel)
00733                      QAOutput("We didn't get the returned nsIChannel object.", 1);
00734 
00735 
00736               // AllowPort() test
00737               PRBool retPort;
00738               rv = protocolHandler->AllowPort(theDefaultPort, "http", &retPort);
00739               RvTestResult(rv, "protocolHandler->AllowPort() test", 1);
00740               FormatAndPrintOutput("AllowPort() boolean = ", retPort, 1);
00741 
00742               
00743        }
00744 }
00745 
00746 // *********************************************************
00747 // *********************************************************
00748 //                                 TOOLS to help us
00749 
00750 void CTests::OnToolsRemoveGHPage()
00751 
00752 {
00753        PRBool theRetVal = PR_FALSE;
00754        nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
00755 
00756        if (!myGHistory)
00757        {
00758               QAOutput("Could not get the global history object.", 2);
00759               return;
00760        }
00761 
00762        nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
00763        if(NS_FAILED(rv)) {
00764               QAOutput("Could not get the history object.", 2);
00765               return;
00766        }
00767 
00768        if (myDialog.DoModal() == IDOK)
00769        {
00770               QAOutput("Begin URL removal from the GH file.", 2);
00771 
00772               myGHistory->IsVisited(myDialog.m_urlfield, &theRetVal);
00773               if (theRetVal)
00774               {
00775                      nsCOMPtr<nsIIOService> ios = do_GetIOService();
00776                      if (ios)
00777                      {
00778                             nsCOMPtr<nsIURI> uri;
00779                             ios->NewURI(nsDependentCString(myDialog.m_urlfield), nsnull, nsnull,
00780                                                  getter_AddRefs(uri));
00781                             if (uri)
00782                             {
00783                                    rv = myHistory->RemovePage(uri);
00784                                    RvTestResult(rv, "RemovePage() test (url removal from GH file)", 2);
00785                             }
00786                      }
00787               }
00788               else
00789               {
00790                      QAOutput("The URL wasn't in the GH file.\r\n", 1);
00791               }
00792               QAOutput("End URL removal from the GH file.", 2);
00793        }
00794        else
00795               QAOutput("URL removal from the GH file not executed.", 2);
00796 }
00797 
00798 void CTests::OnToolsRemoveAllGH()
00799 {
00800 
00801        nsCOMPtr<nsIGlobalHistory> myGHistory(do_GetService(NS_GLOBALHISTORY_CONTRACTID));
00802        if (!myGHistory)
00803        {
00804               QAOutput("Could not get the global history object.", 2);
00805               return;
00806        }
00807 
00808        nsCOMPtr<nsIBrowserHistory> myHistory = do_QueryInterface(myGHistory, &rv);
00809        if(NS_FAILED(rv)) {
00810               QAOutput("Could not get the history object.", 2);
00811               return;
00812        }
00813 
00814        QAOutput("Begin removal of all pages from the GH file.", 2);
00815 
00816        rv = myHistory->RemoveAllPages();
00817        RvTestResult(rv, "removeAllPages().", 2);
00818 
00819        QAOutput("End removal of all pages from the GH file.", 2);
00820 }
00821 
00822 void CTests::OnToolsViewLogfile()
00823 {
00824        char theURI[1024];
00825 
00826        CStdioFile myFile; 
00827     CFileException e; 
00828     CString strFileName = "c:\\temp\\TestOutput.txt"; 
00829        myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
00830                         | CStdioFile::modeNoTruncate, &e );               
00831        myFile.Close();
00832 
00833        strcpy(theURI, "file://C|/temp/TestOutput.txt");
00834        rv = qaWebNav->LoadURI(NS_ConvertASCIItoUCS2(theURI).get(),
00835                nsIWebNavigation::LOAD_FLAGS_NONE, nsnull,nsnull, nsnull);
00836 }
00837 
00838 void CTests::OnToolsDeleteLogfile()
00839 {
00840        CStdioFile myFile; 
00841     CFileException e; 
00842     CString strFileName = "c:\\temp\\TestOutput.txt"; 
00843        myFile.Open( strFileName, CStdioFile::modeCreate | CStdioFile::modeWrite
00844                         | CStdioFile::modeNoTruncate, &e );       
00845        myFile.Close();
00846 
00847        nsCOMPtr<nsILocalFile> theOriginalFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
00848 
00849        rv = theOriginalFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\TestOutput.txt"));
00850     nsCOMPtr<nsIFile> theTestFile = do_QueryInterface(theOriginalFile);
00851        rv = theTestFile->Remove(PR_FALSE);
00852 }
00853 
00854 // ***********************************************************************
00855 
00856 void CTests::OnToolsTestYourMethod()
00857 {      
00858        // place your test code here
00859 }
00860 
00861 // ***********************************************************************
00862 
00863 void CTests::OnToolsTestYourMethod2()
00864 {
00865        // place your test code here
00866 }
00867 
00868 // ***********************************************************************
00869 // ***************** Bug Verifications ******************
00870 // ***********************************************************************
00871 
00872 void CTests::OnVerifybugs70228()
00873 {
00874        nsCOMPtr<nsIHelperAppLauncherDialog>
00875                      myHALD(do_CreateInstance(NS_IHELPERAPPLAUNCHERDLG_CONTRACTID));
00876        if (!myHALD)
00877               QAOutput("Object not created. It should be. It's a component!", 2);
00878        else
00879               QAOutput("Object is created. It's a component!", 2);
00880 }
00881 
00882 void CTests::OnVerifybugs90195()
00883 {
00884     nsWeakPtr weakling(
00885         do_GetWeakReference(NS_STATIC_CAST(nsITooltipListener*, qaBrowserImpl)));
00886 
00887     rv = qaWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsITooltipListener));
00888        RvTestResult(rv, "AddWebBrowserListener(). Add Tool Tip Lstnr test", 2);
00889 
00890 /*     nsCOMPtr<nsITooltipTextProvider> oTooltipTextProvider = do_GetService(NS_TOOLTIPTEXTPROVIDER_CONTRACTID) ;
00891        if (!oTooltipTextProvider)
00892               AfxMEssageBox("Asdfadf");
00893 */
00894 }
00895 
00896 void CTests::OnVerifybugs169617()
00897 {
00898        nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
00899        nsCAutoString theStr;
00900 
00901        QAOutput("Verification for bug 169617!", 2);
00902 
00903        theStr = "file://C|/Program Files";
00904        rv = NS_NewURI(getter_AddRefs(theURI), theStr);
00905        RvTestResult(rv, "NS_NewURI() test for file url", 1);
00906 
00907        GetTheURI(theURI, 1);
00908 
00909        rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
00910        RvTestResult(rv, "NS_NewChannel() test for file url", 1);
00911 
00912        rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
00913        RvTestResult(rv, "nsIUriLoader->OpenURI() test for file url", 2);
00914 
00915 }
00916 
00917 void CTests::OnVerifybugs170274()
00918 {
00919        nsCOMPtr<nsIURILoader> myLoader(do_GetService(NS_URI_LOADER_CONTRACTID,&rv));
00920        nsCAutoString theStr;
00921 
00922        QAOutput("Verification for bug 170274!", 2);
00923 
00924        theStr = "data:text/plain;charset=iso-8859-7,%be%fg%be";
00925        rv = NS_NewURI(getter_AddRefs(theURI), theStr);
00926        RvTestResult(rv, "NS_NewURI() test for data url", 1);
00927 
00928        GetTheURI(theURI, 1);
00929 
00930        rv = NS_NewChannel(getter_AddRefs(theChannel), theURI, nsnull, nsnull);
00931        RvTestResult(rv, "NS_NewChannel() test for data url", 1);
00932 
00933        rv = myLoader->OpenURI(theChannel, PR_TRUE, qaBrowserImpl);
00934        RvTestResult(rv, "nsIUriLoader->OpenURI() test for data url", 2);
00935 }
00936 
00937 // ***********************************************************************
00938 
00939 BOOL CTests::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
00940 {
00941    // To handle Menu handlers add here. Don't have to do if not handling
00942    // menu handlers
00943        nCommandID = nID;
00944 
00945        return CWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
00946 }
00947 
00948 void CTests::OnInterfacesNsirequest()
00949 {
00950        CNsIRequest oNsIRequest(qaWebBrowser,/*qaBaseWindow,qaWebNav,*/ qaBrowserImpl);
00951        oNsIRequest.OnStartTests(nCommandID);
00952 }
00953 
00954 void CTests::OnInterfacesNsidirectoryservice()
00955 {
00956        CNsIDirectoryService oNsIDirectoryService;
00957        oNsIDirectoryService.StartTests(nCommandID);
00958 }
00959 
00960 void CTests::OnInterfacesNsidomwindow()
00961 {
00962        CDomWindow oDomWindow(qaWebBrowser);
00963        oDomWindow.OnStartTests(nCommandID);
00964 }
00965 
00966 void CTests::OnInterfacesNsiselection()
00967 {
00968        CSelection oSelection(qaWebBrowser);
00969        oSelection.OnStartTests(nCommandID);
00970 }
00971 
00972 void CTests::OnInterfacesNsiprofile()
00973 {
00974        CProfile oProfile(qaWebBrowser);
00975        oProfile.OnStartTests(nCommandID);
00976 }
00977 
00978 void CTests::OnInterfacesNsishistory()
00979 {
00980        CNsIHistory oHistory(qaWebNav);
00981        oHistory.OnStartTests(nCommandID);
00982 }
00983 
00984 void CTests::OnInterfacesNsiwebnav()
00985 {
00986        CNsIWebNav oWebNav(qaWebNav);
00987        oWebNav.OnStartTests(nCommandID);
00988 }
00989 
00990 
00991 void CTests::OnInterfacesNsiclipboardcommands()
00992 {
00993        CNsIClipBoardCmd  oClipCmd(qaWebBrowser);
00994        oClipCmd.OnStartTests(nCommandID);
00995 }
00996 
00997 void CTests::OnInterfacesNsiobserverservice()
00998 {
00999        CnsIObserServ oObserv;
01000        oObserv.OnStartTests(nCommandID);
01001 }
01002 
01003 void CTests::OnInterfacesNsifile()
01004 {
01005        CNsIFile oFile ;
01006        oFile.OnStartTests(nCommandID);
01007 }
01008 
01009 void CTests::OnInterfacesNsiwebbrowser()
01010 {
01011        CNsIWebBrowser oWebBrowser(qaWebBrowser, qaBrowserImpl);
01012        oWebBrowser.OnStartTests(nCommandID);
01013 }
01014 
01015 void CTests::OnInterfacesNsiwebprogress()
01016 {
01017        CnsiWebProg oWebProgress(qaWebBrowser, qaBrowserImpl);
01018        oWebProgress.OnStartTests(nCommandID);
01019 }
01020 
01021 void CTests::OnInterfacesNsiwebbrowfind()
01022 {
01023        CNsIWebBrowFind oWebBrowFind(qaWebBrowser, qaBrowserImpl);
01024        oWebBrowFind.OnStartTests(nCommandID);
01025 }
01026 
01027 void CTests::OnInterfacesNsieditingsession()
01028 {
01029        CnsIEditSession oEditSession(qaWebBrowser);
01030        oEditSession.OnStartTests(nCommandID);
01031 }
01032 
01033 void CTests::OnInterfacesNsicommandmgr()
01034 {
01035        CnsICommandMgr oCommandMgr(qaWebBrowser);
01036        oCommandMgr.OnStartTests(nCommandID);
01037 }
01038 
01039 void CTests::OnInterfacesNsicmdparams()
01040 {
01041        CnsICmdParams oCmdParams(qaWebBrowser);
01042        oCmdParams.OnStartTests(nCommandID);
01043 }
01044 
01045 void CTests::OnInterfacesNsichannel()
01046 {
01047        CnsIChannelTests oChannelTests(qaWebBrowser, qaBrowserImpl);
01048        oChannelTests.OnStartTests(nCommandID);
01049 }
01050 
01051 void CTests::OnInterfacesNsihttpchannel()
01052 {
01053        CnsIHttpChannelTests oHttpChannelTests(qaWebBrowser, qaBrowserImpl);
01054        oHttpChannelTests.OnStartTests(nCommandID);
01055 }
01056 
01057 
01058 //Run all interface test cases in automation
01059 
01060 void CTests::OnInterfacesRunalltestcases() 
01061 {
01062        CNsIFile oFile ;
01063        oFile.OnStartTests(ID_INTERFACES_NSIFILE_RUNALLTESTS);
01064 
01065        CNsIHistory oHistory(qaWebNav);
01066        oHistory.OnStartTests(ID_INTERFACES_NSISHISTORY_RUNALLTESTS);
01067 
01068 
01069        // Can only be run manually
01070 //     CNsIWebNav oWebNav(qaWebNav);
01071 //     oWebNav.OnStartTests(ID_INTERFACES_NSIWEBNAV_RUNALLTESTS);
01072 
01073 
01074        CnsIObserServ oObserv;
01075        oObserv.OnStartTests(ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS);
01076 
01077 
01078        CNsIDirectoryService oNsIDirectoryService;
01079        oNsIDirectoryService.StartTests(ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS);
01080 
01081 
01082        CDomWindow oDomWindow(qaWebBrowser) ;
01083        oDomWindow.OnStartTests(ID_INTERFACES_NSIDOMWINDOW_RUNALLTESTS);
01084 
01085 
01086        // Can only be run manually
01087        //CSelection oSelection(qaWebBrowser);
01088        //oSelection.OnStartTests(ID_INTERFACES_NSISELECTION_RUNALLTESTS);
01089 
01090 
01091        CProfile oProfile(qaWebBrowser);
01092        oProfile.OnStartTests(ID_INTERFACES_NSIPROFILE_RUNALLTESTS);
01093 
01094 
01095        // Can only be run manually
01096        //CNsIClipBoardCmd  oClipCmd(qaWebBrowser);
01097        //oClipCmd.OnStartTests(nCommandID);
01098 
01099 
01100        CNsIRequest oNsIRequest(qaWebBrowser,/*qaBaseWindow,qaWebNav,*/ qaBrowserImpl);
01101        oNsIRequest.OnStartTests(ID_INTERFACES_NSIREQUEST_RUNALLTESTS);
01102 
01103 
01104        CNsIWebBrowser oWebBrowser(qaWebBrowser, qaBrowserImpl);
01105        oWebBrowser.OnStartTests(ID_INTERFACES_NSIWEBBROWSER_RUNALLTESTS);
01106 
01107 
01108        CnsiWebProg oWebProgress(qaWebBrowser, qaBrowserImpl);
01109        oWebProgress.OnStartTests(ID_INTERFACES_NSIWEBPROGRESS_RUNALLTESTS);
01110 
01111 
01112        CNsIWebBrowFind oWebBrowFind(qaWebBrowser, qaBrowserImpl);
01113        oWebBrowFind.OnStartTests(ID_INTERFACES_NSIWEBBROWSERFIND_RUNALLTESTS);
01114 
01115 
01116        CnsIEditSession oEditSession(qaWebBrowser);
01117        oEditSession.OnStartTests(ID_INTERFACES_NSIEDITINGSESSION_RUNALLTESTS);
01118 
01119 
01120        CnsICommandMgr oCommandMgr(qaWebBrowser);
01121        oCommandMgr.OnStartTests(ID_INTERFACES_NSICOMMANDMANAGER_RUNALLTESTS);
01122 
01123 
01124        CnsICmdParams oCmdParams(qaWebBrowser);
01125        oCmdParams.OnStartTests(ID_INTERFACES_NSICOMMANDPARAMS_RUNALLTESTS);
01126 
01127        CnsIChannelTests oChannelTests(qaWebBrowser, qaBrowserImpl);
01128        oChannelTests.OnStartTests(ID_INTERFACES_NSICHANNEL_RUNALLTESTS);
01129 
01130        CnsIHttpChannelTests oHttpChannelTests(qaWebBrowser, qaBrowserImpl);
01131        oHttpChannelTests.OnStartTests(ID_INTERFACES_NSIHTTPCHANNEL_RUNALLTESTS);
01132 }