mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
fixed makefile.win. some minor updates to other files.
a=asa for QA checkins that are not part of the default builds
This commit is contained in:
parent
c9062a9ec9
commit
1a5edf11e1
@ -1,111 +1,111 @@
|
||||
#
|
||||
# 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 Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
necko \
|
||||
webBrowser_core \
|
||||
widget \
|
||||
docshell \
|
||||
dom \
|
||||
uriloader \
|
||||
embed_base \
|
||||
webshell \
|
||||
shistory \
|
||||
pref \
|
||||
profile \
|
||||
find \
|
||||
gfx \
|
||||
windowwatcher \
|
||||
layout \
|
||||
history \
|
||||
helperAppDlg \
|
||||
content \
|
||||
webbrowserpersist \
|
||||
$(NULL)
|
||||
|
||||
DIRS=components \
|
||||
$(NULL)
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
|
||||
MODULE = testembed
|
||||
PROGRAM = .\$(OBJDIR)\$(MODULE).exe
|
||||
RESFILE = $(MODULE).res
|
||||
|
||||
LINCS = -Icomponents \
|
||||
$(NULL)
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\TestEmbed.obj \
|
||||
.\$(OBJDIR)\BrowserFrm.obj \
|
||||
.\$(OBJDIR)\BrowserFrameGlue.obj \
|
||||
.\$(OBJDIR)\BrowserView.obj \
|
||||
.\$(OBJDIR)\BrowserImpl.obj \
|
||||
.\$(OBJDIR)\BrowserImplWebPrgrsLstnr.obj \
|
||||
.\$(OBJDIR)\BrowserImplHistoryLstnr.obj \
|
||||
.\$(OBJDIR)\BrowserImplCtxMenuLstnr.obj \
|
||||
.\$(OBJDIR)\Dialogs.obj \
|
||||
.\$(OBJDIR)\ProfileMgr.obj \
|
||||
.\$(OBJDIR)\ProfilesDlg.obj \
|
||||
.\$(OBJDIR)\winEmbedFileLocProvider.obj \
|
||||
.\$(OBJDIR)\MostRecentUrls.obj \
|
||||
.\$(OBJDIR)\PrintProgressDialog.obj \
|
||||
.\$(OBJDIR)\Preferences.obj \
|
||||
.\$(OBJDIR)\StdAfx.obj \
|
||||
.\$(OBJDIR)\UrlDialog.obj \
|
||||
.\$(OBJDIR)\QaUtils.obj \
|
||||
.\$(OBJDIR)\Tests.obj \
|
||||
.\$(OBJDIR)\nsirequest.obj \
|
||||
.\$(OBJDIR)\nsihistory.obj \
|
||||
.\$(OBJDIR)\nsiwebnav.obj \
|
||||
.\$(OBJDIR)\nsiDirServ.obj \
|
||||
.\$(OBJDIR)\domwindow.obj \
|
||||
.\$(OBJDIR)\selection.obj \
|
||||
.\$(OBJDIR)\nsProfile.obj \
|
||||
.\$(OBJDIR)\nsIClipBoardCmd.obj \
|
||||
.\$(OBJDIR)\nsIObserServ.obj \
|
||||
.\$(OBJDIR)\nsIFile.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\baseembed_s.lib \
|
||||
$(DIST)\lib\gkgfx.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\testEmbedComponents.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON"
|
||||
LLFLAGS = -SUBSYSTEM:windows
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
$(MAKE_INSTALL) testembed.htm $(DIST)\bin
|
||||
|
||||
clobber_all::
|
||||
$(RM) $(DIST)\bin\$(MODULE).exe
|
||||
$(RM) $(DIST)\bin\testembed.htm
|
||||
|
||||
#
|
||||
# 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 Communicator client code,
|
||||
# released March 31, 1998.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
necko \
|
||||
webBrowser_core \
|
||||
widget \
|
||||
docshell \
|
||||
dom \
|
||||
uriloader \
|
||||
embed_base \
|
||||
webshell \
|
||||
shistory \
|
||||
pref \
|
||||
profile \
|
||||
find \
|
||||
gfx \
|
||||
windowwatcher \
|
||||
layout \
|
||||
history \
|
||||
helperAppDlg \
|
||||
content \
|
||||
webbrowserpersist \
|
||||
$(NULL)
|
||||
|
||||
DIRS=components \
|
||||
$(NULL)
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
|
||||
MODULE = testembed
|
||||
PROGRAM = .\$(OBJDIR)\$(MODULE).exe
|
||||
RESFILE = $(MODULE).res
|
||||
|
||||
LINCS = -Icomponents \
|
||||
$(NULL)
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\TestEmbed.obj \
|
||||
.\$(OBJDIR)\BrowserFrm.obj \
|
||||
.\$(OBJDIR)\BrowserFrameGlue.obj \
|
||||
.\$(OBJDIR)\BrowserView.obj \
|
||||
.\$(OBJDIR)\BrowserImpl.obj \
|
||||
.\$(OBJDIR)\BrowserImplWebPrgrsLstnr.obj \
|
||||
.\$(OBJDIR)\BrowserImplHistoryLstnr.obj \
|
||||
.\$(OBJDIR)\BrowserImplCtxMenuLstnr.obj \
|
||||
.\$(OBJDIR)\Dialogs.obj \
|
||||
.\$(OBJDIR)\ProfileMgr.obj \
|
||||
.\$(OBJDIR)\ProfilesDlg.obj \
|
||||
.\$(OBJDIR)\winEmbedFileLocProvider.obj \
|
||||
.\$(OBJDIR)\MostRecentUrls.obj \
|
||||
.\$(OBJDIR)\PrintProgressDialog.obj \
|
||||
.\$(OBJDIR)\Preferences.obj \
|
||||
.\$(OBJDIR)\StdAfx.obj \
|
||||
.\$(OBJDIR)\UrlDialog.obj \
|
||||
.\$(OBJDIR)\QaUtils.obj \
|
||||
.\$(OBJDIR)\Tests.obj \
|
||||
.\$(OBJDIR)\nsirequest.obj \
|
||||
.\$(OBJDIR)\nsihistory.obj \
|
||||
.\$(OBJDIR)\nsiwebnav.obj \
|
||||
.\$(OBJDIR)\nsiDirServ.obj \
|
||||
.\$(OBJDIR)\domwindow.obj \
|
||||
.\$(OBJDIR)\selection.obj \
|
||||
.\$(OBJDIR)\nsProfile.obj \
|
||||
.\$(OBJDIR)\nsIClipBoardCmd.obj \
|
||||
.\$(OBJDIR)\nsIObserServ.obj \
|
||||
.\$(OBJDIR)\nsIFile.obj \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\baseembed_s.lib \
|
||||
$(DIST)\lib\gkgfx.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\testEmbedComponents.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = /D "_AFXDLL" /D "USE_SINGLE_SIGN_ON"
|
||||
LLFLAGS = -SUBSYSTEM:windows
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(PROGRAM)
|
||||
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||
$(MAKE_INSTALL) testembed.htm $(DIST)\bin
|
||||
|
||||
clobber_all::
|
||||
$(RM) $(DIST)\bin\$(MODULE).exe
|
||||
$(RM) $(DIST)\bin\testembed.htm
|
||||
|
||||
|
@ -1,226 +1,450 @@
|
||||
/* -*- 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);
|
||||
}
|
||||
|
||||
|
||||
// ***********************************************************************
|
||||
// Individual nsIFile tests
|
||||
|
||||
void CNsIFile::InitWithPathTest(nsILocalFile *theTestFile)
|
||||
{
|
||||
rv = theTestFile->InitWithPath("c:\\temp\\");
|
||||
RvTestResult(rv, "InitWithPath() test (initializing file path)", 2);
|
||||
}
|
||||
|
||||
void CNsIFile::AppendRelativePathTest(nsILocalFile *theTestFile)
|
||||
{
|
||||
rv = theTestFile->AppendRelativePath("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->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);
|
||||
}
|
||||
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->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\\");
|
||||
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");
|
||||
if (NS_FAILED(rv))
|
||||
QAOutput("The path wasn't found.", 2);
|
||||
else
|
||||
QAOutput("The path was found.", 2);
|
||||
|
||||
rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
|
||||
RvTestResult(rv, "rv CopyTo() test", 2);
|
||||
|
||||
rv = theTestFile->InitWithPath("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\\");
|
||||
if (NS_FAILED(rv))
|
||||
QAOutput("The target dir wasn't found.", 2);
|
||||
|
||||
rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
|
||||
if (NS_FAILED(rv))
|
||||
QAOutput("The path wasn't found.", 2);
|
||||
|
||||
rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
|
||||
RvTestResult(rv, "MoveTo() test", 2);
|
||||
|
||||
rv = theTestFile->InitWithPath("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);
|
||||
}
|
||||
/* -*- 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ***********************************************************************
|
||||
|
||||
// Individual nsIFile tests
|
||||
|
||||
|
||||
|
||||
void CNsIFile::InitWithPathTest(nsILocalFile *theTestFile)
|
||||
|
||||
{
|
||||
|
||||
rv = theTestFile->InitWithPath("c:\\temp\\");
|
||||
|
||||
RvTestResult(rv, "InitWithPath() test (initializing file path)", 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CNsIFile::AppendRelativePathTest(nsILocalFile *theTestFile)
|
||||
|
||||
{
|
||||
|
||||
rv = theTestFile->AppendRelativePath("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->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);
|
||||
|
||||
}
|
||||
|
||||
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->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\\");
|
||||
|
||||
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");
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
||||
QAOutput("The path wasn't found.", 2);
|
||||
|
||||
else
|
||||
|
||||
QAOutput("The path was found.", 2);
|
||||
|
||||
|
||||
|
||||
rv = theTestFile->CopyTo(theFileOpDir, "myFile2.txt");
|
||||
|
||||
RvTestResult(rv, "rv CopyTo() test", 2);
|
||||
|
||||
|
||||
|
||||
rv = theTestFile->InitWithPath("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\\");
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
||||
QAOutput("The target dir wasn't found.", 2);
|
||||
|
||||
|
||||
|
||||
rv = theTestFile->InitWithPath("c:\\temp\\myFile2.txt");
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
||||
QAOutput("The path wasn't found.", 2);
|
||||
|
||||
|
||||
|
||||
rv = theTestFile->MoveTo(theFileOpDir, "myFile2.txt");
|
||||
|
||||
RvTestResult(rv, "MoveTo() test", 2);
|
||||
|
||||
|
||||
|
||||
rv = theTestFile->InitWithPath("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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,12 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* David Epstein <depstein@netscape.com>
|
||||
* Ashish Bhatt <ashishbhatt@netscape.com>
|
||||
*
|
||||
*
|
||||
* 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"),
|
||||
@ -49,11 +52,15 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CnsIObserServ::CnsIObserServ()
|
||||
{
|
||||
mRefCnt = 1 ;
|
||||
CnsIObserServ::CnsIObserServ()
|
||||
|
||||
{
|
||||
|
||||
mRefCnt = 1 ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
CnsIObserServ::~CnsIObserServ()
|
||||
{
|
||||
|
||||
@ -71,33 +78,58 @@ ObserverElement ObserverTable[] = {
|
||||
{"quit-application", PR_TRUE},
|
||||
{"session-logout", PR_FALSE}
|
||||
};
|
||||
|
||||
void CnsIObserServ::OnStartTests(UINT nMenuID)
|
||||
{
|
||||
// Calls all or indivdual test cases on the basis of the
|
||||
// option selected from menu.
|
||||
|
||||
switch(nMenuID)
|
||||
{
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS :
|
||||
RunAllTests();
|
||||
break;
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS :
|
||||
AddObserversTest();
|
||||
break;
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS :
|
||||
EnumerateObserversTest();
|
||||
break;
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_NOTIFYOBSERVERS :
|
||||
NotifyObserversTest();
|
||||
break;
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS :
|
||||
RemoveObserversTest();
|
||||
break;
|
||||
default :
|
||||
AfxMessageBox("Not added menu handler for this menu item");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
void CnsIObserServ::OnStartTests(UINT nMenuID)
|
||||
|
||||
{
|
||||
|
||||
// Calls all or indivdual test cases on the basis of the
|
||||
// option selected from menu.
|
||||
|
||||
|
||||
switch(nMenuID)
|
||||
|
||||
{
|
||||
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_RUNALLTESTS :
|
||||
|
||||
RunAllTests();
|
||||
|
||||
break;
|
||||
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_ADDOBSERVERS :
|
||||
|
||||
AddObserversTest();
|
||||
|
||||
break;
|
||||
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_ENUMERATEOBSERVERS :
|
||||
|
||||
EnumerateObserversTest();
|
||||
|
||||
break;
|
||||
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_NOTIFYOBSERVERS :
|
||||
|
||||
NotifyObserversTest();
|
||||
|
||||
break;
|
||||
|
||||
case ID_INTERFACES_NSIOBSERVERSERVICE_REMOVEOBSERVERS :
|
||||
|
||||
RemoveObserversTest();
|
||||
|
||||
break;
|
||||
|
||||
default :
|
||||
|
||||
AfxMessageBox("Not added menu handler for this menu item");
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CnsIObserServ::RunAllTests()
|
||||
{
|
||||
@ -116,19 +148,21 @@ void CnsIObserServ::AddObserversTest()
|
||||
QAOutput("nsIObserverService::AddObserversTest().");
|
||||
if (!observerService)
|
||||
{
|
||||
QAOutput("Can't get nsIObserverService object. Tests fail.");
|
||||
QAOutput("Can't get nsIObserverService object. Tests fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
observerService->AddObserver(this, "text/xml", PR_TRUE);
|
||||
|
||||
|
||||
|
||||
observerService->AddObserver(this, "text/xml", PR_TRUE);
|
||||
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
rv = observerService->AddObserver(this, ObserverTable[i].theTopic,
|
||||
ObserverTable[i].theOwnsWeak);
|
||||
RvTestResult(rv, "AddObservers() test", 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CnsIObserServ::RemoveObserversTest()
|
||||
@ -142,17 +176,19 @@ void CnsIObserServ::RemoveObserversTest()
|
||||
{
|
||||
QAOutput("Can't get nsIObserverService object. Tests fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
AddObserversTest();
|
||||
|
||||
}
|
||||
|
||||
|
||||
AddObserversTest();
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
rv = observerService->RemoveObserver(this, ObserverTable[i].theTopic);
|
||||
RvTestResult(rv, "RemoveObservers() test", 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CnsIObserServ::NotifyObserversTest()
|
||||
{
|
||||
QAOutput("nsIObserverService::NotifyObserversTest().");
|
||||
@ -170,15 +206,19 @@ void CnsIObserServ::EnumerateObserversTest()
|
||||
{
|
||||
QAOutput("Can't get nsIObserverService object. Tests fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
AddObserversTest();
|
||||
|
||||
}
|
||||
|
||||
|
||||
AddObserversTest();
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
// need to handle Simple Enumerator
|
||||
rv = observerService->EnumerateObservers(ObserverTable[i].theTopic,
|
||||
getter_AddRefs(simpleEnum));
|
||||
// need to handle Simple Enumerator
|
||||
|
||||
rv = observerService->EnumerateObservers(ObserverTable[i].theTopic,
|
||||
|
||||
getter_AddRefs(simpleEnum));
|
||||
|
||||
|
||||
RvTestResult(rv, "EnumerateObserversTest() test", 2);
|
||||
if (!simpleEnum)
|
||||
@ -188,19 +228,24 @@ void CnsIObserServ::EnumerateObserversTest()
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserver> observer;
|
||||
PRBool theLoop = PR_TRUE;
|
||||
PRBool bLoop = PR_TRUE;
|
||||
PRBool theLoop = PR_TRUE;
|
||||
|
||||
PRBool bLoop = PR_TRUE;
|
||||
|
||||
while( NS_SUCCEEDED(simpleEnum->HasMoreElements(&theLoop)) && bLoop)
|
||||
{
|
||||
|
||||
simpleEnum->GetNext(getter_AddRefs(observer));
|
||||
|
||||
|
||||
|
||||
simpleEnum->GetNext(getter_AddRefs(observer));
|
||||
|
||||
|
||||
|
||||
rv = observer->Observe(observer, ObserverTable[i].theTopic, 0);
|
||||
RvTestResult(rv, "Observer() test", 2);
|
||||
|
||||
// compare 'this' with observer object
|
||||
// if (this ==(CnsIObserServ *)observer)
|
||||
|
||||
// if (this ==(CnsIObserServ *)observer)
|
||||
|
||||
|
||||
if( this == NS_REINTERPRET_CAST(CnsIObserServ*,NS_REINTERPRET_CAST(void*, observer.get())))
|
||||
QAOutput("match. Test passes.");
|
||||
@ -209,9 +254,10 @@ void CnsIObserServ::EnumerateObserversTest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(CnsIObserServ, nsIObserver, nsISupportsWeakReference);
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(CnsIObserServ, nsIObserver, nsISupportsWeakReference);
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP CnsIObserServ::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData)
|
||||
|
@ -76,11 +76,11 @@ CNsIWebNav::~CNsIWebNav()
|
||||
|
||||
// Url table for web navigation
|
||||
NavElement UrlTable[] = {
|
||||
{"http://www.netscape.com/", nsIWebNavigation::LOAD_FLAGS_NONE},
|
||||
{"http://www.intel.com/", nsIWebNavigation::LOAD_FLAGS_NONE},
|
||||
{"http://www.yahoo.com/", nsIWebNavigation::LOAD_FLAGS_NONE},
|
||||
{"http://www.oracle.com/", nsIWebNavigation::LOAD_FLAGS_IS_LINK},
|
||||
{"http://www.sun.com/", nsIWebNavigation::LOAD_FLAGS_IS_REFRESH},
|
||||
{"http://www.aol.com/", nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY},
|
||||
{"ftp://ftp.mozilla.org/", nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY},
|
||||
{"https://www.yahoo.com/", nsIWebNavigation::LOAD_FLAGS_NONE},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user