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 printlog( "Test case 1: Presence of the Usage Tracking featureset (API)" )
54 if ( not gOOoImprovementIsEnabled ) then
55 warnlog( "Could not access API for usage tracking program" )
60 '*******************************************************************************
62 testcase tUsageTracking2
64 ' There must not be a log file to start with.
66 printlog( "Test case 2: There must be no logfile present yet" )
68 dim cLogFile as string
69 cLogFile = gOfficePath & LOGFILE
70 cLogFile = convertpath( cLogFile )
72 if ( dir( cLogFile ) = "" ) then
73 printlog( "No log file. Good" )
75 warnlog( "Logfile not esxpected: " & cLogFile )
76 hDeleteFile( cLogFile )
81 '*******************************************************************************
83 testcase tUsageTracking3
85 ' When the usage tracking mechanism is off we want the ui to reflect that.
87 printlog( "Test case 3: Presence of configuration tabpage and button states for disabled functionality" )
90 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
92 kontext "TabOOoImprovement"
93 if ( TabOOoImprovement.exists( 1 ) ) then
95 if ( not ParticipateNo.isChecked() ) then
96 qaerrorlog( "#i98736# - UI should reflect current status for usage tracking: No" )
99 if ( ShowData.isEnabled() ) then
100 qaerrorlog( "#i97340# - Show data button should not be enabled if nothing is logged" )
105 if ( Active.exists( 2 ) ) then
106 qaerrorlog( "Messagebox not required as control should not be enabled (see #i97340#)" )
110 if ( TextImport.exists( 5 ) ) then
111 warnlog( "There should be nothing to load if usage tracking is disabled" )
116 if ( DocumentCalc.exists( 3 ) ) then
119 warnlog( "If a log exists it should open in a new Calc document" )
125 warnlog( "OOo Improvement Tabpage (Tools/Options) is missing" )
128 kontext "OptionenDlg"
133 '*******************************************************************************
135 testcase tUsageTracking4
137 ' When enabling usage tracking we want the mechanism to work at once
139 printlog( "Test case 4: Enable usage tracking, track something and display the log" )
141 dim iDocumentType as integer
143 dim cLogFile as string
144 cLogFile = gOfficePath & LOGFILE
145 cLogFile = convertpath( cLogFile )
147 dim lFileSize as long
149 const FILE_SIZE = 2000
151 hDeleteFile( cLogFile )
155 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
157 kontext "TabOOoImprovement"
158 if ( TabOOoImprovement.exists( 1 ) ) then
160 ParticipateYes.check()
162 if ( hForceUsageTrackingOn() ) then
164 kontext "OptionenDlg"
167 ' Open different document types and modify them so something is logged
168 for iDocumentType = 1 to 4
170 hNumericDocType( iDocumentType )
179 hToolsOptions( "StarOffice" , "IMPROVEMENT" )
181 kontext "TabOOoImprovement"
182 if ( TabOOoImprovement.exists( 1 ) ) then
184 lFileSize = hGetFileSizeAsLong( cLogFile )
185 printlog( "Filesize is: " & lFileSize & " byte" )
186 if ( lFileSize <> FILE_SIZE ) then
187 warnlog( "The logfile does not have the expected size" )
188 printlog( "Expected: " & FILE_SIZE )
189 printlog( "Found...: " & lFileSize )
195 if ( TextImport.exists( 3 ) ) then
200 if ( DocumentCalc.exists( 3 ) ) then
201 printlog( "Calc document is open" )
202 if ( getDocumentCount <> 1 ) then
203 warnlog( "Other, unexpected documents are open" )
208 warnlog( "Logfile should open in a new spreadsheet document, document missing" )
213 warnlog( "Text Import (CSV) settings dialog did not open" )
216 if ( Active.exists() ) then
217 warnlog( "Unexpected messagebox" )
218 printlog( Active.getText() )
223 kontext "TabOOoImprovement"
224 ParticipateNo.click()
227 if ( Active.exists( 3 ) ) then
230 qaerrorlog( "#i98739# - No delete option available when stopping usage tracking" )
235 qaerrorlog( "#i98741# - Failed to force Usage Tracking on via API" )
238 kontext "OptionenDlg"
243 hDeleteFile( cLogFile )
247 '*******************************************************************************
249 function hForceUsageTrackingOn()
251 ' the usage tracking extension was disabled by force, in this function
252 ' we force it back on as the switch in the UI is ignored
254 Dim oUnoOfficeConnection as object
255 Dim oUnoConfigurationAccess as object
256 Dim aPropertyValue(1) As new com.sun.star.beans.PropertyValue ' Array of pairs: Property with Value
259 Dim oOOoImprovementController as object ' Check presence of the OOo Improvement Program
262 oUnoConfigurationAccess=oUnoOfficeConnection.createInstance("com.sun.star.configuration.ConfigurationProvider")
263 if (isNull(oUnoConfigurationAccess)) then
264 warnlog (sFileFunction+"Couldn't create Configuration access")
268 aPropertyValue(0).Name="nodepath"
269 aPropertyValue(1).Name="lazywrite"
270 aPropertyValue(1).Value=False
272 oOOoImprovementController = oUnoOfficeConnection.createInstance( "com.sun.star.oooimprovement.CoreController" )
273 if ( isNull( oOOoImprovementController ) ) then
274 hForceUsageTrackingOn() = FALSE
276 aPropertyValue(0).Value="/org.openoffice.Office.Logging/OOoImprovement"
277 xViewRoot=oUnoConfigurationAccess.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess",aPropertyValue())
278 xViewRoot.replaceByName("EnablingAllowed", true )
279 xViewRoot.commitChanges()
280 if xViewRoot.hasPendingChanges() then
281 qaErrorLog("Configuration not flushed: OOoImprovementProgram/InvitationAccepted: FALSE")
284 hForceUsageTrackingOn() = TRUE
288 printlog( "Could not enable Usage Tracking via API" )