1*cd519653SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cd519653SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cd519653SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cd519653SAndrew Rist  * distributed with this work for additional information
6*cd519653SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cd519653SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cd519653SAndrew Rist  * "License"); you may not use this file except in compliance
9*cd519653SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cd519653SAndrew Rist  *
11*cd519653SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cd519653SAndrew Rist  *
13*cd519653SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cd519653SAndrew Rist  * software distributed under the License is distributed on an
15*cd519653SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cd519653SAndrew Rist  * KIND, either express or implied.  See the License for the
17*cd519653SAndrew Rist  * specific language governing permissions and limitations
18*cd519653SAndrew Rist  * under the License.
19*cd519653SAndrew Rist  *
20*cd519653SAndrew Rist  *************************************************************/
21*cd519653SAndrew Rist 
22*cd519653SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.script.framework.provider;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import drafts.com.sun.star.script.framework.provider.XFunctionProvider;
27cdf0e10cSrcweir import drafts.com.sun.star.script.framework.provider.XFunction;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
30cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
31cdf0e10cSrcweir import com.sun.star.uno.XInterface;
32cdf0e10cSrcweir import com.sun.star.ucb.XSimpleFileAccess;
33cdf0e10cSrcweir import com.sun.star.uno.Exception;
34cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir import java.io.PrintWriter;
37cdf0e10cSrcweir import lib.MultiMethodTest;
38cdf0e10cSrcweir import lib.StatusException;
39cdf0e10cSrcweir import lib.Parameters;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir import java.util.Collection;
42cdf0e10cSrcweir import java.util.Iterator;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir public class _XFunctionProvider extends MultiMethodTest {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     public XFunctionProvider oObj = null;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     /**
49cdf0e10cSrcweir     * Retrieves object relation.
50cdf0e10cSrcweir     */
before()51cdf0e10cSrcweir     public void before() throws StatusException {
52cdf0e10cSrcweir     }
53cdf0e10cSrcweir 
_getFunction()54cdf0e10cSrcweir     public void _getFunction() {
55cdf0e10cSrcweir         boolean result = true;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir         Collection c =
58cdf0e10cSrcweir             (Collection) tEnv.getObjRelation("_getFunction");
59cdf0e10cSrcweir 
60cdf0e10cSrcweir         Iterator tests;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         if (c != null) {
63cdf0e10cSrcweir             tests = c.iterator();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir             while (tests.hasNext()) {
66cdf0e10cSrcweir                 result &= runGetFunctionTest((Parameters)tests.next());
67cdf0e10cSrcweir             }
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir         else {
70cdf0e10cSrcweir             result = false;
71cdf0e10cSrcweir         }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         tRes.tested("getFunction()", result);
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir 
runGetFunctionTest(Parameters testdata)76cdf0e10cSrcweir     private boolean runGetFunctionTest(Parameters testdata) {
77cdf0e10cSrcweir         String description = testdata.get("description");
78cdf0e10cSrcweir         String logicalname = testdata.get("logicalname");
79cdf0e10cSrcweir         String expected = testdata.get("expected");
80cdf0e10cSrcweir         String output = "";
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         log.println(testdata.get("description"));
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         XFunction function = oObj.getFunction(logicalname);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         if (function == null)
87cdf0e10cSrcweir             output = "null";
88cdf0e10cSrcweir         else
89cdf0e10cSrcweir             output = "XFunction.class";
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         log.println("expected: " + expected + ", output: " + output);
92cdf0e10cSrcweir         if (output.equals(expected))
93cdf0e10cSrcweir             return true;
94cdf0e10cSrcweir         else
95cdf0e10cSrcweir             return false;
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir }
98