1 /*************************************************************************
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 ************************************************************************/
30 import lib
.MultiMethodTest
;
31 import util
.ValueChanger
;
33 import com
.sun
.star
.beans
.XPropertySet
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.lang
.XServiceInfo
;
36 import com
.sun
.star
.sheet
.FunctionArgument
;
37 import com
.sun
.star
.uno
.AnyConverter
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
42 * Testing <code>com.sun.star.sheet.FunctionDescription</code>
45 * <li><code>Arguments</code></li>
46 * <li><code>Category</code></li>
47 * <li><code>Description</code></li>
48 * <li><code>Id</code></li>
49 * <li><code>Name</code></li>
51 * @see com.sun.star.sheet.FunctionDescription
53 public class _FunctionDescription
extends MultiMethodTest
{
55 public XPropertySet oObj
= null; // oObj filled by MultiMethodTest
57 public _FunctionDescription() {
60 public void _Arguments() {
61 // check if Service is available
62 XServiceInfo xInfo
= (XServiceInfo
)
63 UnoRuntime
.queryInterface(XServiceInfo
.class, oObj
);
65 if ( ! xInfo
.supportsService
66 ( "com.sun.star.sheet.FunctionDescription" ) ) {
67 log
.println( "Service not available !" );
68 tRes
.tested( "Supported", false );
72 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
)tParam
.getMSF();
74 XInterface FA
= (XInterface
)oDocMSF
.
75 createInstance("com.sun.star.sheet.FunctionArgument");
76 FunctionArgument arg
= (FunctionArgument
)AnyConverter
.toObject
77 (FunctionArgument
.class, FA
);
79 arg
.Description
= "FunctionDescription argument description" ;
80 arg
.Name
= "FunctionDescriptiuon argument name" ;
81 arg
.IsOptional
= true ;
83 Object sValue
= oObj
.getPropertyValue("Arguments") ;
84 oObj
.setPropertyValue("Arguments", new FunctionArgument
[] {arg
}) ;
85 Object nValue
= oObj
.getPropertyValue("Arguments") ;
87 if (sValue
.equals(nValue
)) {
88 log
.println("Property 'Arguments' didn't change: OK") ;
89 tRes
.tested("Arguments", true) ;
91 log
.println("Readonly property 'Arguments' changed: Failed") ;
92 tRes
.tested("Arguments", false) ;
94 } catch (Exception e
) {
96 "Exception occurred while testing property 'Arguments'" );
97 e
.printStackTrace( log
);
98 tRes
.tested( "Arguments", false );
102 public void _Category() {
103 tryChangeProp("Category") ;
106 public void _Description() {
107 tryChangeProp( "Category" );
111 tryChangeProp( "Id" );
114 public void _Name() {
115 tryChangeProp( "Name" );
118 public void tryChangeProp( String name
) {
120 Object gValue
= null;
121 Object sValue
= null;
122 Object ValueToSet
= null;
126 //waitForAllThreads();
127 gValue
= oObj
.getPropertyValue( name
);
129 //waitForAllThreads();
130 ValueToSet
= ValueChanger
.changePValue( gValue
);
131 //waitForAllThreads();
132 oObj
.setPropertyValue( name
, ValueToSet
);
133 sValue
= oObj
.getPropertyValue( name
);
135 //check get-set methods
136 if( gValue
.equals( sValue
) ) {
137 log
.println( "Value for '"+name
+"' hasn't changed. OK." );
138 tRes
.tested( name
, true );
141 log
.println( "Property '" + name
+
142 "' changes it's value : Failed !" );
143 tRes
.tested( name
, false );
146 catch ( Exception e
) {
148 "Exception occurred while testing property '" + name
+ "'" );
149 e
.printStackTrace( log
);
150 tRes
.tested( name
, false );
152 } // end of changeProp
154 } //finish class _TextContent