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: ch_tools_statistics.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-13 14:27:02 $
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 : Tool library for Statistics dialog
38 '**************************************************************************************************
40 ' #1 fInvokeTrendlinesDialog
41 ' #1 fInvokeInsertYErrorBarsDialog
42 ' #1 fInsertMeanValueLines
43 ' #1 fSetErrorCategory
45 ' #1 fSetErrorIndicatorItem
46 ' #1 fSetRegressionCurvesItem
48 '\************************************************************************************************
50 ' ch_tools_statistics.inc - Library for automation of the 'Insert::Statistics...' dialog
51 ' This Include contains a set of functions to modify the controls of the Statistics dialog.
52 ' All functions are designed to return error-codes depending on the behaviour of the action applied.
55 ' Error 1: The basic action beeing applied caused a serious problem, e.g. a crash.
56 ' Error 2 TO 9: A functional problem occured.
57 ' Error 11 TO 19: Wrong marginal conditions end up in failture, e.g. control not visible.
58 ' NOTE: This errors can also be used for 'negative' testing.
59 ' Error 42: Wrong input. Probably only of interest during test development.
60 ' Error 99: Unexpected behaviour - Shouldn't normally occur.
62 ' Only Errors 42 and 99 throw 'warnlogs'.
63 ' All other errors are silent.
64 ' They only throw QAErrorlogs the give a hint what probably went wrong.
65 ' Expected Errors MUST exclusivly be handled by the calling routine.
67 '--------------------------------------------------------------------
69 function fInvokeTrendlinesDialog() as INTEGER
70 fInvokeTrendlinesDialog = 99
71 ' Function to invoke the 'Insert::Statistics...' dialog
75 ' 1 := Serious problem trying to invoke the dialog
76 ' 2 := Failure (Dialog not present after invocation)
77 '99 := Unexpected error
79 printlog "** Invoking 'Insert::Trendlines...' in menu"
80 '/// Execute menu item 'Insert::Trendlines...'
84 qaErrorLog "Error 1: Invoking menu item 'Insert::Trendlines...' failed"
85 fInvokeTrendlinesDialog = 1
89 '/// Lookup if call was successful
91 active.SetPage "TabTrendLineType"
92 Kontext "TabTrendLineType"
93 if TabTrendLineType.exists(2) then
94 printlog ">> Trend lines dialog is visible now."
95 fInvokeTrendlinesDialog = 0
97 qaErrorLog "Error 2: OOPS, calling the slot '.uno:InsertTrendlines' didn't cause any problem ..."
98 qaErrorLog "..., BUT the dialog doesn't seem to be visible"
99 fInvokeTrendlinesDialog = 2
102 if fInvokeTrendlinesDialog = 99 then
103 warnlog "Error 99: Something unexpected happened!!"
107 '--------------------------------------------------------------------
109 function fInvokeInsertYErrorBarsDialog() as INTEGER
110 fInvokeInsertYErrorBarsDialog = 99
111 ' Function to invoke the 'Insert::InsertYErrorBars...' dialog
113 ' Returns error-code:
115 ' 1 := Serious problem trying to invoke the dialog
116 ' 2 := Failure (Dialog not present after invocation)
117 '99 := Unexpected error
118 printlog "** Invoking 'Insert::InsertYErrorBars...' in menu"
119 '/// Execute menu item 'Insert::InsertYErrorBars...'
123 qaErrorLog "Error 1: Invoking menu item 'Insert::YErrorBars...' failed"
124 fInvokeInsertYErrorBarsDialog = 1
128 '/// Lookup if call was successful
129 Kontext "InsertYErrorBarsDLG"
130 if InsertYErrorBarsDLG.exists(2) then
131 printlog ">> InsertYErrorBars dialog is visible now."
132 fInvokeInsertYErrorBarsDialog = 0
134 qaErrorLog "Error 2: OOPS, calling the slot '.uno:InsertYErrorBars' didn't cause any problem ..."
135 qaErrorLog "..., BUT the dialog doesn't seem to be visible"
136 fInvokeInsertYErrorBarsDialog = 2
139 if fInvokeInsertYErrorBarsDialog = 99 then
140 warnlog "Error 99: Something unexpected happened!!"
144 '-------------------------------------------------------------------------
146 function fInsertMeanValueLines() as INTEGER
147 fInsertMeanValueLines = 99
148 ' Function to insert mean value lines in an activated chart object
150 QAErrorLog "#i86055#-Insert/ Mean Value Lines needs a check box in sub-menu to remove all lines with once click"
151 ' Returns error-code:
153 ' 1 := Serious problem trying to execute the command
154 ' 2 := Serious problem trying to check if the line has been inserted
155 ' 3 := Uncorrect selected object
156 ' 4 := Format Line-dialog did not occour
157 '99 := Unexpected error
159 printlog "** Executing 'Insert::MeanValueLines...' in menu"
160 '/// Execute menu item 'Insert::MeanValueLines...'
164 qaErrorLog "Error 1: Executing menu item 'Insert::MeanValueLines...' failed"
165 fInsertMeanValueLines = 1
169 Kontext "DocumentChart"
170 '/// Type three times TAB-key to select the first data series
171 DocumentChart.TypeKeys "<TAB>" , 3
172 '/// Type F3-function key to select the mean value line of that data series
173 DocumentChart.TypeKeys "<F3>"
174 '/// Open the context menu
175 DocumentChart.OpenContextMenu TRUE
176 if hMenuItemGetCount = 6 then
177 '/// Select the first entry (properties)
180 qaErrorLog "Error 2: Opening context menu on inserted mean value line failed!"
181 fInsertMeanValueLines = 2
185 '/// There should be one tab page (chart line)
186 Active.SetPage TabFormatChartLine
187 if Active.GetPageCount <> 1 then
188 qaErrorLog "Error 3: Incorrect selected object!"
189 fInsertMeanValueLines = 3
193 Kontext "TabFormatChartLine"
194 if TabFormatChartLine.Exists(1) then
195 fInsertMeanValueLines = 0
196 '/// Leave the dialog with CANCEL
197 TabFormatChartLine.CANCEL
198 printlog ">> Inserting 'Mean Value Lines' seems to work"
200 qaErrorLog "Error 4: Format Line-dialog did not occour!"
201 fInsertMeanValueLines = 4
204 if fInsertMeanValueLines = 99 then
205 warnlog "Error 99: Something unexpected happened!!"
209 '--------------------------------------------------------------------
211 function fSetErrorCategory ( oErrorCategory as OBJECT ) as INTEGER
212 fSetErrorCategory = 99
213 ' Function to select 'Error Category'
215 ' OBJECT oErrorCategory
216 ' Declaration name of Radio-Button (valid values):
219 ' - StandardDeviation
223 ' Returns error-code:
225 ' 1 := Serious problem trying to check 'Error Category' radio-button
226 ' 2 := 'Error Category' radio-button was not set
227 '12 := Radio-Button for desired 'Error Category' is not enabled
228 '42 := User error, input doesn't match.
229 '99 := Unexpected error
230 printlog "** Setting 'Error Category'"
231 '/// Check if desired 'Error Category' radio-button is enabled
232 Kontext "InsertStatisticsDialog"
233 if NOT oErrorCategory.IsEnabled then
234 qaErrorLog "Error 12: Radio-Button for desired 'Error Category' is not enabled"
235 qaErrorLog "... BUG or Script problem -> Check this out!"
236 fSetErrorCategory = 12
239 '/// Try to check desired 'Error Category'
240 Kontext "InsertStatisticsDialog"
244 ' Throw error 1 and quit on serious problem
245 qaErrorLog "Error 1: Check 'Error Category' radio-button seems to cause a serious problem -> Check this out!"
246 fSetErrorCategory = 1
249 '/// Verify (against input) if 'Error Category' radio-button was checked
250 if oErrorCategory.IsChecked then
251 fSetErrorCategory = 0
252 printlog ">> Setting 'Error Category' radio-button seems to work"
254 qaErrorLog "Error 2: Desires 'Error Category' radio-button was not checked -> Check this out!"
255 fSetErrorCategory = 2
258 if fSetErrorCategory = 99 then
259 warnlog "Error 99: Something unexpected happened!!"
263 '--------------------------------------------------------------------
265 function fSetErrorValue ( oErrorValue as OBJECT , _
266 sErrorValue as STRING , _
267 OPTIONAL bCheckResult as BOOLEAN , _
268 OPTIONAL sExpectedValue as STRING ) as INTEGER
270 ' Function to set 'Error Value'
273 ' Declaration name of Spin-Field (valid values):
276 ' - ConstantValuePlus
277 ' - ConstantValueMinus
278 ' - STRING (numeric) sErrorValue
279 ' - Value to assign to Spin-Field
280 ' Returns error-code:
282 ' 1 := Serious problem trying to check 'Error Value' Spin-Field
283 ' 2 := 'Error Value' Spin-Field was not set
284 '12 := Spin-Field for desired 'Error Value' is not enabled
285 '42 := User error, input doesn't match.
286 '99 := Unexpected error
287 if isMissing ( bCheckResult ) then
290 if isMissing ( sExpectedValue ) then
291 sExpectedValue = sErrorValue
294 printlog "** Setting 'Error Value'"
295 '/// Check if desired 'Error Value' Spin-Field is enabled
296 Kontext "InsertStatisticsDialog"
297 if NOT oErrorValue.IsEnabled then
298 qaErrorLog "Error 12: Spin-Field for desired 'Error Value' is not enabled"
299 qaErrorLog "... BUG or Script problem -> Check this out!"
303 '/// Try to set desired 'Error Value'
304 Kontext "InsertStatisticsDialog"
306 oErrorValue.setText ( sErrorValue )
308 ' Throw error 1 and quit on serious problem
309 qaErrorLog "Error 1: Setting 'Error Value' Spin-Field seems to cause a serious problem -> Check this out!"
313 '/// Verify (against input) if 'Error Value' Spin-Field was set correctly
315 if oErrorValue.getText = sExpectedValue then
317 printlog ">> Setting 'Error Value' Spin-Field seems to work"
319 qaErrorLog "Error 2: Desires 'Error Value' Spin-Field was not set correctly (value out of range?) -> Check this out!"
320 qaErrorLog "Expected result: " & sExpectedValue
321 qaErrorLog "Obtained result: " & oErrorValue.getText
326 qaErrorLog "!! Skipped verification of result"
329 if fSetErrorValue = 99 then
330 warnlog "Error 99: Something unexpected happened!!"
334 '--------------------------------------------------------------------
336 function fSetErrorIndicatorItem ( iErrorIndicatorNumber as INTEGER ) as INTEGER
337 fSetErrorIndicatorItem = 99
338 ' Function to select the 'Error Indicator' item
340 ' INTEGER iErrorIndicatorNumber:
341 ' Position in 'Error Indicator' control.
342 ' Posible Values are 1 to 4
343 ' NOTE: Currently the 'Error Indicator' control can only be addressed using 'typekeys'.
344 ' -> No 100% proof verification of success possible!
345 ' Returns error-code:
347 ' 1 := Serious problem while selecting the variant control.
348 '11 := 'Error Indicator' is not visible
349 '42 := User error, input out of range.
350 '99 := Unexpected error.
351 '/// Check if 'Error Indicator' is visible
352 Kontext "InsertStatisticsDialog"
353 if NOT ErrorIndicator.IsVisible then
354 qaErrorLog "Error 11: 'Error Indicator' is not visible"
355 qaErrorLog "... BUG or Script problem -> Check this out!"
356 fSetErrorIndicatorItem = 11
359 '/// Lookup valid input value for 'Error Indicator Item'
360 if ( iErrorIndicatorNumber < 1 ) OR ( iErrorIndicatorNumber > 4 ) then
361 fSetErrorIndicatorItem = 42
362 warnlog "USER ERROR: Input doesn't match!"
365 printlog "** Selecting the 'Error Indicator'"
366 '/// Select the desired entry number
367 Kontext "InsertStatisticsDialog"
369 ErrorIndicator.typeKeys "<HOME>"
370 ErrorIndicator.typeKeys "<RIGHT>", ( iErrorIndicatorNumber - 1 )
371 fSetErrorIndicatorItem = 0
372 printlog ">> Selecting the 'Error Indicator' probably worked"
374 ' Throw error 1 and quit on serious problem
375 qaErrorLog "Error 1: Selecting 'Error Indicator' seems to cause a serious problem -> Check this out!"
376 fSetErrorIndicatorItem = 1
380 if fSetErrorIndicatorItem = 99 then
381 warnlog "Error 99: Something unexpected happened!!"
385 '--------------------------------------------------------------------
387 function fSetRegressionCurvesItem ( iRegressionCurveNumber as INTEGER ) as INTEGER
388 fSetRegressionCurvesItem = 99
389 ' Function to select the 'Regression Curves' item
391 ' INTEGER iRegressionCurveNumber:
392 ' Position in 'Regression Curves' control.
393 ' Posible Values are 1 to 5
394 ' NOTE: Currently the 'Regression Curves' control can only be addressed using 'typekeys'.
395 ' -> No 100% proof verification of success possible!
396 ' Returns error-code:
398 ' 1 := Serious problem while selecting the variant control.
399 '11 := 'Regression Curves' is not visible
400 '42 := User error, input out of range.
401 '99 := Unexpected error.
402 ' Check if 'Regression Curves' is visible
403 Kontext "InsertStatisticsDialog"
404 if NOT RegressionCurves.IsVisible then
405 qaErrorLog "Error 11: 'Regression Curves' is not visible"
406 qaErrorLog "... BUG or Script problem -> Check this out!"
407 fSetRegressionCurvesItem = 11
410 '/// Lookup valid input value for 'Regression Curves Item'
411 if ( iRegressionCurveNumber < 1 ) OR ( iRegressionCurveNumber > 5 ) then
412 fSetRegressionCurvesItem = 42
413 warnlog "USER ERROR: Input doesn't match!"
416 printlog "** Selecting the 'Regression Curves'"
417 '/// Select the desired entry number
418 Kontext "InsertStatisticsDialog"
420 RegressionCurves.typeKeys "<HOME>"
421 RegressionCurves.typeKeys "<RIGHT>", ( iRegressionCurveNumber - 1 )
422 fSetRegressionCurvesItem = 0
423 printlog ">> Selecting the 'Regression Curves' probably worked"
425 ' Throw error 1 and quit on serious problem
426 qaErrorLog "Error 1: Selecting 'Regression Curves' seems to cause a serious problem -> Check this out!"
427 fSetRegressionCurvesItem = 1
431 if fSetRegressionCurvesItem = 99 then
432 warnlog "Error 99: Something unexpected happened!!"