merge the formfield patch from ooo-build
[ooovba.git] / testautomation / framework / required / includes / window_functions.inc
blobae672ee4274bfc882448ee3d0b56cfe84395bcef
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: window_functions.inc,v $
11 '* $Revision: 1.2 $
13 '* last change: $Author: rt $ $Date: 2008-09-04 09:16:41 $
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 : Window/Titlebar functionality
38 '\******************************************************************************
40 testcase tWindowFunctions
42     printlog( "Update test for window functions" )
44     if ( gtSysName = "Mac OS X" ) then
45         printlog( "No testing for Mac as some Window attributes do not exist" )
46         goto endsub
47     endif
49     
50     printlog( "Create initial document" )
51     gApplication = "WRITER"
52     hInitSingleDoc()
53     hInitWriteDocIdentifier( "F_updt_windowfuncs.bas" )
54     
55     printlog( "New document" )
56     hNewDocument()
57     if ( getDocumentCount <> 2 ) then
58         warnlog( "Two open documents were expected, found " & getDocumentCount )
59     endif    
61     kontext "DocumentWriter"
62     printlog( "Close document" )
63     DocumentWriter.close()
65     if ( getDocumentCount <> 1 ) then
66         warnlog( "One open document was expected, found " & getDocumentCount )
67     endif
69     printlog( "New document" )
70     hNewDocument()
71     if ( getDocumentCount <> 2) then
72         warnlog( "Two open documents were expected, found " & getDocumentCount )
73     endif    
75     printlog( "Enter some text into the second writer document" )
76     kontext "DocumentWriter"
77     DocumentWriter.TypeKeys( "test" )
78     DocumentWriter.close()
80     kontext "active"
81     if ( Active.exists() ) then
82         printlog( "Close messagebox with Cancel (leaves the document open)" )
83         Active.Cancel()
84     else
85         warnlog( "No warning that data will be lost on close of this document" )
86     endif
87     
88     kontext "DocumentWriter"    
89     if ( getDocumentCount = 2 ) then
90         printlog( "Two documents open. Good." )
91     else
92         warnlog( "Incorrect document count. Expected two, found " & getDocumentCount )
93     endif
95     kontext "DocumentWriter"
96     printlog( "Close the document" )
97     FileClose()
98     
99     kontext "Active"
100     if ( Active.exists() ) then  
101         printlog( "Do not save the document" )
102         Active.No()
103     else
104         warnlog( "Warning: No data loss warning" )
105     endif
106     
107     kontext "DocumentWriter"
108     if ( getDocumentCount = 1 ) then
109         printlog( "One document open. Good." )
110     else
111         warnlog( "Incorrect document count. Expected one, found " & getDocumentCount )
112     endif    
114     Kontext "DocumentWriter"
115     printlog( "Minimize window" )
116     DocumentWriter.Minimize()
117     Wait( 2000 )
119     kontext "DocumentWriter"
120     if ( DocumentWriter.IsMin() ) then
121         printlog( "Window is minimized" )
122     else
123         qaerrorlog( "#i32672# Window not minimized" )
124     endif
126     kontext "DocumentWriter"
127     printlog( "Restore window" )
128     DocumentWriter.Restore()
129     Wait( 2000 )
131     if ( DocumentWriter.IsRestore() ) then
132         printlog( "Window is Restored" )
133     else
134         warnlog( " * Window not Restored" )
135     endif
137     kontext "DocumentWriter"
138     printlog( "Maximize window" )
139     DocumentWriter.Maximize()
140     Wait( 2000 )
141     
142     kontext "DocumentWriter"
143     if ( DocumentWriter.IsMax() ) then
144         printlog( "Window is maximized" )
145     else
146         warnlog( " * Window not maximized" )
147     endif
149     hDestroyDocument()
151 endcase
153 '*******************************************************************************
155 sub sAllWindowTitle
157     printlog( "Window titles for the applications" )
158     
159     printlog( "Writer" )
160     gApplication = "WRITER"
161     call tCheckWindowTitle("swriter","Writer")
163     printlog( "Master Document" )
164     gApplication = "MASTERDOCUMENT"
165     call tCheckWindowTitle("sglobal","Writer")
167     printlog( "HTML" )
168     gApplication = "HTML"
169     call tCheckWindowTitle("sweb","Writer/Web")
171     printlog( "Spreadsheet" )
172     gApplication = "CALC"
173     call tCheckWindowTitle("scalc","Calc")
175     printlog( "Presentation" )
176     gApplication = "IMPRESS"
177     call tCheckWindowTitle("simpress","Impress")
179     printlog( "Drawing" )
180     gApplication = "DRAW"
181     call tCheckWindowTitle("sdraw","Draw")
183     printlog( "Formula" )
184     gApplication = "MATH"
185     call tCheckWindowTitle("smath","Math")
187     qaerrorlog( "Excluded BASE and BACKINGWINDOW" )
189     'gApplication = "DATABASE"
190     'call tCheckWindowTitle("DATABASE","Base")
192     'fileclose
193     'call tCheckWindowTitle("soffice","")
195 end sub
197 '*******************************************************************************
199 testcase tCheckWindowTitle(sApplication as string, sReference as string)
201     printlog( "Update test for the office window titles" )
202     '<u>Input</u>:
203     '<ol>
204     '+<li>Name of application (string), case sensitive. Valid options are:</li>
205     '<ol>
206     '+<li>&quot;swriter&quot;</li>
207     '+<li>&quot;sglobal&quot;</li>
208     '+<li>&quot;sweb&quot;</li>
209     '+<li>&quot;scalc&quot;</li>
210     '+<li>&quot;simpress&quot;</li>
211     '+<li>&quot;sdraw&quot;</li>
212     '+<li>&quot;smath&quot;</li>
213     '+<li>&quot;insight&quot; * Currently disabled</li>
214     '+<li>&quot;soffice&quot; * Currently disabled</li>
215     '</ol>
216     '+<li>Reference name (string), matches name of application</li>
217     '<ol>
218     '+<li>&quot;Writer&quot;</li>
219     '+<li>&quot;Writer/Web&quot;</li>
220     '+<li>&quot;Calc&quot;</li>
221     '+<li>&quot;Impress&quot;</li>
222     '+<li>&quot;Draw&quot;</li>
223     '+<li>&quot;Math&quot;</li>
224     '+<li>&quot;Base&quot; * Currently disabled</li>
225     '+<li>&quot;&quot; * Currently disabled</li>
226     '</ol>
227     '</ol>
228     '<u>Returns</u>:
229     '<ol>
230     '+<li>Nothing</li>
231     '</ol>
232     '<u>Description</u>:
233     '<ul>
234     
236     dim sTemp as string
237     dim saTemp() as string
238     dim brc as boolean
239     gApplication = UCase (gApplication)
240     printlog " - Application: " + sApplication + "; Title should be: " + sReference
241     
242     printlog( "Ensure that exactly one document is open" )
243     hInitSingleDoc()
245     printlog( "Open another document as specified by gApplication" )    
246     hCreateDocument()
248     printlog( "Verify that the correct window is open" )
249     select case sApplication
250         case"swriter":
251         case"sglobal":
252         case"sweb":
253         case"scalc":
254         case"simpress":
255         case"sdraw":
256         case"smath":
257         case"basic":
258             ToolsMacroMacro
260             kontext "makro"
262             if Makro.exists(5) then
263                 MakroAus.typeKeys "<end>"
265                 if (Neu.isEnabled) then
266                     Neu.click
268                     kontext "basicide"
270                     if BasicIDE.exists(5) then
271                         printlog( "Basic IDE open. Good." )
272                     else
273                         warnlog( "Basic IDE not open. This is unexpected" )
274                     endif
276                 else
277                     warnlog( "New-button is unexpectedly disabled." )
278                 endif
281                 try
283                     kontext "neuesmodul"
285                     if NeuesModul.exists(5) then
286                         NeuesModul.OK
287                     else
288                         warnlog( "New module naming dialog is not open" )
289                     endif
291                 catch
292                     warnlog( "Accessing <New module> dialog failed" )
293                 endcatch
295             else
296                 warnlog( "Couldn't open Tools->Macros->Organize Macros...->StarOffice Basic..." )
297             endif
299         case"chart":
300         case"DATABASE":
301         case"soffice":
302             brc = hDestroyDocument()
303     end select
305     printlog( "Retrieve the caption from the window" )
306     sTemp = hGetWindowCaption(sApplication)
307     printlog( "Caption is: " & sTemp )
308     
309     printlog( "Split up the string to isolate the desired part" )
310     saTemp() = fSplitWindowTitle(sTemp)
311     printlog "Filename/Untitled: '" & saTemp(0) & "'"
313     printlog( "Compare the string to a reference" )
314     if (ubound(saTemp()) > 0) then
316         if (saTemp(1) <> sReference) then
317             warnlog "Applicationname not as expected. Sould be: '" & sReference & "', is: '" & saTemp(1) & "'"
318         endif
320         printlog "Productname: '" & saTemp(2) & "'"
321     else
322         warnlog "#i36173# - Applicationname not as expected. Should be: '" & sReference & "', is: '" & "'"
323     endif
325     printlog( "Cleanup after test" )
326     select case sApplication
327         case"swriter":
328         case"sglobal":
329         case"sweb":
330         case"scalc":
331         case"simpress":
332         case"sdraw":
333         case"smath":
334         case"basic":
335             brc = hDestroyDocument()
336         case"chart":
337         case"DATABASE":
338         case"soffice":
339             hCreateDocument()
340             hCreateDocument()
341     end select
343     printlog( "Close all open documents" )
344     hFileCloseAll()
345     
346 endcase