jl165 merging heads
[LibreOffice.git] / testautomation / framework / optional / includes / filedlg_passwords.inc
bloba52db4690552327da2511e0b82c1cd5258daa2aa
1 'encoding UTF-8  Do not remove or change this line!
2 '**************************************************************************
3 ' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 ' Copyright 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org.  If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/************************************************************************
28 '*  owner : gregor.hartmann@oracle.com
30 '*  short description : save and load passworded files
32 '\******************************************************************************
34 testcase tFiledlgPasswords()
35     
36     dim workfile as string
37     dim workpath as string
38         workpath = hGetWorkPath()
40     dim filetype as string
41     dim filetypeID as string
42     dim cMsg as string
43         
44     dim iCurrentDocumentType as integer
45     dim iCurrentFileFormat as integer
46         
48     for iCurrentDocumentType = 1 to 6
49     
50         printlog( "Document Type: " & hNumericDocType( iCurrentDocumentType ) )
51     
52         for iCurrentFileFormat = 1 to 2
53         
54             select case iCurrentFileFormat
55             case 1 : filetypeID = "645"
56             case 2 : filetypeID = "current"
57             end select
58             
59             hCreateDocument()
60             
61             kontext "Navigator"
62             hCloseDialog( Navigator, "close,optional" )
64             call hChangeDoc()
66             printlog( "Open file-save dialog" )
67             if ( gApplication = "IMPRESS" ) then
68                 printlog( "   IMPRESS is slower than other apps, delaying for 2 sec." )
69                 sleep( 2 )
70             endif
71             
72             FileSave
74             Kontext "SpeichernDlg"
75             if ( SpeichernDlg.exists( 2 ) ) then
77                 filetype = hGetFilter( filetypeID )
78                 hSelectUIFilter( filetype )
79                 
80                 workfile = "password" & hGetSuffix( filetypeID )
81                 DateiName.setText( workpath & workfile )
82                 
83                 printlog( "Using fileformat: " & filetype )
84                 printlog( "Using filename..: " & workfile )
86                 printlog( "Check password" )
87                 if ( passwort.isEnabled() ) then
88                     Passwort.check()
89                 else
90                     warnlog( "#i36663# Password checkbox is disabled" )
91                 endif
93                 printlog( "Save the file" )
94                 Speichern.click()
96                 kontext "active"
97                 if ( active.exists( 2 ) ) then
98                    printlog( "Handle overwrite warning (if any)" )
99                    active.yes()
100                 endif
101                 
103                 Kontext "PasswordFileSave"
104                 printlog( "Enter the name of the file as password and confirm" )
105                 if ( passwordFileSave.exists() ) then
106                     Password.settext( workfile )
107                     PasswordConfirm.settext( workfile )
108                     PasswordFileSave.ok()
109                 else
110                     warnlog( "No password dialog is displayed" )
111                 endif
112                 
113                 kontext "AlienWarning"
114                 if ( AlienWarning.exists( 2 ) ) then
115                     if ( FileTypeID <> "current" ) then
116                         printlog( "Handle alienwarning (expected)" )
117                         AlienWarning.ok()
118                     else
119                         warnlog( "Handle alienwarning (unexpected)" )
120                         AlienWarning.ok()
121                      endif         
122                 endif    
124                 hDestroyDocument()
126                 printlog( "Open the file via file-open" )
127                 FileOpen
129                 Kontext "OeffnenDlg"
130                 if ( OeffnenDlg.exists( 2 ) ) then
131                     Dateiname.settext( workfile )
133                     Oeffnen.click()
135                     Kontext "PasswordFileOpen"
136                     printlog( "Enter the filename as password" )
137                     if ( PasswordFileOpen.exists( 4 ) ) then
138                         PasswortName.settext( workfile )
139                         PasswordFileOpen.ok()
140                     else
141                         kontext "Active"
142                         if ( Active.exists( 2 ) ) then
143                             cMsg = active.getText()
144                             cMsg = hRemoveLineBreaks( cMsg )
145                             printlog( cMsg )
146                                 warnlog( "#i65889# - CWS Warnings01: Cannot read password protected files" )
147                             active.ok()
148                             goto endsub
149                         else
150                             warnlog( "No password dialog is displayed" )
151                         endif
152                     endif
154                     printlog( "Verify that the document is loaded" )
155                     hFileWait( FALSE )
157                     Kontext "Navigator"
158                     if ( Navigator.exists( 1 ) ) then
159                         qaerrorlog( "Navigator should not be visible - setting not saved?" )
160                     endif
161                     else
162                         warnlog( "Second file open failed" )
163                 endif
164             else
165                 warnlog( "File Open dislog did not come up" )
166             endif
168             kontext "Navigator"
169             hCloseDialog( Navigator, "close,optional" )
171             hDestroyDocument()
173             hDeleteFile( workpath & workfile )
175             kontext "Navigator"
176             hCloseDialog( Navigator, "close,optional" )
177             
178         next iCurrentFileFormat
179         
180     next iCurrentDocumentType
184 endcase