added NS_LITERAL_CSTRINGs to nsIFile.cpp. Some XPIDialog/Progress code in Tests.cpp

This commit is contained in:
depstein%netscape.com 2002-05-01 03:33:18 +00:00
Родитель 89ffe0e697
Коммит a839dd32fb
7 изменённых файлов: 245 добавлений и 342 удалений

Просмотреть файл

@ -83,7 +83,7 @@ FILE * CMostRecentUrls::GetFD(const char * aMode)
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> local_file(do_QueryInterface(file));
local_file->Append("urls.txt");
local_file->Append(NS_LITERAL_CSTRING("urls.txt"));
local_file->OpenANSIFileDesc(aMode, &fd);
}

Просмотреть файл

@ -125,6 +125,9 @@
#include "nsITooltipListener.h"
#include "nsISimpleEnumerator.h"
#include "nsIXPIProgressDialog.h"
#include "nsIXPIDialogService.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

Просмотреть файл

@ -59,9 +59,12 @@
#include "domwindow.h"
#include "selection.h"
#include "nsProfile.h"
#include "nsIClipboardCmd.h"
#include "nsIObserServ.h"
#include "nsIFile.h"
#include "nsIClipboardCmd.h"
#include "nsIObserServ.h"
#include "nsIFile.h"
#include "QaUtils.h"
#include <stdio.h>
@ -83,57 +86,78 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_TESTS_GLOBALHISTORY, OnTestsGlobalHistory)
ON_COMMAND(ID_TESTS_CREATEFILE, OnTestsCreateFile)
ON_COMMAND(ID_TESTS_CREATEPROFILE, OnTestsCreateprofile)
ON_COMMAND(ID_TESTS_ADDWEBPROGLISTENER, OnTestsAddWebProgListener)
ON_COMMAND(ID_TESTS_ADDHISTORYLISTENER, OnTestsAddHistoryListener)
ON_COMMAND(ID_TESTS_ADDWEBPROGLISTENER, OnTestsAddWebProgListener)
ON_COMMAND(ID_TESTS_ADDHISTORYLISTENER, OnTestsAddHistoryListener)
ON_COMMAND(ID_TOOLS_REMOVEGHPAGE, OnToolsRemoveGHPage)
ON_COMMAND(ID_TOOLS_REMOVEALLGH, OnToolsRemoveAllGH)
ON_COMMAND(ID_TOOLS_TESTYOURMETHOD, OnToolsTestYourMethod)
ON_COMMAND(ID_TOOLS_TESTYOURMETHOD2, OnToolsTestYourMethod2)
ON_COMMAND(ID_VERIFYBUGS_70228, OnVerifybugs70228)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_CANCEL, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_RUNALLTESTS, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_INIT, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_CANCEL, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_RUNALLTESTS, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_INIT, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSISELECTION_RUNALLTESTS, OnInterfacesNsiselection)
ON_COMMAND(ID_VERIFYBUGS_90195, OnVerifybugs90195)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_RUNALLTESTS, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETCOUNT, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETCOUNT, OnInterfacesNsishistory)
ON_COMMAND(ID_TESTS_REMOVEHISTORYLISTENER, OnTestsRemovehistorylistener)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETCANGOBACK, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GETCANGOBACK, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCOPYSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_REGISTERPROVIDER, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_RUNALLTESTS, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSIDIRECTORYSERVICE_UNREGISTERPROVIDER, OnInterfacesNsidirectoryservice)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETDOMDOCUMENT, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETFRAMES, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETNAME, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETPARENT, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCROLLBARS, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCROLLBARS, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCROLLY, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSCSOLLX, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSELECTION, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETSELECTION, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBY, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYLINES, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYPAGES, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYLINES, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLBYPAGES, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SCROLLTO, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SIZETOCONTENT, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETANCHORNODE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SIZETOCONTENT, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETANCHORNODE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_ADDRANGE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSETOEND, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSETOEND, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_COLLAPSETOSTART, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_CONTAINSNODE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_DELETEFROMDOCUMENT, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_EXTEND, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETANCHOROFFSET, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETFOCUSNODE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETFOCUSOFFSET, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETISCOLLAPSED, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETFOCUSOFFSET, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETISCOLLAPSED, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETRANGEAT, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETRANGECOUNT, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_GETRANGECOUNT, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_REMOVEALLRANGES, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_REMOVERANGE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_SELECTALLCHILDREN, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_SELECTALLCHILDREN, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_SELECTIONLANGUAGECHANGE, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSISELECTION_TOSTRING, OnInterfacesNsiselection)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_CLONEPROFILE, OnInterfacesNsiprofile)
@ -141,9 +165,12 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_DELETEPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETCURRENTPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETPROFILECOUNT, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETPROFILELIST, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_PROFILEEXISTS, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_RENAMEPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_GETPROFILELIST, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_PROFILEEXISTS, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_RENAMEPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_SETCURRENTPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSIPROFILE_SHUTDOWNCURRENTPROFILE, OnInterfacesNsiprofile)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETENTRYATINDEX, OnInterfacesNsishistory)
@ -151,7 +178,8 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETMAXLENGTH, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_GETSHISTORYENUMERATOR, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_PURGEHISTORY, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_RUNALLTESTS, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_RUNALLTESTS, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_SETMAXLENGTH, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETISSUBFRAME, OnInterfacesNsishistory)
ON_COMMAND(ID_INTERFACES_NSISHISTORY_NSIHISTORYENTRY_GETTITLE, OnInterfacesNsishistory)
@ -165,7 +193,8 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GOFORWARD, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_GOTOINDEX, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_LOADURI, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_RELOAD, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_RELOAD, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_RUNALLTESTS, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_SETSESSIONHISTORY, OnInterfacesNsiwebnav)
ON_COMMAND(ID_INTERFACES_NSIWEBNAV_STOP, OnInterfacesNsiwebnav)
@ -178,29 +207,45 @@ BEGIN_MESSAGE_MAP(CTests, CWnd)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_SETLOADFLAGS, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_SETLOADGROUP, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_SUSPEND, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_RUNALLTESTS, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIREQUEST_RUNALLTESTS, OnInterfacesNsirequest)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_GETTEXTZOOM, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSIDOMWINDOW_SETTEXTZOOM, OnInterfacesNsidomwindow)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANCUTSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CANPASTE, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYLINKLOCATION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_COPYSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_CUTSELECTION, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_PASTE, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTALL, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSICLIPBOARDCOMMANDS_SELECTNONE, OnInterfacesNsiclipboardcommands)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_NOTIFYOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIFILE_APPENDRELATICEPATH, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_COPYTO, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_CREATE, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_EXISTS, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_INITWITHPATH, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_MOVETO, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_RUNALLTESTS, OnInterfacesNsifile)
//}}AFX_MSG_MAP
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_NOTIFYOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS, OnInterfacesNsiobserverservice)
ON_COMMAND(ID_INTERFACES_NSIFILE_APPENDRELATICEPATH, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_COPYTO, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_CREATE, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_EXISTS, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_INITWITHPATH, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_MOVETO, OnInterfacesNsifile)
ON_COMMAND(ID_INTERFACES_NSIFILE_RUNALLTESTS, OnInterfacesNsifile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@ -367,7 +412,7 @@ void CTests::OnTestsCreateFile()
QAOutput("Start Create File test.", 2);
rv = theTestFile->InitWithPath("c:\\temp\\theFile.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\theFile.txt"));
rv = theTestFile->Exists(&exists);
QAOutput("File (theFile.txt) doesn't exist. We'll create it.\r\n", 1);
@ -514,7 +559,48 @@ void CTests::OnToolsRemoveAllGH()
void CTests::OnToolsTestYourMethod()
{
// place your test code here
PRInt32 stateValue=0;
short state=0;
PRUint32 stateIndex=0, progIndex=0, progValue=0, progMaxVal=0;
nsCOMPtr<nsIXPIDialogService>
myXPIDlog(do_CreateInstance("@mozilla.org/embedui/xpinstall-dialog-service;1"));
if (!myXPIDlog)
QAOutput("XPIDlogService object not created.", 2);
else
QAOutput("XPIDlogService object is created.", 2);
nsCOMPtr<nsIXPIProgressDialog>
myProgDlog(do_QueryInterface(myXPIDlog, &rv));
if (!myProgDlog)
QAOutput("XPIProgDlog object not created.", 2);
else
QAOutput("XPIProgDlog object is created.", 2);
/*
NS_IMPL_THREADSAFE_ISUPPORTS1(CTests, nsIXPIProgressDialog);
rv = myProgDlog->onStateChange(stateIndex, state, stateValue);
RvTestResult(rv, "xpiProgDlog->onStateChange() test ", 2);
rv = myProgDlog->onProgress(progIndex, progValue, progMaxVal);
RvTestResult(rv, "xpiProgDlog->onProgress() test ", 2);
*/
}
/*
NS_IMETHODIMP CTests::onStateChange(PRUint32 stateIndex, short state, PRInt32 stateValue)
{
QAOutput("Entered onStateChange().", 2);
return NS_OK;
}
NS_IMETHODIMP CTests::onProgress(PRUint32 progIndex, PRUint32 progValue, PRUint32 progMaxVal);
{
QAOutput("Entered onProgress().", 2);
return NS_OK;
}
*/
// ***********************************************************************
void CTests::OnToolsTestYourMethod2()
@ -612,19 +698,33 @@ void CTests::OnInterfacesNsiwebnav()
void CTests::OnInterfacesNsiclipboardcommands()
{
CNsIClipBoardCmd oClipCmd(qaWebBrowser) ;
oClipCmd.OnStartTests(nCommandID);
CNsIClipBoardCmd oClipCmd(qaWebBrowser) ;
oClipCmd.OnStartTests(nCommandID);
}
void CTests::OnInterfacesNsiobserverservice()
{
CnsIObserServ oObserv ;
oObserv.OnStartTests(nCommandID);
}
void CTests::OnInterfacesNsifile()
{
CNsIFile oFile ;
oFile.OnStartTests(nCommandID);
void CTests::OnInterfacesNsiobserverservice()
{
CnsIObserServ oObserv ;
oObserv.OnStartTests(nCommandID);
}
void CTests::OnInterfacesNsifile()
{
CNsIFile oFile ;
oFile.OnStartTests(nCommandID);
}

Просмотреть файл

@ -59,6 +59,11 @@
class CBrowserImpl;
class CBrowserView;
/*
class CTests:public CWnd,
nsIXPIDialogService,
nsIXPIProgressDialog
*/
class CTests:public CWnd
{
public:
@ -78,6 +83,9 @@ public:
nsCOMPtr<nsIWebNavigation> qaWebNav;
CBrowserImpl *qaBrowserImpl;
// NS_DECL_ISUPPORTS
// NS_DECL_NSIXPIDIALOGSERVICE
// NS_DECL_NSIXPIPROGRESSDIALOG
// local test methods
@ -105,45 +113,47 @@ private:
// Generated message map functions
protected:
//{{AFX_MSG(CTests)
afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
afx_msg void OnTestsChangeUrl();
afx_msg void OnTestsGlobalHistory();
afx_msg void OnTestsCreateFile();
afx_msg void OnTestsCreateprofile();
afx_msg void OnTestsAddWebProgListener();
afx_msg void OnTestsAddHistoryListener();
afx_msg void OnInterfacesNsifile();
afx_msg void OnToolsRemoveGHPage();
afx_msg void OnToolsRemoveAllGH();
afx_msg void OnToolsTestYourMethod();
afx_msg void OnToolsTestYourMethod2();
afx_msg void OnVerifybugs70228();
afx_msg void OnPasteTest();
afx_msg void OnCopyTest();
afx_msg void OnSelectAllTest();
afx_msg void OnSelectNoneTest();
afx_msg void OnCutSelectionTest();
afx_msg void copyLinkLocationTest();
afx_msg void canCopySelectionTest();
afx_msg void canCutSelectionTest();
afx_msg void canPasteTest();
afx_msg void OnInterfacesNsirequest();
afx_msg void OnInterfacesNsidomwindow();
afx_msg void OnInterfacesNsidirectoryservice();
afx_msg void OnInterfacesNsiselection();
afx_msg void OnVerifybugs90195();
afx_msg void OnInterfacesNsiprofile();
afx_msg void OnInterfacesNsishistory();
afx_msg void OnTestsRemovehistorylistener();
afx_msg void OnInterfacesNsiwebnav();
afx_msg void OnInterfacesNsiclipboardcommands();
afx_msg void OnInterfacesNsiobserverservice();
//}}AFX_MSG
afx_msg void OnUpdateNavBack(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavForward(CCmdUI* pCmdUI);
afx_msg void OnUpdateNavStop(CCmdUI* pCmdUI);
afx_msg void OnUpdateCut(CCmdUI* pCmdUI);
afx_msg void OnUpdateCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdatePaste(CCmdUI* pCmdUI);
afx_msg void OnTestsChangeUrl();
afx_msg void OnTestsGlobalHistory();
afx_msg void OnTestsCreateFile();
afx_msg void OnTestsCreateprofile();
afx_msg void OnTestsAddWebProgListener();
afx_msg void OnTestsAddHistoryListener();
afx_msg void OnInterfacesNsifile();
afx_msg void OnToolsRemoveGHPage();
afx_msg void OnToolsRemoveAllGH();
afx_msg void OnToolsTestYourMethod();
afx_msg void OnToolsTestYourMethod2();
afx_msg void OnVerifybugs70228();
afx_msg void OnPasteTest();
afx_msg void OnCopyTest();
afx_msg void OnSelectAllTest();
afx_msg void OnSelectNoneTest();
afx_msg void OnCutSelectionTest();
afx_msg void copyLinkLocationTest();
afx_msg void canCopySelectionTest();
afx_msg void canCutSelectionTest();
afx_msg void canPasteTest();
afx_msg void OnInterfacesNsirequest();
afx_msg void OnInterfacesNsidomwindow();
afx_msg void OnInterfacesNsidirectoryservice();
afx_msg void OnInterfacesNsiselection();
afx_msg void OnVerifybugs90195();
afx_msg void OnInterfacesNsiprofile();
afx_msg void OnInterfacesNsishistory();
afx_msg void OnTestsRemovehistorylistener();
afx_msg void OnInterfacesNsiwebnav();
afx_msg void OnInterfacesNsiclipboardcommands();
afx_msg void OnInterfacesNsiobserverservice();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// individual nsIFile tests

Просмотреть файл

@ -42,6 +42,7 @@ REQUIRES = \
helperAppDlg \
content \
webbrowserpersist \
xpinstall \
$(NULL)
DIRS=components \

Просмотреть файл

@ -1,245 +1,132 @@
/* -*- 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):
* Ashish Bhatt <ashishbhatt@netscape.com>
*
*
* 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....
//
// Test cases for the nsIClipBoardCommand Interface
#include "stdafx.h"
#include "QaUtils.h"
#include <stdio.h>
#include "nsIFile.h"
CNsIFile::CNsIFile()
{
}
CNsIFile::~CNsIFile()
{
}
void CNsIFile::OnStartTests(UINT nMenuID)
{
// Calls all or indivdual test cases on the basis of the
// option selected from menu.
nsCOMPtr<nsILocalFile> theTestFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
nsCOMPtr<nsILocalFile> theFileOpDir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
if (!theTestFile)
{
QAOutput("File object doesn't exist. No File tests performed.", 2);
return;
}
if (!theFileOpDir)
{
QAOutput("File object doesn't exist. No File tests performed.", 2);
return;
}
QAOutput("Begin nsIFile tests.", 2);
switch(nMenuID)
{
{
case ID_INTERFACES_NSIFILE_RUNALLTESTS :
RunAllTests(theTestFile,theFileOpDir);
break ;
case ID_INTERFACES_NSIFILE_INITWITHPATH :
InitWithPathTest(theTestFile);
break ;
case ID_INTERFACES_NSIFILE_APPENDRELATICEPATH :
AppendRelativePathTest(theTestFile);
break ;
case ID_INTERFACES_NSIFILE_EXISTS :
FileCreateTest(theTestFile);
break ;
case ID_INTERFACES_NSIFILE_CREATE :
FileExistsTest(theTestFile);
break ;
case ID_INTERFACES_NSIFILE_COPYTO :
FileCopyTest(theTestFile, theFileOpDir);
break ;
case ID_INTERFACES_NSIFILE_MOVETO :
FileMoveTest(theTestFile, theFileOpDir);
break ;
}
}
// ***********************************************************************
// ************************** Interface Tests ****************************
// ***********************************************************************
// nsIFile:
void CNsIFile::RunAllTests(nsILocalFile *theTestFile, nsILocalFile *theFileOpDir)
{
InitWithPathTest(theTestFile);
AppendRelativePathTest(theTestFile);
FileCreateTest(theTestFile);
FileExistsTest(theTestFile);
FileCopyTest(theTestFile, theFileOpDir);
FileMoveTest(theTestFile, theFileOpDir);
}
@ -253,198 +140,102 @@ void CNsIFile::RunAllTests(nsILocalFile *theTestFile, nsILocalFile *theFileOpDir
void CNsIFile::InitWithPathTest(nsILocalFile *theTestFile)
{
rv = theTestFile->InitWithPath("c:\\temp\\");
RvTestResult(rv, "InitWithPath() test (initializing file path)", 2);
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\"));
RvTestResult(rv, "InitWithNativePath() test (initializing file path)", 2);
}
void CNsIFile::AppendRelativePathTest(nsILocalFile *theTestFile)
{
rv = theTestFile->AppendRelativePath("myFile.txt");
rv = theTestFile->AppendRelativePath(NS_LITERAL_CSTRING("myFile.txt"));
RvTestResult(rv, "AppendRelativePath() test (append file to the path)", 2);
}
void CNsIFile::FileCreateTest(nsILocalFile *theTestFile)
{
PRBool exists = PR_TRUE;
rv = theTestFile->InitWithPath("c:\\temp\\");
rv = theTestFile->AppendRelativePath("myFile.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\"));
rv = theTestFile->AppendRelativePath(NS_LITERAL_CSTRING("myFile.txt"));
rv = theTestFile->Exists(&exists);
if (!exists)
{
QAOutput("File doesn't exist. We'll try creating it.", 2);
rv = theTestFile->Create(nsIFile::NORMAL_FILE_TYPE, 0777);
RvTestResult(rv, " File Create() test ('myFile.txt')", 2);
RvTestResult(rv, "File Create() test ('myFile.txt')", 2);
}
else
QAOutput("File already exists (myFile.txt). We won't create it.", 2);
}
void CNsIFile::FileExistsTest(nsILocalFile *theTestFile)
{
PRBool exists = PR_TRUE;
rv = theTestFile->InitWithPath("c:\\temp\\");
rv = theTestFile->AppendRelativePath("myFile.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\"));
rv = theTestFile->AppendRelativePath(NS_LITERAL_CSTRING("myFile.txt"));
rv = theTestFile->Exists(&exists);
if (!exists)
QAOutput("Exists() test Failed. File (myFile.txt) doesn't exist.", 2);
else
QAOutput("Exists() test Passed. File (myFile.txt) exists.", 2);
}
void CNsIFile::FileCopyTest(nsILocalFile *theTestFile, nsILocalFile *theFileOpDir)
{
PRBool exists = PR_TRUE;
QAOutput("Start File Copy test.", 2);
rv = theFileOpDir->InitWithPath("c:\\temp\\");
rv = theFileOpDir->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\"));
if (NS_FAILED(rv))
QAOutput("The target dir wasn't found.", 2);
else
QAOutput("The target dir was found.", 2);
rv = theTestFile->InitWithPath("c:\\temp\\myFile.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\myFile.txt"));
if (NS_FAILED(rv))
QAOutput("The path wasn't found.", 2);
else
QAOutput("The path was found.", 2);
rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
rv = theTestFile->CopyTo(theFileOpDir, NS_LITERAL_CSTRING("myFile2.txt"));
RvTestResult(rv, "rv CopyTo() test", 2);
rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\myFile2.txt"));
rv = theTestFile->Exists(&exists);
if (!exists)
QAOutput("File didn't copy. CopyTo() test Failed.", 2);
else
QAOutput("File copied. CopyTo() test Passed.", 2);
}
void CNsIFile::FileMoveTest(nsILocalFile *theTestFile, nsILocalFile *theFileOpDir)
{
PRBool exists = PR_TRUE;
QAOutput("Start File Move test.", 2);
rv = theFileOpDir->InitWithPath("c:\\Program Files\\");
rv = theFileOpDir->InitWithNativePath(NS_LITERAL_CSTRING("c:\\Program Files\\"));
if (NS_FAILED(rv))
QAOutput("The target dir wasn't found.", 2);
rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\temp\\myFile2.txt"));
if (NS_FAILED(rv))
QAOutput("The path wasn't found.", 2);
rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
rv = theTestFile->MoveTo(theFileOpDir, NS_LITERAL_CSTRING("myFile2.txt"));
RvTestResult(rv, "MoveTo() test", 2);
rv = theTestFile->InitWithPath("c:\\Program Files\\myFile2.txt");
rv = theTestFile->InitWithNativePath(NS_LITERAL_CSTRING("c:\\Program Files\\myFile2.txt"));
rv = theTestFile->Exists(&exists);
if (!exists)
QAOutput("File wasn't moved. MoveTo() test Failed.", 2);
else
QAOutput("File was moved. MoveTo() test Passed.", 2);
}

Просмотреть файл

@ -36,16 +36,16 @@
// WARNING: These hard coded names need to go away. They need to
// come from localizable resources
#define APP_REGISTRY_NAME "registry.dat"
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat")
#define PROFILE_ROOT_DIR_NAME "Profiles"
#define DEFAULTS_DIR_NAME "defaults"
#define DEFAULTS_PREF_DIR_NAME "pref"
#define DEFAULTS_PROFILE_DIR_NAME "profile"
#define RES_DIR_NAME "res"
#define CHROME_DIR_NAME "chrome"
#define PLUGINS_DIR_NAME "plugins"
#define SEARCH_DIR_NAME "searchplugins"
#define PROFILE_ROOT_DIR_NAME NS_LITERAL_CSTRING("Profiles")
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults")
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref")
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("profile")
#define RES_DIR_NAME NS_LITERAL_CSTRING("res")
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome")
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins")
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins")
//*****************************************************************************
@ -167,9 +167,8 @@ NS_METHOD winEmbedFileLocProvider::CloneMozBinDirectory(nsILocalFile **aLocalFil
// This will be set if a directory was passed to NS_InitXPCOM
// 2. If that doesn't work, set it to be the current process directory
// NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
@ -208,9 +207,8 @@ NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile
PRBool exists;
nsCOMPtr<nsILocalFile> localDir;
//NS_WITH_SERVICE(nsIProperties, directoryService, NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
rv = directoryService->Get(NS_WIN_APPDATA_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
if (NS_SUCCEEDED(rv))
@ -223,7 +221,7 @@ NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile
}
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath(mProductDirName);
rv = localDir->AppendRelativeNativePath(nsDependentCString(mProductDirName));
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)