1 /*************************************************************************
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: _FunctionDescription.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import lib
.MultiMethodTest
;
34 import util
.ValueChanger
;
36 import com
.sun
.star
.beans
.XPropertySet
;
37 import com
.sun
.star
.lang
.XMultiServiceFactory
;
38 import com
.sun
.star
.lang
.XServiceInfo
;
39 import com
.sun
.star
.sheet
.FunctionArgument
;
40 import com
.sun
.star
.uno
.AnyConverter
;
41 import com
.sun
.star
.uno
.UnoRuntime
;
42 import com
.sun
.star
.uno
.XInterface
;
45 * Testing <code>com.sun.star.sheet.FunctionDescription</code>
48 * <li><code>Arguments</code></li>
49 * <li><code>Category</code></li>
50 * <li><code>Description</code></li>
51 * <li><code>Id</code></li>
52 * <li><code>Name</code></li>
54 * @see com.sun.star.sheet.FunctionDescription
56 public class _FunctionDescription
extends MultiMethodTest
{
58 public XPropertySet oObj
= null; // oObj filled by MultiMethodTest
60 public _FunctionDescription() {
63 public void _Arguments() {
64 // check if Service is available
65 XServiceInfo xInfo
= (XServiceInfo
)
66 UnoRuntime
.queryInterface(XServiceInfo
.class, oObj
);
68 if ( ! xInfo
.supportsService
69 ( "com.sun.star.sheet.FunctionDescription" ) ) {
70 log
.println( "Service not available !" );
71 tRes
.tested( "Supported", false );
75 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
)tParam
.getMSF();
77 XInterface FA
= (XInterface
)oDocMSF
.
78 createInstance("com.sun.star.sheet.FunctionArgument");
79 FunctionArgument arg
= (FunctionArgument
)AnyConverter
.toObject
80 (FunctionArgument
.class, FA
);
82 arg
.Description
= "FunctionDescription argument description" ;
83 arg
.Name
= "FunctionDescriptiuon argument name" ;
84 arg
.IsOptional
= true ;
86 Object sValue
= oObj
.getPropertyValue("Arguments") ;
87 oObj
.setPropertyValue("Arguments", new FunctionArgument
[] {arg
}) ;
88 Object nValue
= oObj
.getPropertyValue("Arguments") ;
90 if (sValue
.equals(nValue
)) {
91 log
.println("Property 'Arguments' didn't change: OK") ;
92 tRes
.tested("Arguments", true) ;
94 log
.println("Readonly property 'Arguments' changed: Failed") ;
95 tRes
.tested("Arguments", false) ;
97 } catch (Exception e
) {
99 "Exception occured while testing property 'Arguments'" );
100 e
.printStackTrace( log
);
101 tRes
.tested( "Arguments", false );
105 public void _Category() {
106 tryChangeProp("Category") ;
109 public void _Description() {
110 tryChangeProp( "Category" );
114 tryChangeProp( "Id" );
117 public void _Name() {
118 tryChangeProp( "Name" );
121 public void tryChangeProp( String name
) {
123 Object gValue
= null;
124 Object sValue
= null;
125 Object ValueToSet
= null;
129 //waitForAllThreads();
130 gValue
= oObj
.getPropertyValue( name
);
132 //waitForAllThreads();
133 ValueToSet
= ValueChanger
.changePValue( gValue
);
134 //waitForAllThreads();
135 oObj
.setPropertyValue( name
, ValueToSet
);
136 sValue
= oObj
.getPropertyValue( name
);
138 //check get-set methods
139 if( gValue
.equals( sValue
) ) {
140 log
.println( "Value for '"+name
+"' hasn't changed. OK." );
141 tRes
.tested( name
, true );
144 log
.println( "Property '" + name
+
145 "' changes it's value : Failed !" );
146 tRes
.tested( name
, false );
149 catch ( Exception e
) {
151 "Exception occured while testing property '" + name
+ "'" );
152 e
.printStackTrace( log
);
153 tRes
.tested( name
, false );
155 } // end of changeProp
157 } //finish class _TextContent