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 |
* |
26 |
*/ |
27 |
package testcase.formula.catalog; |
28 |
|
29 |
import static testlib.AppUtil.*; |
30 |
import static testlib.UIMap.*; |
31 |
import static org.junit.Assert.*; |
32 |
import org.junit.After; |
33 |
import org.junit.Before; |
34 |
import org.junit.Rule; |
35 |
import org.junit.Test; |
36 |
import testlib.Log; |
37 |
|
38 |
/** |
39 |
* |
40 |
*/ |
41 |
public class AddDeleteSymbolsFromCatalog { |
42 |
|
43 |
@Rule |
44 |
public Log LOG = new Log(); |
45 |
|
46 |
@Before |
47 |
public void setUp() throws Exception { |
48 |
app.start(); |
49 |
|
50 |
// New a formula document |
51 |
startcenter.menuItem("File->New->Formula").select(); |
52 |
sleep(3); |
53 |
|
54 |
// Click catalog button |
55 |
math_CatalogButton.click(); |
56 |
sleep(1); |
57 |
|
58 |
// Verify if the "Symbols" dialog pop up |
59 |
assertTrue("Symbols dialog does not pop up", math_SymbolsDlg.exists(3)); |
60 |
|
61 |
// Select "Special", click "Edit" button |
62 |
math_SymbolsDlgListbox.select("Special"); |
63 |
math_SymbolsDlgEditButton.click(); |
64 |
sleep(1); |
65 |
|
66 |
// Verify if the "Edit Symbols" dialog pop up |
67 |
assertTrue("Edit Symbols dialog does not pop up", math_EditSymbolsDlg.exists(3)); |
68 |
} |
69 |
|
70 |
@After |
71 |
public void tearDown() throws Exception { |
72 |
app.close(); |
73 |
} |
74 |
|
75 |
/** |
76 |
* Test add custom symbols from Catalog->Symbols |
77 |
* @throws Exception |
78 |
*/ |
79 |
@Test |
80 |
public void testAddSymbolFromCatalog() throws Exception{ |
81 |
|
82 |
// Choose a symbol which is not in the list, click "Add" and "OK" |
83 |
String selectedSymbol; |
84 |
boolean bSelectSymbolNotInList; |
85 |
int nListCount; |
86 |
int nIndex = 1; |
87 |
do { |
88 |
math_EditSymbolsDlgViewControl.click(100*nIndex, 10); // risk: after 6 or 7 circles, this will click out of ViewControl |
89 |
sleep(1); |
90 |
selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
91 |
nIndex++; |
92 |
// Find if the selected symbol is already in the list |
93 |
bSelectSymbolNotInList = false; |
94 |
nListCount = math_EditSymbolsDlgSymbol.getItemCount(); |
95 |
for (int i=0; i<nListCount; i++) { |
96 |
if (selectedSymbol.equals(math_EditSymbolsDlgSymbol.getItemText(i))) { |
97 |
bSelectSymbolNotInList = true; |
98 |
break; |
99 |
} |
100 |
} |
101 |
} while (bSelectSymbolNotInList); |
102 |
math_EditSymbolsDlgAdd.click(); |
103 |
math_EditSymbolsDlg.ok(); |
104 |
sleep(1); |
105 |
|
106 |
// Verify if the symbol is added to Symbol set |
107 |
math_SymbolsDlgEditButton.click(); |
108 |
bSelectSymbolNotInList = false; |
109 |
nListCount = math_EditSymbolsDlgSymbol.getItemCount(); |
110 |
for (int i=0; i<nListCount; i++) { |
111 |
if (selectedSymbol.equals(math_EditSymbolsDlgSymbol.getItemText(i))) { |
112 |
bSelectSymbolNotInList = true; |
113 |
break; |
114 |
} |
115 |
} |
116 |
assertTrue("Symbol is not added to Symbol set", bSelectSymbolNotInList); |
117 |
|
118 |
// Close all dialogs |
119 |
math_EditSymbolsDlg.cancel(); |
120 |
math_SymbolsDlg.close(); |
121 |
app.dispatch(".uno:CloseDoc"); |
122 |
} |
123 |
|
124 |
/** |
125 |
* Test modify font of custom symbols from Catalog->Symbols |
126 |
* @throws Exception |
127 |
*/ |
128 |
@Test |
129 |
public void testModifySymbolFontFromCatalog() throws Exception{ |
130 |
|
131 |
// Modify the font of selected symbol |
132 |
//String selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
133 |
int oldSymbolFontIndex = math_EditSymbolsDlgFont.getSelIndex(); |
134 |
int modifiedSymbolFondIndex = (oldSymbolFontIndex+1==math_EditSymbolsDlgFont.getItemCount()) ? 0 : (oldSymbolFontIndex+1); |
135 |
math_EditSymbolsDlgFont.select(modifiedSymbolFondIndex); // select the next font of old font |
136 |
String modifiedSymbolFont = math_EditSymbolsDlgFont.getSelText(); |
137 |
String selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
138 |
math_EditSymbolsDlgModify.click(); |
139 |
math_EditSymbolsDlg.ok(); |
140 |
sleep(1); |
141 |
|
142 |
// Verify if the font of symbol is modified successfully |
143 |
math_SymbolsDlgEditButton.click(); |
144 |
math_EditSymbolsDlgSymbol.select(selectedSymbol); |
145 |
assertEquals("Font of symbol is not modified successfully", modifiedSymbolFont, math_EditSymbolsDlgFont.getSelText()); |
146 |
|
147 |
// Close all dialogs |
148 |
math_EditSymbolsDlg.cancel(); |
149 |
math_SymbolsDlg.close(); |
150 |
app.dispatch(".uno:CloseDoc"); |
151 |
} |
152 |
|
153 |
/** |
154 |
* Test modify typeface of custom symbols from Catalog->Symbols |
155 |
* @throws Exception |
156 |
*/ |
157 |
@Test |
158 |
public void testModifySymbolTypefaceFromCatalog() throws Exception{ |
159 |
|
160 |
// Modify the typeface of selected symbol |
161 |
// String selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
162 |
int oldSymbolTypefaceIndex = math_EditSymbolsDlgTypeface.getSelIndex(); |
163 |
int modifiedSymbolTypefaceIndex = (oldSymbolTypefaceIndex+1==math_EditSymbolsDlgTypeface.getItemCount()) ? 0 : (oldSymbolTypefaceIndex+1); |
164 |
math_EditSymbolsDlgTypeface.select(modifiedSymbolTypefaceIndex); // select the next typeface of old typeface |
165 |
String modifiedSymbolTypeface= math_EditSymbolsDlgTypeface.getSelText(); |
166 |
String selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
167 |
math_EditSymbolsDlgModify.click(); |
168 |
math_EditSymbolsDlg.ok(); |
169 |
sleep(1); |
170 |
|
171 |
// Verify if the typeface of symbol is modified successfully |
172 |
math_SymbolsDlgEditButton.click(); |
173 |
math_EditSymbolsDlgSymbol.select(selectedSymbol); |
174 |
assertEquals("Typeface of symbol is not modified successfully", modifiedSymbolTypeface, math_EditSymbolsDlgTypeface.getSelText()); |
175 |
|
176 |
// Close all dialogs |
177 |
math_EditSymbolsDlg.cancel(); |
178 |
math_SymbolsDlg.close(); |
179 |
app.dispatch(".uno:CloseDoc"); |
180 |
} |
181 |
|
182 |
/** |
183 |
* Test delete custom symbols from Catalog->Symbols |
184 |
* @throws Exception |
185 |
*/ |
186 |
@Test |
187 |
public void testDeleteSymbolFromCatalog() throws Exception{ |
188 |
|
189 |
// Delete the selected symbol |
190 |
String selectedSymbol = math_EditSymbolsDlgSymbol.getText(); |
191 |
math_EditSymbolsDlgDelete.click(); |
192 |
math_EditSymbolsDlg.ok(); |
193 |
sleep(1); |
194 |
|
195 |
// Verify if the selected symbol is deleted successfully |
196 |
math_SymbolsDlgEditButton.click(); |
197 |
boolean isDeleted = true; |
198 |
for (int i=0; i<math_EditSymbolsDlgSymbol.getItemCount(); i++) { |
199 |
if (selectedSymbol.equals(math_EditSymbolsDlgSymbol.getItemText(i))){ |
200 |
isDeleted = false; |
201 |
break; |
202 |
} |
203 |
} |
204 |
assertTrue("Symbol is not deleted successfully", isDeleted); |
205 |
|
206 |
// Close all dialogs |
207 |
math_EditSymbolsDlg.cancel(); |
208 |
math_SymbolsDlg.close(); |
209 |
app.dispatch(".uno:CloseDoc"); |
210 |
} |
211 |
} |