xref: /trunk/main/scripting/workben/ifc/scripting/_XFunctionProvider.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 package ifc.script.framework.provider;
29 
30 import drafts.com.sun.star.script.framework.provider.XFunctionProvider;
31 import drafts.com.sun.star.script.framework.provider.XFunction;
32 
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.lang.XMultiServiceFactory;
35 import com.sun.star.uno.XInterface;
36 import com.sun.star.ucb.XSimpleFileAccess;
37 import com.sun.star.uno.Exception;
38 import com.sun.star.beans.XPropertySet;
39 
40 import java.io.PrintWriter;
41 import lib.MultiMethodTest;
42 import lib.StatusException;
43 import lib.Parameters;
44 
45 import java.util.Collection;
46 import java.util.Iterator;
47 
48 public class _XFunctionProvider extends MultiMethodTest {
49 
50     public XFunctionProvider oObj = null;
51 
52     /**
53     * Retrieves object relation.
54     */
55     public void before() throws StatusException {
56     }
57 
58     public void _getFunction() {
59         boolean result = true;
60 
61         Collection c =
62             (Collection) tEnv.getObjRelation("_getFunction");
63 
64         Iterator tests;
65 
66         if (c != null) {
67             tests = c.iterator();
68 
69             while (tests.hasNext()) {
70                 result &= runGetFunctionTest((Parameters)tests.next());
71             }
72         }
73         else {
74             result = false;
75         }
76 
77         tRes.tested("getFunction()", result);
78     }
79 
80     private boolean runGetFunctionTest(Parameters testdata) {
81         String description = testdata.get("description");
82         String logicalname = testdata.get("logicalname");
83         String expected = testdata.get("expected");
84         String output = "";
85 
86         log.println(testdata.get("description"));
87 
88         XFunction function = oObj.getFunction(logicalname);
89 
90         if (function == null)
91             output = "null";
92         else
93             output = "XFunction.class";
94 
95         log.println("expected: " + expected + ", output: " + output);
96         if (output.equals(expected))
97             return true;
98         else
99             return false;
100     }
101 }
102