bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScIndexEnumeration_FunctionDescriptionEnumeration.java
blob21e15cdbed6ebf98ec1d7ebdfe31b24439f21f71
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.container.XEnumerationAccess;
30 import com.sun.star.lang.XComponent;
31 import com.sun.star.lang.XMultiServiceFactory;
32 import com.sun.star.sheet.XSpreadsheetDocument;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 public class ScIndexEnumeration_FunctionDescriptionEnumeration extends TestCase {
37 private XSpreadsheetDocument xSheetDoc = null;
39 /**
40 * Creates Spreadsheet document.
42 protected void initialize( TestParameters tParam, PrintWriter log ) {
43 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
45 try {
46 log.println( "creating a Spreadsheet document" );
47 xSheetDoc = SOF.createCalcDoc(null);
48 } catch (com.sun.star.uno.Exception e) {
49 // Some exception occurs.FAILED
50 e.printStackTrace( log );
51 throw new StatusException( "Couldn't create document", e );
56 /**
57 * Disposes Spreadsheet document.
59 protected void cleanup( TestParameters tParam, PrintWriter log ) {
60 log.println( " disposing xSheetDoc " );
61 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
62 util.DesktopTools.closeDoc(oComp);
65 protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
67 XInterface oObj = null;
69 // creation of testobject here
70 // first we write what we are intend to do to log file
71 log.println( "Creating a test environment" );
73 log.println("Getting test object ") ;
75 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)Param.getMSF();
76 try {
77 oObj = (XInterface)oDocMSF.createInstance(
78 "com.sun.star.sheet.FunctionDescriptions");
79 log.println("Creating object - " +
80 ((oObj == null) ? "FAILED" : "OK"));
81 } catch (com.sun.star.uno.Exception e) {
82 e.printStackTrace(log) ;
83 throw new StatusException(
84 "Error getting test object from spreadsheet document", e);
87 XEnumerationAccess ea = UnoRuntime.queryInterface(XEnumerationAccess.class,oObj);
89 oObj = ea.createEnumeration();
91 log.println("ImplementationName: "+util.utils.getImplName(oObj));
92 // creating test environment
93 TestEnvironment tEnv = new TestEnvironment( oObj );
95 tEnv.addObjRelation("ENUM",ea);
97 return tEnv;