Not part of the build. Updated layout-plugin code. Added method to output the regression data to a file.

This commit is contained in:
dcone%netscape.com 2002-12-04 22:11:40 +00:00
Родитель 5a7c3a50ce
Коммит 04cc9b2096
6 изменённых файлов: 90 добавлений и 577 удалений

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

@ -1,94 +0,0 @@
/* -*- 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) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Don Cone <dcone@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 ***** */
#include "nsISupports.idl"
[scriptable, uuid(1B4CD090-0531-11d6-A876-00105A183419)]
interface nsIDebugObject : nsISupports
{
/**
* creates a directory.. only locally
* @param
* @param
*/
void CreateDirectory(in wstring aDirectoryPath, in unsigned long aFlags);
/**
* Dumps the content of a window
* @param
* @param
*/
void DumpContent(in nsISupports aUrlToDump,in wstring aFilePath,in wstring aFileName, in unsigned long aFlags);
/**
* Compares the contents of frame model files
* @param
* @param
*/
void CompareFrameModels(in wstring aBasePath,in wstring aVerPath,in wstring aBaseFile,in wstring aVerFile, in unsigned long aFlags);
/**
* Printing Runtime Error Checking
*/
const short PRT_RUNTIME_NONE = 0;
const short PRT_RUNTIME_CHECKFORPRINTERS = 1;
const short PRT_RUNTIME_CREATEPRTSESSION = 2;
const short PRT_RUNTIME_INITPRTOBJ = 3;
const short PRT_RUNTIME_CREATESPECFACTORY = 4;
const short PRT_RUNTIME_NOPROMPTSERVICE = 5;
const short PRT_RUNTIME_NODEVSPEC = 6;
const short PRT_RUNTIME_NEXTPAGE = 7;
const short PRT_RUNTIME_REFLOWDOCLIST = 8;
const short PRT_RUNTIME_PREPAREDOC = 9;
const short PRT_RUNTIME_BEGINDOC = 10;
attribute boolean doRuntimeTests; // indicates whether the runtime test will be run
attribute short testId; // id of test to run
attribute boolean printAsIs; // print asis when printing to a file
attribute wstring printFileName; // name of output file
};
%{ C++
%}

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

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
interface nsIDebugPlugin : nsISupports {
readonly attribute string version;
void CreateDirectory(in wstring aDirPath,in unsigned long aFlags,[retval] out long aResult);
void DumpLayout(in nsISupports aWindow,in wstring aFilePath,in wstring aFileName,in unsigned long aFlags,[retval] out long aResult );
void StartDirectorySearch(in string aFilePath);
void GetNextFileInDirectory([retval] out string aFileName);
void CompareLayoutFiles(in wstring aBasePath,in wstring aVerPath,in wstring aBaseFile,in wstring aVerFile,in unsigned long aFlags,[retval] out long aResult);
void PluginShutdown();
/**
* Printing Runtime Error Checking
*/
const short PRT_RUNTIME_NONE = 0;
const short PRT_RUNTIME_CHECKFORPRINTERS = 1;
const short PRT_RUNTIME_CREATEPRTSESSION = 2;
const short PRT_RUNTIME_INITPRTOBJ = 3;
const short PRT_RUNTIME_CREATESPECFACTORY = 4;
const short PRT_RUNTIME_NOPROMPTSERVICE = 5;
const short PRT_RUNTIME_NODEVSPEC = 6;
const short PRT_RUNTIME_NEXTPAGE = 7;
const short PRT_RUNTIME_REFLOWDOCLIST = 8;
const short PRT_RUNTIME_PREPAREDOC = 9;
const short PRT_RUNTIME_BEGINDOC = 10;
attribute boolean doRuntimeTests; // indicates whether the runtime test will be run
attribute short testId; // id of test to run
attribute boolean printAsIs; // print asis when printing to a file
attribute wstring printFileName; // name of output file
void SetBoolPref(in wstring aPrefName, in boolean aVal);
};

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

@ -163,6 +163,30 @@ PRBool retVal;
return rv;
}
/** ---------------------------------------------------
* See documentation in nsScriptablePeer.h
* @update 9/25/02 dwc
*/
NS_IMETHODIMP
nsScriptablePeer::OutputTextToFile(PRBool aNewFile,const PRUnichar *aFilePath, const PRUnichar *aFileName,
const PRUnichar *aOutputString,PRInt32 *aResult)
{
nsresult rv = NS_OK;
PRBool retVal;
if(mDebugObj){
retVal = mDebugObj->OutputTextToFile(aNewFile,aFilePath,aFileName,aOutputString);
if (retVal == NS_OK) {
*aResult= 0;
} else {
*aResult = 1; // not really fatal...
}
}
return rv;
}
/** ---------------------------------------------------
* See documentation in nsScriptablePeer.h
* @update 9/25/02 dwc

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

@ -1,426 +0,0 @@
<HTML>
<HEAD>
<TITLE>Debug Plug-in Test</TITLE>
</HEAD>
<BODY>
<center>
<h2> Example XPConnect Scriptable Debug Plug-in Regression Page</h2>
</center>
<embed type="application/debug-plugin" width=1 height=1 hidden="true"><br>
<script>
var embed = document.embeds[0];
var started = false;
var theWindow;
var fileDirectory;
var baseExt;
var verExt;
var baseDir;
var verDir;
var testType;
var changed = false;
var lb,mb,pb,sb,stb,tb;
var origLeft;
var origTop;
var origWidth;
var origHeight;
var dirType;
var curIndex;
var startIndex;
var endIndex;
var dumpStyle;
var myArray = new Array(15);
// table
myArray[0] = "file:///S|/mozilla/layout/html/tests/table/dom";
myArray[1] = "s:/regressiontests/";
myArray[2] = "s:/regressiontests/";
myArray[3] = "file:///S|/mozilla/layout/html/tests/table/core";
myArray[4] = "s:/regressiontests/";
myArray[5] = "s:/regressiontests/";
myArray[6] = "file:///S|/mozilla/layout/html/tests/table/other";
myArray[7] = "s:/regressiontests/";
myArray[8] = "s:/regressiontests/";
myArray[9] = "file:///S|/mozilla/layout/html/tests/table/dom";
myArray[10] = "s:/regressiontests/";
myArray[11] = "s:/regressiontests/";
myArray[12] = "file:///S|/mozilla/layout/html/tests/table/printing";
myArray[13] = "s:/regressiontests/";
myArray[14] = "s:/regressiontests/";
// block
myArray[15] = "file:///S|/mozilla/layout/html/tests/block/base";
myArray[16] = "s:/regressiontests/";
myArray[17] = "s:/regressiontests/";
myArray[18] = "file:///S|/mozilla/layout/html/tests/block/bugs";
myArray[19] = "s:/regressiontests/";
myArray[20] = "s:/regressiontests/";
// form controls
myArray[21] = "file:///S|/mozilla/layout/html/tests/formctls/base";
myArray[22] = "s:/regressiontests/";
myArray[23] = "s:/regressiontests/";
myArray[24] = "file:///S|/mozilla/layout/html/tests/formctls/bugs";
myArray[25] = "s:/regressiontests/";
myArray[26] = "s:/regressiontests/";
//=============================================================================
function CompareFiles(aBaseDir,aVerDir,aBaselineFile,aVerFile)
{
var err = embed.CompareLayoutFiles(aBaseDir,aVerDir,aBaselineFile,aVerFile,1);
if(err == 0) {
WriteOutput("File \" "+aVerFile + "\" PASSED",false,"success",true,true );
} else {
WriteOutput("File \" "+aVerFile + "\" FAILED ",false,"failure",true,true );
}
}
//=============================================================================
function ClearOutput()
{
var textarea = document.getElementById('output');
textarea.innerHTML = "";
}
//=============================================================================
function WriteOutput( aText, aReplace, aTextColor,aToStatus, aToOutPut )
{
var textarea = document.getElementById('output');
var statusarea = document.getElementById('status');
var thecolor = "<font color=black>";
if(aTextColor == "failure")
thecolor = "<font color=red>";
if(aTextColor == "success")
thecolor = "<font color=green>";
if ( aToStatus ) {
statusarea.innerHTML = thecolor + aText +"</font>";
}
if (aToOutPut) {
if( aReplace ) {
textarea.innerHTML = thecolor + aText +"</font>";
} else {
textarea.innerHTML = thecolor + textarea.innerHTML + "<br>" + aText +"</font>";
}
}
}
//=============================================================================
function placeWindows(aOutputWindow,aTestWindow)
{
// save old values, get rid of chrome and move and resize the windows
if ( changed == false ) {
lb = aOutputWindow.locationbar.visible;
mb = aOutputWindow.menubar.visible;
pb = aOutputWindow.personalbar.visible;
sb = aOutputWindow.scrollbars.visible;
stb = aOutputWindow.statusbar.visible;
tb = aOutputWindow.toolbar.visible;
aOutputWindow.focus();
origLeft = aOutputWindow.screen.left;
origTop = aOutputWindow.screen.top;
origWidth = aOutputWindow.outerWidth;
origHeight = aOutputWindow.outerHeight;
changed = true;
}
aOutputWindow.locationbar.visible = false;
aOutputWindow.menubar.visible = false;
aOutputWindow.personalbar.visible = false;
aOutputWindow.scrollbars.visible = false;
aOutputWindow.statusbar.visible = false;
aOutputWindow.toolbar.visible = false;
var top = window.screen.availTop;
var left = window.screen.availLeft;
var height = window.screen.availHeight;
var width = window.screen.availWidth;
if (height > 1000) {
height = 800;
} else {
height = height - 200;
}
if (width > 800) {
width = 800;
}
// size the window to the largest possible
aTestWindow.moveTo(left,200);
aTestWindow.resizeTo(width,height);
aOutputWindow.focus();
//aOutputWindow.moveTo(left,top);
//aOutputWindow.resizeTo(width,200);
//aOutputWindow.scroll(0,1000);
}
//=============================================================================
function ShowDirectories()
{
for(i=0;i<(myArray.length);i+=3){
WriteOutput( myArray[i], false, "normal" ,false,true );
}
}
//=============================================================================
function runTests()
{
if (document.getElementById('ar').checked ) {
// all
startIndex = 0; endIndex = myArray.length;
} else if (document.getElementById('tr').checked ) {
// table
startIndex = 0; endIndex = 15;
} else if (document.getElementById('br').checked ) {
// base
startIndex = 15; endIndex = 21;
} else if (document.getElementById('fcr').checked ) {
// form controls
startIndex = 21; endIndex = 27;
}
// three buttons we use to check the kind of test we run (rb rv rvc)
if (document.getElementById('rb').checked ) {
// baseline
testType = 1;
} else if (document.getElementById('rv').checked ) {
// verify
testType = 2;
}
ClearOutput();
WriteOutput( "Starting Directory Tests",true,"normal",true,false );
curIndex = 0;
DumpDirectoryies(testType);
}
//=============================================================================
function DumpDirectoryies(aTestType)
{
if ( curIndex == 0) {
WriteOutput( "Starting Tests",true,"normal",true,false );
}
if ( curIndex < endIndex ) {
fileDirectory = myArray[curIndex];
baseDir = myArray[curIndex+1];
verDir = myArray[curIndex+2];
baseExt = ".bas";
verExt = ".ver";
var dirURL;
var err;
// create the output directories
if ( testType == 1 ) {
dirURL = "file:///"+ baseDir;
err = embed.CreateDirectory(dirURL,0);
}
if ( (testType == 1) || (testType == 2) ) {
dirURL = "file:///"+ verDir;
err = embed.CreateDirectory(dirURL,0);
}
WriteOutput( "New Directory" , false, "normal" ,true, true );
DumpFrames(true,0,aTestType);
} else {
// all completed
theWindow.close();
RestoreWindow();
}
}
//=============================================================================
function DumpFrames(firstTime,lastFile,aTestType)
{
var loadingFlag;
if (firstTime == true) {
ClearOutput();
WriteOutput( "Starting Tests",true,"normal",true,false );
embed.StartDirectorySearch(fileDirectory);
filename=embed.GetNextFileInDirectory();
if ( filename != null) {
outputWindow = window;
theWindow = window.open(filename,0);
placeWindows(outputWindow,theWindow);
}
if ( document.getElementById('ds').checked ) {
dumpStyle = 1;
} else {
dumpStyle = 0;
}
started = true;
} else {
filename = lastFile;
}
while ( filename != null) {
// take off the file path.. so we just have the file name for the output
var startindex = filename.lastIndexOf("/");
var outputfilename = filename.slice(startindex+1,filename.length);
if (aTestType==1) {
// baseline
outputfilename = outputfilename.replace (".html",baseExt);
loading = embed.DumpLayout(theWindow,baseDir,outputfilename,dumpStyle);
} else if ((aTestType==2)|| (aTestType==3) ) {
// verify
outputfilename = outputfilename.replace (".html",verExt);
loading = embed.DumpLayout(theWindow,verDir,outputfilename,dumpStyle);
} else if (aTestType==4) {
// just compare
outputfilename = outputfilename.replace (".html",verExt);
loading = 0;
}
if (loading == 1) {
// page was not loaded
testtype = aTestType;
setTimeout("DumpFrames(false,filename,testtype,dumpStyle)",250);
break;
} else if (loading == 0) {
// successful in loading the page
if ( aTestType<4 ){
WriteOutput("Writing File " + "\""+outputfilename+"\"",false,"success",true,true );
}
if ( (aTestType==3) || (aTestType==4) ){
baseline = outputfilename.replace (verExt,baseExt);
CompareFiles(baseDir,verDir,baseline,outputfilename);
}
filename=embed.GetNextFileInDirectory();
if ( filename != null) {
theWindow.location = filename;
} else {
// all complete
if (dirType == 1) {
theWindow.close();
RestoreWindow();
} else {
curIndex+=3;
DumpDirectoryies(aTestType);
}
}
} else {
// fatal error.. break
WriteOutput("FATAL ERROR" + "\""+outputfilename+"\"",false,"failure",true,true );
break;
}
}
}
//=============================================================================
</script>
<center>
<form name="TestForm">
<table>
<tr>
<td>
<table bgcolor="#FDFEDA" width=800>
<tr>
<td colspan="4">
<input id="ar" type="radio" name="dirTypes" value="runDirList" checked>
All Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="tr" type="radio" name="dirTypes" value="runDirList" >
Table Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="br" type="radio" name="dirTypes" value="runDirList" >
Block Regression
</td>
</tr>
<tr>
<td colspan="4">
<input id="fcr" type="radio" name="dirTypes" value="runDirList" >
Form Controls Regression
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width=800>
<tr>
<td>
Generate Baseline
<input id="rb" type="radio" name="testType" value="runbaseline" checked >
</td>
<td>
Verify and Compare
<input id="rv" type="radio" name="testType" value="runverify" >
</td>
</tr>
<tr>
<td>
Dump Style
<input id="ds" type="checkbox" name="styleDump" value="dumpStyle" checked >
</td>
</tr>
<tr>
<td>
<input type=button value="Execute" onclick='runTests()'>
</td>
</tr>
</table>
</td>
</tr>
<table>
</form>
</center>
<h4 id="status"> OUTPUT IDLE </h4>
<div id="output" align="left" style="overflow:auto; width:700; height:100; border:solid red">
</div>
</BODY>
</HTML>

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

@ -124,6 +124,39 @@ nsDebugObject::CreateDirectory( const PRUnichar *aFilePath, PRUint32 aFlags)
return result;
}
/** ---------------------------------------------------
* See documentation in nsDebugObject.h
* @update 5/16/02 dwc
*/
NS_IMETHODIMP
nsDebugObject::OutputTextToFile(PRBool aNewFile, const PRUnichar *aFilePath, const PRUnichar *aFileName, const PRUnichar *aOutputString)
{
nsresult result = NS_ERROR_FAILURE;
nsCAutoString outputPath;
outputPath.AssignWithConversion(aFilePath);
outputPath.AppendWithConversion(aFileName);
char* filePath = ToNewCString(outputPath);
FILE* fp;
if ( aNewFile ) {
fp = fopen(filePath, "wt");
} else {
fp = fopen(filePath, "at");
}
if ( fp ) {
nsCAutoString outputString;
outputString.AssignWithConversion(aOutputString);
char* theOutput = ToNewCString(outputString);
fprintf(fp,theOutput);
fprintf(fp,"\n");
fclose(fp);
delete filePath;
}
return result;
}
/** ---------------------------------------------------
* See documentation in nsDebugObject.h

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

@ -124,6 +124,39 @@ nsDebugObject::CreateDirectory( const PRUnichar *aFilePath, PRUint32 aFlags)
return result;
}
/** ---------------------------------------------------
* See documentation in nsDebugObject.h
* @update 5/16/02 dwc
*/
NS_IMETHODIMP
nsDebugObject::OutputTextToFile(PRBool aNewFile, const PRUnichar *aFilePath, const PRUnichar *aFileName, const PRUnichar *aOutputString)
{
nsresult result = NS_ERROR_FAILURE;
nsCAutoString outputPath;
outputPath.AssignWithConversion(aFilePath);
outputPath.AppendWithConversion(aFileName);
char* filePath = ToNewCString(outputPath);
FILE* fp;
if ( aNewFile ) {
fp = fopen(filePath, "wt");
} else {
fp = fopen(filePath, "at");
}
if ( fp ) {
nsCAutoString outputString;
outputString.AssignWithConversion(aOutputString);
char* theOutput = ToNewCString(outputString);
fprintf(fp,theOutput);
fprintf(fp,"\n");
fclose(fp);
delete filePath;
}
return result;
}
/** ---------------------------------------------------
* See documentation in nsDebugObject.h