Kaydet (Commit) a405184a authored tarafından Noel Grandin's avatar Noel Grandin

java: inline CheckMemoryUsage test properties

Change-Id: Ia5ee0fdc7617b43c4874aa285459f9a1a52cea12
üst 9b8fb077
...@@ -25,8 +25,6 @@ import java.io.File; ...@@ -25,8 +25,6 @@ import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import lib.TestParameters; import lib.TestParameters;
...@@ -39,6 +37,8 @@ import org.junit.Test; ...@@ -39,6 +37,8 @@ import org.junit.Test;
import org.openoffice.test.OfficeConnection; import org.openoffice.test.OfficeConnection;
import util.DesktopTools; import util.DesktopTools;
import util.OSName;
import util.PropertyName;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XStorable; import com.sun.star.frame.XStorable;
...@@ -57,13 +57,6 @@ import com.sun.star.util.XCloseable; ...@@ -57,13 +57,6 @@ import com.sun.star.util.XCloseable;
* Needed parameters: * Needed parameters:
* <ul> * <ul>
* <li>"TestDocumentPath" - the path where test documents are located.</li> * <li>"TestDocumentPath" - the path where test documents are located.</li>
* <li>"AllowMemoryIncrease" (optional) - the allowed memory increase measured in kByte per exported document. The default is 10 kByte.</li>
* <li>"ExportDocCount" (optional) - the amount of exports for each document that is loaded. Is defaulted to 25.
* <li>"FileExportFilter" (optional) - a relation between loaded document type and used export filter. Is defaulted to
* writer, calc and impress. This parameter can be set with a number to give more than one relation. Example:<br>
* "FileExportFilter1=sxw,writer_pdf_Export"<br>
* "FileExportFilter2=sxc,calc_pdf_Export"<br>
* "FileExportFilter3=sxi,impress_pdf_Export"<br></li>
* All parameters are used for iteration over the test document path. * All parameters are used for iteration over the test document path.
* </ul> * </ul>
*/ */
...@@ -92,12 +85,11 @@ class TempDir ...@@ -92,12 +85,11 @@ class TempDir
public class CheckMemoryUsage public class CheckMemoryUsage
{ {
private static final String sWriterDoc = "sxw,writer_pdf_Export";
private static final String sCalcDoc = "sxc,calc_pdf_Export";
private static final String sImpressDoc = "sxi,impress_pdf_Export";
TempDir m_aTempDir; TempDir m_aTempDir;
private String[][] sDocTypeExportFilter; private String[][] sDocTypeExportFilter;
private String[][] sDocuments; private String[][] sDocuments;
// the allowed memory increase measured in kByte per exported document. The default is 10 kByte.
// the allowed memory increase per exported document: if the memory increase is higher than this number, the test will fail
private static final int iAllowMemoryIncrease = 10; private static final int iAllowMemoryIncrease = 10;
private int iExportDocCount = 25; private int iExportDocCount = 25;
...@@ -112,10 +104,10 @@ public class CheckMemoryUsage ...@@ -112,10 +104,10 @@ public class CheckMemoryUsage
// some Tests need the qadevOOo TestParameters, it is like a Hashmap for Properties. // some Tests need the qadevOOo TestParameters, it is like a Hashmap for Properties.
TestParameters param = new TestParameters(); TestParameters param = new TestParameters();
param.put("ServiceFactory", xMsf); // some qadevOOo functions need the ServiceFactory param.put(PropertyName.SERVICE_FACTORY, xMsf); // some qadevOOo functions need the ServiceFactory
// test does definitely not run on Windows. // test does definitely not run on Windows.
if (param.get("OperatingSystem").equals("wntmsci")) if (param.get(PropertyName.OPERATING_SYSTEM).equals(OSName.WNTMSCI))
{ {
System.out.println("Test can only reasonably be executed with a tool that " System.out.println("Test can only reasonably be executed with a tool that "
+ "displays the memory usage of StarOffice."); + "displays the memory usage of StarOffice.");
...@@ -127,45 +119,22 @@ public class CheckMemoryUsage ...@@ -127,45 +119,22 @@ public class CheckMemoryUsage
// how many times is every document exported. // how many times is every document exported.
int count = param.getInt("ExportDocCount"); // the amount of exported documents: each loaded document will be written 'ExportDocCount' times
if (count != 0) iExportDocCount = 25;
{
iExportDocCount = count;
}
// get the temp dir for creating the command scripts. // get the temp dir for creating the command scripts.
m_aTempDir = new TempDir(util.utils.getOfficeTemp/*Dir*/(xMsf)); m_aTempDir = new TempDir(util.utils.getOfficeTemp/*Dir*/(xMsf));
// get the file extension, export filter connection // get the file extension, export filter connection
Iterator<String> keys = param.keySet().iterator(); // the import and export filters
ArrayList<String> v = new ArrayList<String>();
while (keys.hasNext())
{
String key = keys.next();
if (key.startsWith("FileExportFilter"))
{
v.add((String) param.get(key));
}
}
// if no param given, set defaults.
if (v.isEmpty())
{
v.add(sWriterDoc);
v.add(sCalcDoc);
v.add(sImpressDoc);
}
// store a file extension // store a file extension
sDocTypeExportFilter = new String[v.size()][2]; sDocTypeExportFilter = new String[3][2];
for (int i = 0; i < v.size(); i++) sDocTypeExportFilter[0][0] = "sxw";
{ sDocTypeExportFilter[0][1] = "writer_pdf_Export";
// 2do: error routine for wrong given params sDocTypeExportFilter[1][0] = "sxc";
final String sVContent = v.get(i); sDocTypeExportFilter[1][1] = "calc_pdf_Export";
StringTokenizer t = new StringTokenizer(sVContent, ","); sDocTypeExportFilter[2][0] = "sxi";
final String sExt = t.nextToken(); sDocTypeExportFilter[2][1] = "impress_pdf_Export";
final String sName = t.nextToken();
sDocTypeExportFilter[i][0] = sExt;
sDocTypeExportFilter[i][1] = sName;
}
// get files to load and export // get files to load and export
String sDocumentPath = TestDocument.getUrl(); String sDocumentPath = TestDocument.getUrl();
......
...@@ -19,14 +19,4 @@ ...@@ -19,14 +19,4 @@
# the path to the test documents # the path to the test documents
TestDocumentPath=../../testdocuments TestDocumentPath=../../testdocuments
# the allowed memory increase per exported document: if the memory increase is higher than this number, the test will fail
AllowMemoryIncrease=20
# the amount of exported documents: each loaded document will be written 'ExportDocCount' times
ExportDocCount=25
# the import and export filters, separated by comma; further relations can be added with increasing numbers, like
#'FileExportFilter4=sxd,draw_pdf_Export'
FileExportFilter1=sxw,writer_pdf_Export
FileExportFilter2=sxc,calc_pdf_Export
FileExportFilter3=sxi,impress_pdf_Export
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment