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 : oliver.craemer@oracle.com
30 '* short description : Check content.xml for correct scenario attributes
32 '*************************************************************************************************
34 ' #1 subScenarioAttributes
35 ' #1 tScenarioAttributes
36 ' #1 subCreateScenario
37 ' #1 subCheckScenarioInContentXML
39 '\*************************************************************************************************
40 sub subScenarioAttributes
41 printLog Chr(13) + "--------- scenario attributes ----------"
43 call tScenarioAttributes
47 '************************************************************
48 testcase tScenarioAttributes
54 dim sNameSheet1 as STRING
56 dim sNameSheet2 as STRING
58 dim sNameSheet3 as STRING
62 dim sOutputFile as STRING
63 sOutputFile = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ) & sExtension )
65 dim sUnpackedStorageDir as STRING
66 sUnpackedStorageDir = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ))
67 if (dir ( sUnpackedStorageDir ) <> "" ) then
68 rmDir ( sUnpackedStorageDir )
69 if (dir ( sUnpackedStorageDir ) <> "" ) then
70 warnlog "Diretory has not been deleted. Exiting test."
75 dim sContentXML as STRING
76 sContentXML = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ) & ConvertPath( "\content.xml" ))
78 printlog "Create a new spreadsheet document"
82 printlog "Type in the first cell the number 1 and press RETURN"
83 Kontext "DocumentCalc"
84 DocumentCalc.TypeKeys "1<RETURN>"
86 printlog "Format / Sheet / Rename"
88 Kontext "TabelleUmbenennen"
90 case 1 : Tabellenname.SetText sNameSheet1
91 printlog " In first round name it 'Ten'"
92 case 2 : Tabellenname.SetText sNameSheet2
93 printlog " In first round name it 'Moves'"
94 case 3 : Tabellenname.SetText sNameSheet3
95 printlog " In first round name it 'Ahead'"
97 printlog "Press OK on dialog"
100 printlog "Edit / Sheet / Select"
102 Kontext "SelectSheets"
103 printlog "In round 1 and 2 select the next sheet."
104 printlog "In round three select the first sheet."
106 SheetSelectionBox.Select sNameSheet1
108 SheetSelectionBox.Select ( iIndex + 1 )
110 printlog "Press OK on dialog."
114 printlog "If not visible: View / Toolbars / Formula bar"
115 Kontext "RechenleisteCalc"
116 if not RechenleisteCalc.isvisible then
117 ViewToolbarsFormulaBar
120 Kontext "RechenleisteCalc"
121 printlog "In the Formular bar edit area type:"
122 Bereich.TypeKeys "<MOD1 A>"
124 Bereich.TypeKeys "C3"
128 Bereich.TypeKeys "<RETURN>"
130 Kontext "DocumentCalc"
131 printlog "Type in the spreadsheet document:"
132 printlog "1[RETURN]2[RETURN]3[RETURN]"
133 DocumentCalc.typekeys "1<RETURN>2<RETURN>3<RETURN>"
134 Kontext "RechenleisteCalc"
135 printlog "In the Formula bar type in the edit area:"
137 Bereich.TypeKeys "<MOD1 A>"
139 Bereich.TypeKeys "C3:C5"
142 Bereich.TypeKeys "<RETURN>"
144 printlog "Tools / scenarios..."
145 printlog "Scenario name: Scenario_XML_Test"
146 printlog "Scenario comment: Created by Peter Junge"
147 printlog "Color index: 1"
148 printlog "Display border unchecked"
149 printlog "Copy back unchecked"
150 printlog "Copy entire sheet unchecked"
151 printlog "Prevent changes unchecked"
152 subCreateScenario ( "Scenario_XML_Test" , "Created by Peter Junge" , 1 , 0 , 0 , 0 , 0 )
154 printlog "Create a another scenario on this selection with the following parameters:"
155 printlog "Scenario name: AnotherScenario"
156 printlog "Scenario comment: Random Comment"
157 printlog "Color index: 13"
158 printlog "Display border checked"
159 printlog "Copy back checked"
160 printlog "Copy entire sheet checked"
161 printlog "Prevent changes checked"
162 subCreateScenario ( "AnotherScenario" , "Random Comment" , 13 , 1 , 1 , 1 , 1 )
164 printlog "Edit / Sheet / Select"
166 Kontext "SelectSheets"
167 printlog "Select 'Moves'"
168 SheetSelectionBox.Select "Moves"
172 printlog "Type in Formula bar:"
173 Kontext "RechenleisteCalc"
175 Bereich.TypeKeys "<MOD1 A>"
177 Bereich.TypeKeys "d5"
180 Bereich.TypeKeys "<RETURN>"
182 printlog "Type in spreadsheet document"
183 Kontext "DocumentCalc"
184 printlog "1[RETURN]2[RETURN]3[RETURN]"
185 DocumentCalc.typekeys "1<RETURN>2<RETURN>3<RETURN>"
186 Kontext "RechenleisteCalc"
187 printlog "Type in Formula bar:"
189 Bereich.TypeKeys "<MOD1 A>"
191 Bereich.TypeKeys "d5:d7"
194 Bereich.TypeKeys "<RETURN>"
196 printlog "Creat another scenario:"
197 subCreateScenario ( "標準" , "기본값" , 9 , 1 , 1 , 0 , 0 )
198 printlog "Scenario name: 標準"
199 printlog "Scenario comment: 기본값"
200 printlog "Color index: 9"
201 printlog "Display border checked"
202 printlog "Copy back checked"
203 printlog "Copy entire sheet unchecked"
204 printlog "Prevent changes unchecked"
206 '///<li>Create a another scenario on this selection</li>///
207 subCreateScenario ( "1标准9" , "2預設0" , 16 , 0 , 0 , 1 , 1 )
208 printlog "Scenario name: 1标准9"
209 printlog "Scenario comment: 2預設0"
210 printlog "Color index: 16"
211 printlog "Display border unchecked"
212 printlog "Copy back unchecked"
213 printlog "Copy entire sheet checked"
214 printlog "Prevent changes checked"
216 printlog "Save in current default format"
217 if hFileSaveAsWithFilterKill ( sOutputFile , "calc8" ) = FALSE then
218 warnlog "Saving " & sOutputFile & " failed! -> Exiting test!"
221 printlog "Close the document."
224 printlog "Unpack storage of test document."
225 UnpackStorage( sOutputFile , sUnpackedStorageDir )
226 printlog "Read the test documents DOM."
227 SAXReadFile( sContentXML )
229 printlog "Set the DOM pointer on element 'office:spreadsheet'"
231 SAXSeekElement( "/" )
232 printlog " |-office:document-content"
233 SAXSeekElement( "office:document-content" )
234 printlog " |-office:body"
235 SAXSeekElement( "office:body" )
236 printlog " |-office:spreadsheet"
237 SAXSeekElement( "office:spreadsheet" )
238 printlog "For all tables check if they are scenarios"
239 printlog "For those tables which are scenarios check correct attributes"
241 printlog " |-table:table"
242 SAXSeekElement( "table:table" , iIndex )
244 case 1 : subCheckScenarioInContentXML ( "Ten" , FALSE )
245 case 2 : subCheckScenarioInContentXML ( _
246 "Scenario_XML_Test" , TRUE , TRUE , "#000000" , TRUE , "false" , FALSE , "false" , _
247 "Scenario_XML_Test.C3:Scenario_XML_Test.C5" , "Created by Peter Junge" )
248 case 3 : subCheckScenarioInContentXML ( _
249 "AnotherScenario" , TRUE , FALSE , "#ff0000" , FALSE , "false" , TRUE , "true" , _
250 "AnotherScenario.C3:AnotherScenario.C5" , "Random Comment" )
251 case 4 : subCheckScenarioInContentXML ( "Moves" , FALSE )
252 case 5 : subCheckScenarioInContentXML ( _
253 "標準" , TRUE , FALSE , "#c0c0c0" , FALSE , "false" , FALSE , "false" , _
254 "標準.D5:標準.D7" , "기본값" )
255 case 6 : subCheckScenarioInContentXML ( _
256 "1标准9" , TRUE , TRUE , "#ffffff" , TRUE , "false" , TRUE , "true" , _
257 "1标准9.D5:1标准9.D7" , "2預設0" )
258 case 7 : subCheckScenarioInContentXML ( "Ahead" , FALSE )
262 printlog "Check if too much sheets exist"
264 SAXSeekElement( "table:table" , 8 )
265 warnlog "OOPS, it's expected to have only seven sheet but we got eight or more -> Check this out!"
273 '---------------------------------------------------------------------------
275 sub subCreateScenario ( sScenarioName as STRING, _
276 sComment as STRING, _
277 iColorIndex as INTEGER, _
278 bDisplayBorder as BOOLEAN, _
279 bCopyBack as BOOLEAN, _
280 bCopyEntireSheet as BOOLEAN, _
281 bPreventChanges as BOOLEAN )
283 printlog "tools / scenarios..."
285 Kontext "SzenarioAnlegen"
286 printlog "Set options as requested through arguments"
287 SzenarioName.SetText ( sScenarioName )
288 Kommentar.SetText ( sComment )
289 Rahmenfarbe.Select ( iColorIndex )
290 if bDisplayBorder then
293 RahmenAnzeigen.UnCheck
296 Zurueckkopieren.Check
298 Zurueckkopieren.UnCheck
300 if bCopyEntireSheet then
305 if bPreventChanges then
308 PreventChanges.UnCheck
315 '---------------------------------------------------------------------------
317 sub subCheckScenarioInContentXML ( sTableName as STRING , _
318 bTableShouldBeScenario as BOOLEAN , _
319 optional bCheckDisplayBorder as BOOLEAN , _
320 optional sBorderColor as STRING , _
321 optional bCheckCopyBack as BOOLEAN , _
322 optional sCopyStyles as STRING , _
323 optional bCheckProtected as BOOLEAN , _
324 optional sIsActive as STRING , _
325 optional sScenarioRanges as STRING , _
326 optional sComment as STRING)
328 '///<u><b>Check attibutes for scenarios in 'content.xml'</b></u>///
329 dim bTableIsScenario as BOOLEAN
330 bTableIsScenario = FALSE
332 '///<li>Check correct table name</li>///
333 if SAXGetAttributeValue( "table:name" ) = sTableName then
334 printlog "Table name is as expected"
336 warnlog "Table name is " & SAXGetAttributeValue( "table:name" ) & " instead of " & sTableName
338 '///<li>Find out if current table is a scenario</li>///
340 SAXSeekElement( "table:scenario")
341 bTableIsScenario = TRUE
342 if bTableShouldBeScenario then
343 printlog "OK, this table is a scenario!"
345 warnlog "OOPS, this table shouldn't be a scenario -> Check this out!"
348 if bTableShouldBeScenario then
349 warnlog "OOPS, this table should be a scenario but it isn't -> Check this out!"
351 printlog "Right, this table isn't a scenario"
354 '///<li>Check scenario attributes</li>///
355 if bTableShouldBeScenario AND bTableIsScenario then
356 if bCheckDisplayBorder then
357 if SAXGetAttributeValue ( "table:display-border" ) = "false" then
358 printlog "OK, attribute 'table:display-border' has expected value: 'false'"
360 warnlog "OOPS, attribute 'table:display-border' has unexpected value: " & SAXGetAttributeValue( "table:display-border" )
363 if SAXGetAttributeValue ( "table:display-border" ) <> "" then
364 warnlog "OOPS, attribute 'table:display-border' shouldn't exist here"
368 if SAXGetAttributeValue( "table:border-color" ) = sBorderColor then
369 printlog "OK, attribute 'table:border-color' has expected value"
371 warnlog "OOPS, attribute 'table:border-color' has unexpected value: " & SAXGetAttributeValue( "table:border-color" )
374 if bCheckCopyBack then
375 if SAXGetAttributeValue( "table:copy-back" ) = "false" then
376 printlog "OK, attribute 'table:copy-back' has expected value: 'false'"
378 warnlog "OOPS, attribute 'table:copy-back' has unexpected value: " & SAXGetAttributeValue( "table:copy-back" )
381 if SAXGetAttributeValue ( "table:copy-back" ) <> "" then
382 warnlog "OOPS, attribute 'table:copy-back' shouldn't exist here"
386 if SAXGetAttributeValue( "table:copy-styles" ) = sCopyStyles then
387 printlog "OK, attribute 'table:copy-styles' has expected value"
389 warnlog "OOPS, attribute 'table:copy-styles' has unexpected value: " & SAXGetAttributeValue( "table:copy-styles" )
392 if bCheckProtected then
393 if SAXGetAttributeValue( "table:protected" ) = "true" then
394 printlog "OK, attribute 'table:protected' has expected value: 'true'"
396 warnlog "OOPS, attribute 'table:protected' has unexpected value: " & SAXGetAttributeValue( "table:protected" )
399 if SAXGetAttributeValue ( "table:protected" ) <> "" then
400 warnlog "OOPS, attribute 'table:protected' shouldn't exist here"
404 if SAXGetAttributeValue( "table:is-active" ) = sIsActive then
405 printlog "OK, attribute 'table:is-active' has expected value"
407 warnlog "OOPS, attribute 'table:is-active' has unexpected value: " & SAXGetAttributeValue( "table:is-active" )
410 if SAXGetAttributeValue( "table:scenario-ranges" ) = sScenarioRanges then
411 printlog "OK, attribute 'table:scenario-ranges' has expected value"
413 warnlog "OOPS, attribute 'table:scenario-ranges' has unexpected value: " & SAXGetAttributeValue( "table:scenario-ranges" )
414 qaErrorLog "Expected: " & sScenarioRanges
417 if SAXGetAttributeValue( "table:comment" ) = sComment then
418 printlog "OK, attribute 'table:comment' has expected value"
420 warnlog "OOPS, attribute 'table:comment' has unexpected value: " & SAXGetAttributeValue( "table:comment" )
421 qaErrorLog "Expected: " & sComment
424 printlog "Checking scenario details was skipped!"
427 if bTableIsScenario then