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 : Window/Titlebar functionality
32 '\******************************************************************************
34 testcase tWindowFunctions
36 printlog( "Update test for window functions" )
38 printlog( "Create initial document" )
39 gApplication = "WRITER"
41 hInitWriteDocIdentifier( "F_updt_windowfuncs.bas" )
43 printlog( "New document" )
45 if ( getDocumentCount <> 2 ) then
46 warnlog( "Two open documents were expected, found " & getDocumentCount )
49 kontext "DocumentWriter"
50 printlog( "Close document" )
51 DocumentWriter.close()
53 if ( getDocumentCount <> 1 ) then
54 warnlog( "One open document was expected, found " & getDocumentCount )
57 printlog( "New document" )
59 if ( getDocumentCount <> 2) then
60 warnlog( "Two open documents were expected, found " & getDocumentCount )
63 printlog( "Enter some text into the second writer document" )
64 kontext "DocumentWriter"
65 DocumentWriter.TypeKeys( "test" )
66 DocumentWriter.close()
69 if ( Active.exists() ) then
70 printlog( "Close messagebox with Cancel (leaves the document open)" )
73 warnlog( "No warning that data will be lost on close of this document" )
76 kontext "DocumentWriter"
77 if ( getDocumentCount = 2 ) then
78 printlog( "Two documents open. Good." )
80 warnlog( "Incorrect document count. Expected two, found " & getDocumentCount )
83 kontext "DocumentWriter"
84 printlog( "Close the document" )
88 if ( Active.exists() ) then
89 printlog( "Do not save the document" )
92 warnlog( "Warning: No data loss warning" )
95 kontext "DocumentWriter"
96 if ( getDocumentCount = 1 ) then
97 printlog( "One document open. Good." )
99 warnlog( "Incorrect document count. Expected one, found " & getDocumentCount )
102 Kontext "DocumentWriter"
103 printlog( "Minimize window" )
104 DocumentWriter.Minimize()
107 kontext "DocumentWriter"
108 if ( DocumentWriter.IsMin() ) then
109 printlog( "Window is minimized" )
111 warnlog( "Window not minimized" )
114 kontext "DocumentWriter"
115 printlog( "Restore window" )
116 DocumentWriter.Restore()
119 if ( DocumentWriter.IsRestore() ) then
120 printlog( "Window is Restored" )
122 warnlog( " * Window not Restored" )
125 kontext "DocumentWriter"
126 printlog( "Maximize window" )
127 DocumentWriter.Maximize()
130 kontext "DocumentWriter"
131 if ( DocumentWriter.IsMax() ) then
132 printlog( "Window is maximized" )
134 warnlog( " * Window not maximized" )
141 '*******************************************************************************
145 printlog( "Window titles for the applications: " & gProductName )
148 gApplication = "WRITER"
149 call tCheckWindowTitle( "swriter", "Writer" )
151 printlog( "Master Document" )
152 gApplication = "MASTERDOCUMENT"
153 call tCheckWindowTitle( "sglobal", "Writer" )
156 gApplication = "HTML"
157 call tCheckWindowTitle( "sweb", "Writer/Web" )
159 printlog( "Spreadsheet" )
160 gApplication = "CALC"
161 call tCheckWindowTitle( "scalc", "Calc" )
163 printlog( "Presentation" )
164 gApplication = "IMPRESS"
165 call tCheckWindowTitle( "simpress", "Impress" )
167 printlog( "Drawing" )
168 gApplication = "DRAW"
169 call tCheckWindowTitle( "sdraw", "Draw" )
171 printlog( "Formula" )
172 gApplication = "MATH"
173 call tCheckWindowTitle( "smath", "Math" )
175 printlog( "BASIC IDE" )
176 gApplication = "WRITER"
177 call tCheckWindowTitle( "basic", "Basic" )
179 printlog( "Database" )
180 gApplication = "DATABASE"
181 call tCheckWindowTitle( "database", "Base" )
183 printlog( "Backing Window / StartCenter" )
184 gApplication = "BACKGROUND"
185 call tCheckWindowTitle( "soffice", "" )
189 '*******************************************************************************
191 testcase tCheckWindowTitle( sApplication as string, sReference as string )
193 printlog( "Update test for the office window titles" )
195 ' This is a Testtool-only problem that the product name is not displayed
196 ' after calling hCloseDocument() on the last document.
197 if ( sApplication = "soffice" ) then
198 qaerrorlog( "#i113760# - Product name missing for backing window" )
202 const BASIC_MODULE = "tCheckWindowTitle"
203 const STRING_NOT_FOUND = 0
204 const STRING_LEFTMOST = 1
206 dim cWindowCaption as string
208 dim iProductnamePosition as integer
209 dim iApplicationPosition as integer
211 dim cProductNameString as string
212 dim cApplicationString as string
214 ' hGetWindowCaption modifies it's function parameter, so we pass a copy instead
215 ' This is a thing that justifies the use of a four letter word for sure.
216 dim sApplicationTemp as string : sApplicationTemp = sApplication
218 printlog( "Application: " & sApplication & "; Title should be: " & sReference )
219 printlog( "Open the work windows (documents)" )
222 printlog( "Verify that the correct window is open" )
223 select case sApplication
224 case "basic" : hInitBasicIDE( BASIC_MODULE )
225 case "soffice" : hFileCloseAll()
226 case else : hCreateDocument()
229 ' Note: The Testtool connection string does not belong to the window caption
230 ' so we do not check for it here.
231 cWindowCaption = hGetWindowCaption( sApplicationTemp )
232 printlog( "Caption is: " & cWindowCaption )
234 ' This prevents accidential matches like "base" in a document name like "database8.odb"
235 ' And we have a - (minus) as delimiter between the document name and the product name
236 cProductnameString = " - " & gProductName & " "
237 cApplicationString = " " & sReference
239 ' Find out where in the caption the substrings are
240 iProductNamePosition = instr( cWindowCaption, cProductnameString )
241 iApplicationPosition = instr( cWindowCaption, cApplicationString )
243 ' Verify that the productname is contained within the string
244 if ( iProductNamePosition = STRING_NOT_FOUND ) then
245 if ( lcase( gPlatform ) = "osx" ) then
246 printlog( "The product name is missing" )
247 ' life is different on that platform compared to testtool world
249 warnlog( "The product name is missing" )
253 ' Verify that the application name (e.g. "Writer") is contained in the string
254 ' The StartCenter should not have any application name
255 if ( sApplication = "soffice" ) then
256 if ( iApplicationPosition > STRING_NOT_FOUND ) then
257 printlog( "The StartCenter should not have an application name" )
260 if ( iApplicationPosition = STRING_NOT_FOUND ) then
261 warnlog( "The application name is missing" )
265 if ( sApplication = "soffice" ) then
266 printlog( "Backing window should exclusively show the product name" )
268 ' If one of Productname or application is leftmost in the string, we have a
269 ' missing document identifier. This can be different things - the filename,
270 ' the module name (BASIC) etc.
271 if ( ( iApplicationPosition = STRING_LEFTMOST ) OR _
272 iProductnamePosition = STRING_LEFTMOST ) then
273 warnlog( "Current document identifier missing (like e.g. <Unknown 1>)" )
276 ' Verify that the order is correct: Product name first, the application
277 if ( iProductNamePosition >= iApplicationPosition ) then
278 warnlog( "The order of the strings is incorrect" )
279 printlog( "Expected: <Product Name> <Application>" )
283 printlog( "Cleanup after test" )
284 select case sApplication
285 case "basic" : hDestroyDocument()
286 case "soffice" : hCreateDocument()
289 printlog( "Close all open documents" )