bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScRecentFunctionsObj.java
blobaffd1dbaeefd193e1dce3fa3ea7a7739df8efc9e
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.XNameAccess;
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 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.sheet.RecentFunctions</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::sheet::XRecentFunctions</code></li>
42 * </ul>
43 * @see com.sun.star.sheet.RecentFunctions
44 * @see com.sun.star.sheet.XRecentFunctions
45 * @see ifc.sheet._XRecentFunctions
47 public class ScRecentFunctionsObj extends TestCase {
48 private XSpreadsheetDocument xSheetDoc = null;
50 /**
51 * Creates Spreadsheet document.
53 protected void initialize( TestParameters tParam, PrintWriter log ) {
54 SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF() );
56 try {
57 log.println( "creating a Spreadsheet document" );
58 xSheetDoc = SOF.createCalcDoc(null);
59 } catch ( com.sun.star.uno.Exception e ) {
60 // Some exception occurs.FAILED
61 e.printStackTrace( log );
62 throw new StatusException( "Couldn't create document", e );
66 /**
67 * Disposes Spreadsheet document.
69 protected void cleanup( TestParameters tParam, PrintWriter log ) {
70 log.println( " disposing xSheetDoc " );
71 XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSheetDoc) ;
72 util.DesktopTools.closeDoc(oComp);
75 /**
76 * Creating a Testenvironment for the interfaces to be tested.
77 * Creates an instance of the service
78 * <code>com.sun.star.sheet.RecentFunctions</code> and an instance of the
79 * service <code>com.sun.star.sheet.FunctionDescriptions</code>.
80 * Object relations created :
81 * <ul>
82 * <li> <code>'FUNCTIONLIST'</code> for
83 * {@link ifc.sheet._XRecentFunctions}(the second created instance)</li>
84 * </ul>
86 public synchronized TestEnvironment createTestEnvironment(
87 TestParameters Param, PrintWriter log ) throws StatusException {
89 XInterface oObj = null;
90 XInterface allFunctions = null;
92 // creation of testobject here
93 // first we write what we are intend to do to log file
94 log.println( "Creating a test environment" );
96 try {
97 log.println("Getting test object ") ;
98 XMultiServiceFactory oDocMSF = (XMultiServiceFactory)Param.getMSF();
99 oObj = (XInterface)oDocMSF.createInstance(
100 "com.sun.star.sheet.RecentFunctions");
101 allFunctions = (XInterface)oDocMSF.createInstance(
102 "com.sun.star.sheet.FunctionDescriptions");
104 log.println("Creating object - " +
105 ((oObj == null) ? "FAILED" : "OK"));
106 } catch (com.sun.star.uno.Exception e) {
107 e.printStackTrace(log) ;
108 throw new StatusException("Couldn't create instance", e);
111 TestEnvironment tEnv = new TestEnvironment( oObj );
113 // Other parameters required for interface tests
114 XNameAccess NA = UnoRuntime.queryInterface(XNameAccess.class, allFunctions);
115 tEnv.addObjRelation("FUNCTIONLIST", NA);
117 return tEnv;