[Title]
authorshihyun.kim <shihyun.kim@samsung.com>
Tue, 3 Sep 2013 06:44:10 +0000 (15:44 +0900)
committershihyun.kim <shihyun.kim@samsung.com>
Tue, 3 Sep 2013 06:44:10 +0000 (15:44 +0900)
* Add xml result format of test

Change-Id: I52bdf21f0f967d44da3e846e6e3b04f2d8a33a24

InstallManager_java/src/org/tizen/installmanager/core/Performance.java
InstallManager_java/src/org/tizen/installmanager/ui/InstallManagerWindow.java

index deb0b1d..34909ac 100644 (file)
@@ -154,6 +154,53 @@ public class Performance {
                }
        }
        
+       public static void printTestResultXmlFormat() {
+               //get file name of test result
+                               SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
+                               String testFileName = formatter.format(imStartTime) + ".xml";
+                               
+                               String testResultFilePath = PathUtil.get(InstallManagerConstants.getInstallManagerTestResultPath(), testFileName);
+                               File testResultFile = new File(testResultFilePath);
+                               
+                               if (!testResultFile.getParentFile().exists()) {
+                                       testResultFile.getParentFile().mkdirs();
+                               }
+                               
+                               BufferedWriter out = null;
+                               try {
+                                       out = new BufferedWriter(new FileWriter(testResultFile));
+                                       out.write(getTestSuiteXml("InstallManager performance test", 4, getTotalTime()));
+                                       out.newLine();
+                                       out.write(getTestCaseXml("The initialization time", getInitializeTime()));
+                                       out.newLine();
+                                       out.write(getTestCaseXml("The download time", getDownloadTime()));
+                                       out.newLine();
+                                       out.write(getTestCaseXml("The installation time", getInstallationTime()));
+                                       out.newLine();
+                                       out.write(getTestCaseXml("The removal time", getRemovalTime()));
+                                       out.newLine();
+                                       out.write("</testsuite>");
+                               } catch (IOException e) {
+                                       Log.ExceptionLog(e);
+                               } finally {
+                                       if (out != null) {
+                                               try {
+                                                       out.close();
+                                               } catch (IOException e) {
+                                                       Log.ExceptionLog(e);
+                                               }
+                                       }
+                               }
+       }
+       
+       private static String getTestSuiteXml(String testName, int testNum, long time) {
+               return "<testsuite errors=\"\" failures=\"\" name=\"" + testName + "\" skips=\"\" tests=\"" + testNum +"\" time=\""+ time +"\">";
+       }
+       
+       private static String getTestCaseXml(String testName, long time) {
+               return "<testcase classname=\"\" name=\"" + testName + "\" time=\"" + time +"\"/>";
+       }
+       
        private static long getInitializeTime() {
                if (initializeStartTime == null || initializeEndTime == null) {
                        return 0;
index a09872a..640223f 100644 (file)
@@ -854,7 +854,7 @@ public class InstallManagerWindow extends ApplicationWindow {
                                
                                Performance.setIMEndTime();
                                if (Options.doTest) {
-                                       Performance.printTestResult();
+                                       Performance.printTestResultXmlFormat();
                                }
                                
                                System.exit(0);
@@ -943,7 +943,7 @@ public class InstallManagerWindow extends ApplicationWindow {
                        Performance.printToLogFile();
                        
                        if (Options.doTest) {
-                               Performance.printTestResult();
+                               Performance.printTestResultXmlFormat();
                        }
                        
                        Log.LogTitle("Installmanager finish");