merge the formfield patch from ooo-build
[ooovba.git] / testautomation / framework / optional / includes / filedlg_passwords.inc
blob4ca451ef423b5b59a7bdc31b08e6fe50e311a7e6
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: filedlg_passwords.inc,v $
11 '* $Revision: 1.1 $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:14 $
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 : joerg.skottke@sun.com
36 '*  short description : save and load passworded files
38 '\******************************************************************************
40 testcase tFiledlgPasswords()
42     '///<h1>Test saving/loading passworded files in three different formats</h1>
43     
44     dim workfile as string
45     dim workpath as string
46         workpath = hGetWorkPath()
48     dim filetype as string
49     dim filetypeID as string
50     dim cMsg as string
51         
52     dim iCurrentDocumentType as integer
53     dim iCurrentFileFormat as integer
54         
56     for iCurrentDocumentType = 1 to 6
57     
58         printlog( "Document Type: " & hNumericDocType( iCurrentDocumentType ) )
59     
60         for iCurrentFileFormat = 1 to 2
61         
62             select case iCurrentFileFormat
63             case 1 : filetypeID = "645"
64             case 2 : filetypeID = "current"
65             end select
66             
67             '///<ul>
68             '///+<li>open a new document</li>
69             hCreateDocument()
70             
71             '///+<li>Close the navigator - if present</li>
72             hCloseNavigator()
74             '///+<li>enter some random text</li>
75             call hChangeDoc()
77             '///+<li>Open file-save dialog</li>
78             printlog( "Open file-save dialog" )
79             if ( gApplication = "IMPRESS" ) then
80                 printlog( "   IMPRESS is slower than other apps, delaying for 2 sec." )
81                 sleep( 2 )
82             endif
83             
84             FileSave
86             Kontext "SpeichernDlg"
87             if ( SpeichernDlg.exists( 2 ) ) then
89                 '///+<li>Name the file and select filter</li>
90                 filetype = hGetFilter( filetypeID )
91                 hSelectUIFilter( filetype )
92                 
93                 workfile = "password" & hGetSuffix( filetypeID )
94                 DateiName.setText( workpath & workfile )
95                 
96                 printlog( "Using fileformat: " & filetype )
97                 printlog( "Using filename..: " & workfile )
99                 '///+<li>Check password</li>
100                 printlog( "Check password" )
101                 if ( passwort.isEnabled() ) then
102                     Passwort.check()
103                 else
104                     warnlog( "#i36663# Password checkbox is disabled" )
105                 endif
107                 '///+<li>Save the file</li>
108                 printlog( "Save the file" )
109                 Speichern.click()
111                 kontext "active"
112                 if ( active.exists( 2 ) ) then
113                    printlog( "Handle overwrite warning (if any)" )
114                    active.yes()
115                 endif
116                 
118                 '///+<li>Enter the filename as password and confirm</li>
119                 Kontext "PasswordFileSave"
120                 printlog( "Enter the name of the file as password and confirm" )
121                 if ( passwordFileSave.exists() ) then
122                     Password.settext( workfile )
123                     PasswordConfirm.settext( workfile )
124                     PasswordFileSave.ok()
125                 else
126                     warnlog( "No password dialog is displayed" )
127                 endif
128                 
129                 kontext "AlienWarning"
130                 if ( AlienWarning.exists( 2 ) ) then
131                     if ( FileTypeID <> "current" ) then
132                         printlog( "Handle alienwarning (expected)" )
133                         AlienWarning.ok()
134                     else
135                         warnlog( "Handle alienwarning (unexpected)" )
136                         AlienWarning.ok()
137                      endif         
138                 endif    
140                 '///+<li>Close the document</li>
141                 hDestroyDocument()
143                 '///+<li>Open the file via file-open</li>
144                 printlog( "Open the file via file-open" )
145                 FileOpen
147                 Kontext "OeffnenDlg"
148                 if ( OeffnenDlg.exists( 2 ) ) then
149                     Dateiname.settext( workfile )
151                     Oeffnen.click()
153                     Kontext "PasswordFileOpen"
154                     '///+<li>Enter the filename as password</li>
155                     printlog( "Enter the filename as password" )
156                     if ( PasswordFileOpen.exists( 4 ) ) then
157                         PasswortName.settext( workfile )
158                         PasswordFileOpen.ok()
159                     else
160                         kontext "Active"
161                         if ( Active.exists( 2 ) ) then
162                             cMsg = active.getText()
163                             cMsg = hRemoveLineBreaks( cMsg )
164                             printlog( cMsg )
165                                 warnlog( "#i65889# - CWS Warnings01: Cannot read password protected files" )
166                             active.ok()
167                             goto endsub
168                         else
169                             warnlog( "No password dialog is displayed" )
170                         endif
171                     endif
173                     '///+<li>Verify that the document is loaded</li>
174                     printlog( "Verify that the document is loaded" )
175                     call IsItLoaded()
177                     '///+<li>Close the navigator if present</li>
178                     Kontext "Navigator"
179                     if ( Navigator.exists( 1 ) ) then
180                         qaerrorlog( "Navigator should not be visible - setting not saved?" )
181                     endif
182                     else
183                         warnlog( "Second file open failed" )
184                 endif
185             else
186                 warnlog( "File Open dislog did not come up" )
187             endif
189             '///+<li>Close navigator if present</li>
190             hCloseNavigator()
192             '///+<li>Close the document</li>
193             hDestroyDocument()
195             '///+<li>Delete the file</li>    
196             hDeleteFile( workpath & workfile )
198             '///+<li>Close navigator if present</li>
199             hCloseNavigator()
200             
201         next iCurrentFileFormat
202         
203     next iCurrentDocumentType
205     '///</ul>
208 endcase