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: basic_delete_modules.inc,v $
13 '* last change: $Author: jsi $ $Date: 2008-06-16 12:18:13 $
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 : joerg.skottke@sun.com
36 '* short description : Usage tracking
38 '\******************************************************************************
41 ' The usage tracking functionality is disabled during test init.
42 ' Configuration is done in Tools/Options. There a tabpage must exist that
43 ' offers the functionality to enable/disable tracking and to show what has
46 private const LOGFILE = "user\temp\Feedback\Current.csv"
48 '*******************************************************************************
50 testcase tUsageTracking1
52 ' Here we just check that the functionality is present - the API call in
53 ' master.inc does only print a qaerrorlog. Here it is a bug.
55 printlog( "Test case 1: Presence of the Usage Tracking featureset (API)" )
57 if ( not gOOoImprovementIsEnabled ) then
58 warnlog( "Could not access API for usage tracking program" )
63 '*******************************************************************************
65 testcase tUsageTracking2
67 ' There must not be a log file to start with.
69 printlog( "Test case 2: There must be no logfile present yet" )
71 dim cLogFile as string
72 cLogFile = gOfficePath & LOGFILE
73 cLogFile = convertpath( cLogFile )
75 if ( dir( cLogFile ) = "" ) then
76 printlog( "No log file. Good" )
78 warnlog( "Logfile not esxpected: " & cLogFile )
79 hDeleteFile( cLogFile )
84 '*******************************************************************************
86 testcase tUsageTracking3
88 ' When the usage tracking mechanism is off we want the ui to reflect that.
90 printlog( "Test case 3: Presence of configuration tabpage and button states for disabled functionality" )
93 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
95 kontext "TabOOoImprovement"
96 if ( TabOOoImprovement.exists( 1 ) ) then
98 if ( not ParticipateNo.isChecked() ) then
99 qaerrorlog( "#i98736# - UI should reflect current status for usage tracking: No" )
102 if ( ShowData.isEnabled() ) then
103 qaerrorlog( "#i97340# - Show data button should not be enabled if nothing is logged" )
108 if ( Active.exists( 2 ) ) then
109 qaerrorlog( "Messagebox not required as control should not be enabled (see #i97340#)" )
113 if ( TextImport.exists( 5 ) ) then
114 warnlog( "There should be nothing to load if usage tracking is disabled" )
119 if ( DocumentCalc.exists( 3 ) ) then
122 warnlog( "If a log exists it should open in a new Calc document" )
128 warnlog( "OOo Improvement Tabpage (Tools/Options) is missing" )
131 kontext "OptionenDlg"
136 '*******************************************************************************
138 testcase tUsageTracking4
140 ' When enabling usage tracking we want the mechanism to work at once
142 printlog( "Test case 4: Enable usage tracking, track something and display the log" )
144 dim iDocumentType as integer
146 dim cLogFile as string
147 cLogFile = gOfficePath & LOGFILE
148 cLogFile = convertpath( cLogFile )
150 dim lFileSize as long
152 const FILE_SIZE = 2000
154 hDeleteFile( cLogFile )
158 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
160 kontext "TabOOoImprovement"
161 if ( TabOOoImprovement.exists( 1 ) ) then
163 ParticipateYes.check()
165 if ( hForceUsageTrackingOn() ) then
167 kontext "OptionenDlg"
170 ' Open different document types and modify them so something is logged
171 for iDocumentType = 1 to 4
173 hNumericDocType( iDocumentType )
182 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
184 kontext "TabOOoImprovement"
185 if ( TabOOoImprovement.exists( 1 ) ) then
187 lFileSize = hGetFileSizeAsLong( cLogFile )
188 printlog( "Filesize is: " & lFileSize & " byte" )
189 if ( lFileSize <> FILE_SIZE ) then
190 warnlog( "The logfile does not have the expected size" )
191 printlog( "Expected: " & FILE_SIZE )
192 printlog( "Found...: " & lFileSize )
198 if ( TextImport.exists( 3 ) ) then
203 if ( DocumentCalc.exists( 3 ) ) then
204 printlog( "Calc document is open" )
205 if ( getDocumentCount <> 1 ) then
206 warnlog( "Other, unexpected documents are open" )
211 warnlog( "Logfile should open in a new spreadsheet document, document missing" )
216 warnlog( "Text Import (CSV) settings dialog did not open" )
219 if ( Active.exists() ) then
220 warnlog( "Unexpected messagebox" )
221 printlog( Active.getText() )
226 kontext "TabOOoImprovement"
227 ParticipateNo.click()
230 if ( Active.exists( 3 ) ) then
233 qaerrorlog( "#i98739# - No delete option available when stopping usage tracking" )
238 qaerrorlog( "#i98741# - Failed to force Usage Tracking on via API" )
241 kontext "OptionenDlg"
246 hDeleteFile( cLogFile )
250 '*******************************************************************************
252 function hForceUsageTrackingOn()
254 ' the usage tracking extension was disabled by force, in this function
255 ' we force it back on as the switch in the UI is ignored
257 Dim oUnoOfficeConnection as object
258 Dim oUnoConfigurationAccess as object
259 Dim aPropertyValue(1) As new com.sun.star.beans.PropertyValue ' Array of pairs: Property with Value
262 Dim oOOoImprovementController as object ' Check presence of the OOo Improvement Program
265 oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.configuration.ConfigurationProvider")
266 if (isNull(oUnoConfigurationAccess)) then
267 warnlog (sFileFunction+"Couldn't create Configuration access")
271 aPropertyValue(0).Name="nodepath"
272 aPropertyValue(1).Name="lazywrite"
273 aPropertyValue(1).Value=False
275 oOOoImprovementController = oUnoOfficeConnection.createInstance( "com.sun.star.oooimprovement.CoreController" )
276 if ( isNull( oOOoImprovementController ) ) then
277 hForceUsageTrackingOn() = FALSE
279 aPropertyValue(0).Value="/org.openoffice.Office.Logging/OOoImprovement"
280 xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
281 xViewRoot.replaceByName("EnablingAllowed", true )
282 xViewRoot.commitChanges()
283 if xViewRoot.hasPendingChanges() then
284 qaErrorLog("Configuration not flushed: OOoImprovementProgram/InvitationAccepted: FALSE")
287 hForceUsageTrackingOn() = TRUE
291 printlog( "Could not enable Usage Tracking via API" )