xref: /trunk/test/testuno/source/fvt/mix/MixedTest.java (revision f0480a3d)
1 package testcase.mix;
2 
3 import org.junit.After;
4 import org.junit.Assert;
5 import org.junit.Before;
6 import org.junit.Test;
7 import org.openoffice.test.uno.UnoApp;
8 import org.openoffice.test.vcl.widgets.VclApp;
9 import org.openoffice.test.vcl.widgets.VclListBox;
10 import org.openoffice.test.vcl.widgets.VclTabPage;
11 import org.openoffice.test.vcl.widgets.VclWindow;
12 
13 import com.sun.star.beans.XPropertySet;
14 import com.sun.star.text.XText;
15 import com.sun.star.text.XTextCursor;
16 import com.sun.star.text.XTextDocument;
17 import com.sun.star.uno.UnoRuntime;
18 
19 /**
20  * Demo for testing with both UNO and VCLAuto
21  * @author test
22  *
23  */
24 public class MixedTest {
25 	UnoApp unoApp = new UnoApp();
26 	VclApp vclApp = new VclApp();
27 	VclWindow writer = new VclWindow("SW_HID_EDIT_WIN");
28 	VclTabPage effectsPage = new VclTabPage("CUI_HID_SVXPAGE_CHAR_EFFECTS");
29 	VclListBox colorList = new VclListBox("cui:ListBox:RID_SVXPAGE_CHAR_EFFECTS:LB_FONTCOLOR");
30 	XTextDocument textDocument = null;
31 	/**
32 	 * @throws java.lang.Exception
33 	 */
34 	@Before
35 	public void setUp() throws Exception {
36 		unoApp.start();
37 	}
38 
39 	@After
40 	public void tearDown() throws Exception {
41 		unoApp.closeDocument(textDocument);
42 		unoApp.close();
43 	}
44 
45 	@Test
46 	public void testUseBothUNOAndGuiAPI()  throws Exception  {
47 		//Use UNO API to create a new document
48 		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, unoApp.newDocument("swriter"));
49 		XText xText = textDocument.getText();
50 		xText.setString("UNO: Hello World!");
51 		//Input something by typing keyboard
52 		writer.typeKeys("GUI: Hello world!");
53 		//Set text color to green via GUI
54 		writer.drag(10, 10, 300, 400);
55 		writer.menuItem("Format->Character...").select();
56 		effectsPage.select();
57 		colorList.select("Light green");
58 		effectsPage.ok();
59 		//Verify the result via UNO API
60 		XTextCursor xTextCursor = xText.createTextCursor();
61 		XPropertySet xps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
62 		Assert.assertEquals("Text Color", 0x0000FF00, xps.getPropertyValue("CharColor"));
63 	}
64 }
65