merge the formfield patch from ooo-build
[ooovba.git] / testautomation / math / required / includes / m_001_.inc
blobfd7905ef382a52f9e42b3db35768bd255217b12e
1 'encoding UTF-8  Do not remove or change this line!
2 '**************************************************************************
3 '* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 '* 
5 '* Copyright 2008 by Sun Microsystems, Inc.
6 '*
7 '* OpenOffice.org - a multi-platform office productivity suite
8 '*
9 '* $RCSfile: m_001_.inc,v $
11 '* $Revision: 1.1 $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 11:51:23 $
15 '* This file is part of OpenOffice.org.
17 '* OpenOffice.org is free software: you can redistribute it and/or modify
18 '* it under the terms of the GNU Lesser General Public License version 3
19 '* only, as published by the Free Software Foundation.
21 '* OpenOffice.org is distributed in the hope that it will be useful,
22 '* but WITHOUT ANY WARRANTY; without even the implied warranty of
23 '* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 '* GNU Lesser General Public License version 3 for more details
25 '* (a copy is included in the LICENSE file that accompanied this code).
27 '* You should have received a copy of the GNU Lesser General Public License
28 '* version 3 along with OpenOffice.org.  If not, see
29 '* <http://www.openoffice.org/license.html>
30 '* for a copy of the LGPLv3 License.
32 '/************************************************************************
34 '* Owner : thorsten.bosbach@sun.com
36 '* short description :
38 '\*****************************************************************
40  global cActFilter as string ' used filter for save
41  Const cActFilterExt = ".odf" ' used filter for save (extension)
43 ' "StarMath 5.0" ".smf"
44 '   Datei$ = convertpath( gOfficePath + "user\work\killme" + cActFilterExt)
45 '   Datei$ = convertpath( gOfficePath + "user\work\Erwin2"+cActFilterExt)
46 '   Datei = convertpath(gofficepath + "user\work\test"+cActFilterExt)
48 sub M_001_
49    Printlog Chr(13) + "--  File Menu  m_001_ --"
51    cActFilter = gMathFilter
53    Call tmFileNew
54   Call tmFileOpen
55 '   Call Autopilot               'in Inc\desktop\autopilo.inc
56   Call tmFileClose
57   Call tmFileSave
58   Call tmFileSaveAs
59   Call tmFileSaveAll
60    Call tmFileReload
61    Call tmFileVersions
62    Call tmExportAsPDF
63    Call tmFileProperties
64    Call tmFilePrint
65   Call tmFilePrinterSetting
66    Call tmFilePassword
67 end sub
69 testcase tmFileNew
70 '/// open application ///'
71    Call hNewDocument
72    '/// File->New->Templates and Documents ///'
73    FileNewFromTemplate
74    sleep 3
75    Kontext "TemplateAndDocuments"
76    if TemplateAndDocuments.exists (5) then
77       try
78          '/// klick button 'Organize' ///'
79          Organize.click
80          kontext "DVVerwalten"
81          if DVVerwalten.exists (5) then
82             Call DialogTest (DVVerwalten)
83             sleep 1
84             '/// close dialog 'Template Management' ///'
85             DVVerwalten.close
86          else
87             warnlog "DVVerwalten didn't exist :-("
88          endif
89       catch
90           warnlog "error ;-) - 1"
91       endcatch
92    else
93       warnlog "templates and dokuments didn't exist :-("
94    endif
95    try
96      sleep 1
97      kontext "TemplateAndDocuments"
98      sleep 1
99      Call DialogTest ( TemplateAndDocuments )
100    catch
101      warnlog "no dialogtest possibele :-("
102    endcatch
104 ' TBO i don't get in deep here, because it is not math specific
105 '     and IMHO it doesn't make that sense here!
106 '     should be enoug in writer...
107    '/// close dialog 'Templates and Documents' ///'
108    TemplateAndDocuments.Cancel
109 '/// close application ///'
110         Call hCloseDocument
111 endcase
113 testcase tmFilePassword
114    Dim DokumentPfad$
115    Dim Datei$
116 '/// open application ///'
117 while (getDocumentCount > 0)
118 hCloseDocument
119 wend
120    hNewDocument
121    '/// type a formula ///'
122    SchreibenInMathdok "a over b"
124    printlog "'/// - save doc as "+cActFilter+" with passwd - ///'"
125    FileSaveAs
126    Kontext "SpeichernDlg"
127    Datei$ = convertpath( gOfficePath + "user\work\killme" + cActFilterExt)
128    if Dir (Datei$) <> "" then kill Datei$
129    printlog "  Testfile: "+Datei$
130    'Dateityp.Select (cActFilter)
131    Passwort.Check
132    Dateiname.SetText Datei$
133    Speichern.Click
134    Kontext "Active"
135    if Active.Exists (5) then
136    ' TBO: ??? what will be ??!
137       Printlog "(1/5) " + Active.GetText
138       Active.Yes
139    end if
141    printlog "'/// Try wrong passwd confirmation ///'"
142    Sleep 2
143    Kontext "PasswordFileSave"
144    sleep (2)
145    try
146       Password.SetText "12345"
147       PasswordConfirm.Settext "54321"
148       PasswordFileSave.OK
149       Sleep 2
150    catch
151       warnlog "had to ask for passwd!!!!"
152    endcatch
153    Kontext
154    if (Active.Exists (5) = FALSE ) then
155       Warnlog "Wrong passwordinput not detected"
156    else
157       Printlog "(2/5) " + Active.GetText
158       Active.OK
159    end if
161    printlog "'/// Now do it right ///'"
162    Kontext "PasswordFileSave"
163    try
164       Password.SetText "12345"
165       PasswordConfirm.Settext "12345"
166       PasswordFileSave.OK
167    catch
168       warnlog "had to ask for passwd!!!!"
169    endcatch
171    Sleep 2
172    printlog "'/// Gotcha & Close file/window ///'"
173    FileClose
174    sleep 1
176    printlog "'/// load again with wrong passwd ///'"
177    Call hFileOpen Datei$
178    sleep 1
179    Kontext "PasswordFileOpen"
180    try
181       Passwortname.SetText "34567"
182       PasswordFileOpen.OK
183    catch
184       warnlog "had to ask for passwd!!!!"
185    endcatch
186    Kontext "Active"
187    if Active.Exists(5) then
188          Printlog "(3/5) " + Active.GetText
189       Active.Ok
190    else
191       Warnlog "Wrong passwordinput not detected by loading the document"
192    end if
194    printlog "'///load now with right passwd ///'"
195    Sleep 3
196    'Call hDateiOeffnen Datei$
197    Kontext "PasswordFileOpen"
198    try
199       Passwortname.SetText "12345"
200       PasswordFileOpen.OK
201    catch
202       warnlog "had to ask for passwd!!!!"
203    endcatch
204    Sleep 2
206    printlog "'/// - save doc with new name under 6.... (has to be automagical selected by loading this doc!) w/o passwd - ///'"
207    Datei$ = convertpath( gOfficePath + "user\work\Erwin2"+cActFilterExt)
208    if Dir (Datei$) <> "" then kill Datei$
209    FileSaveAs
210       Kontext "SpeichernDlg"
211       Dateiname.SetText Datei$
212       if (Passwort.IsChecked <> TRUE) then
213          Warnlog "#i36015# Password has to be checked! :-("
214          Passwort.Check
215          printlog "will be forced checked no!"
216       endif
217       Speichern.Click
218    Kontext "Messagebox"
219       '/// (if messagebox comes up, say YES) ///'
220       if Messagebox.Exists(2) then
221          Messagebox.Yes
222       endif
223       '/// password dialog has to show up! ///'
224    Kontext "PasswordFileSave"
225       if (PasswordFileSave.Exists(5) = FALSE)then
226          Warnlog "- Password dialog Didn't popped up after pressing save"
227       else
228          Kontext "PasswordFileSave"
229          '/// type password "a12345", confirm password: "a12345" -> RIGHT ///'
230          Password.SetText "a12345"
231          PasswordConfirm.SetText "a12345"
232          PasswordFileSave.OK
233          sleep 2
234          '/// close document ///'
235          FileClose
236          sleep 1
237       endif
238    '/// open document ///'
239    FileOpen
240       sleep 1
241       Kontext "OeffnenDlg"
242       Dateiname.SetText Datei$
243       Oeffnen.Click
244       Kontext "PasswordFileOpen"
245       sleep 1
246       '/// type password: "a12345" -> RIGHT ///'
247       PasswortName.SetText "a12345"
248       PasswordFileOpen.OK
249       sleep 5
250    '/// File->SaveAs ///'
251    FileSaveAs
252       Kontext "SpeichernDlg"
253       Dateiname.SetText Datei$
254       if (Passwort.IsChecked <> TRUE) then
255          Warnlog "#i36015# Password has to be checked! :-("
256          Passwort.Check
257          printlog "will be forced checked no!"
258       endif
259       Passwort.UnCheck
260       '/// press 'save', without changing any checkbox! -> file has to be saved WITH password protection ///'
261       Speichern.Click
262    Kontext "Messagebox"
263       '/// (if messagebox comes up, say YES) ///'
264       if Messagebox.Exists(2) then Messagebox.Yes
265    '/// password dialog needn't to show up! ///'
266    Kontext "PasswordFileSave"
267       if (PasswordFileSave.Exists(5))then
268          Warnlog "- Password dialog neeedn't popped up after pressing save"
269          Kontext "PasswordFileSave"
270          passwordFileSave.cancel
271          '/// close document ///'
272          FileClose
273       else
274          '/// close document ///'
275          hCloseDocument
276       end if
277 endcase
279 testcase tmFileReload
280    Dim Datei as String
281    dim sFilterName as string
282    dim sFilter as string
283    dim sFilterExt() as string
285    Datei = convertpath(gofficepath + "user\work\test"+cActFilterExt)
286    if Dir (Datei) <> "" then kill (Datei)
288    ' make sure saving in latest math filter works, checking global filtername and if necessary change it
289    sFilter = hGetUIFiltername("math8")
291    '/// open application ///'
292    hNewDocument
293    '/// type a formula ///'
294    call hTBOtypeInDoc
295    '/// File->Save As ///'
296    FileSaveAs
297    Kontext "SpeichernDlg"
298    '/// select the actual default file format ///'
299    Dateityp.Select (hFindFilterPosition( sFilter ))
300       '/// type a file name ///'
301       Dateiname.SetText Datei
302       '/// click button 'save' ///'
303       Speichern.Click
304       Kontext "Active"
305       if Active.Exists(2) then Active.Yes
306    sleep 3
307    '/// File->Close ///'
308    FileClose
309    Kontext
310    if MessageBox.Exists (1) then
311       WarnLog "After Saving and Closing the following MessageBox appears: " + MessageBox.GetText
312       MessageBox.Yes
313    end if
315    '/// open just saved file ///'
316    Call hFileOpen Datei
317    '/// type a formula ///'
318    call hTBOtypeInDoc
319    sleep (3)
320    '/// File->Reload ///'
321    FileReload
322    sleep (3)
323    Kontext
324    if Active.Exists (1) then
325       PrintLog "Say no to: " + Active.GetText
326       '/// say NO to active ///'
327       active.No
328    else
329       WarnLog "Missing smth to say no to! "
330    end if
332    Sleep 3
333    '/// File->Reload ///'
334    FileReload
335    Kontext
336    if Active.Exists (1) then
337       PrintLog "Said yes to: " + Active.GetText
338       '/// say YES to active ///'
339       active.Yes
340    end if
341    '/// close application ///'
342    Call hCloseDocument
343 endcase
345 testcase tmFileVersions
346    Dim Datei as String
348    Datei = ConvertPath (gOfficePath & "user/work/test"+cActFilterExt)
349    if app.Dir (Datei) <> "" then app.kill (Datei)
351    '/// open application ///'
352    Call hNewDocument
353    sleep 2
354    '/// type a formula ///'
355    SchreibenInMathdok "a over b"
356    '/// save file ///'
357    Call hFileSaveAs(Datei)
358    Sleep 3
359    try
360       '/// File->Versions ///'
361       FileVersions
362    catch
363       Warnlog "- File / Versions not accessible!"
364       goto endsub
365    endcatch
367    Kontext "Versionen"
368    Call DialogTest ( Versionen )
369    '/// click button 'Save New Version' ///'
370    Speichern.Click
371    Kontext "VersionskommentarEingeben"
372    Call DialogTest ( VersionskommentarEingeben )
373    '/// cancel dialog 'Insert Version Comment' ///'
374    VersionskommentarEingeben.Cancel
375    Kontext "Versionen"
376    '/// close dialog 'Version of ...' ///'
377    Versionen.Close
378    '/// close application ///'
379    Call hCloseDocument
380    if app.Dir (Datei) <> "" then app.kill Datei
381 endcase
383 testcase tmFilePrint
384 '/// open application ///'
385    Call hNewDocument
386    sleep 3
387    '/// File->Print ///'
388    FilePrint
389    kontext
390    if active.exists(2) then
391        active.ok
392        qaerrorlog "There is no printer available - please install one on your system!"
393    endif
394    sleep 2
395    Kontext "DruckenDlg"
396    Call DialogTest (DruckenDlg)
397    '/// cancel dialog 'Print' ///'
398    DruckenDlg.Cancel
399    sleep 2
400 '/// close application ///'
401    Call hCloseDocument
402 endcase
404 '-----------------------------------------------------------
405 '*******************   I D  dito   *************************
406 '-----------------------------------------------------------
408 testcase tmFileOpen
409 '/// open application ///'
410    call hNewDocument
411    '/// File->Open ///'
412    FileOpen
413       Kontext "OeffnenDlg"
414       '/// klick button 'Up one level' ///'
415       UebergeordneterOrdner.Click
416       '/// klick button 'Default Directory' ///'
417       Standard.Click
418       '/// check checkbox 'Read Only' ///'
419       NurLesen.check
420       Call DialogTest ( OeffnenDlg )
421       '/// cancel dialog 'Open' ///'
422    OeffnenDlg.Cancel
423    Sleep 2
424    '/// close application ///'
425    Call hCloseDocument
426 endcase
428 testcase tmFileClose
429 '/// open application ///'
430    hNewDocument    ' just for the records: i open ONE document
431    '/// type a formula ///'
432    call hTBOtypeInDoc
433    sleep (2)
434    '/// File->Close ///'
435    FileClose
436    Kontext         ' expecting 'modified, do you want to close?'
437    if active.exists (5) then
438       printlog "  ok, active came up: " + active.gettext
439       '/// say NO to active about 'modified stuff :-)' ///'
440       Active.Cancel   ' no, not this time
441    else
442       warnlog "active missing (1)"
443    endif
444    sleep (2)
445    '/// File->Close ///'
446    FileClose
447    Kontext
448    '/// say YES to active about 'modified stuff :-)' ///'
449    Active.Yes      ' but now - records: this document is closed
450    sleep (2)
451    Kontext "SpeichernDlg"
452    Call DialogTest ( SpeichernDlg )
453    '/// cancel dialog 'Save As' ///'
454    SpeichernDlg.Cancel
455    sleep (2)
457    '/// File->Close ///'
458    FileClose       ' now the office gets closed! (if there were no modifications!)
459    Kontext
460    if active.exists (5) then Active.No
461    sleep (2)
462 endcase
464 testcase tmFileSave
465 '/// open application ///'
466    hNewDocument
467    '/// type a formula ///'
468    call hTBOtypeInDoc
469    '/// File->Save ///'
470    FileSave
471    sleep 2
472    Kontext "SpeichernDlg"
473    UebergeordneterOrdner.click
474    Standard.Click
475 '      NeuerOrdner.Click
476 '      DateiAuswahl.TypeKeys "Hallo<Return>"
477 '      DateiLoeschen
478 '      Kontext "Messagebox"
479 '      MessageBox.Yes
480    Call DialogTest (SpeichernDlg)
481    '/// cancel dialog 'Save' ///'
482    SpeichernDlg.Cancel
483     sleep 2
484    '/// close application ///'
485    Call hCloseDocument
486 endcase
488 testcase tmFileSaveAs
489 '/// open application ///'
490    hNewDocument
491    sleep (2)
492    '/// type a formula ///'
493    call hTBOtypeInDoc
494    '/// File->Save As ///'
495    FileSaveAs
496    sleep 1
497    Kontext "SpeichernDlg"
498    if (SpeichernDlg.exists (5) = FALSE) then
499       warnlog "error :-("
500    endif
501    sleep 2
502    '/// check ceckbox 'save with Password' ///'
503    Passwort.check
504    '/// UNcheck ceckbox 'save with Password' ///'
505    Passwort.uncheck
506    '/// click button 'up one level' ///'
507    UebergeordneterOrdner.click
508    '/// click button 'default directory' ///'
509    Standard.Click
510    '/// click button 'create new directory' ///'
511    NeuerOrdner.click
512       kontext "NeuerOrdner"
513       '/// cancel dialog 'create new folder' ///'
514       NeuerOrdner.cancel
515    Kontext "SpeichernDlg"
516    Call DialogTest (SpeichernDlg)
517    '/// cancel dialog 'Save As' ///'
518    SpeichernDlg.Cancel
519    sleep (2)
520    '/// close application ///'
521    Call hCloseDocument
522 endcase
524 testcase tmFileSaveAll
525 '/// open application ///'
526    hNewDocument
527    '/// type a formula ///'
528    call hTBOtypeInDoc
529    Printlog " '/// open 2. window ///"
530    hNewDocument
531    '/// type a formula ///'
532    call hTBOtypeInDoc
534    Printlog "  call save all"
535    '/// File->Save All ///'
536    FileSaveAll
537    Printlog "  cancel 1. save"
538    Kontext "SpeichernDlg"
539    if SpeichernDlg.exists(5) then
540        '/// cancel dialog 'save as' ///'
541        SpeichernDlg.Cancel
542    else
543        qaErrorlog "First File save dialog did not show up."
544    endif
545    Printlog "  cancel 2. save"
546    Kontext "SpeichernDlg"
547    if SpeichernDlg.exists(5) then
548        '/// cancel dialog 'save as' ///'
549        SpeichernDlg.Cancel
550    else
551        qaErrorlog "Second File save dialog did not show up."
552    endif
554    try
555       Kontext "SpeichernDlg"
556       SpeichernDlg.Cancel
557       printlog "smth had been typed in the starting window (just a hint ;-) )"
558    catch
559       printlog "--------- no other window want's to get saved. :-)"
560    endcatch
562    Sleep 2
563    Printlog "  hCloseDocument both"
564    '/// close document ///'
565    Call hCloseDocument
566    sleep 2
567    Printlog "  first closed"
568    '/// close application ///'
569    try
570    Call hCloseDocument
571    catch
572    printlog "any catching?"
573    endcatch
574    sleep 1
575    Printlog "  second closed"
576    sleep (5)
577 endcase
579 testcase tmExportAsPDF
580    dim sPDF as string
581    dim sTemp as string
583    sPDF = "PDF - Portable Document Format (.pdf)"
585    '/// open application ///'
586    Call hNewDocument
588    '/// click the button 'Export Directly as PDF' on the Functionbar ///'
589    kontext "Standardbar"
590    Sleep 5
591    ExportAsPDF.click
592       ' the 'Export as PDF' dialog has to come up, with the only 'File type' 'PDF - Portable Document Format (.pdf)'
593       kontext "ExportierenDlg"
594       sTemp = Dateityp.GetSelText
595       if (sTemp <> sPDF) then
596          Warnlog "filter for PDF export is missing :-( should: '" + sPDF + "'; is: '" +  + "'"
597       endif
598       '///+ - set Textbox 'File name' to "abc" ///'
599       Dateiname.SetText "abc"
600       '///+ - use the cursor keys in the filebrowser ///'
601       DateiAuswahl.TypeKeys "<home><down>"
602       '///+ - click on the button 'Up one level' ///'
603       UebergeordneterOrdner.Click
604       '///+ - click on the button 'Create New Directory' ///'
605       NeuerOrdner.Click
606          kontext "NeuerOrdner"
607          '///+ - - in the dialog $Foldername set textfield 'New' to 'abc' ///'
608          OrdnerName.SetText "abc"
609          '///+ - - cancel dialog $Foldername ///'
610          NeuerOrdner.cancel
611       kontext "ExportierenDlg"
612       '///+ - click on the button 'Default Directory' ///'
613       Standard.Click
614       '///+ - cancel dialog ///'
615       Kontext "ExportierenDlg"
616       ExportierenDlg.Cancel
617       
618    '/// close application ///'
619    Call hCloseDocument
620 endcase
622 testcase tmFileProperties
623 '/// open application ///'
624    Call hNewDocument
625    '/// File->Properties... ///'
626    FileProperties
628    Kontext
629    '/// select tabpage 'General' ///'
630    active.SetPage TabDokument
631    Kontext "TabDokument"
632    Call DialogTest ( TabDokument )
634    Kontext
635    '/// select tabpage 'Description' ///'
636    active.SetPage TabDokumentInfo
637    Kontext "TabDokumentInfo"
638    Call DialogTest ( TabDokumentInfo )
640    Kontext
641    '/// select tabpage 'Internet' ///'
642    active.SetPage TabInternet
643    Kontext "TabInternet"
644    Call DialogTest (TabInternet)
645    TabInternet.Cancel
646    '/// close application ///'
647    Call hCloseDocument
649    qaerrorlog "#i95523# Custom Properties is not controlable by VCL TestTool Application"
650    goto endsub
652    Kontext
653    '/// select tabpage 'User defined' ///'
654    active.SetPage TabBenutzer
655    Kontext "TabBenutzer"
656    Call DialogTest ( TabBenutzer )
657    '/// click button 'info fields' ///'
658    Infofelder.Click
659       Kontext "InfonamenBearbeiten"
660       Call DialogTest (InfonamenBearbeiten)
661    '/// close dialog 'edit field names' ///'
662    InfoNamenBearbeiten.Cancel
663 endcase
665 testcase tmFilePrinterSetting
666 '/// open application ///'
667    Call hNewDocument
668    sleep 3
669    '/// File->Printer Settings ///'
670    FilePrintersettings
671    kontext
672    if active.exists(2) then
673        active.ok
674        qaerrorlog "There is no printer available - please install one on your system!"
675    endif
676    Kontext "DruckerEinrichten"
677    Call DialogTest (DruckerEinrichten)
678    sleep 2
679    '/// cancel dialog 'printer setup' ///'
680    DruckerEinrichten.Cancel
681    sleep 2
682    '/// close application ///'
683    Call hCloseDocument
684 endcase
686 sub hTBOtypeInDoc
687    SchreibenInMathdok "a over b"
688 end sub