bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScFunctionListObj.java
blob16c8a7b65e8ec488989bec64e255bf1744141afa
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 mod._sc;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
29 import com.sun.star.lang.XComponent;
30 import com.sun.star.lang.XMultiServiceFactory;
31 import com.sun.star.sheet.XSpreadsheetDocument;
32 import com.sun.star.uno.UnoRuntime;
33 import com.sun.star.uno.XInterface;
35 /**
36 * Test for object which is represented by service
37 * <code>com.sun.star.sheet.FunctionDescriptions</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::container::XNameAccess</code></li>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::sheet::XFunctionDescriptions</code></li>
43 * <li> <code>com::sun::star::container::XElementAccess</code></li>
44 * </ul>
45 * @see com.sun.star.sheet.FunctionDescriptions
46 * @see com.sun.star.container.XNameAccess
47 * @see com.sun.star.container.XIndexAccess
48 * @see com.sun.star.sheet.XFunctionDescriptions
49 * @see com.sun.star.container.XElementAccess
50 * @see ifc.container._XNameAccess
51 * @see ifc.container._XIndexAccess
52 * @see ifc.sheet._XFunctionDescriptions
53 * @see ifc.container._XElementAccess
55 public class ScFunctionListObj extends TestCase {
56 private XSpreadsheetDocument xSheetDoc = null;
58 /**
59 * Creates Spreadsheet document.
61 protected void initialize( TestParameters tParam, PrintWriter log ) {
62 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
64 try {
65 log.println( "creating a Spreadsheet document" );
66 xSheetDoc = SOF.createCalcDoc(null);
67 } catch (com.sun.star.uno.Exception e) {
68 // Some exception occurs.FAILED
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
75 /**
76 * Disposes Spreadsheet document.
78 protected void cleanup( TestParameters tParam, PrintWriter log ) {
79 log.println( " disposing xSheetDoc " );
80 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
81 util.DesktopTools.closeDoc(oComp);
84 /**
85 * Creating a Testenvironment for the interfaces to be tested.
86 * Creates an instance of the service
87 * <code>com.sun.star.sheet.FunctionDescriptions</code>.
88 * @see com.sun.star.sheet.FunctionDescriptions
90 public synchronized TestEnvironment createTestEnvironment(
91 TestParameters Param, PrintWriter log) throws StatusException {
93 XInterface oObj = null;
95 // creation of testobject here
96 // first we write what we are intend to do to log file
97 log.println( "Creating a test environment" );
99 log.println("Getting test object ") ;
101 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)Param.getMSF();
102 try {
103 oObj = (XInterface)oDocMSF.createInstance(
104 "com.sun.star.sheet.FunctionDescriptions");
105 log.println("Creating object - " +
106 ((oObj == null) ? "FAILED" : "OK"));
107 } catch (com.sun.star.uno.Exception e) {
108 e.printStackTrace(log) ;
109 throw new StatusException(
110 "Error getting test object from spreadsheet document", e);
113 TestEnvironment tEnv = new TestEnvironment( oObj );
115 return tEnv;