2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
22 import util
.ValueChanger
;
24 import com
.sun
.star
.beans
.XPropertySet
;
25 import com
.sun
.star
.lang
.XMultiServiceFactory
;
26 import com
.sun
.star
.lang
.XServiceInfo
;
27 import com
.sun
.star
.sheet
.FunctionArgument
;
28 import com
.sun
.star
.uno
.AnyConverter
;
29 import com
.sun
.star
.uno
.UnoRuntime
;
30 import com
.sun
.star
.uno
.XInterface
;
33 * Testing <code>com.sun.star.sheet.FunctionDescription</code>
36 * <li><code>Arguments</code></li>
37 * <li><code>Category</code></li>
38 * <li><code>Description</code></li>
39 * <li><code>Id</code></li>
40 * <li><code>Name</code></li>
42 * @see com.sun.star.sheet.FunctionDescription
44 public class _FunctionDescription
extends MultiMethodTest
{
46 public XPropertySet oObj
= null; // oObj filled by MultiMethodTest
48 public _FunctionDescription() {
51 public void _Arguments() {
52 // check if Service is available
53 XServiceInfo xInfo
= UnoRuntime
.queryInterface(XServiceInfo
.class, oObj
);
55 if ( ! xInfo
.supportsService
56 ( "com.sun.star.sheet.FunctionDescription" ) ) {
57 log
.println( "Service not available !" );
58 tRes
.tested( "Supported", false );
62 XMultiServiceFactory oDocMSF
= (XMultiServiceFactory
)tParam
.getMSF();
64 XInterface FA
= (XInterface
)oDocMSF
.
65 createInstance("com.sun.star.sheet.FunctionArgument");
66 FunctionArgument arg
= (FunctionArgument
)AnyConverter
.toObject
67 (FunctionArgument
.class, FA
);
69 arg
.Description
= "FunctionDescription argument description" ;
70 arg
.Name
= "FunctionDescriptiuon argument name" ;
71 arg
.IsOptional
= true ;
73 Object sValue
= oObj
.getPropertyValue("Arguments") ;
74 oObj
.setPropertyValue("Arguments", new FunctionArgument
[] {arg
}) ;
75 Object nValue
= oObj
.getPropertyValue("Arguments") ;
77 if (sValue
.equals(nValue
)) {
78 log
.println("Property 'Arguments' didn't change: OK") ;
79 tRes
.tested("Arguments", true) ;
81 log
.println("Readonly property 'Arguments' changed: Failed") ;
82 tRes
.tested("Arguments", false) ;
84 } catch (Exception e
) {
86 "Exception occurred while testing property 'Arguments'" );
87 e
.printStackTrace( log
);
88 tRes
.tested( "Arguments", false );
92 public void _Category() {
93 tryChangeProp("Category") ;
96 public void _Description() {
97 tryChangeProp( "Category" );
101 tryChangeProp( "Id" );
104 public void _Name() {
105 tryChangeProp( "Name" );
108 public void tryChangeProp( String name
) {
110 Object gValue
= null;
111 Object sValue
= null;
112 Object ValueToSet
= null;
116 //waitForAllThreads();
117 gValue
= oObj
.getPropertyValue( name
);
119 //waitForAllThreads();
120 ValueToSet
= ValueChanger
.changePValue( gValue
);
121 //waitForAllThreads();
122 oObj
.setPropertyValue( name
, ValueToSet
);
123 sValue
= oObj
.getPropertyValue( name
);
125 //check get-set methods
126 if( gValue
.equals( sValue
) ) {
127 log
.println( "Value for '"+name
+"' hasn't changed. OK." );
128 tRes
.tested( name
, true );
131 log
.println( "Property '" + name
+
132 "' changes it's value : Failed !" );
133 tRes
.tested( name
, false );
136 catch ( Exception e
) {
138 "Exception occurred while testing property '" + name
+ "'" );
139 e
.printStackTrace( log
);
140 tRes
.tested( name
, false );
142 } // end of changeProp
144 } //finish class _TextContent