Kaydet (Commit) 41e30e1d authored tarafından Liu Zhe's avatar Liu Zhe

#120234# - testcommon enhancement: uno api test support, multiple instances support.

Replaced AppUtil.initApp to VclApp.start.
üst 428f563b
...@@ -33,10 +33,9 @@ import static testlib.UIMap.*; ...@@ -33,10 +33,9 @@ import static testlib.UIMap.*;
import java.awt.Rectangle; import java.awt.Rectangle;
import org.junit.AfterClass; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.common.FileUtil; import org.openoffice.test.common.FileUtil;
...@@ -53,13 +52,14 @@ public class BVTFileType { ...@@ -53,13 +52,14 @@ public class BVTFileType {
@Rule @Rule
public Log LOG = new Log(); public Log LOG = new Log();
/**
* @throws java.lang.Exception
*/
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initApp(); app.start();
}
@After
public void tearDown() throws Exception {
app.close();
} }
/** /**
...@@ -241,6 +241,7 @@ public class BVTFileType { ...@@ -241,6 +241,7 @@ public class BVTFileType {
String text = "Hello Openoffice"; String text = "Hello Openoffice";
app.dispatch("private:factory/simpress?slot=6686"); app.dispatch("private:factory/simpress?slot=6686");
PresentationWizard.ok(); PresentationWizard.ok();
sleep(1);
impress.click(0.01, 0.01); impress.click(0.01, 0.01);
typeKeys(text); typeKeys(text);
sleep(2); sleep(2);
...@@ -436,9 +437,4 @@ public class BVTFileType { ...@@ -436,9 +437,4 @@ public class BVTFileType {
// Close the file to avoid the app closing the Elements window automatically // Close the file to avoid the app closing the Elements window automatically
app.dispatch(".uno:CloseDoc", 3); app.dispatch(".uno:CloseDoc", 3);
} }
@AfterClass
public static void afterClass() {
app.kill();
}
} }
...@@ -34,14 +34,13 @@ import static testlib.UIMap.*; ...@@ -34,14 +34,13 @@ import static testlib.UIMap.*;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.File; import java.io.File;
import org.junit.AfterClass; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.openoffice.test.common.FileUtil; import org.openoffice.test.common.FileUtil;
import org.openoffice.test.common.GraphicsUtil; import org.openoffice.test.common.GraphicsUtil;
import org.openoffice.test.common.SystemUtil;
import testlib.CalcUtil; import testlib.CalcUtil;
import testlib.Log; import testlib.Log;
...@@ -55,12 +54,14 @@ public class BVTFunction { ...@@ -55,12 +54,14 @@ public class BVTFunction {
@Rule @Rule
public Log LOG = new Log(); public Log LOG = new Log();
/**
* @throws java.lang.Exception
*/
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initApp(); app.start();
}
@After
public void tearDown() throws Exception {
app.close();
} }
...@@ -77,14 +78,10 @@ public class BVTFunction { ...@@ -77,14 +78,10 @@ public class BVTFunction {
FileUtil.deleteFile(exportTo); FileUtil.deleteFile(exportTo);
submitSaveDlg(exportTo); submitSaveDlg(exportTo);
assertTrue("PDF is exported?", new File(exportTo).exists()); assertTrue("PDF is exported?", new File(exportTo).exists());
// Via toolbar
app.dispatch("private:factory/swriter", 3);
assertTrue(toolbox(".HelpId:standardbar").exists(5)); assertTrue(toolbox(".HelpId:standardbar").exists(5));
button(".uno:ExportDirectToPDF").click(); button(".uno:ExportDirectToPDF").click();
assertEquals("PDF - Portable Document Format (.pdf)", FileSave_FileType.getSelText()); assertEquals("PDF - Portable Document Format (.pdf)", FileSave_FileType.getSelText());
FileSave.cancel(); FileSave.cancel();
} }
/** /**
...@@ -112,7 +109,7 @@ public class BVTFunction { ...@@ -112,7 +109,7 @@ public class BVTFunction {
//Create a new text document and launch a Wizards dialog which need JVM work correctly. //Create a new text document and launch a Wizards dialog which need JVM work correctly.
app.dispatch("private:factory/swriter", 3); app.dispatch("private:factory/swriter", 3);
File tempfile=new File(app.getUserInstallation(),"user/template/myAgendaTemplate.ott"); File tempfile=new File(oo.getUserInstallation(),"user/template/myAgendaTemplate.ott");
FileUtil.deleteFile(tempfile); FileUtil.deleteFile(tempfile);
sleep(3); sleep(3);
app.dispatch("service:com.sun.star.wizards.agenda.CallWizard?start"); app.dispatch("service:com.sun.star.wizards.agenda.CallWizard?start");
...@@ -768,9 +765,4 @@ public class BVTFunction { ...@@ -768,9 +765,4 @@ public class BVTFunction {
// Verify if the calculated result is equal to the expected result // Verify if the calculated result is equal to the expected result
assertEquals("The calculated result", expectedResult, CalcUtil.getCellText("B1")); assertEquals("The calculated result", expectedResult, CalcUtil.getCellText("B1"));
} }
@AfterClass
public static void afterClass() {
app.kill();
}
} }
...@@ -28,6 +28,7 @@ import static testlib.UIMap.*; ...@@ -28,6 +28,7 @@ import static testlib.UIMap.*;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
...@@ -50,7 +51,12 @@ public class LongRun { ...@@ -50,7 +51,12 @@ public class LongRun {
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initApp(); app.start();
}
@After
public void tearDown() throws Exception {
app.close();
} }
Rectangle rect = new Rectangle(400, 200, 60, 60); Rectangle rect = new Rectangle(400, 200, 60, 60);
...@@ -129,7 +135,7 @@ public class LongRun { ...@@ -129,7 +135,7 @@ public class LongRun {
saveNewDrawing("draw_saveas.std"); saveNewDrawing("draw_saveas.std");
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
LOG.info("Iterator: " + i + ", Elapsed Hours: " + ((end - start) / 3600000)); LOG.info("Iterator: " + i + ", Elapsed Hours: " + ((end - start) / 3600000));
SystemUtil.execScript("ps -eo vsz,rss,comm | grep soffice.bin", false); SystemUtil.execScript("ps -eo vsz,rss,comm | grep soffice.bin");
} }
} }
......
...@@ -27,6 +27,7 @@ import static org.junit.Assert.*; ...@@ -27,6 +27,7 @@ import static org.junit.Assert.*;
import static testlib.AppUtil.*; import static testlib.AppUtil.*;
import static testlib.UIMap.*; import static testlib.UIMap.*;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -50,17 +51,25 @@ public class SayHelloToOO { ...@@ -50,17 +51,25 @@ public class SayHelloToOO {
@Rule @Rule
public Log LOG = new Log(); public Log LOG = new Log();
/** /**
* initApp helps us to do * Do some setup task before running test
* 1. Patch the OpenOffice to enable automation if necessary. * @throws Exception
* 2. Start OpenOffice with automation enabled if necessary.
* 3. Reset OpenOffice to startcenter.
*
* @throws java.lang.Exception
*/ */
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initApp(); //Start OpenOffice
app.start();
}
/**
* Clean task after testing
* @throws Exception
*/
@After
public void tearDown() throws Exception {
//Close OpenOffice
app.close();
} }
/** /**
......
...@@ -30,7 +30,7 @@ import static testlib.UIMap.*; ...@@ -30,7 +30,7 @@ import static testlib.UIMap.*;
import java.io.File; import java.io.File;
import org.junit.AfterClass; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
...@@ -43,11 +43,17 @@ public class SmokeTest { ...@@ -43,11 +43,17 @@ public class SmokeTest {
public Log LOG = new Log(); public Log LOG = new Log();
File smoketestOutput; File smoketestOutput;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
initApp(true); app.getOpenOffice().cleanUserInstallation();
smoketestOutput = new File(app.getUserInstallation(), "user/temp"); app.start();
deleteFile(smoketestOutput); smoketestOutput = new File(oo.getUserInstallation(), "user/temp");
}
@After
public void tearDown() throws Exception {
app.close();
} }
@Test @Test
...@@ -66,9 +72,4 @@ public class SmokeTest { ...@@ -66,9 +72,4 @@ public class SmokeTest {
assertTrue("No Error", !smoketestlog.contains("error") && !testclosurelog.contains("error")); assertTrue("No Error", !smoketestlog.contains("error") && !testclosurelog.contains("error"));
} }
@AfterClass
public static void afterClass() {
app.kill();
}
} }
...@@ -24,14 +24,10 @@ ...@@ -24,14 +24,10 @@
package testcase; package testcase;
import static org.openoffice.test.vcl.Tester.sleep; import static org.openoffice.test.vcl.Tester.*;
import static testlib.AppUtil.fullPath; import static testlib.AppUtil.*;
import static testlib.AppUtil.handleBlocker;
import static testlib.AppUtil.initApp;
import static testlib.AppUtil.openStartcenter;
import static testlib.AppUtil.submitOpenDlg;
import static testlib.AppUtil.submitSaveDlg;
import static testlib.UIMap.*; import static testlib.UIMap.*;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
...@@ -121,7 +117,7 @@ public class TestSample { ...@@ -121,7 +117,7 @@ public class TestSample {
*/ */
@Before @Before
public void setUp() { public void setUp() {
initApp(); app.start();
FileUtil.deleteFile(fullPath("temp")); FileUtil.deleteFile(fullPath("temp"));
File temp = new File(fullPath("temp")); File temp = new File(fullPath("temp"));
......
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