1 '**************************************************************************
2 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '* Copyright 2008 by Sun Microsystems, Inc.
6 '* OpenOffice.org - a multi-platform office productivity suite
8 '* $RCSfile: w_calculate.inc,v $
12 '* last change: $Author: vg $ $Date: 2008-08-18 12:23:54 $
14 '* This file is part of OpenOffice.org.
16 '* OpenOffice.org is free software: you can redistribute it and/or modify
17 '* it under the terms of the GNU Lesser General Public License version 3
18 '* only, as published by the Free Software Foundation.
20 '* OpenOffice.org is distributed in the hope that it will be useful,
21 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
22 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 '* GNU Lesser General Public License version 3 for more details
24 '* (a copy is included in the LICENSE file that accompanied this code).
26 '* You should have received a copy of the GNU Lesser General Public License
27 '* version 3 along with OpenOffice.org. If not, see
28 '* <http://www.openoffice.org/license.html>
29 '* for a copy of the LGPLv3 License.
31 '/************************************************************************
33 '* owner : helge.delfs@sun.com
35 '* short description : Put description here
37 '\***********************************************************************
47 testcase tToolsCalculate1
48 Printlog "- Tools / calculation base functionality formula bar"
52 Call wTypeKeys "2+3+4+5<Shift Home>"
54 Call wTypeKeys "<End> = "
56 if GetClipboardText <> "14" then Warnlog "Result of Add is not 14 but "+ GetClipboardText
58 Printlog " - Subtract"
59 Call wTypeKeys "<Return>101-3-4-155<Shift Home>"
61 Call wTypeKeys "<End> = "
63 if GetClipboardText <> "-61" then Warnlog "Result of Subtract is not -61 but "+ GetClipboardText
65 Printlog " - multiply"
66 Call wTypeKeys "<Return>11*3*1" & DecimalSeparator & "5<Shift Home>"
68 Call wTypeKeys "<End> = "
70 if GetClipboardText <> "49" & DecimalSeparator & "50" and GetClipboardText <> "49" & DecimalSeparator & "5" then Warnlog "Result of Multiply is not 49" & DecimalSeparator & "50 but " & GetClipboardText
72 Printlog " - Division"
73 Call wTypeKeys "<Return>111/3/2<Shift Home>"
75 Call wTypeKeys "<End> = "
77 if GetClipboardText <> "18" & DecimalSeparator & "50" and GetClipboardText <> "18" & DecimalSeparator & "5" then Warnlog "Result of Multiply is not 18" & DecimalSeparator & "50 but " & GetClipboardText
79 Printlog " - random with brackets"
80 Call wTypeKeys "<Return>((12*2)/4" & DecimalSeparator & "5+3)-1" & DecimalSeparator & "5 <Shift Home>"
83 Call wTypeKeys "<End> = "
85 if Left$(GetClipboardText,4) <> "6" & DecimalSeparator & "83" then Warnlog "Result of mixed calculation not 6" & DecimalSeparator & "83 but " & GetClipboardText
90 ' *******************************************************************
92 testcase tToolsCalculate2
93 Printlog "- Tools / Calculate Basic functionality"
98 Kontext "OL_SW_Rechenleiste"
99 EingabeFeld.SetText "2+3+4+5" : EingabeFeld.TypeKeys "<Return>"
100 if ErmittleErgebnis ( "14" ) = FALSE then Warnlog "Result of Add not 14 but "+ GetClipboardText
102 Printlog " - Subtract"
103 Call wTypeKeys "<End> <Return><F2>"
104 Kontext "OL_SW_Rechenleiste"
105 EingabeFeld.SetText "101-3-4-155" : EingabeFeld.TypeKeys "<Return>"
106 if ErmittleErgebnis ( "-61" ) = FALSE then Warnlog "Result of Subtract not -61 but "+ GetClipboardText
108 Printlog " - Multiply"
109 Call wTypeKeys "<End> <Return><F2>"
110 Kontext "OL_SW_Rechenleiste"
111 EingabeFeld.SetText "11*3*1" & DecimalSeparator & "5" : EingabeFeld.TypeKeys "<Return>"
112 if ErmittleErgebnis ( "49" & DecimalSeparator & "5" ) = FALSE then Warnlog "Result of Multiplication not 49" & DecimalSeparator & "5 but " & GetClipboardText
114 Printlog " - Division"
115 Call wTypeKeys "<End><Return><F2>"
116 Kontext "OL_SW_Rechenleiste"
117 EingabeFeld.SetText "111/3/2" : EingabeFeld.TypeKeys "<Return>"
118 if ErmittleErgebnis ( "18" & DecimalSeparator & "5" ) = FALSE then Warnlog "Result of Division not 18" & DecimalSeparator & "5 but " & GetClipboardText
120 Printlog " - random with brackets"
121 Call wTypeKeys "<End><Return><F2>"
122 Kontext "OL_SW_Rechenleiste"
123 EingabeFeld.SetText "((12*2)/4" & DecimalSeparator & "5+3)-1" & DecimalSeparator & "5" : EingabeFeld.TypeKeys "<Return>"
124 if ErmittleErgebnis ( "6" & DecimalSeparator & "83" ) = FALSE then Warnlog "Result of mixed calculation not 6" & DecimalSeparator & "83 but " & GetClipboardText
129 ' *******************************************************************
131 testcase tToolsCalculate3
132 Dim Fehlermeldung as String
134 Printlog "- Tools / Calculate Basic functionality (formula button)"
137 Printlog " - Sum (6)"
138 Call wTypeKeys "<F2>"
139 Kontext "OL_SW_Rechenleiste"
142 Call hMenuSelectNr ( 1 )
144 EingabeFeld.TypeKeys " (6)" : EingabeFeld.TypeKeys "<Return>"
146 if ErmittleErgebnis ( "6" ) = FALSE then Warnlog "Result is not 6 but "+ GetClipboardText
148 Printlog " - Sum ( <a1:B2>|<b4:r3> )"
149 Call wTypeKeys "<End> <Return><F2>"
150 Kontext "OL_SW_Rechenleiste"
153 Call hMenuSelectNr ( 1 )
155 EingabeFeld.TypeKeys " ( <a1:B2" : EingabeFeld.TypeKeys ">|<b4:r3" : EingabeFeld.TypeKeys "> )" : EingabeFeld.TypeKeys "<Return>"
157 case 01 : Fehlermeldung = "** Expression is faulty **"
158 case 03 : Fehlermeldung = "** Expressão incorrecta **"
159 case 31 : Fehlermeldung = "** Foutieve expressie **"
160 case 33 : Fehlermeldung = "** Expression errone **"
161 case 34 : Fehlermeldung = "** Expresión errónea **"
162 case 39 : Fehlermeldung = "** Errore nell'espressione **"
163 case 45 : Fehlermeldung = "** Fejlagtigt udtryk **"
164 case 46 : Fehlermeldung = "** Felaktigt uttryck **"
165 case 48 : Fehlermeldung = "** Nieprawiedlowe wyralenie **"
166 case 49 : Fehlermeldung = "** Fehlerhafter Ausdruck **"
167 case else : Fehlermeldung = ""
170 if ErmittleErgebnis ( Fehlermeldung ) = FALSE then
171 if Fehlermeldung > "" then
172 Warnlog "Result is not " + Fehlermeldung + " but " & GetClipboardText
174 QAErrorlog "** Errortext for this language not defined **"
177 Printlog " - 1323,3 round 1"
178 Call wTypeKeys "<End> <Return><F2>"
179 Kontext "OL_SW_Rechenleiste"
180 EingabeFeld.TypeKeys "1323" & DecimalSeparator & "345 "
183 Call hMenuSelectNr ( 2 )
185 EingabeFeld.TypeKeys "<End> 1" : EingabeFeld.TypeKeys "<Return>"
186 if ErmittleErgebnis ( "1323" & DecimalSeparator & "3" ) = FALSE then Warnlog "Result is not 1323" & DecimalSeparator & "3 but " & GetClipboardText
188 Printlog " - 10 + 20 PHD ( Percent )"
189 Call wTypeKeys "<End> <Return><F2>"
190 Kontext "OL_SW_Rechenleiste"
191 EingabeFeld.TypeKeys "10 + 20 "
194 Call hMenuSelectNr ( 3 )
196 EingabeFeld.TypeKeys "<End><Return>"
197 if ErmittleErgebnis ( "10" & DecimalSeparator & "2" ) = FALSE then Warnlog "Result is not 10" & DecimalSeparator & "2 but " & GetClipboardText
199 Printlog " - SQRT 144 ( Square Root )"
200 Call wTypeKeys "<End> <Return><F2>"
201 Kontext "OL_SW_Rechenleiste"
204 Call hMenuSelectNr ( 4 )
206 EingabeFeld.TypeKeys "<End> 144 <Return>"
207 if ErmittleErgebnis ( "12" ) = FALSE then Warnlog "Result is not 12 but "+ GetClipboardText
209 Printlog " - 4 POW 8 ( Power )"
210 Call wTypeKeys "<End> <Return><F2>"
211 Kontext "OL_SW_Rechenleiste"
212 EingabeFeld.TypeKeys "4 "
215 Call hMenuSelectNr ( 5 )
217 EingabeFeld.TypeKeys "<End> 8 <Return>"
218 if ErmittleErgebnis ( "65536" ) = FALSE then Warnlog "Result is not 65536 but "+ GetClipboardText
220 Printlog "- Tools / Calculate Operators with formula button"
221 Printlog " - 2 EQ 2 ( equal )"
222 Call wTypeKeys "<End> <Return><F2>"
223 Kontext "OL_SW_Rechenleiste"
224 EingabeFeld.TypeKeys "2 "
227 Call hMenuSelectNr ( 6 )
229 Call hMenuSelectNr ( 2 )
231 EingabeFeld.TypeKeys "<End> 2 <Return>"
232 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
234 Printlog " - 2 NEQ 2 ( not equal )"
235 Call wTypeKeys "<End> <Return><F2>"
236 Kontext "OL_SW_Rechenleiste"
237 EingabeFeld.TypeKeys "2 "
240 Call hMenuSelectNr ( 6 )
242 Call hMenuSelectNr ( 3 )
244 EingabeFeld.TypeKeys "<End> 2 <Return>"
245 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
247 Printlog " - 2 LEQ 3 ( Less than or equal )"
248 Call wTypeKeys "<End> <Return><F2>"
249 Kontext "OL_SW_Rechenleiste"
250 EingabeFeld.TypeKeys "2 "
253 Call hMenuSelectNr ( 6 )
255 Call hMenuSelectNr ( 4 )
257 EingabeFeld.TypeKeys "<End> 3 <Return>"
258 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
260 Printlog " - 2 GEO 2,0 ( greater than or equal )"
261 Call wTypeKeys "<End> <Return><F2>"
262 Kontext "OL_SW_Rechenleiste"
263 EingabeFeld.TypeKeys "2 "
266 Call hMenuSelectNr ( 6 )
268 Call hMenuSelectNr ( 5 )
270 EingabeFeld.TypeKeys "<End> 2" & DecimalSeparator & "0 <Return>"
271 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
273 Printlog " - 2 L 2 ( less )"
274 Call wTypeKeys "<End> <Return><F2>"
275 Kontext "OL_SW_Rechenleiste"
276 EingabeFeld.TypeKeys "2 "
279 Call hMenuSelectNr ( 6 )
281 Call hMenuSelectNr ( 6 )
283 EingabeFeld.TypeKeys "<End> 2 <Return>"
284 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
286 Printlog " - 2,01 g 2 ( greater )"
287 Call wTypeKeys "<End> <Return><F2>"
288 Kontext "OL_SW_Rechenleiste"
289 EingabeFeld.TypeKeys "2" & DecimalSeparator & "01 "
292 Call hMenuSelectNr ( 6 )
294 Call hMenuSelectNr ( 7 )
296 EingabeFeld.TypeKeys "<End> 2 <Return>"
297 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
299 Printlog " - 0 OR 0 ( Boolean or )"
300 Call wTypeKeys "<End> <Return><F2>"
301 Kontext "OL_SW_Rechenleiste"
302 EingabeFeld.TypeKeys "0 "
305 Call hMenuSelectNr ( 6 )
307 Call hMenuSelectNr ( 8 )
309 EingabeFeld.TypeKeys "<End> 0 <Return>"
310 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
312 Printlog " - 0 XOR 1 ( Boolean XOR )"
313 Call wTypeKeys "<End> <Return><F2>"
314 Kontext "OL_SW_Rechenleiste"
315 EingabeFeld.TypeKeys "0 "
318 Call hMenuSelectNr ( 6 )
320 Call hMenuSelectNr ( 9 )
322 EingabeFeld.TypeKeys "<End> 1 <Return>"
323 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
325 Printlog " - 1 AND 0 ( Boolean And )"
326 Call wTypeKeys "<End> <Return><F2>"
327 Kontext "OL_SW_Rechenleiste"
328 EingabeFeld.TypeKeys "1 "
331 Call hMenuSelectNr ( 6 )
333 Call hMenuSelectNr ( 10 )
335 EingabeFeld.TypeKeys "<End> 0 <Return>"
336 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
338 Printlog " - 0 NOT 0 ( Boolean Or )"
339 Call wTypeKeys "<End> <Return><F2>"
340 Kontext "OL_SW_Rechenleiste"
341 EingabeFeld.TypeKeys "0 "
344 Call hMenuSelectNr ( 6 )
346 Call hMenuSelectNr ( 11 )
348 EingabeFeld.TypeKeys "<End> 0 <Return>"
349 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
351 Printlog "- Tools / Calculate Statistical function with formula button"
352 Printlog " - mean 30|40|20 ( Mean )"
353 Call wTypeKeys "<End> <Return><F2>"
354 Kontext "OL_SW_Rechenleiste"
357 Call hMenuSelectNr ( 7 )
359 Call hMenuSelectNr ( 1 )
361 EingabeFeld.TypeKeys "<End> 30|40|20 <Return>"
362 if ErmittleErgebnis ( "30" ) = FALSE then Warnlog "Result is not 30 but "+ GetClipboardText
364 Printlog " - min 1|1,01|1,001 ( Minimum )"
365 Call wTypeKeys "<End> <Return><F2>"
366 Kontext "OL_SW_Rechenleiste"
369 Call hMenuSelectNr ( 7 )
371 Call hMenuSelectNr ( 2 )
373 EingabeFeld.TypeKeys "<End> 1|1" & DecimalSeparator & "01|1" & DecimalSeparator & "001 <Return>"
374 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
376 Printlog " - max 1|1,01|1,001 ( Maximum )"
377 Call wTypeKeys "<End> <Return><F2>"
378 Kontext "OL_SW_Rechenleiste"
381 Call hMenuSelectNr ( 7 )
383 Call hMenuSelectNr ( 3 )
385 EingabeFeld.TypeKeys "<End> 1|1" & DecimalSeparator & "01|1" & DecimalSeparator & "001 <Return>"
386 if ErmittleErgebnis ( "1" & DecimalSeparator & "01" ) = FALSE then Warnlog "Result is not 1" & DecimalSeparator & "01 but "+ GetClipboardText
388 Printlog "- Tools / Calculate Further functions"
389 Printlog " - sin (PI/2) ( Sine )"
390 Call wTypeKeys "<End> <Return><F2>"
391 Kontext "OL_SW_Rechenleiste"
394 Call hMenuSelectNr ( 8 )
396 Call hMenuSelectNr ( 1 )
398 EingabeFeld.TypeKeys "<End> (PI/2) <Return>"
399 if ErmittleErgebnis ( "1" ) = FALSE then Warnlog "Result is not 1 but "+ GetClipboardText
401 Printlog " - cos (PI/2) ( Cosine )"
402 Call wTypeKeys "<End> <Return><F2>"
403 Kontext "OL_SW_Rechenleiste"
406 Call hMenuSelectNr ( 8 )
408 Call hMenuSelectNr ( 2 )
410 EingabeFeld.TypeKeys "<End> (PI/2) <Return>"
411 if ErmittleErgebnis ( "0" ) = FALSE then Warnlog "Result is not 0 but "+ GetClipboardText
413 Printlog " - tan (PI/2 - 0,001) ( Tangent )"
414 Call wTypeKeys "<End> <Return><F2>"
415 Kontext "OL_SW_Rechenleiste"
418 Call hMenuSelectNr ( 8 )
420 Call hMenuSelectNr ( 3 )
422 EingabeFeld.TypeKeys "<End> (PI/2 - 0" & DecimalSeparator & "001) <Return>"
423 if ErmittleErgebnis ( "1000" ) = FALSE then Warnlog "Result is not 1000 but "+ GetClipboardText
425 Printlog " - asin 1 ( Arc-Sine )"
426 Call wTypeKeys "<End> <Return><F2>"
427 Kontext "OL_SW_Rechenleiste"
430 Call hMenuSelectNr ( 8 )
432 Call hMenuSelectNr ( 4 )
434 EingabeFeld.TypeKeys "<End> 1 <Return>"
435 if ErmittleErgebnis ( Fehlermeldung ) = FALSE then
436 if Fehlermeldung > "" then
437 Warnlog "Result is not " + Fehlermeldung + " but " & GetClipboardText
439 QAErrorlog "** Errortext for this language not defined **"
444 Printlog " - acos 0 ( Arc-Cosine )"
445 Call wTypeKeys "<End> <Return><F2>"
446 Kontext "OL_SW_Rechenleiste"
449 Call hMenuSelectNr ( 8 )
451 Call hMenuSelectNr ( 5 )
453 EingabeFeld.TypeKeys "<End> 0 <Return>"
454 if ErmittleErgebnis ( "1" & DecimalSeparator & "57" ) = FALSE then Warnlog "Result is not 1" & DecimalSeparator & "57 but "+ GetClipboardText
456 Printlog " - asin 1 ( Arc-Tangent )"
457 Call wTypeKeys "<End> <Return><F2>"
458 Kontext "OL_SW_Rechenleiste"
461 Call hMenuSelectNr ( 8 )
463 Call hMenuSelectNr ( 6 )
465 EingabeFeld.TypeKeys "<End> 1 <Return>"
466 if ErmittleErgebnis ( "0" & DecimalSeparator & "79" ) = FALSE then Warnlog "Result is not 0" & DecimalSeparator & "79 but "+ GetClipboardText