View | Details | Raw Unified | Return to issue 120733
Collapse All | Expand All

(-)testgui/source/testcase/gui/sd/shape/ShapeTypes.java (+139 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
24
25
package testcase.gui.sd.shape;
26
import static org.openoffice.test.common.Testspace.*;
27
import static testlib.gui.AppUtil.*;
28
import static testlib.gui.UIMap.*;
29
import static org.junit.Assert.*;
30
import static org.openoffice.test.vcl.Tester.*;
31
32
import org.junit.After;
33
import org.junit.AfterClass;
34
import org.junit.Before;
35
import org.junit.BeforeClass;
36
import org.junit.Rule;
37
import org.junit.Test;
38
import org.openoffice.test.common.FileUtil;
39
40
import testlib.gui.ImpressUtil;
41
import testlib.gui.Log;
42
43
44
45
public class ShapeTypes {
46
	@Rule
47
	public Log LOG = new Log();
48
49
	@Before
50
	public void setUp() throws Exception {
51
		app.start();
52
53
		// New a impress, insert some slides
54
		app.dispatch("private:factory/simpress?slot=6686");
55
		PresentationWizard.ok();
56
		// Pop up navigator panel
57
		if (!SD_NavigatorDlg.exists()) {
58
			app.dispatch(".uno:Navigator");
59
		}
60
			
61
		if(!SD_Drawing_Toolbar.exists()){
62
			app.dispatch(".uno:AvailableToolbars?Toolbar:string=toolbar");
63
		}
64
	}
65
66
	@After
67
	public void tearDown() throws Exception {
68
		app.close();
69
	}
70
71
	/**
72
	 * Insert a new CallOut shape 
73
	 * @throws Exception
74
	 */
75
	@Test
76
	public void testCalloutShapes() throws Exception{
77
78
		impress.focus();
79
		//---before insert CallOut Shape
80
		SD_Navigator.focus();
81
		SD_Navigator_Shape_Filter.click();
82
		typeKeys("<down><down>");
83
		typeKeys("<enter>");
84
		SD_Navigator.select(0);
85
		typeKeys("<enter>");
86
		String[] allShapes=SD_Navigator.getAllItemsText();
87
		assertEquals(3, allShapes.length);
88
		
89
		//--- After insert CallOut shape
90
		SD_CalloutShapes.click();
91
		impress.focus();
92
		impress.drag(100, 100, 200, 200);
93
		SD_NavigatorDlg.focus();
94
		SD_Navigator_Shape_Filter.click();
95
		typeKeys("<down><down>");
96
		typeKeys("<enter>");
97
		SD_Navigator.focus();
98
		SD_Navigator.select(0);
99
		typeKeys("<enter>");
100
		allShapes=SD_Navigator.getAllItemsText();
101
		assertEquals(4, allShapes.length);
102
103
	}
104
	/**
105
	 * Insert a new Star shape
106
	 * @throws Exception
107
	 */
108
	@Test
109
	public void testStarsShapes() throws Exception{
110
111
		impress.focus();
112
		//---before insert CallOut Shape
113
		SD_Navigator.focus();
114
		SD_Navigator_Shape_Filter.click();
115
		typeKeys("<down><down>");
116
		typeKeys("<enter>");
117
		SD_Navigator.select(0);
118
		typeKeys("<enter>");
119
		String[] allShapes=SD_Navigator.getAllItemsText();
120
		assertEquals(3, allShapes.length);
121
		
122
		//--- After insert CallOut shape
123
		SD_StarShapes.click();
124
		impress.focus();
125
		impress.drag(100, 100, 200, 200);
126
		SD_NavigatorDlg.focus();
127
		SD_Navigator_Shape_Filter.click();
128
		typeKeys("<down><down>");
129
		typeKeys("<enter>");
130
		SD_Navigator.focus();
131
		SD_Navigator.select(0);
132
		typeKeys("<enter>");
133
		allShapes=SD_Navigator.getAllItemsText();
134
		assertEquals(4, allShapes.length);
135
136
	}
137
138
}
139
(-)testgui/source/testlib/gui/UIMap.java (+6 lines)
Lines 469-474 Link Here
469
	//Fontwork
469
	//Fontwork
470
	public static final VclDialog FontworkGalleryDlg = dialog("svx:ModalDialog:RID_SVX_MDLG_FONTWORK_GALLERY");
470
	public static final VclDialog FontworkGalleryDlg = dialog("svx:ModalDialog:RID_SVX_MDLG_FONTWORK_GALLERY");
471
	
471
	
472
	//Impress: Navigator dialog.
473
	public static final VclTreeListBox SD_Navigator = tree("SD_HID_SD_NAVIGATOR_TLB");
474
	public static final VclButton SD_Navigator_Shape_Filter = button("SD_HID_SD_NAVIGATOR_TBI_SHAPE_FILTER");
475
	public static final VclButton SD_CalloutShapes = button(".uno:CalloutShapes");
476
	public static final VclButton SD_StarShapes = button(".uno:StarShapes");
477
	public static final VclToolBox SD_Drawing_Toolbar = toolbox(".HelpId:toolbar");
472
	
478
	
473
	
479
	
474
480
(-)testuno/source/testcase/uno/sd/shape/ShapeTypes.java (+178 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
package testcase.uno.sd.shape;
22
23
import static org.junit.Assert.assertEquals;
24
25
import org.junit.After;
26
import org.junit.Before;
27
import org.junit.Test;
28
import org.openoffice.test.common.FileUtil;
29
import org.openoffice.test.common.Testspace;
30
import org.openoffice.test.uno.UnoApp;
31
32
import testlib.uno.PageUtil;
33
import testlib.uno.ShapeUtil;
34
35
import com.sun.star.awt.Point;
36
import com.sun.star.awt.Size;
37
import com.sun.star.beans.PropertyValue;
38
import com.sun.star.beans.XPropertySet;
39
import com.sun.star.drawing.XDrawPage;
40
import com.sun.star.drawing.XDrawPages;
41
import com.sun.star.drawing.XDrawPagesSupplier;
42
import com.sun.star.drawing.XShape;
43
import com.sun.star.drawing.XShapes;
44
import com.sun.star.frame.XStorable;
45
import com.sun.star.lang.XComponent;
46
import com.sun.star.presentation.XPresentation;
47
import com.sun.star.presentation.XPresentationSupplier;
48
import com.sun.star.uno.UnoRuntime;
49
50
public class ShapeTypes {
51
	UnoApp unoApp = new UnoApp();
52
	XPresentationSupplier sdDocument = null;
53
	XPresentation pre = null;
54
	XComponent precomp = null;
55
	XComponent impressDocument = null;
56
	XComponent reLoadFile = null;
57
	XDrawPagesSupplier drawsupplier = null;
58
	XDrawPages drawpages = null;
59
	XShapes xShapes = null;
60
	XDrawPage xpage = null;
61
	String filePath = null;
62
63
	@Before
64
	public void setUp() throws Exception {
65
		unoApp.start();
66
		createDocumentAndSlide();
67
	}
68
69
	@After
70
	public void tearDown() throws Exception {
71
		unoApp.closeDocument(impressDocument);
72
		unoApp.closeDocument(reLoadFile);
73
		unoApp.close();
74
		if (filePath != null)
75
			FileUtil.deleteFile(filePath);
76
	}
77
78
	@Test
79
	public void testLineShape() throws Exception {
80
		Point po = new Point(1000, 8000);
81
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
82
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
83
				5000, 5000), "com.sun.star.drawing.LineShape");
84
		xShapes.add(xShape);
85
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
86
				XPropertySet.class, xShape);
87
		xPropSet.setPropertyValue("Name", "test");
88
89
		xShape = saveAndLoadShape(1, 0);
90
		XPropertySet xPropSet2 = (XPropertySet) UnoRuntime.queryInterface(
91
				XPropertySet.class, xShape);
92
		assertEquals("Not the same shape", "test",
93
				xPropSet2.getPropertyValue("Name"));
94
		assertEquals("Not LineShape", "com.sun.star.drawing.LineShape",
95
				xShape.getShapeType());
96
	}
97
98
	@Test
99
	public void testBasicShape() throws Exception {
100
		Point po = new Point(1000, 8000);
101
		xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xpage);
102
		XShape xShape = ShapeUtil.createShape(impressDocument, po, new Size(
103
				5000, 5000), "com.sun.star.drawing.RectangleShape");
104
		xShapes.add(xShape);
105
		XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
106
				XPropertySet.class, xShape);
107
		xPropSet.setPropertyValue("Name", "test");
108
109
		xShape = saveAndLoadShape(1, 0);
110
		XPropertySet xPropSet2 = (XPropertySet) UnoRuntime.queryInterface(
111
				XPropertySet.class, xShape);
112
		assertEquals("Not the same shape", "test",
113
				xPropSet2.getPropertyValue("Name"));
114
		assertEquals("Not RectangleShape",
115
				"com.sun.star.drawing.RectangleShape", xShape.getShapeType());
116
	}
117
	
118
119
120
	/**
121
	 * create a new presentation document and insert a new slide.
122
	 * 
123
	 * @throws Exception
124
	 */
125
	public void createDocumentAndSlide() throws Exception {
126
		impressDocument = (XComponent) UnoRuntime.queryInterface(
127
				XComponent.class, unoApp.newDocument("simpress"));
128
		drawsupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(
129
				XDrawPagesSupplier.class, impressDocument);
130
		drawpages = drawsupplier.getDrawPages();
131
		drawpages.insertNewByIndex(1);
132
		xpage = PageUtil.getDrawPageByIndex(impressDocument, 1);
133
	}
134
135
	/**
136
	 * Save presentation and reLoad the presentation and shape in it.
137
	 * 
138
	 * @param po
139
	 * @param shapeType
140
	 * @return
141
	 * @throws Exception
142
	 */
143
	public XShape saveAndLoadShape(int pageIndex, int shapeIndex)
144
			throws Exception {
145
		reLoadFile = saveAndReloadDoc(impressDocument,
146
				"StarOffice XML (Impress)", "odp");
147
		xShapes = ShapeUtil.getShapes(reLoadFile, pageIndex);
148
		return (XShape) UnoRuntime.queryInterface(XShape.class,
149
				xShapes.getByIndex(shapeIndex));
150
	}
151
152
	/**
153
	 * save and reload Presentation document.
154
	 * 
155
	 * @param presentationDocument
156
	 * @param sFilter
157
	 * @param sExtension
158
	 * @return
159
	 * @throws Exception
160
	 */
161
	private XComponent saveAndReloadDoc(XComponent presentationDocument,
162
			String sFilter, String sExtension) throws Exception {
163
		filePath = Testspace.getPath("tmp/presentationtest." + sExtension);
164
		PropertyValue[] aStoreProperties = new PropertyValue[2];
165
		aStoreProperties[0] = new PropertyValue();
166
		aStoreProperties[1] = new PropertyValue();
167
		aStoreProperties[0].Name = "Override";
168
		aStoreProperties[0].Value = true;
169
		aStoreProperties[1].Name = "FilterName";
170
		aStoreProperties[1].Value = sFilter;
171
		XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
172
				XStorable.class, presentationDocument);
173
		xStorable.storeToURL(FileUtil.getUrl(filePath), aStoreProperties);
174
175
		return UnoRuntime.queryInterface(XComponent.class,
176
				unoApp.loadDocument(filePath));
177
	}
178
}

Return to issue 120733