summaryrefslogtreecommitdiff
path: root/testautomation/spreadsheet/optional/includes/getpivotdata/c_getpivotdata.inc
blob: 216551959dedf53044438bddca404b00902f3282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
'encoding UTF-8  Do not remove or change this line!
'**************************************************************************
' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
'
' Copyright 2000, 2010 Oracle and/or its affiliates.
'
' OpenOffice.org - a multi-platform office productivity suite
'
' This file is part of OpenOffice.org.
'
' OpenOffice.org is free software: you can redistribute it and/or modify
' it under the terms of the GNU Lesser General Public License version 3
' only, as published by the Free Software Foundation.
'
' OpenOffice.org is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Lesser General Public License version 3 for more details
' (a copy is included in the LICENSE file that accompanied this code).
'
' You should have received a copy of the GNU Lesser General Public License
' version 3 along with OpenOffice.org.  If not, see
' <http://www.openoffice.org/license.html>
' for a copy of the LGPLv3 License.
'
'/***********************************************************************
'*
'* owner : oliver.craemer@oracle.com
'*
'* short description : level 2 test for the getpivotdata function
'*
'************************************************************************
'*
' #1 tgetpivotdata_function_wizard     ' Testcase for manually input of the function
' #1 tgetpivotdata_xls_filter     ' Testcase for import/export of the function
'*
'\***********************************************************************

testcase tgetpivotdata_function_wizard

    dim stestdocument as string
    dim slocalfile as string
    dim sfunctionstring as string
    dim sfunctionname as string
    dim sfunctionwithparameter as string
    
    stestdocument = Convertpath (gTesttoolPath + "spreadsheet\optional\input\datapilot.ods" )
    slocalfile = Convertpath ( gOfficePath + "user\work\datapilot.ods" )
    setclipboard = ""
    
    '/// Get localised string for function GETPIVOTDATA by fFunctionname
    printlog "Get localised string for function GETPIVOTDATA by fFunctionname" 
    sfunctionname = fFunctionname("GETPIVOTDATA")
        
    '/// Load testdocument <i>gTestToolPath</i>/spreadsheet/optional/input/datapilot.ods
    printlog "Load testdocument datapilot.ods"
    call hFileOpen ( stestdocument )
    sleep (2)
    '/// If the file is not editable, click the edit button on standardbar
    printlog "If the file is not editable, click the edit button on standardbar"
    sMakeReadOnlyDocumentEditable()
        
    '/// Select cell I8 and open function wizard by INSERT FUNCTION
    printlog "Select cell I8 and open function wizard by INSERT FUNCTION"
    call fGotoCell ( "I8" )
    InsertFunction
    kontext ( "FunctionWizard" )
    '/// Select category SPREADSHEET (11th category in listbox)
    printlog "Select category SPREADSHEET (11th category in listbox)"
    CategoryLB.select 11
    '/// Select the function GETPIVOTDATA in the now filtered function list
    printlog "Select the function GETPIVOTDATA in the now filtered function list"
    try 
        FunctionLB.select sfunctionname
        printlog "  Function " & sfunctionname & " selected in category SPREADSHEET"
    catch
        warnlog "The function is not available under category SPREADSHEET"
    endcatch
    CategoryLB.select 2
    try
        FunctionLB.select sfunctionname
    catch
        warnlog "The function is generally not available"
        FunctionWizard.OK
        call hCloseDocument
        goto endsub
    endcatch
    '/// Press NEXT button
    printlog "Press NEXT button"
    Forward.click
    '/// Enter 2000 for parameter Data Field
    printlog "Enter 2000 for parameter Data Field"
    kontext "FunctionWizard"
    Editfield1.settext "2000"
    '/// Enter C29 for parameter DataPilot
    printlog "Enter C29 for parameter DataPilot"
    Editfield2.settext "C29"
    '/// Enter C3 for parameter Field Name / Item 1
    printlog "Enter C3 for parameter Field Name / Item 1"
    Editfield3.settext "C3"
    '/// Enter C16 for parameter Field Name / Item 2
    printlog "Enter C16 for parameter Field Name / Item 2"
    Editfield4.settext "C16"
    '/// Scroll down to enable the next field
    printlog "Scroll down to enable the next field"
    Editfield4.TypeKeys "<DOWN>"
    '/// Enter C26 for parameter Field Name / Item 3
    printlog "Enter C26 for parameter Field Name / Item 3"
    Editfield4.settext "C26"
    '/// Scroll down to enable the next field
    printlog "Scroll down to enable the next field"
    Editfield4.TypeKeys "<DOWN>"
    '/// Enter F27 for parameter Field Name / Item 4
    printlog "Enter F27 for parameter Field Name / Item 4"
    Editfield4.settext "F27"
    '/// Close functionwizard by pressing OK button
    printlog "Close functionwizard by pressing OK button"
    FunctionWizard.OK
    '/// Memorize cellcontent
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    printlog "Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    '/// Verify that the function result is 100000
    printlog "Verify that the function result is 100000"
    call fCalcCompareCellValue ( "I8",100000 )
    '/// Save the document again
    printlog "Save the document again"
    if NOT hFileSaveAsKill (slocalfile) then
        warnlog "Saving test document localy failed -> Aborting"
        call hCloseDocument
        goto endsub
    else
        printlog "  File saved successfully."
    end if    
    '/// Close the file with File/close
    printlog "Close the file with File/close"
    call hCloseDocument
    sleep(3)
    '/// Load localy saved document
    printlog "Load localy saved document"
    call hFileOpen ( slocalfile )
    '/// Verify that cell I8 still shows 100000
    printlog "Verify that cell I8 still shows 100000"
    call fCalcCompareCellValue ( "I8",100000 )
    '/// Verify that the function in cell I8 is still =GETPIVOTDATA("2000";C29;C3;C16;C26;F27)
    printlog "Verify that the function in cell I8 is still " & sfunctionwithparameter
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    if GetClipboardText () = sfunctionwithparameter then
        printlog "  The function was successfully saved and reloaded"
    else warnlog "The function is not " & sfunctionwithparameter & ", it is " & GetClipboardText ()
    end if
    '/// Press twice <ESCAPE> to leave the cell
    printlog "Press twice <ESCAPE> to leave the chart object"
    kontext "DocumentCalc"
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    '/// Close document
    printlog "Close document"
    call hCloseDocument
    sleep(3)
'///
endcase
'
'---------------------------------------------------------------------------
'
testcase tgetpivotdata_xls_filter

    dim stestdocument as string
    dim slocalfile as string
    dim sfunctionparameter as string
    dim sfunctionname as string
    dim sfunctionwithparameter as string
    dim sdecimalseperator as string
    
    stestdocument = Convertpath (gTesttoolPath + "spreadsheet\optional\input\getpivotdata2.xls" )
    'stestdocument = Convertpath ( gOfficePath + "user\work\test.ods" )
    slocalfile = Convertpath ( gOfficePath + "user\work\getpivotdata2.xls" )
    sdecimalseperator = GetDecimalSeperator
    setclipboard = ""
    sfunctionname = fFunctionname("GETPIVOTDATA")
    
    '/// Load testdocument <i>gTestToolPath</i>/spreadsheet/optional/input/getpivotdata2.xls
    printlog "Load testdocument getpivotdata2.xls"
    call hFileOpen ( stestdocument )
    sleep (2)
    '/// If the file is not editable, click the edit button on standardbar
    printlog "If the file is not editable, click the edit button on standardbar"
    call sMakeReadOnlyDocumentEditable    
    '/// Verify that Cell G12 shows 2.5
    printlog "Verify that Cell G12 shows 2" & sdecimalseperator & "5"
    call fCalcCompareCellValue ("G12","2" & sdecimalseperator & "5")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$5;"col1";"a";"col2";"x")
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$5;""col1"";""a"";""col2"";""x"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog "Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$5;""col1"";""a"";""col2"";""x"")" then
        printlog "  The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$5;""col1"";""a"";""col2"";""x"")"
    end if

    '/// Verify that Cell G27 shows 0.05
    printlog "Verify that Cell G27 shows 0" & sdecimalseperator & "05"
    call fCalcCompareCellValue ("G27","0" & sdecimalseperator & "05")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$19;"col1";"a";"col2";"y")
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$19;""col1"";""a"";""col2"";""y"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog "Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$19;""col1"";""a"";""col2"";""y"")" then
        printlog "  The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$19;""col1"";""a"";""col2"";""y"")"
    end if
    
    '/// Verify that Cell G43 shows 3
    printlog "Verify that Cell G43 shows 3"
    call fCalcCompareCellValue ("G43","3")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$33;"col1";"a";"col2";"z";"col3";"p"))
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog "Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")" then
        printlog "  The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")"
    end if
    
    '/// Save document back to xls locally
    printlog "Save document back to xls locally"
    call hFileSaveAsKill ( slocalfile )
    
    '/// Close document
    printlog "Close document"
    call hCloseDocument

    '/// Load Document
    printlog "Load Document"
    call hFileOpen ( slocalfile )
    sleep (2)
    
'/// Verify that Cell G12 shows 2.5
    printlog "Verify that Cell G12 shows 2" & sdecimalseperator & "5"
    call fCalcCompareCellValue ("G12","2" & sdecimalseperator & "5")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$5;"col1";"a";"col2";"x")
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$5;""col1"";""a"";""col2"";""x"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog " Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$5;""col1"";""a"";""col2"";""x"")" then
        printlog "  The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$5;""col1"";""a"";""col2"";""x"")"
    end if

    '/// Verify that Cell G27 shows 0.05
    printlog "Verify that Cell G27 shows 0" & sdecimalseperator & "05"
    call fCalcCompareCellValue ("G27","0" & sdecimalseperator & "05")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$19;"col1";"a";"col2";"y")
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$19;""col1"";""a"";""col2"";""y"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog " Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$19;""col1"";""a"";""col2"";""y"")" then
        printlog "  The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$19;""col1"";""a"";""col2"";""y"")"
    end if
    
    '/// Verify that Cell G43 shows 3
    printlog "Verify that Cell G43 shows 3"
    call fCalcCompareCellValue ("G43","3")
    '/// Verify that the function is =GETPIVOTDATA("val";$F$33;"col1";"a";"col2";"z";"col3";"p"))
    printlog "Verify that the function is =GETPIVOTDATA(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")"
    kontext ( "RechenleisteCalc" ) 
    EingabeZeileCalc.TypeKeys ("<f2><mod1 a>")
    editcopy
    sfunctionwithparameter = GetClipboardText ()
    '/// Press twice <ESCAPE> to leave the cell
    'printlog " Press twice <ESCAPE> to leave the cell"
    kontext ( "DocumentCalc" )
    DocumentCalc.TypeKeys "<ESCAPE>" , 2
    if sfunctionwithparameter = "=" & sfunctionname & "(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")" then
        printlog "The function is correct"
    else
        warnlog "The function is " & sfunctionwithparameter & " instead of =GETPIVOTDATA(""val"";$F$33;""col1"";""a"";""col2"";""z"";""col3"";""p"")"
    end if
    
    '/// Close document
    printlog "Close document"
    call hCloseDocument
    sleep(3)
endcase