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 2000, 2010 Oracle and/or its affiliates.
7 ' OpenOffice.org - a multi-platform office productivity suite
9 ' This file is part of OpenOffice.org.
11 ' OpenOffice.org is free software: you can redistribute it and/or modify
12 ' it under the terms of the GNU Lesser General Public License version 3
13 ' only, as published by the Free Software Foundation.
15 ' OpenOffice.org is distributed in the hope that it will be useful,
16 ' but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ' GNU Lesser General Public License version 3 for more details
19 ' (a copy is included in the LICENSE file that accompanied this code).
21 ' You should have received a copy of the GNU Lesser General Public License
22 ' version 3 along with OpenOffice.org. If not, see
23 ' <http://www.openoffice.org/license.html>
24 ' for a copy of the LGPLv3 License.
26 '/******************************************************************************
28 '* owner : gregor.hartmann@oracle.com
30 '* short description : Usage tracking
32 '\******************************************************************************
34 private const LOGFILE = "user\temp\Feedback\Current.csv"
36 '*******************************************************************************
38 testcase tUsageTracking1
40 printlog( "Test case 1: Presence of the Usage Tracking featureset" )
42 ' Broken in CWS sb111'
43 ' Currently missing: Check for Office brand, StarOffice should always have OOoImp enabled'
45 if ( not gOOoImprovementIsEnabled ) then
46 warnlog( "Usage tracking program is not enabled for this build" )
51 '*******************************************************************************
53 testcase tUsageTracking2
55 ' There must not be a log file to start with.
57 printlog( "Test case 2: There must be no logfile present yet" )
59 dim cLogFile as string
60 cLogFile = gOfficePath & LOGFILE
61 cLogFile = convertpath( cLogFile )
63 if ( dir( cLogFile ) = "" ) then
64 printlog( "No log file. Good" )
66 warnlog( "Logfile not esxpected: " & cLogFile )
67 hDeleteFile( cLogFile )
72 '*******************************************************************************
74 testcase tUsageTracking3
76 ' When the usage tracking mechanism is off we want the ui to reflect that.
78 printlog( "Test case 3: Presence of configuration tabpage and button states for disabled functionality" )
81 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
83 kontext "TabOOoImprovement"
84 if ( TabOOoImprovement.exists( 1 ) ) then
86 if ( not ParticipateNo.isChecked() ) then
87 warnlog( "#i98736# - UI should reflect current status for usage tracking: No" )
90 if ( ShowData.isEnabled() ) then
91 warnlog( "#i116461# - Show data button should not be enabled if nothing is logged" )
95 kontext "FilterAuswahl"
96 if ( FilterAuswahl.exists( 2 ) ) then
97 warnlog( "Filter Selection dialog is not expected at this point, ")
98 FilterAuswahl.cancel()
102 if ( Active.exists( 2 ) ) then
103 warnlog( "Messagebox not required as control should not be enabled (see #i116461#)" )
107 if ( TextImport.exists( 5 ) ) then
108 warnlog( "There should be nothing to load if usage tracking is disabled" )
113 if ( DocumentCalc.exists( 3 ) ) then
116 warnlog( "If a log exists it should open in a new Calc document" )
122 warnlog( "OOo Improvement Tabpage (Tools/Options) is missing" )
125 kontext "OptionenDlg"
130 '*******************************************************************************
132 testcase tUsageTracking4
134 ' When enabling usage tracking we want the mechanism to work at once
136 printlog( "Test case 4: Enable usage tracking, track something and display the log" )
138 dim iDocumentType as integer
140 dim cLogFile as string
141 cLogFile = gOfficePath & LOGFILE
142 cLogFile = convertpath( cLogFile )
144 dim lFileSize as long
146 const FILE_SIZE = 2000
148 hDeleteFile( cLogFile )
152 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
154 kontext "TabOOoImprovement"
155 if ( TabOOoImprovement.exists( 1 ) ) then
157 ParticipateYes.check()
159 if ( hForceUsageTrackingOn() ) then
161 kontext "OptionenDlg"
164 ' Open different document types and modify them so something is logged
165 for iDocumentType = 1 to 4
167 hNumericDocType( iDocumentType )
176 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
178 kontext "TabOOoImprovement"
179 if ( TabOOoImprovement.exists( 1 ) ) then
181 lFileSize = hGetFileSizeAsLong( cLogFile )
182 printlog( "Filesize is: " & lFileSize & " byte" )
183 if ( lFileSize <> FILE_SIZE ) then
184 warnlog( "The logfile does not have the expected size" )
185 printlog( "Expected: " & FILE_SIZE )
186 printlog( "Found...: " & lFileSize )
192 if ( TextImport.exists( 3 ) ) then
197 if ( DocumentCalc.exists( 3 ) ) then
198 printlog( "Calc document is open" )
199 if ( getDocumentCount <> 1 ) then
200 warnlog( "Other, unexpected documents are open" )
205 warnlog( "Logfile should open in a new spreadsheet document, document missing" )
210 warnlog( "Text Import (CSV) settings dialog did not open" )
213 if ( Active.exists() ) then
214 warnlog( "Unexpected messagebox" )
215 printlog( Active.getText() )
220 kontext "TabOOoImprovement"
221 ParticipateNo.click()
224 if ( Active.exists( 3 ) ) then
227 qaerrorlog( "#i98739# - No delete option available when stopping usage tracking" )
232 qaerrorlog( "#i98741# - Failed to force Usage Tracking on via API" )
235 kontext "OptionenDlg"
240 hDeleteFile( cLogFile )
244 '*******************************************************************************
246 function hForceUsageTrackingOn()
248 ' the usage tracking extension was disabled by force, in this function
249 ' we force it back on as the switch in the UI is ignored
251 Dim oUnoOfficeConnection as object
252 Dim oUnoConfigurationAccess as object
253 Dim aPropertyValue(1) As new com.sun.star.beans.PropertyValue ' Array of pairs: Property with Value
256 Dim oOOoImprovementController as object ' Check presence of the OOo Improvement Program
259 oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.configuration.ConfigurationProvider")
260 if (isNull(oUnoConfigurationAccess)) then
261 warnlog (sFileFunction+"Couldn't create Configuration access")
265 aPropertyValue(0).Name="nodepath"
266 aPropertyValue(1).Name="lazywrite"
267 aPropertyValue(1).Value=False
269 oOOoImprovementController = oUnoOfficeConnection.createInstance( "com.sun.star.oooimprovement.CoreController" )
270 if ( isNull( oOOoImprovementController ) ) then
271 hForceUsageTrackingOn() = FALSE
273 aPropertyValue(0).Value="/org.openoffice.Office.Logging/OOoImprovement"
274 xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
275 xViewRoot.replaceByName("EnablingAllowed", true )
276 xViewRoot.commitChanges()
277 if xViewRoot.hasPendingChanges() then
278 qaErrorLog("Configuration not flushed: OOoImprovementProgram/InvitationAccepted: FALSE")
281 hForceUsageTrackingOn() = TRUE
285 printlog( "Could not enable Usage Tracking via API" )