bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _FunctionDescription.java
blob8787a2844d401fd60ab9b28263e772bdc8b96c7a
1 /*
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 .
19 package ifc.sheet;
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;
32 /**
33 * Testing <code>com.sun.star.sheet.FunctionDescription</code>
34 * service properties:
35 * <ul>
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>
41 * </ul> <p>
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 );
61 try {
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) ;
80 } else {
81 log.println("Readonly property 'Arguments' changed: Failed") ;
82 tRes.tested("Arguments", false) ;
84 } catch (Exception e) {
85 log.println(
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" );
100 public void _Id() {
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;
115 try {
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 );
130 else {
131 log.println( "Property '" + name +
132 "' changes it's value : Failed !" );
133 tRes.tested( name, false );
136 catch ( Exception e ) {
137 log.println(
138 "Exception occurred while testing property '" + name + "'" );
139 e.printStackTrace( log );
140 tRes.tested( name, false );
142 } // end of changeProp
144 } //finish class _TextContent