Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / ifc / sheet / _FunctionDescription.java
blob800d74514cb1d463ff837795d9eaf0b87c3cc397
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 void _Arguments() {
49 // check if Service is available
50 XServiceInfo xInfo = UnoRuntime.queryInterface(XServiceInfo.class, oObj );
52 if ( ! xInfo.supportsService
53 ( "com.sun.star.sheet.FunctionDescription" ) ) {
54 log.println( "Service not available !" );
55 tRes.tested( "Supported", false );
58 try {
59 XMultiServiceFactory oDocMSF = tParam.getMSF();
61 XInterface FA = (XInterface)oDocMSF.
62 createInstance("com.sun.star.sheet.FunctionArgument");
63 FunctionArgument arg = (FunctionArgument)AnyConverter.toObject
64 (FunctionArgument.class, FA);
66 arg.Description = "FunctionDescription argument description" ;
67 arg.Name = "FunctionDescriptiuon argument name" ;
68 arg.IsOptional = true ;
70 Object sValue = oObj.getPropertyValue("Arguments") ;
71 oObj.setPropertyValue("Arguments", new FunctionArgument[] {arg}) ;
72 Object nValue = oObj.getPropertyValue("Arguments") ;
74 if (sValue.equals(nValue)) {
75 log.println("Property 'Arguments' didn't change: OK") ;
76 tRes.tested("Arguments", true) ;
77 } else {
78 log.println("Readonly property 'Arguments' changed: Failed") ;
79 tRes.tested("Arguments", false) ;
81 } catch (Exception e) {
82 log.println(
83 "Exception occurred while testing property 'Arguments'" );
84 e.printStackTrace( log );
85 tRes.tested( "Arguments", false );
89 public void _Category() {
90 tryChangeProp("Category") ;
93 public void _Description() {
94 tryChangeProp( "Category" );
97 public void _Id() {
98 tryChangeProp( "Id" );
101 public void _Name() {
102 tryChangeProp( "Name" );
105 public void tryChangeProp( String name ) {
107 Object gValue = null;
108 Object sValue = null;
109 Object ValueToSet = null;
112 try {
113 gValue = oObj.getPropertyValue( name );
115 ValueToSet = ValueChanger.changePValue( gValue );
116 oObj.setPropertyValue( name, ValueToSet );
117 sValue = oObj.getPropertyValue( name );
119 //check get-set methods
120 if( gValue.equals( sValue ) ) {
121 log.println( "Value for '"+name+"' hasn't changed. OK." );
122 tRes.tested( name, true );
124 else {
125 log.println( "Property '" + name +
126 "' changes its value : Failed !" );
127 tRes.tested( name, false );
130 catch ( Exception e ) {
131 log.println(
132 "Exception occurred while testing property '" + name + "'" );
133 e.printStackTrace( log );
134 tRes.tested( name, false );
136 } // end of changeProp
138 } //finish class _TextContent