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_datapilot_pagefields.inc,v $
13 '* last change: $Author: rt $ $Date: 2008-07-11 07:28:50 $
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.craemer@sun.com
36 '* short description : Check content.xml for attribute 'table:selected-page'
38 '*************************************************************************************************
41 ' #1 tDatapilotPagefields
43 '\*************************************************************************************************
45 printLog Chr(13) + "--------- datapilot pagefields ----------"
47 printlog "Testing Page '- all -'"
48 call tDatapilotPagefields("- all -")
49 printlog "Testing Page 'Audio'"
50 call tDatapilotPagefields("Audio")
51 printlog "Testing Page 'DVD'"
52 call tDatapilotPagefields("DVD")
53 printlog "Testing Page 'Video'"
54 call tDatapilotPagefields("Video")
58 '************************************************************
59 testcase tDatapilotPagefields ( sCurrentPage as STRING )
60 dim bTableSelectedPageShouldExist as BOOLEAN
62 dim sComfirmAttribute as STRING
63 dim sWarnAttribute as STRING
64 select case sCurrentPage
65 case ("- all -") : bTableSelectedPageShouldExist = "false"
67 case ("Audio") : bTableSelectedPageShouldExist = "true"
69 sComfirmAttribute = "OK, value for attribute 'table:selected-page' is 'Audio'"
70 sWarnAttribute = "Unexpected value for attibute 'table:selected-page' -> Check this out!"
71 case ("DVD") : bTableSelectedPageShouldExist = "true"
73 sComfirmAttribute = "OK, value for attribute 'table:selected-page' is 'DVD'"
74 sWarnAttribute = "Unexpected value for attibute 'table:selected-page' -> Check this out!"
75 case ("Video") : bTableSelectedPageShouldExist = "true"
77 sComfirmAttribute = "OK, value for attribute 'table:selected-page' is 'Video'"
78 sWarnAttribute = "Unexpected value for attibute 'table:selected-page' -> Check this out!"
81 dim sInputFile as STRING
82 sInputFile = ( gTesttoolPath & ConvertPath( "xml\optional\input\calc\ooo10\pagefields_datapilot" & iIndex & ".sxc" ))
84 dim sOutputFile as STRING
85 sOutputFile = ( gOfficePath & ConvertPath( "user\work\datapilotPagefields" ) & iIndex & ".ods" )
87 dim sUnpackedStorageDir as STRING
88 sUnpackedStorageDir = ( gOfficePath & ConvertPath( "user\work\datapilotPagefields" ) & iIndex )
89 if (dir(sUnpackedStorageDir) <> "") then
90 rmDir (sUnpackedStorageDir)
91 if (dir(sUnpackedStorageDir) <> "") then
92 warnlog "Directory has not been deleted. Test ends here."
97 dim sContentXML as STRING
98 sContentXML = ( gOfficePath & ConvertPath( "user\work\datapilotPagefields" ) & iIndex & ConvertPath( "\content.xml" ))
100 dim iSaxSeekIndex as INTEGER
103 dim bContinueSeek as BOOLEAN
106 dim iAttributeIndex as INTEGER
108 printlog "Open test document"
109 call hFileOpen ( sInputFile )
110 printlog "Save in current default application format (ODF)"
111 if hFileSaveAsWithFilterKill ( sOutputFile , "calc8" ) = FALSE then
112 warnlog "Saving " & sOutputFile & " failed! -> Exiting test!"
116 printlog "CLose the document."
118 printlog "Unpack storage of test document."
119 UnpackStorage( sOutputFile , sUnpackedStorageDir )
120 printlog "Read the test documents DOM."
121 SAXReadFile( sContentXML )
123 printlog "Set the DOM pointer on element 'table:data-pilot-table'"
125 SAXSeekElement( "/" )
126 printlog " |-office:document-content"
127 SAXSeekElement( "office:document-content" )
128 printlog " |-office:body"
129 SAXSeekElement( "office:body" )
130 printlog " |-office:spreadsheet"
131 SAXSeekElement( "office:spreadsheet" )
132 printlog " |-table:data-pilot-tables"
133 SAXSeekElement( "table:data-pilot-tables" )
134 printlog " |-table:data-pilot-table"
135 SAXSeekElement( "table:data-pilot-table" )
136 printlog "Seek in (all) elements 'table:data-pilot-field'"
137 while SAXHasElement( "table:data-pilot-field" , iSaxSeekIndex ) AND bContinueSeek
138 printlog " |-table:data-pilot-field"
139 SAXSeekElement( "table:data-pilot-field" , iSaxSeekIndex )
140 printlog ".. for attribute 'table:selected-page'"
141 for iAttributeIndex = 1 to SAXGetAttributeCount
142 if SaxGetAttributeName ( iAttributeIndex ) = "table:selected-page" then
143 printlog "When found, check if it should exist (unexpected for page selection '- all -')"
144 bContinueSeek = FALSE
145 if bTableSelectedPageShouldExist then
146 printlog "Bingo, found attribute 'table:selected-page'"
147 'Check correct index of expected node
148 if iSaxSeekIndex <> 1 then
149 warnlog "Found 'table:selected-page' on an unexpected Node -> Check this out!"
150 qaErrorLog "TODO: Check if change of file format was announced!"
151 qaErrorLog "TODO: Modify test if change of file format was intended!"
153 'Check correct attribute index
154 if iAttributeIndex <> 3 then
155 warnlog "Found 'table:selected-page' on unexpected attribute position -> Check this out!"
156 qaErrorLog "TODO: Check if change of file format was announced!"
157 qaErrorLog "TODO: Modify test if change of file format was intended!"
159 printlog "Now check for expected value of 'table:selected-page'!"
160 if SAXGetAttributeValue( "table:selected-page" ) = sCurrentPage then
161 printlog sComfirmAttribute
163 warnlog sWarnAttribute
166 warnlog "OOPS, attribute 'table:selected-page' shouldn't exist for '- all -' pages."
170 iSaxSeekIndex = iSaxSeekIndex + 1
174 ' Throw warning if testcase didn't succeed at all!
175 if bContinueSeek AND bTableSelectedPageShouldExist then
176 warnlog "OOPS, attribute 'table:selected-page' wasn't found though it should exist -> Check this out!"