summaryrefslogtreecommitdiff
path: root/testautomation/chart2/tools/ch_tools_statistics.inc
blob: a36ef07ac07dd57b56874d48fc27e351c9415f3f (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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
'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@sun.com
'*
'* short description : Tool library for Statistics dialog
'*
'**************************************************************************************************
'*
' #1 fInvokeTrendlinesDialog
' #1 fInvokeInsertYErrorBarsDialog
' #1 fInsertMeanValueLines
' #1 fSetErrorCategory
' #1 fSetErrorValue
' #1 fSetErrorIndicatorItem
' #1 fSetRegressionCurvesItem
'*
'\************************************************************************************************

' ch_tools_statistics.inc - Library for automation of the 'Insert::Statistics...' dialog
' This Include contains a set of functions to modify the controls of the Statistics dialog.
' All functions are designed to return error-codes depending on the behaviour of the action applied.
' Return codes:
' Error 0: Success.
' Error 1: The basic action beeing applied caused a serious problem, e.g. a crash.
' Error 2 TO 9: A functional problem occured.
' Error 11 TO 19: Wrong marginal conditions end up in failture, e.g. control not visible.
' NOTE: This errors can also be used for 'negative' testing.
' Error 42: Wrong input. Probably only of interest during test development.
' Error 99: Unexpected behaviour - Shouldn't normally occur.
' ATTENTION:
' Only Errors 42 and 99 throw 'warnlogs'.
' All other errors are silent.
' They only throw QAErrorlogs the give a hint what probably went wrong.
' Expected Errors MUST exclusivly be handled by the calling routine.
'
'--------------------------------------------------------------------
'
function fInvokeTrendlinesDialog() as INTEGER
         fInvokeTrendlinesDialog = 99
' Function to invoke the 'Insert::Statistics...' dialog
' No Input
' Returns error-code:
' 0 := Sucess
' 1 := Serious problem trying to invoke the dialog
' 2 := Failure (Dialog not present after invocation)
'99 := Unexpected error
    
    printlog "** Invoking 'Insert::Trendlines...' in menu"
    '/// Execute menu item 'Insert::Trendlines...'
    try 
        InsertTrendlines
    catch
        qaErrorLog "Error 1: Invoking menu item 'Insert::Trendlines...' failed"
        fInvokeTrendlinesDialog = 1
        exit function
    endcatch
    
    '/// Lookup if call was successful
	Kontext
	active.SetPage (TabTrendLineType)
    Kontext "TabTrendLineType"
    if TabTrendLineType.exists(2) then
        printlog ">> Trend lines dialog is visible now."
        fInvokeTrendlinesDialog = 0
    else
        qaErrorLog "Error 2: OOPS, calling the slot '.uno:InsertTrendlines' didn't cause any problem ..."
        qaErrorLog "..., BUT the dialog doesn't seem to be visible"
        fInvokeTrendlinesDialog = 2
    endif

    if fInvokeTrendlinesDialog = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif    
end function
'
'--------------------------------------------------------------------
'
function fInvokeInsertYErrorBarsDialog() as INTEGER
         fInvokeInsertYErrorBarsDialog = 99
' Function to invoke the 'Insert::InsertYErrorBars...' dialog
' No Input
' Returns error-code:
' 0 := Sucess
' 1 := Serious problem trying to invoke the dialog
' 2 := Failure (Dialog not present after invocation)
'99 := Unexpected error    
    printlog "** Invoking 'Insert::InsertYErrorBars...' in menu"
    '/// Execute menu item 'Insert::InsertYErrorBars...'
    try 
        InsertYErrorBars
    catch
        qaErrorLog "Error 1: Invoking menu item 'Insert::YErrorBars...' failed"
        fInvokeInsertYErrorBarsDialog = 1
        exit function
    endcatch
    
    '/// Lookup if call was successful
    Kontext "InsertYErrorBarsDLG"
    if InsertYErrorBarsDLG.exists(2) then
        printlog ">> InsertYErrorBars dialog is visible now."
        fInvokeInsertYErrorBarsDialog = 0
    else
        qaErrorLog "Error 2: OOPS, calling the slot '.uno:InsertYErrorBars' didn't cause any problem ..."
        qaErrorLog "..., BUT the dialog doesn't seem to be visible"
        fInvokeInsertYErrorBarsDialog = 2
    endif
    
    if fInvokeInsertYErrorBarsDialog = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif
end function
'
'-------------------------------------------------------------------------
'
function fInsertMeanValueLines() as INTEGER
         fInsertMeanValueLines = 99
' Function to insert mean value lines in an activated chart object
' Input:
    QAErrorLog "#i86055#-Insert/ Mean Value Lines needs a check box in sub-menu to remove all lines with once click"
' Returns error-code:
' 0 := Sucess
' 1 := Serious problem trying to execute the command
' 2 := Serious problem trying to check if the line has been inserted
' 3 := Uncorrect selected object
' 4 := Format Line-dialog did not occour
'99 := Unexpected error
    
    printlog "** Executing 'Insert::MeanValueLines...' in menu"
    '/// Execute menu item 'Insert::MeanValueLines...'
    try 
        InsertMeanValueLines
    catch
        qaErrorLog "Error 1: Executing menu item 'Insert::MeanValueLines...' failed"
        fInsertMeanValueLines = 1
        exit function
    endcatch
    
    Kontext "DocumentChart"
    '/// Type three times TAB-key to select the first data series
    DocumentChart.TypeKeys "<TAB>" , 3
    '/// Type F3-function key to select the mean value line of that data series
    DocumentChart.TypeKeys "<F3>"
    '/// Open the context menu
    DocumentChart.OpenContextMenu TRUE     
    if hMenuItemGetCount = 6 then       
        '/// Select the first entry (properties)
        hMenuSelectNr (1)
    else
        qaErrorLog "Error 2: Opening context menu on inserted mean value line failed!"        
        fInsertMeanValueLines = 2
        exit function        
    endif
    Kontext
    '/// There should be one tab page (chart line)
    Active.SetPage TabFormatChartLine
    if Active.GetPageCount <> 1 then
        qaErrorLog "Error 3: Incorrect selected object!"        
        fInsertMeanValueLines = 3
        Active.Cancel        
        exit function
    endif
    Kontext "TabFormatChartLine"
    if TabFormatChartLine.Exists(1) then        
        fInsertMeanValueLines = 0
        '/// Leave the dialog with CANCEL
        TabFormatChartLine.CANCEL
        printlog ">> Inserting 'Mean Value Lines' seems to work"
    else
        qaErrorLog "Error 4: Format Line-dialog did not occour!"        
        fInsertMeanValueLines = 4        
        exit function                            
    end if          
    if fInsertMeanValueLines = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif   
end function
'
'--------------------------------------------------------------------
'
function fSetErrorCategory ( oErrorCategory as OBJECT ) as INTEGER
         fSetErrorCategory = 99
' Function to select 'Error Category'
' Input:
' OBJECT oErrorCategory
' Declaration name of Radio-Button (valid values):
' - NoFunction
' - Variance<
' - StandardDeviation
' - Percentage 
' - ErrorMargin
' - ConstantValue
' Returns error-code:
' 0 := Sucess
' 1 := Serious problem trying to check 'Error Category' radio-button
' 2 := 'Error Category' radio-button was not set
'12 := Radio-Button for desired 'Error Category' is not enabled
'42 := User error, input doesn't match.
'99 := Unexpected error
    printlog "** Setting 'Error Category'"
    '/// Check if desired 'Error Category' radio-button is enabled
    Kontext "InsertStatisticsDialog"
    if NOT oErrorCategory.IsEnabled then
        qaErrorLog "Error 12: Radio-Button for desired 'Error Category' is not enabled"
        qaErrorLog "... BUG or Script problem -> Check this out!"
        fSetErrorCategory = 12
        exit function
    endif
    '/// Try to check desired 'Error Category'
    Kontext "InsertStatisticsDialog"
    try 
        oErrorCategory.Check
    catch
        ' Throw error 1 and quit on serious problem
        qaErrorLog "Error 1: Check 'Error Category' radio-button seems to cause a serious problem -> Check this out!"
        fSetErrorCategory = 1
        exit function
    endcatch
    '/// Verify (against input) if 'Error Category' radio-button was checked
    if oErrorCategory.IsChecked then
        fSetErrorCategory = 0
        printlog ">> Setting 'Error Category' radio-button seems to work"
    else
        qaErrorLog "Error 2: Desires 'Error Category' radio-button was not checked -> Check this out!"
        fSetErrorCategory = 2
    endif

    if fSetErrorCategory = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif  
end function
'
'--------------------------------------------------------------------
'
function fSetErrorValue ( oErrorValue as OBJECT , _
                          sErrorValue as STRING , _
                          OPTIONAL bCheckResult as BOOLEAN , _
                          OPTIONAL sExpectedValue as STRING ) as INTEGER
         fSetErrorValue = 99
' Function to set 'Error Value'
' Input:
' OBJECT oErrorValue
' Declaration name of Spin-Field (valid values):
' - PercentageValue
' - ErrorMarginValue
' - ConstantValuePlus
' - ConstantValueMinus
' - STRING (numeric) sErrorValue
' - Value to assign to Spin-Field
' Returns error-code:
' 0 := Sucess
' 1 := Serious problem trying to check 'Error Value' Spin-Field
' 2 := 'Error Value' Spin-Field was not set
'12 := Spin-Field for desired 'Error Value' is not enabled
'42 := User error, input doesn't match.
'99 := Unexpected error
    if isMissing ( bCheckResult ) then
        bCheckResult = FALSE
    endif
    if isMissing ( sExpectedValue ) then
        sExpectedValue = sErrorValue
    endif
    printlog ""
    printlog "** Setting 'Error Value'"
    '/// Check if desired 'Error Value' Spin-Field is enabled
    Kontext "InsertStatisticsDialog"
    if NOT oErrorValue.IsEnabled then
        qaErrorLog "Error 12: Spin-Field for desired 'Error Value' is not enabled"
        qaErrorLog "... BUG or Script problem -> Check this out!"
        fSetErrorValue = 12
        exit function
    endif
    '/// Try to set desired 'Error Value'
    Kontext "InsertStatisticsDialog"
    try 
        oErrorValue.setText ( sErrorValue )
    catch
        ' Throw error 1 and quit on serious problem
        qaErrorLog "Error 1: Setting 'Error Value' Spin-Field seems to cause a serious problem -> Check this out!"
        fSetErrorValue = 1
        exit function
    endcatch
    '/// Verify (against input) if 'Error Value' Spin-Field was set correctly
    if bCheckResult then
        if oErrorValue.getText = sExpectedValue then
            fSetErrorValue = 0
            printlog ">> Setting 'Error Value' Spin-Field seems to work"
        else
            qaErrorLog "Error 2: Desires 'Error Value' Spin-Field was not set correctly (value out of range?) -> Check this out!"
            qaErrorLog "Expected result: " & sExpectedValue
            qaErrorLog "Obtained result: " & oErrorValue.getText
            fSetErrorValue = 2
        endif
    else
        fSetErrorValue = 0
        qaErrorLog "!! Skipped verification of result"
    endif

    if fSetErrorValue = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif   
end function
'
'--------------------------------------------------------------------
'
function fSetErrorIndicatorItem ( iErrorIndicatorNumber as INTEGER ) as INTEGER
         fSetErrorIndicatorItem = 99
' Function to select the 'Error Indicator' item
' Input:
' INTEGER iErrorIndicatorNumber:
' Position in 'Error Indicator' control.
' Posible Values are 1 to 4
' NOTE: Currently the 'Error Indicator' control can only be addressed using 'typekeys'.
' -> No 100% proof verification of success possible!
' Returns error-code:
' 0 := Sucess.
' 1 := Serious problem while selecting the variant control.
'11 := 'Error Indicator' is not visible
'42 := User error, input out of range.
'99 := Unexpected error. 
    '/// Check if 'Error Indicator' is visible
    Kontext "InsertStatisticsDialog"
    if NOT ErrorIndicator.IsVisible then
        qaErrorLog "Error 11: 'Error Indicator' is not visible"
        qaErrorLog "... BUG or Script problem -> Check this out!"
        fSetErrorIndicatorItem = 11
        exit function
    endif
    '/// Lookup valid input value for 'Error Indicator Item'
    if ( iErrorIndicatorNumber < 1 ) OR ( iErrorIndicatorNumber > 4 ) then
         fSetErrorIndicatorItem = 42
         warnlog "USER ERROR: Input doesn't match!"
         exit function
    endif   
    printlog "** Selecting the 'Error Indicator'"
    '/// Select the desired entry number
    Kontext "InsertStatisticsDialog"
    try 
        ErrorIndicator.typeKeys "<HOME>"
        ErrorIndicator.typeKeys "<RIGHT>", ( iErrorIndicatorNumber - 1 )
        fSetErrorIndicatorItem = 0
        printlog ">> Selecting the 'Error Indicator' probably worked"
    catch
        ' Throw error 1 and quit on serious problem
        qaErrorLog "Error 1: Selecting 'Error Indicator' seems to cause a serious problem -> Check this out!"
        fSetErrorIndicatorItem = 1
        exit function
    endcatch
    
    if fSetErrorIndicatorItem = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif   
end function
'
'--------------------------------------------------------------------
'
function fSetRegressionCurvesItem ( iRegressionCurveNumber as INTEGER ) as INTEGER
         fSetRegressionCurvesItem = 99
' Function to select the 'Regression Curves' item
' Input:
' INTEGER iRegressionCurveNumber:
' Position in 'Regression Curves' control.
' Posible Values are 1 to 5
' NOTE: Currently the 'Regression Curves' control can only be addressed using 'typekeys'.
' -> No 100% proof verification of success possible!
' Returns error-code:
' 0 := Sucess.
' 1 := Serious problem while selecting the variant control.
'11 := 'Regression Curves' is not visible
'42 := User error, input out of range.
'99 := Unexpected error.
    ' Check if 'Regression Curves' is visible
    Kontext "InsertStatisticsDialog"
    if NOT RegressionCurves.IsVisible then
        qaErrorLog "Error 11: 'Regression Curves' is not visible"
        qaErrorLog "... BUG or Script problem -> Check this out!"
        fSetRegressionCurvesItem = 11
        exit function
    endif
    '/// Lookup valid input value for 'Regression Curves Item'
    if ( iRegressionCurveNumber < 1 ) OR ( iRegressionCurveNumber > 5 ) then
         fSetRegressionCurvesItem = 42
         warnlog "USER ERROR: Input doesn't match!"
         exit function
    endif        
    printlog "** Selecting the 'Regression Curves'"
    '/// Select the desired entry number
    Kontext "InsertStatisticsDialog"
    try 
        RegressionCurves.typeKeys "<HOME>"
        RegressionCurves.typeKeys "<RIGHT>", ( iRegressionCurveNumber - 1 )
        fSetRegressionCurvesItem = 0
        printlog ">> Selecting the 'Regression Curves' probably worked"
    catch
        ' Throw error 1 and quit on serious problem
        qaErrorLog "Error 1: Selecting 'Regression Curves' seems to cause a serious problem -> Check this out!"
        fSetRegressionCurvesItem = 1
        exit function
    endcatch
    
    if fSetRegressionCurvesItem = 99 then
        warnlog "Error 99: Something unexpected happened!!"
    endif   
end function