incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1359488 - in /incubator/ooo/trunk/main/test/testoo/src/testlib: AppUtil.java CalcUtil.java Log.java UIMap.java
Date Tue, 10 Jul 2012 06:42:36 GMT
Author: liuzhe
Date: Tue Jul 10 06:42:36 2012
New Revision: 1359488

URL: http://svn.apache.org/viewvc?rev=1359488&view=rev
Log:
#120234# - testcommon enhancement: uno api test support, multiple instances support.
AppUtil.initApp is removed.  Should use VclApp.start in future test case development. e.g.
@Before
public void setUp() {

Modified:
    incubator/ooo/trunk/main/test/testoo/src/testlib/AppUtil.java
    incubator/ooo/trunk/main/test/testoo/src/testlib/CalcUtil.java
    incubator/ooo/trunk/main/test/testoo/src/testlib/Log.java
    incubator/ooo/trunk/main/test/testoo/src/testlib/UIMap.java

Modified: incubator/ooo/trunk/main/test/testoo/src/testlib/AppUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testlib/AppUtil.java?rev=1359488&r1=1359487&r2=1359488&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testoo/src/testlib/AppUtil.java (original)
+++ incubator/ooo/trunk/main/test/testoo/src/testlib/AppUtil.java Tue Jul 10 06:42:36 2012
@@ -56,66 +56,15 @@ public class AppUtil extends Tester {
 		} else if (SystemUtil.isLinux()) {
 			
 		} 
-//		patch();
 	}
 	
-	/**
-	 * This method is used to start OpenOffice and make it ready for testing.
-	 * 
-	 * @param cleanUserInstallation if use a totally clean user installation data
-	 * @param userInstallation Specify user installation directory. If it's null, the default
will be used.
-	 */
-	public static void initApp(boolean cleanUserInstallation, String userInstallation) {
-		File newUserInstallation = userInstallation == null ? app.getDefaultUserInstallation()
: new File(fullPath(userInstallation));
-		if (!newUserInstallation.equals(app.getUserInstallation())) {
-			// user installation changed...
-			app.kill();
-			app.setUserInstallation(userInstallation == null ? null : newUserInstallation);
-		}
-		
-		patch(cleanUserInstallation);
-		
-		//try to reset application
-		for (int i = 0; i < 3; i++) {
-			try {
-				if (app.exists()) {
-					app.reset();
-					openStartcenter();
-					if (startcenter.exists(2))
-						return;
-				}
-			} catch (Exception e){
-				
-			}
-			
-			app.kill();
-			if (app.start() != 0)
-				throw new Error("OpenOffice can't be started! Testing aborted!");
-			sleep(3); // this sleep is important. 
-			app.waitForExistence(30, 5);
-		}
-	}
 
-	/**
-	 * @see initApp(boolean cleanUserInstallation, String userInstallation)
-	 */
-	public static void initApp(boolean cleanUserInstallation) {
-		initApp(cleanUserInstallation, System.getProperty("openoffice.userinstallation"));
-	}
-	
-	/**
-	 * @see initApp(boolean cleanUserInstallation, String userInstallation)
-	 */
-	public static void initApp() {
-		initApp(false);
-	}
-	
 	public static void openStartcenter() {
 		if (startcenter.exists())
 			return;
 		
 		if (SystemUtil.isMac()) {
-			SystemUtil.execScript("osascript -e 'tell app \"OpenOffice.org\" to activate'", false);
+			SystemUtil.execScript("osascript -e 'tell app \"OpenOffice.org\" to activate'");
 			typeKeys("<command n>");
 		}
 		
@@ -191,30 +140,6 @@ public class AppUtil extends Tester {
 		sleep(1);
 	}
 	
-	/**
-	 * In order to automatically test OO, some settings/files need to be modified
-	 */
-	public static void patch(boolean force) {
-		File userInstallationDir = app.getUserInstallation();
-		File patchMark = new File(userInstallationDir, "automationenabled");
-		if (!force && patchMark.exists())
-			return;
-	
-		// remove user installation dir
-		app.kill();
-		sleep(1);		
-		FileUtil.deleteFile(userInstallationDir);
-		app.start();
-		sleep(10);
-		app.kill();
-		sleep(1);
-		
-		FileUtil.copyFile(new File("patch/Common.xcu"), new File(userInstallationDir, "user/registry/data/org/openoffice/Office/Common.xcu"));
-		FileUtil.copyFile(new File("patch/Setup.xcu"), new File(userInstallationDir, "user/registry/data/org/openoffice/Setup.xcu"));
-		FileUtil.copyFile(new File("patch/registrymodifications.xml"), new File(userInstallationDir,
"user/registrymodifications.xcu"));
-		FileUtil.writeStringToFile(patchMark.getAbsolutePath(), "patched for automation");
-	}
-	
 	public static void handleBlocker(final VclWindow... windows) {
 		new Condition() {
 			@Override

Modified: incubator/ooo/trunk/main/test/testoo/src/testlib/CalcUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testlib/CalcUtil.java?rev=1359488&r1=1359487&r2=1359488&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testoo/src/testlib/CalcUtil.java (original)
+++ incubator/ooo/trunk/main/test/testoo/src/testlib/CalcUtil.java Tue Jul 10 06:42:36 2012
@@ -26,13 +26,17 @@ package testlib;
 import static org.openoffice.test.vcl.Tester.*;
 import static testlib.UIMap.*;
 
+import java.lang.reflect.Array;
 import java.util.StringTokenizer;
+import java.util.logging.Logger;
 
 
 
 
 public class CalcUtil {
 	
+	private static Logger LOG = Logger.getLogger(CalcUtil.class.getName());
+	
 	/**
 	 * Select a range.
 	 * 
@@ -221,7 +225,34 @@ public class CalcUtil {
 				break;
 			}
 		}
+		
+		LOG.info("Text of range [" + range + "]:\n" + arrayToString(texts));
 		return texts;
 	}
 
+	private static String arrayToString(Object array) {
+		if (array == null)
+			return "null";
+		if (!array.getClass().isArray()) 
+			return array.toString();
+			
+		int len = Array.getLength(array);
+		String ret = "{";
+		for (int i= 0; i < len; i++) {
+			Object el = Array.get(array, i);
+			if (el == null) {
+				ret += "null";
+			} else if (el.getClass().isArray()) {
+				ret += arrayToString(el);
+			} else {
+				ret += "\"" + el + "\"";
+			}
+			
+			if (i + 1 != len)
+				ret += ",";
+			
+		}
+		ret += "}";
+		return ret;
+	}
 }
\ No newline at end of file

Modified: incubator/ooo/trunk/main/test/testoo/src/testlib/Log.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testlib/Log.java?rev=1359488&r1=1359487&r2=1359488&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testoo/src/testlib/Log.java (original)
+++ incubator/ooo/trunk/main/test/testoo/src/testlib/Log.java Tue Jul 10 06:42:36 2012
@@ -19,13 +19,10 @@
  * 
  *************************************************************/
 
-
-
 package testlib;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.logging.ConsoleHandler;
 import java.util.logging.FileHandler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -33,42 +30,42 @@ import java.util.logging.SimpleFormatter
 
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
+import org.openoffice.test.OpenOffice;
 import org.openoffice.test.common.GraphicsUtil;
 import org.openoffice.test.vcl.client.CommunicationException;
 
-
 /**
  * The class is used to capture extra information during the testing, including
- * 1. Take a screenshot when testing is failed.
- * 2. Collect data as the clue when oo crashes.
- *
+ * 1. Take a screenshot when testing is failed. 2. Collect data as the clue when
+ * oo crashes.
+ * 
  */
 public class Log extends TestWatcher {
 	static File screenshotOutput = null;
 	static File logOutput = null;
 	static Logger logger;
-	static {	
-		screenshotOutput =  Testspace.getFile("output/screenshot");
+	static {
+		screenshotOutput = Testspace.getFile("output/screenshot");
 		screenshotOutput.mkdirs();
-		
+
 		logOutput = Testspace.getFile("output/logs");
 		logOutput.mkdirs();
 		try {
 			logger = Logger.getLogger("vclauto");
-			FileHandler fh = new FileHandler(logOutput.getAbsolutePath()+ "/" + "%u.log", true);
+			FileHandler fh = new FileHandler(logOutput.getAbsolutePath() + "/" + "%u.log", true);
 			logger.addHandler(fh);
 			logger.setLevel(Level.ALL);
 			SimpleFormatter sf = new SimpleFormatter();
 			fh.setFormatter(sf);
-//			ConsoleHandler ch = new ConsoleHandler();
-//			logger.addHandler(ch);
-//			logger.setLevel(Level.ALL);
-//			ch.setFormatter(sf);
+			// ConsoleHandler ch = new ConsoleHandler();
+			// logger.addHandler(ch);
+			// logger.setLevel(Level.ALL);
+			// ch.setFormatter(sf);
 		} catch (IOException e) {
-			//ignore;
+			// ignore;
 		}
 	}
-	
+
 	@Override
 	protected void starting(Description description) {
 		logger.info("Start " + description);
@@ -84,20 +81,20 @@ public class Log extends TestWatcher {
 		} else {
 			screenshotType = "error";
 		}
-		
-		
-		File file = new File(screenshotOutput, description.getClassName()+"."+description.getMethodName()+"."
+ screenshotType + ".png");
+
+		File file = new File(screenshotOutput, description.getClassName() + "." + description.getMethodName()
+ "." + screenshotType + ".png");
 		GraphicsUtil.screenShot(file.getAbsolutePath());
 		logger.log(Level.SEVERE, "Testing is failed. Screenshot: " + file.getAbsolutePath(), e);
 		// Check if crash occurs!
 		if (e instanceof CommunicationException) {
 			logger.severe("Pay attention! OpenOffice maybe crashed or freezed. ");
-			// If testcase is failed, kill AOO to avoid impacting the following test cases.
-			UIMap.app.kill();
+			// If testcase is failed, kill AOO to avoid impacting the following
+			// test cases.
+			OpenOffice.killAll();
 		}
-		
+
 	}
-	
+
 	public void info(String message) {
 		logger.info(message);
 	}

Modified: incubator/ooo/trunk/main/test/testoo/src/testlib/UIMap.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/test/testoo/src/testlib/UIMap.java?rev=1359488&r1=1359487&r2=1359488&view=diff
==============================================================================
--- incubator/ooo/trunk/main/test/testoo/src/testlib/UIMap.java (original)
+++ incubator/ooo/trunk/main/test/testoo/src/testlib/UIMap.java Tue Jul 10 06:42:36 2012
@@ -24,13 +24,17 @@
 package testlib;
 import java.io.File;
 
+import org.openoffice.test.OpenOffice;
 import org.openoffice.test.vcl.IDList;
+import org.openoffice.test.vcl.client.Constant;
 import org.openoffice.test.vcl.widgets.VclApp;
 import org.openoffice.test.vcl.widgets.VclButton;
 import org.openoffice.test.vcl.widgets.VclComboBox;
 import org.openoffice.test.vcl.widgets.VclControl;
 import org.openoffice.test.vcl.widgets.VclDialog;
+import org.openoffice.test.vcl.widgets.VclDockingWin;
 import org.openoffice.test.vcl.widgets.VclEditBox;
+import org.openoffice.test.vcl.widgets.VclField;
 import org.openoffice.test.vcl.widgets.VclListBox;
 import org.openoffice.test.vcl.widgets.VclMenuItem;
 import org.openoffice.test.vcl.widgets.VclMessageBox;
@@ -39,8 +43,6 @@ import org.openoffice.test.vcl.widgets.V
 import org.openoffice.test.vcl.widgets.VclTabPage;
 import org.openoffice.test.vcl.widgets.VclToolBox;
 import org.openoffice.test.vcl.widgets.VclWindow;
-import org.openoffice.test.vcl.widgets.VclField;
-import org.openoffice.test.vcl.widgets.VclDockingWin;
 
 /**
  * Define all UI controls in the class.
@@ -49,9 +51,9 @@ import org.openoffice.test.vcl.widgets.V
  */
 public class UIMap {
 	private static IDList idList = new IDList(new File("./ids"));
-	public static final VclMessageBox ActiveMsgBox = new VclMessageBox(idList.getId("UID_ACTIVE"));
-	public static final VclMessageBox MsgBox_AdditionalRowsNotSaved = new VclMessageBox(idList.getId("UID_ACTIVE"),
"Additional rows were not saved.");
-	public static final VclTabControl ActiveTabControl = new VclTabControl(idList.getId("UID_ACTIVE"));
+	public static final VclMessageBox ActiveMsgBox = new VclMessageBox(Constant.UID_ACTIVE);
+	public static final VclMessageBox MsgBox_AdditionalRowsNotSaved = new VclMessageBox(Constant.UID_ACTIVE,
"Additional rows were not saved.");
+	public static final VclTabControl ActiveTabControl = new VclTabControl(Constant.UID_ACTIVE);
 	
 	public static VclEditBox editbox(String id) {
 		return new VclEditBox(idList.getId(id));
@@ -71,7 +73,7 @@ public class UIMap {
 	}
 	
 	public static VclTabPage tabpage(String id) {
-		return new VclTabPage(idList.getId(id), ActiveTabControl);
+		return new VclTabPage(idList.getId(id));
 	}
 	
 	public static VclListBox listbox(String id) {
@@ -112,8 +114,8 @@ public class UIMap {
 	public static VclDockingWin dockingwin(String id){
 		return new VclDockingWin(idList.getId(id));
 	}
-	
-	public static final VclApp app = new VclApp(null);
+	public static final OpenOffice oo = new OpenOffice(null);
+	public static final VclApp app = VclApp.getDefault();
 	public static final VclWindow writer = window("SW_HID_EDIT_WIN");
 	public static final VclWindow startcenter = window("FWK_HID_BACKINGWINDOW");
 	public static final VclWindow calc = window("SC_HID_SC_WIN_GRIDWIN");



Mime
View raw message