am 3fb2d576: am c0446aa9: Merge change I4d2a57bc into eclair-mr2

Merge commit '3fb2d576e9f386ecaa6a2637131c8fac89d05276'

* commit '3fb2d576e9f386ecaa6a2637131c8fac89d05276':
  Moved values into attributes of xml elements where they belong
This commit is contained in:
mike ritter
2009-11-05 14:11:46 -08:00
committed by Android Git Automerger
2 changed files with 17 additions and 31 deletions

View File

@@ -52,12 +52,11 @@ import org.jheer.XMLWriter;
* mr.close(); * mr.close();
* *
* With MonkeyRunner this should output an xml file, <script_name>-yyyyMMdd-HH:mm:ss.xml, into the * With MonkeyRunner this should output an xml file, <script_name>-yyyyMMdd-HH:mm:ss.xml, into the
* directory out/<script_name>-yyyyMMdd-HH:mm:ss with the contents: * directory out/<script_name>-yyyyMMdd-HH:mm:ss with the contents like:
* *
* <?xml version="1.0" encoding='UTF-8'?> * <?xml version="1.0" encoding='UTF-8'?>
* <script_run> * <!-- Monkey Script Results -->
* script_name="filename" * <script_run script_name="filename" monkeyRunnerVersion="0.2">
* monkeyRunnerVersion="0.2"
* <!-- Device specific variables --> * <!-- Device specific variables -->
* <device_var var_name="name" var_value="value" /> * <device_var var_name="name" var_value="value" />
* <device_var name="build.display" value="opal-userdebug 1.6 DRC79 14207 test-keys"/> * <device_var name="build.display" value="opal-userdebug 1.6 DRC79 14207 test-keys"/>
@@ -95,14 +94,15 @@ public class MonkeyRecorder {
private static final String ROOT_DIR = "out"; private static final String ROOT_DIR = "out";
// for getting the date and time in now() // for getting the date and time in now()
private static final SimpleDateFormat SIMPLE_DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMdd-HH:mm:ss"); private static final SimpleDateFormat SIMPLE_DATE_TIME_FORMAT =
new SimpleDateFormat("yyyyMMdd-HH:mm:ss");
/** /**
* Create a new MonkeyRecorder that records commands and zips up screenshots for submittal * Create a new MonkeyRecorder that records commands and zips up screenshots for submittal
* *
* @param scriptName filepath of the monkey script we are running * @param scriptName filepath of the monkey script we are running
*/ */
public MonkeyRecorder(String scriptName) throws IOException { public MonkeyRecorder(String scriptName, String version) throws IOException {
// Create directory structure to store xml file, images and zips // Create directory structure to store xml file, images and zips
File scriptFile = new File(scriptName); File scriptFile = new File(scriptName);
scriptName = scriptFile.getName(); // Get rid of path scriptName = scriptFile.getName(); // Get rid of path
@@ -111,7 +111,7 @@ public class MonkeyRecorder {
// Initialize xml file // Initialize xml file
mXmlFilename = stampFilename(stripType(scriptName) + ".xml"); mXmlFilename = stampFilename(stripType(scriptName) + ".xml");
initXmlFile(scriptName); initXmlFile(scriptName, version);
} }
// Get the current date and time in a simple string format (used for timestamping filenames) // Get the current date and time in a simple string format (used for timestamping filenames)
@@ -123,14 +123,16 @@ public class MonkeyRecorder {
* Initialize the xml file writer * Initialize the xml file writer
* *
* @param scriptName filename (not path) of the monkey script, stored as attribute in the xml file * @param scriptName filename (not path) of the monkey script, stored as attribute in the xml file
* @param version of the monkey runner test system
*/ */
private static void initXmlFile(String scriptName) throws IOException { private static void initXmlFile(String scriptName, String version) throws IOException {
String[] names = new String[] { "script_name", "monkeyRunnerVersion" };
String[] values = new String[] { scriptName, version };
mXmlFile = new FileWriter(mDirname + "/" + mXmlFilename); mXmlFile = new FileWriter(mDirname + "/" + mXmlFilename);
mXmlWriter = new XMLWriter(mXmlFile); mXmlWriter = new XMLWriter(mXmlFile);
mXmlWriter.begin(); mXmlWriter.begin();
mXmlWriter.comment("Monkey Script Results"); mXmlWriter.comment("Monkey Script Results");
mXmlWriter.start("script_run"); mXmlWriter.start("script_run", names, values, names.length);
mXmlWriter.addAttribute("script_name", scriptName);
} }
/** /**
@@ -146,8 +148,7 @@ public class MonkeyRecorder {
* Begin writing a command xml element * Begin writing a command xml element
*/ */
public static void startCommand() throws IOException { public static void startCommand() throws IOException {
mXmlWriter.start("command"); mXmlWriter.start("command", "dateTime", now());
mXmlWriter.addAttribute("dateTime", now());
} }
/** /**
@@ -187,7 +188,7 @@ public class MonkeyRecorder {
} }
/** /**
* Add an attribut to an xml element. name="escaped_value" * Add an attribut to an open xml element. name="escaped_value"
* *
* @param name name of the attribute * @param name name of the attribute
* @param value value of the attribute * @param value value of the attribute
@@ -253,20 +254,6 @@ public class MonkeyRecorder {
return filename; return filename;
return filename.substring(0, typeIndex); return filename.substring(0, typeIndex);
} }
/**
* Add a signature element
*
* @param filename path of file to be signatured
*/
private static void addMD5Signature(String filename) throws IOException {
String signature = "";
// find signature... MD5 sig = new MD5(filename); signature = sig.toString();
String[] names = new String[] { "type", "filename", "signature" };
String[] values = new String[] { "md5", filename, signature };
mXmlWriter.tag("Signature", names, values, values.length);
}
/** /**
* Close the monkeyRecorder by closing the xml file and zipping it up with the screenshots. * Close the monkeyRecorder by closing the xml file and zipping it up with the screenshots.

View File

@@ -69,7 +69,7 @@ public class MonkeyRunner {
final static int KEY_INPUT_DELAY = 1000; final static int KEY_INPUT_DELAY = 1000;
// version of monkey runner // version of monkey runner
final static String monkeyRunnerVersion = "0.31"; final static String monkeyRunnerVersion = "0.4";
// TODO: interface cmd; class xml tags; fix logger; test class/script // TODO: interface cmd; class xml tags; fix logger; test class/script
@@ -222,10 +222,9 @@ public class MonkeyRunner {
press("home", false); press("home", false);
// Start recording the script output, might want md5 signature of file for completeness // Start recording the script output, might want md5 signature of file for completeness
monkeyRecorder = new MonkeyRecorder(scriptName); monkeyRecorder = new MonkeyRecorder(scriptName, monkeyRunnerVersion);
// Record what device and version of software we are running on // Record what device we are running on
monkeyRecorder.addAttribute("monkeyRunnerVersion", monkeyRunnerVersion);
addDeviceVars(); addDeviceVars();
monkeyRecorder.addComment("Script commands"); monkeyRecorder.addComment("Script commands");
} }