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 2008 by Sun Microsystems, Inc.
7 '* OpenOffice.org - a multi-platform office productivity suite
9 '* $RCSfile: c_xml_scenario.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-07-11 07:29:28 $
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 : oliver.creamer@sun.com
36 '* short description : Check content.xml for correct scenario attributes
38 '*************************************************************************************************
40 ' #1 subScenarioAttributes
41 ' #1 tScenarioAttributes
42 ' #1 subCreateScenario
43 ' #1 subCheckScenarioInContentXML
45 '\*************************************************************************************************
46 sub subScenarioAttributes
47 printLog Chr(13) + "--------- scenario attributes ----------"
49 call tScenarioAttributes
53 '************************************************************
54 testcase tScenarioAttributes
60 dim sNameSheet1 as STRING
62 dim sNameSheet2 as STRING
64 dim sNameSheet3 as STRING
68 dim sOutputFile as STRING
69 sOutputFile = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ) & sExtension )
71 dim sUnpackedStorageDir as STRING
72 sUnpackedStorageDir = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ))
73 if (dir ( sUnpackedStorageDir ) <> "" ) then
74 rmDir ( sUnpackedStorageDir )
75 if (dir ( sUnpackedStorageDir ) <> "" ) then
76 warnlog "Diretory has not been deleted. Exiting test."
81 dim sContentXML as STRING
82 sContentXML = ( gOfficePath & ConvertPath( "user\work\scenarioAttributes" ) & ConvertPath( "\content.xml" ))
84 printlog "Create a new spreadsheet document"
88 printlog "Type in the first cell the number 1 and press RETURN"
89 Kontext "DocumentCalc"
90 DocumentCalc.TypeKeys "1<RETURN>"
92 printlog "Format / Sheet / Rename"
94 Kontext "TabelleUmbenennen"
96 case 1 : Tabellenname.SetText sNameSheet1
97 printlog " In first round name it 'Ten'"
98 case 2 : Tabellenname.SetText sNameSheet2
99 printlog " In first round name it 'Moves'"
100 case 3 : Tabellenname.SetText sNameSheet3
101 printlog " In first round name it 'Ahead'"
103 printlog "Press OK on dialog"
106 printlog "Edit / Sheet / Select"
108 Kontext "SelectSheets"
109 printlog "In round 1 and 2 select the next sheet."
110 printlog "In round three select the first sheet."
112 SheetSelectionBox.Select sNameSheet1
114 SheetSelectionBox.Select ( iIndex + 1 )
116 printlog "Press OK on dialog."
120 printlog "If not visible: View / Toolbars / Formula bar"
121 Kontext "RechenleisteCalc"
122 if not RechenleisteCalc.isvisible then
123 ViewToolbarsFormulaBar
126 Kontext "RechenleisteCalc"
127 printlog "In the Formular bar edit area type:"
128 Bereich.TypeKeys "<MOD1 A>"
130 Bereich.TypeKeys "C3"
134 Bereich.TypeKeys "<RETURN>"
136 Kontext "DocumentCalc"
137 printlog "Type in the spreadsheet document:"
138 printlog "1[RETURN]2[RETURN]3[RETURN]"
139 DocumentCalc.typekeys "1<RETURN>2<RETURN>3<RETURN>"
140 Kontext "RechenleisteCalc"
141 printlog "In the Formula bar type in the edit area:"
143 Bereich.TypeKeys "<MOD1 A>"
145 Bereich.TypeKeys "C3:C5"
148 Bereich.TypeKeys "<RETURN>"
150 printlog "Tools / scenarios..."
151 printlog "Scenario name: Scenario_XML_Test"
152 printlog "Scenario comment: Created by Peter Junge"
153 printlog "Color index: 1"
154 printlog "Display border unchecked"
155 printlog "Copy back unchecked"
156 printlog "Copy entire sheet unchecked"
157 printlog "Prevent changes unchecked"
158 subCreateScenario ( "Scenario_XML_Test" , "Created by Peter Junge" , 1 , 0 , 0 , 0 , 0 )
160 printlog "Create a another scenario on this selection with the following parameters:"
161 printlog "Scenario name: AnotherScenario"
162 printlog "Scenario comment: Random Comment"
163 printlog "Color index: 13"
164 printlog "Display border checked"
165 printlog "Copy back checked"
166 printlog "Copy entire sheet checked"
167 printlog "Prevent changes checked"
168 subCreateScenario ( "AnotherScenario" , "Random Comment" , 13 , 1 , 1 , 1 , 1 )
170 printlog "Edit / Sheet / Select"
172 Kontext "SelectSheets"
173 printlog "Select 'Moves'"
174 SheetSelectionBox.Select "Moves"
178 printlog "Type in Formula bar:"
179 Kontext "RechenleisteCalc"
181 Bereich.TypeKeys "<MOD1 A>"
183 Bereich.TypeKeys "d5"
186 Bereich.TypeKeys "<RETURN>"
188 printlog "Type in spreadsheet document"
189 Kontext "DocumentCalc"
190 printlog "1[RETURN]2[RETURN]3[RETURN]"
191 DocumentCalc.typekeys "1<RETURN>2<RETURN>3<RETURN>"
192 Kontext "RechenleisteCalc"
193 printlog "Type in Formula bar:"
195 Bereich.TypeKeys "<MOD1 A>"
197 Bereich.TypeKeys "d5:d7"
200 Bereich.TypeKeys "<RETURN>"
202 printlog "Creat another scenario:"
203 subCreateScenario ( "標準" , "기본값" , 9 , 1 , 1 , 0 , 0 )
204 printlog "Scenario name: 標準"
205 printlog "Scenario comment: 기본값"
206 printlog "Color index: 9"
207 printlog "Display border checked"
208 printlog "Copy back checked"
209 printlog "Copy entire sheet unchecked"
210 printlog "Prevent changes unchecked"
212 '///<li>Create a another scenario on this selection</li>///
213 subCreateScenario ( "1标准9" , "2預設0" , 16 , 0 , 0 , 1 , 1 )
214 printlog "Scenario name: 1标准9"
215 printlog "Scenario comment: 2預設0"
216 printlog "Color index: 16"
217 printlog "Display border unchecked"
218 printlog "Copy back unchecked"
219 printlog "Copy entire sheet checked"
220 printlog "Prevent changes checked"
222 printlog "Save in current default format"
223 if hFileSaveAsWithFilterKill ( sOutputFile , "calc8" ) = FALSE then
224 warnlog "Saving " & sOutputFile & " failed! -> Exiting test!"
227 printlog "Close the document."
230 printlog "Unpack storage of test document."
231 UnpackStorage( sOutputFile , sUnpackedStorageDir )
232 printlog "Read the test documents DOM."
233 SAXReadFile( sContentXML )
235 printlog "Set the DOM pointer on element 'office:spreadsheet'"
237 SAXSeekElement( "/" )
238 printlog " |-office:document-content"
239 SAXSeekElement( "office:document-content" )
240 printlog " |-office:body"
241 SAXSeekElement( "office:body" )
242 printlog " |-office:spreadsheet"
243 SAXSeekElement( "office:spreadsheet" )
244 printlog "For all tables check if they are scenarios"
245 printlog "For those tables which are scenarios check correct attributes"
247 printlog " |-table:table"
248 SAXSeekElement( "table:table" , iIndex )
250 case 1 : subCheckScenarioInContentXML ( "Ten" , FALSE )
251 case 2 : subCheckScenarioInContentXML ( _
252 "Scenario_XML_Test" , TRUE , TRUE , "#000000" , TRUE , "false" , FALSE , "false" , _
253 "Scenario_XML_Test.C3:Scenario_XML_Test.C5" , "Created by Peter Junge" )
254 case 3 : subCheckScenarioInContentXML ( _
255 "AnotherScenario" , TRUE , FALSE , "#ff0000" , FALSE , "false" , TRUE , "true" , _
256 "AnotherScenario.C3:AnotherScenario.C5" , "Random Comment" )
257 case 4 : subCheckScenarioInContentXML ( "Moves" , FALSE )
258 case 5 : subCheckScenarioInContentXML ( _
259 "標準" , TRUE , FALSE , "#c0c0c0" , FALSE , "false" , FALSE , "false" , _
260 "標準.D5:標準.D7" , "기본값" )
261 case 6 : subCheckScenarioInContentXML ( _
262 "1标准9" , TRUE , TRUE , "#ffffff" , TRUE , "false" , TRUE , "true" , _
263 "1标准9.D5:1标准9.D7" , "2預設0" )
264 case 7 : subCheckScenarioInContentXML ( "Ahead" , FALSE )
268 printlog "Check if too much sheets exist"
270 SAXSeekElement( "table:table" , 8 )
271 warnlog "OOPS, it's expected to have only seven sheet but we got eight or more -> Check this out!"
279 '---------------------------------------------------------------------------
281 sub subCreateScenario ( sScenarioName as STRING, _
282 sComment as STRING, _
283 iColorIndex as INTEGER, _
284 bDisplayBorder as BOOLEAN, _
285 bCopyBack as BOOLEAN, _
286 bCopyEntireSheet as BOOLEAN, _
287 bPreventChanges as BOOLEAN )
289 printlog "tools / scenarios..."
291 Kontext "SzenarioAnlegen"
292 printlog "Set options as requested through arguments"
293 SzenarioName.SetText ( sScenarioName )
294 Kommentar.SetText ( sComment )
295 Rahmenfarbe.Select ( iColorIndex )
296 if bDisplayBorder then
299 RahmenAnzeigen.UnCheck
302 Zurueckkopieren.Check
304 Zurueckkopieren.UnCheck
306 if bCopyEntireSheet then
311 if bPreventChanges then
314 PreventChanges.UnCheck
321 '---------------------------------------------------------------------------
323 sub subCheckScenarioInContentXML ( sTableName as STRING , _
324 bTableShouldBeScenario as BOOLEAN , _
325 optional bCheckDisplayBorder as BOOLEAN , _
326 optional sBorderColor as STRING , _
327 optional bCheckCopyBack as BOOLEAN , _
328 optional sCopyStyles as STRING , _
329 optional bCheckProtected as BOOLEAN , _
330 optional sIsActive as STRING , _
331 optional sScenarioRanges as STRING , _
332 optional sComment as STRING)
334 '///<u><b>Check attibutes for scenarios in 'content.xml'</b></u>///
335 dim bTableIsScenario as BOOLEAN
336 bTableIsScenario = FALSE
338 '///<li>Check correct table name</li>///
339 if SAXGetAttributeValue( "table:name" ) = sTableName then
340 printlog "Table name is as expected"
342 warnlog "Table name is " & SAXGetAttributeValue( "table:name" ) & " instead of " & sTableName
344 '///<li>Find out if current table is a scenario</li>///
346 SAXSeekElement( "table:scenario")
347 bTableIsScenario = TRUE
348 if bTableShouldBeScenario then
349 printlog "OK, this table is a scenario!"
351 warnlog "OOPS, this table shouldn't be a scenario -> Check this out!"
354 if bTableShouldBeScenario then
355 warnlog "OOPS, this table should be a scenario but it isn't -> Check this out!"
357 printlog "Right, this table isn't a scenario"
360 '///<li>Check scenario attributes</li>///
361 if bTableShouldBeScenario AND bTableIsScenario then
362 if bCheckDisplayBorder then
363 if SAXGetAttributeValue ( "table:display-border" ) = "false" then
364 printlog "OK, attribute 'table:display-border' has expected value: 'false'"
366 warnlog "OOPS, attribute 'table:display-border' has unexpected value: " & SAXGetAttributeValue( "table:display-border" )
369 if SAXGetAttributeValue ( "table:display-border" ) <> "" then
370 warnlog "OOPS, attribute 'table:display-border' shouldn't exist here"
374 if SAXGetAttributeValue( "table:border-color" ) = sBorderColor then
375 printlog "OK, attribute 'table:border-color' has expected value"
377 warnlog "OOPS, attribute 'table:border-color' has unexpected value: " & SAXGetAttributeValue( "table:border-color" )
380 if bCheckCopyBack then
381 if SAXGetAttributeValue( "table:copy-back" ) = "false" then
382 printlog "OK, attribute 'table:copy-back' has expected value: 'false'"
384 warnlog "OOPS, attribute 'table:copy-back' has unexpected value: " & SAXGetAttributeValue( "table:copy-back" )
387 if SAXGetAttributeValue ( "table:copy-back" ) <> "" then
388 warnlog "OOPS, attribute 'table:copy-back' shouldn't exist here"
392 if SAXGetAttributeValue( "table:copy-styles" ) = sCopyStyles then
393 printlog "OK, attribute 'table:copy-styles' has expected value"
395 warnlog "OOPS, attribute 'table:copy-styles' has unexpected value: " & SAXGetAttributeValue( "table:copy-styles" )
398 if bCheckProtected then
399 if SAXGetAttributeValue( "table:protected" ) = "true" then
400 printlog "OK, attribute 'table:protected' has expected value: 'true'"
402 warnlog "OOPS, attribute 'table:protected' has unexpected value: " & SAXGetAttributeValue( "table:protected" )
405 if SAXGetAttributeValue ( "table:protected" ) <> "" then
406 warnlog "OOPS, attribute 'table:protected' shouldn't exist here"
410 if SAXGetAttributeValue( "table:is-active" ) = sIsActive then
411 printlog "OK, attribute 'table:is-active' has expected value"
413 warnlog "OOPS, attribute 'table:is-active' has unexpected value: " & SAXGetAttributeValue( "table:is-active" )
416 if SAXGetAttributeValue( "table:scenario-ranges" ) = sScenarioRanges then
417 printlog "OK, attribute 'table:scenario-ranges' has expected value"
419 warnlog "OOPS, attribute 'table:scenario-ranges' has unexpected value: " & SAXGetAttributeValue( "table:scenario-ranges" )
420 qaErrorLog "Expected: " & sScenarioRanges
423 if SAXGetAttributeValue( "table:comment" ) = sComment then
424 printlog "OK, attribute 'table:comment' has expected value"
426 warnlog "OOPS, attribute 'table:comment' has unexpected value: " & SAXGetAttributeValue( "table:comment" )
427 qaErrorLog "Expected: " & sComment
430 printlog "Checking scenario details was skipped!"
433 if bTableIsScenario then