diff --git a/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRecorder.java b/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRecorder.java index efc002b5a..f06eafd45 100644 --- a/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRecorder.java +++ b/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRecorder.java @@ -52,12 +52,11 @@ import org.jheer.XMLWriter; * mr.close(); * * With MonkeyRunner this should output an xml file, -yyyyMMdd-HH:mm:ss.xml, into the - * directory out/-yyyyMMdd-HH:mm:ss with the contents: + * directory out/-yyyyMMdd-HH:mm:ss with the contents like: * * - * - * script_name="filename" - * monkeyRunnerVersion="0.2" + * + * * * * @@ -95,14 +94,15 @@ public class MonkeyRecorder { private static final String ROOT_DIR = "out"; // 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 * * @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 File scriptFile = new File(scriptName); scriptName = scriptFile.getName(); // Get rid of path @@ -111,7 +111,7 @@ public class MonkeyRecorder { // Initialize xml file 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) @@ -123,14 +123,16 @@ public class MonkeyRecorder { * Initialize the xml file writer * * @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); mXmlWriter = new XMLWriter(mXmlFile); mXmlWriter.begin(); mXmlWriter.comment("Monkey Script Results"); - mXmlWriter.start("script_run"); - mXmlWriter.addAttribute("script_name", scriptName); + mXmlWriter.start("script_run", names, values, names.length); } /** @@ -146,8 +148,7 @@ public class MonkeyRecorder { * Begin writing a command xml element */ public static void startCommand() throws IOException { - mXmlWriter.start("command"); - mXmlWriter.addAttribute("dateTime", now()); + mXmlWriter.start("command", "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 value value of the attribute @@ -253,20 +254,6 @@ public class MonkeyRecorder { return filename; 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. diff --git a/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java b/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java index 07a473917..4734ba104 100644 --- a/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java +++ b/tools/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java @@ -69,7 +69,7 @@ public class MonkeyRunner { final static int KEY_INPUT_DELAY = 1000; // 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 @@ -222,10 +222,9 @@ public class MonkeyRunner { press("home", false); // 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 - monkeyRecorder.addAttribute("monkeyRunnerVersion", monkeyRunnerVersion); + // Record what device we are running on addDeviceVars(); monkeyRecorder.addComment("Script commands"); }