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

(-)testuno/source/testcase/uno/sd/CheckBulletStyle.java (+173 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
package testcase.uno.sd;
25
import static org.junit.Assert.*;
26
import static testlib.uno.PageUtil.getDrawPageByIndex;
27
import static testlib.uno.ShapeUtil.*;
28
29
import org.junit.After;
30
import org.junit.AfterClass;
31
import org.junit.Before;
32
import org.junit.BeforeClass;
33
import org.junit.Test;
34
import org.openoffice.test.common.FileUtil;
35
import org.openoffice.test.common.Testspace;
36
import org.openoffice.test.uno.UnoApp;
37
38
import com.sun.star.beans.PropertyValue;
39
import com.sun.star.beans.XPropertySet;
40
import com.sun.star.container.XIndexReplace;
41
import com.sun.star.drawing.XShape;
42
43
import com.sun.star.lang.XComponent;
44
45
import com.sun.star.style.NumberingType;
46
import com.sun.star.uno.UnoRuntime;
47
import testlib.uno.SDUtil;
48
49
/**
50
 * 1. New a SD
51
2. Insert some text
52
3. Set bullet on
53
4. Change the bullet color and bullet size
54
5. save/close/reopen and then check the bullet color and size
55
 *
56
 */
57
public class CheckBulletStyle {
58
59
	private static final UnoApp app = new UnoApp();
60
61
	private XComponent m_xSDComponent = null;
62
	private String m_filePath = null;
63
//	private XShape m_xsecondTextBox = null;
64
	Object m_numberingRules = null;
65
	XPropertySet m_textProperty = null;
66
	XIndexReplace m_xReplace = null;
67
68
	@Before
69
	public void setUpDocument() throws Exception {
70
		m_filePath = Testspace.getPath("temp/CheckBulletStyle.odt");
71
		if(FileUtil.fileExists(m_filePath))
72
		{	//load			
73
			m_xReplace = load();
74
		}
75
		else{
76
			//create a sd
77
			m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, app.newDocument("simpress"));	
78
			Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);
79
			Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1);
80
			XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox);
81
			m_textProperty = addPortion(xsecondTextBox, "Test Bullet Style", false);
82
			
83
			//get numberingRules
84
			m_numberingRules = m_textProperty.getPropertyValue("NumberingRules");
85
			
86
			m_xReplace = (XIndexReplace) UnoRuntime.queryInterface(
87
		             XIndexReplace.class, m_numberingRules);    
88
			
89
			PropertyValue[] props = new PropertyValue[1];
90
		    props[0] = new PropertyValue();
91
		    props[0].Name = "NumberingType";
92
		    props[0].Value = new Short(NumberingType.CHAR_SPECIAL );
93
			
94
		    //set numberingType
95
		    m_xReplace.replaceByIndex(0, props);
96
		    m_textProperty.setPropertyValue("NumberingRules", m_numberingRules);
97
		    //set numbering level to 0			
98
		    m_textProperty.setPropertyValue("NumberingLevel", new Short((short)0));
99
		}		
100
	}
101
	private XIndexReplace load() throws Exception{
102
		m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, 
103
				app.loadDocument(m_filePath));
104
		Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);
105
		Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1);
106
		XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox);
107
		m_textProperty = getPortion(xsecondTextBox, 0);
108
	
109
		m_numberingRules = m_textProperty.getPropertyValue("NumberingRules");
110
		
111
		XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface(
112
	             XIndexReplace.class, m_numberingRules);   
113
		return xReplace;
114
	}
115
116
	@After
117
	public void tearDownDocument() {
118
		app.closeDocument(m_xSDComponent);
119
	}
120
121
	@BeforeClass
122
	public static void setUpConnection() throws Exception {
123
		app.start();
124
	}
125
126
	@AfterClass
127
	public static void tearDownConnection() throws InterruptedException,
128
			Exception {
129
		app.close();
130
		//remove the temp file
131
		FileUtil.deleteFile(Testspace.getPath("temp"));
132
	}
133
134
	@Test
135
	public void testBulletColor() throws Exception {
136
		//BulletColor, Integer
137
		PropertyValue[] props = new PropertyValue[1];
138
	    props[0] = new PropertyValue();
139
	    props[0].Name = "BulletColor";
140
	    props[0].Value = new Integer(255);
141
		
142
	    m_xReplace.replaceByIndex(0, props);
143
	    m_textProperty.setPropertyValue("NumberingRules", m_numberingRules);		
144
	    
145
	    app.saveDocument(m_xSDComponent, m_filePath);
146
		app.closeDocument(m_xSDComponent);
147
		
148
		XIndexReplace xReplace = load();
149
		PropertyValue[] proValues = (PropertyValue[])xReplace.getByIndex(0);
150
		assertEquals("name should be BulletColor", "BulletColor", proValues[11].Name);
151
		assertEquals("BulletColor should be 255(Blue)", new Integer(255), proValues[11].Value);
152
	}
153
	
154
	@Test
155
	public void testBulletSize() throws Exception {
156
		//BulletRelSize, default 45
157
		PropertyValue[] props = new PropertyValue[1];
158
	    props[0] = new PropertyValue();
159
	    props[0].Name = "BulletRelSize";
160
	    props[0].Value = new Short((short)200);
161
			    
162
	    m_xReplace.replaceByIndex(0, props);
163
	    m_textProperty.setPropertyValue("NumberingRules", m_numberingRules);
164
	    
165
	    app.saveDocument(m_xSDComponent, m_filePath);
166
		app.closeDocument(m_xSDComponent);
167
		
168
		XIndexReplace xReplace = load();
169
		PropertyValue[] proValues = (PropertyValue[])xReplace.getByIndex(0);
170
		assertEquals("name should be BulletRelSize", "BulletRelSize", proValues[12].Name);
171
		assertEquals("BulletRelSize should be 200%", new Short((short)200), proValues[12].Value);		
172
	}
173
}

Return to issue 120632