support for regression testing. r=rods

This commit is contained in:
dcone%netscape.com 2000-01-26 15:14:41 +00:00
Родитель 1ddb177877
Коммит b0fee5d1bd
14 изменённых файлов: 185 добавлений и 67 удалений

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

@ -68,6 +68,7 @@
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIFrameDebug.h"
#include "nsIServiceManager.h"
@ -181,11 +182,12 @@ protected:
nsCOMPtr<nsIStyleSheet> mUAStyleSheet;
PRBool mEnableRendering;
PRBool mEnableRendering;
PRInt16 mNumURLStarts;
PRBool mIsPrinting;
// printing members
nsIDeviceContext *mPrintDC;
nsIPresContext *mPrintPC;
@ -193,6 +195,7 @@ protected:
nsIPresShell *mPrintPS;
nsIViewManager *mPrintVM;
nsIView *mPrintView;
FILE *mFilePointer; // a file where information can go to when printing
// document management data
// these items are specific to markup documents (html and xml)
@ -233,6 +236,7 @@ DocumentViewerImpl::DocumentViewerImpl()
{
NS_INIT_REFCNT();
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -246,6 +250,7 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
mAllowPlugins = PR_TRUE;
mIsFrame = PR_FALSE;
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -659,7 +664,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->Init(mDocument, cx, vm, ss);
//lay it out...
//aDContext->BeginDocument();
ps->InitialReflow(width, height);
// Ask the page sequence frame to print all the pages
@ -668,7 +672,22 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->GetPageSequenceFrame(&pageSequence);
NS_ASSERTION(nsnull != pageSequence, "no page sequence frame");
pageSequence->Print(cx, options, nsnull);
if (nsnull != mFilePointer) {
// output the regression test
nsIFrameDebug* fdbg;
nsIFrame* root;
ps->GetRootFrame(&root);
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(cx, mFilePointer, 0);
}
fclose(mFilePointer);
} else {
pageSequence->Print(cx, options, nsnull);
}
aDContext->EndDocument();
ps->EndObservingDocument();
@ -1094,11 +1113,11 @@ static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTOR
/** ---------------------------------------------------
* See documentation above in the DocumentViewerImpl class definition
* @update 07/09/99 dwc
* See documentation above in the nsIContentViewerfile class definition
* @update 01/24/00 dwc
*/
NS_IMETHODIMP
DocumentViewerImpl::Print()
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
nsCOMPtr<nsIWebShell> webContainer;
nsCOMPtr<nsIDeviceContextSpecFactory> factory;
@ -1119,8 +1138,9 @@ nsCOMPtr<nsIPref> prefs;
nsIDeviceContextSpec *devspec = nsnull;
nsCOMPtr<nsIDeviceContext> dx;
mPrintDC = nsnull;
mFilePointer = aFile;
factory->CreateDeviceContextSpec(nsnull, devspec, PR_FALSE);
factory->CreateDeviceContextSpec(nsnull, devspec, aSilent);
if (nsnull != devspec) {
mPresContext->GetDeviceContext(getter_AddRefs(dx));
nsresult rv = dx->GetDeviceContextFor(devspec, mPrintDC);

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

@ -1653,7 +1653,7 @@ GlobalWindowImpl::Print()
if (nsnull != viewer) {
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
if (viewerFile) {
result = viewerFile->Print();
result = viewerFile->Print(PR_FALSE,nsnull);
}
}
}

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

@ -68,6 +68,7 @@
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIFrameDebug.h"
#include "nsIServiceManager.h"
@ -181,11 +182,12 @@ protected:
nsCOMPtr<nsIStyleSheet> mUAStyleSheet;
PRBool mEnableRendering;
PRBool mEnableRendering;
PRInt16 mNumURLStarts;
PRBool mIsPrinting;
// printing members
nsIDeviceContext *mPrintDC;
nsIPresContext *mPrintPC;
@ -193,6 +195,7 @@ protected:
nsIPresShell *mPrintPS;
nsIViewManager *mPrintVM;
nsIView *mPrintView;
FILE *mFilePointer; // a file where information can go to when printing
// document management data
// these items are specific to markup documents (html and xml)
@ -233,6 +236,7 @@ DocumentViewerImpl::DocumentViewerImpl()
{
NS_INIT_REFCNT();
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -246,6 +250,7 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
mAllowPlugins = PR_TRUE;
mIsFrame = PR_FALSE;
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -659,7 +664,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->Init(mDocument, cx, vm, ss);
//lay it out...
//aDContext->BeginDocument();
ps->InitialReflow(width, height);
// Ask the page sequence frame to print all the pages
@ -668,7 +672,22 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->GetPageSequenceFrame(&pageSequence);
NS_ASSERTION(nsnull != pageSequence, "no page sequence frame");
pageSequence->Print(cx, options, nsnull);
if (nsnull != mFilePointer) {
// output the regression test
nsIFrameDebug* fdbg;
nsIFrame* root;
ps->GetRootFrame(&root);
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(cx, mFilePointer, 0);
}
fclose(mFilePointer);
} else {
pageSequence->Print(cx, options, nsnull);
}
aDContext->EndDocument();
ps->EndObservingDocument();
@ -1094,11 +1113,11 @@ static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTOR
/** ---------------------------------------------------
* See documentation above in the DocumentViewerImpl class definition
* @update 07/09/99 dwc
* See documentation above in the nsIContentViewerfile class definition
* @update 01/24/00 dwc
*/
NS_IMETHODIMP
DocumentViewerImpl::Print()
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
nsCOMPtr<nsIWebShell> webContainer;
nsCOMPtr<nsIDeviceContextSpecFactory> factory;
@ -1119,8 +1138,9 @@ nsCOMPtr<nsIPref> prefs;
nsIDeviceContextSpec *devspec = nsnull;
nsCOMPtr<nsIDeviceContext> dx;
mPrintDC = nsnull;
mFilePointer = aFile;
factory->CreateDeviceContextSpec(nsnull, devspec, PR_FALSE);
factory->CreateDeviceContextSpec(nsnull, devspec, aSilent);
if (nsnull != devspec) {
mPresContext->GetDeviceContext(getter_AddRefs(dx));
nsresult rv = dx->GetDeviceContextFor(devspec, mPrintDC);

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

@ -68,6 +68,7 @@
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIFrameDebug.h"
#include "nsIServiceManager.h"
@ -181,11 +182,12 @@ protected:
nsCOMPtr<nsIStyleSheet> mUAStyleSheet;
PRBool mEnableRendering;
PRBool mEnableRendering;
PRInt16 mNumURLStarts;
PRBool mIsPrinting;
// printing members
nsIDeviceContext *mPrintDC;
nsIPresContext *mPrintPC;
@ -193,6 +195,7 @@ protected:
nsIPresShell *mPrintPS;
nsIViewManager *mPrintVM;
nsIView *mPrintView;
FILE *mFilePointer; // a file where information can go to when printing
// document management data
// these items are specific to markup documents (html and xml)
@ -233,6 +236,7 @@ DocumentViewerImpl::DocumentViewerImpl()
{
NS_INIT_REFCNT();
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -246,6 +250,7 @@ DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext)
mAllowPlugins = PR_TRUE;
mIsFrame = PR_FALSE;
mEnableRendering = PR_TRUE;
mFilePointer = nsnull;
}
@ -659,7 +664,6 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->Init(mDocument, cx, vm, ss);
//lay it out...
//aDContext->BeginDocument();
ps->InitialReflow(width, height);
// Ask the page sequence frame to print all the pages
@ -668,7 +672,22 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
ps->GetPageSequenceFrame(&pageSequence);
NS_ASSERTION(nsnull != pageSequence, "no page sequence frame");
pageSequence->Print(cx, options, nsnull);
if (nsnull != mFilePointer) {
// output the regression test
nsIFrameDebug* fdbg;
nsIFrame* root;
ps->GetRootFrame(&root);
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(cx, mFilePointer, 0);
}
fclose(mFilePointer);
} else {
pageSequence->Print(cx, options, nsnull);
}
aDContext->EndDocument();
ps->EndObservingDocument();
@ -1094,11 +1113,11 @@ static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTOR
/** ---------------------------------------------------
* See documentation above in the DocumentViewerImpl class definition
* @update 07/09/99 dwc
* See documentation above in the nsIContentViewerfile class definition
* @update 01/24/00 dwc
*/
NS_IMETHODIMP
DocumentViewerImpl::Print()
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
nsCOMPtr<nsIWebShell> webContainer;
nsCOMPtr<nsIDeviceContextSpecFactory> factory;
@ -1119,8 +1138,9 @@ nsCOMPtr<nsIPref> prefs;
nsIDeviceContextSpec *devspec = nsnull;
nsCOMPtr<nsIDeviceContext> dx;
mPrintDC = nsnull;
mFilePointer = aFile;
factory->CreateDeviceContextSpec(nsnull, devspec, PR_FALSE);
factory->CreateDeviceContextSpec(nsnull, devspec, aSilent);
if (nsnull != devspec) {
mPresContext->GetDeviceContext(getter_AddRefs(dx));
nsresult rv = dx->GetDeviceContextFor(devspec, mPrintDC);

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

@ -616,7 +616,7 @@ PluginViewerImpl::GetSaveable(PRBool *aSaveable)
}
NS_IMETHODIMP
PluginViewerImpl::Print()
PluginViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
return NS_OK; // XXX: hey, plug in guys! implement me!
}

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

@ -282,7 +282,7 @@ NS_IMETHODIMP nsAddressBook::PrintCard()
{
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
if (viewerFile) {
rv = viewerFile->Print();
rv = viewerFile->Print(PR_FALSE,nsnull);
}
#ifdef DEBUG_seth
else {

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

@ -616,7 +616,7 @@ PluginViewerImpl::GetSaveable(PRBool *aSaveable)
}
NS_IMETHODIMP
PluginViewerImpl::Print()
PluginViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
return NS_OK; // XXX: hey, plug in guys! implement me!
}

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

@ -616,7 +616,7 @@ PluginViewerImpl::GetSaveable(PRBool *aSaveable)
}
NS_IMETHODIMP
PluginViewerImpl::Print()
PluginViewerImpl::Print(PRBool aSilent,FILE *aFile)
{
return NS_OK; // XXX: hey, plug in guys! implement me!
}

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

@ -28,8 +28,16 @@ class nsIContentViewerFile : public nsISupports {
/* readonly attribute boolean saveable; */
NS_IMETHOD GetSaveable(PRBool *aSaveable) = 0;
/* void Print (); */
NS_IMETHOD Print(void) = 0;
/* void Print ();
*/
/**
* Print the current document
* @param aSilent -- if true, the print settings dialog will be suppressed
* @param aFileName -- a file pointer to output regression tests or print to a file
* @return error status
*/
NS_IMETHOD Print(PRBool aSilent,FILE *aFile) = 0;
/* [noscript] void PrintContent (in nsIWebShell parent, in nsIDeviceContext DContext); */
NS_IMETHOD PrintContent(nsIWebShell * parent, nsIDeviceContext * DContext) = 0;
@ -42,7 +50,7 @@ class nsIContentViewerFile : public nsISupports {
#define NS_DECL_NSICONTENTVIEWERFILE \
NS_IMETHOD Save(void); \
NS_IMETHOD GetSaveable(PRBool *aSaveable); \
NS_IMETHOD Print(void); \
NS_IMETHOD Print(PRBool aSilent,FILE *aFile); \
NS_IMETHOD PrintContent(nsIWebShell * parent, nsIDeviceContext * DContext); \
NS_IMETHOD GetPrintable(PRBool *aPrintable);
@ -50,7 +58,7 @@ class nsIContentViewerFile : public nsISupports {
#define NS_FORWARD_NSICONTENTVIEWERFILE(_to) \
NS_IMETHOD Save(void) { return _to ## Save(); } \
NS_IMETHOD GetSaveable(PRBool *aSaveable) { return _to ## GetSaveable(aSaveable); } \
NS_IMETHOD Print(void) { return _to ## Print(); } \
NS_IMETHOD Print(PRBool aSilent,FILE *aFile) { return _to ## Print(); } \
NS_IMETHOD PrintContent(nsIWebShell * parent, nsIDeviceContext * DContext) { return _to ## PrintContent(parent, DContext); } \
NS_IMETHOD GetPrintable(PRBool *aPrintable) { return _to ## GetPrintable(aPrintable); }

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

@ -2421,7 +2421,7 @@ void nsBrowserWindow::DoPrint(void)
{
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
if (viewerFile) {
viewerFile->Print();
viewerFile->Print(PR_FALSE,0);
}
}
}

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

@ -438,6 +438,7 @@ PrintHelpInfo(char **argv)
fprintf(stderr, "-A domain -- add a domain/host that should be avoided (e.g. microsoft.com)\n");
fprintf(stderr, "-N pages -- set the max # of pages to crawl\n");
fprintf(stderr, "-x -- startup and just shutdown to test for leaks under Purify\n");
fprintf(stderr, "-Prt -- printer test will be run\n");
#if defined(NS_DEBUG) && defined(XP_WIN)
fprintf(stderr, "-md # -- set the crt debug flags to #\n");
#endif
@ -654,6 +655,15 @@ nsViewerApp::ProcessArguments(int argc, char** argv)
else if (PL_strcmp(argv[i], "-?") == 0) {
PrintHelpInfo(argv);
}
else if (PL_strcmp(argv[i], "-Prt") == 0) {
int printTestType;
i++;
if (i>=argc || 1!=sscanf(argv[i], "%d", &printTestType)){
PrintHelpInfo(argv);
exit(-1);
}
mCrawler->SetPrintTest(printTestType);
}
}
else
break;

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

@ -49,6 +49,9 @@
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
#include "prprf.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_IID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
@ -183,6 +186,7 @@ nsWebCrawler::nsWebCrawler(nsViewerApp* aViewer)
mVerbose = nsnull;
LL_I2L(mStartLoad, 0);
mRegressing = PR_FALSE;
mPrinterTestType = 0;
}
static void FreeStrings(nsVoidArray& aArray)
@ -297,41 +301,75 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NS_DEBUG
if (mOutputDir.Length() > 0) {
nsIFrame* root;
shell->GetRootFrame(&root);
if (nsnull != root) {
nsCOMPtr<nsIPresContext> presContext;
shell->GetPresContext(getter_AddRefs(presContext));
if (mOutputDir.Length() > 0)
{
nsAutoString regressionFileName;
FILE *fp = GetOutputFile(aURL, regressionFileName);
if (fp) {
nsIFrameDebug* fdbg;
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(presContext, fp, 0);
if ( mPrinterTestType > 0 ) {
nsCOMPtr <nsIContentViewer> viewer;
nsIWebShell* webshell = nsnull;
mBrowser->GetWebShell(webshell);
webshell->GetContentViewer(getter_AddRefs(viewer));
if (viewer){
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
if (viewerFile) {
nsAutoString regressionFileName;
FILE *fp = GetOutputFile(aURL, regressionFileName);
switch (mPrinterTestType) {
case 1:
// dump print data to a file for regression testing
viewerFile->Print(PR_TRUE,fp);
break;
case 2:
// visual printing tests, all go to the printer, no printer dialog
viewerFile->Print(PR_TRUE,0);
break;
case 3:
// visual printing tests, all go to the printer, with a printer dialog
viewerFile->Print(PR_FALSE,0);
break;
default:
break;
}
fclose(fp);
if (mRegressing) {
PerformRegressionTest(regressionFileName);
fclose(fp);
}
}
} else {
nsIFrame* root;
shell->GetRootFrame(&root);
if (nsnull != root) {
nsCOMPtr<nsIPresContext> presContext;
shell->GetPresContext(getter_AddRefs(presContext));
if (mOutputDir.Length() > 0)
{
nsAutoString regressionFileName;
FILE *fp = GetOutputFile(aURL, regressionFileName);
if (fp) {
nsIFrameDebug* fdbg;
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(presContext, fp, 0);
}
fclose(fp);
if (mRegressing) {
PerformRegressionTest(regressionFileName);
}
else {
fputs(regressionFileName, stdout);
printf(" - being written\n");
}
}
else {
fputs(regressionFileName, stdout);
printf(" - being written\n");
char* file;
(void)aURL->GetPath(&file);
printf("could not open output file for %s\n", file);
nsCRT::free(file);
}
}
else {
char* file;
(void)aURL->GetPath(&file);
printf("could not open output file for %s\n", file);
nsCRT::free(file);
}
}
else {
nsIFrameDebug* fdbg;
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(presContext, stdout, 0);
nsIFrameDebug* fdbg;
if (NS_SUCCEEDED(root->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg))) {
fdbg->DumpRegressionData(presContext, stdout, 0);
}
}
}
}
@ -365,6 +403,10 @@ nsWebCrawler::OnEndDocumentLoad(nsIDocumentLoader* loader,
fputs("null pres shell\n", stdout);
}
if (mPostExit && (0 == mQueuedLoadURLs)) {
QueueExit();
}
return NS_OK;
}
@ -809,9 +851,6 @@ nsWebCrawler::LoadNextURL(PRBool aQueueLoad)
mRecord = nsnull;
}
if (mPostExit && (0 == mQueuedLoadURLs)) {
QueueExit();
}
}
nsIPresShell*
@ -1033,9 +1072,7 @@ nsWebCrawler::GoToQueuedURL(const nsString& aURL)
NS_RELEASE(webShell);
}
mQueuedLoadURLs--;
if ((0 == mQueuedLoadURLs) && (0 == mPendingURLs.Count())) {
QueueExit();
}
}
nsresult

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

@ -81,6 +81,8 @@ public:
mDelay = aSeconds;
}
void SetPrintTest(PRInt32 aTestType) { mPrinterTestType = aTestType; }
void EnableJiggleLayout() {
mJiggleLayout = PR_TRUE;
}
@ -179,6 +181,7 @@ protected:
PRTime mStartLoad;
PRBool mVerbose;
PRBool mRegressing;
PRInt32 mPrinterTestType;
nsString mRegressionDir;
nsVoidArray mPendingURLs;

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

@ -1990,7 +1990,7 @@ nsBrowserAppCore::Print()
if (nsnull != viewer) {
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
if (viewerFile) {
NS_ENSURE_SUCCESS(viewerFile->Print(), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(viewerFile->Print(PR_FALSE,nsnull), NS_ERROR_FAILURE);
}
}
}