Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScConsolidationDescriptor.java
blobef522027a052f2cfe9b9674ea70c0f4e4918525c
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.sheet.XConsolidatable;
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.ConsolidationDescriptor</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::sheet::XConsolidationDescriptor</code></li>
41 * </ul>
42 * @see com.sun.star.sheet.ConsolidationDescriptor
43 * @see com.sun.star.sheet.XConsolidationDescriptor
44 * @see ifc.sheet._XConsolidationDescriptor
46 public class ScConsolidationDescriptor extends TestCase {
47 private XSpreadsheetDocument xSheetDoc = null;
49 /**
50 * Creates Spreadsheet document.
52 @Override
53 protected void initialize( TestParameters tParam, PrintWriter log ) {
54 // get a soffice factory object
55 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
57 try {
58 log.println( "creating a sheetdocument" );
59 xSheetDoc = SOF.createCalcDoc(null);
60 } catch (com.sun.star.uno.Exception e) {
61 // Some exception occurs.FAILED
62 e.printStackTrace( log );
63 throw new StatusException( "Couldn't create document", e );
67 /**
68 * Disposes Spreadsheet document.
70 @Override
71 protected void cleanup( TestParameters tParam, PrintWriter log ) {
72 log.println( " disposing xSheetDoc " );
73 XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
74 util.DesktopTools.closeDoc(oComp);
77 /**
78 * Creating a Testenvironment for the interfaces to be tested.
79 * Retrieves a collection of spreadsheets from a document
80 * and takes one of them. Creates consolidation description using
81 * the interface <code>XConsolidatable</code>.
82 * This description is the instance of the service
83 * <code>com.sun.star.sheet.ConsolidationDescriptor</code>.
84 * @see com.sun.star.sheet.ConsolidationDescriptor
85 * @see com.sun.star.sheet.XConsolidatable
87 @Override
88 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
90 XInterface oObj = 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 XConsolidatable xConsolidate = UnoRuntime.queryInterface(XConsolidatable.class, xSheetDoc);
98 oObj = xConsolidate.createConsolidationDescriptor(true);
99 // create testobject here
100 log.println("creating a new environment for object");
101 TestEnvironment tEnv = new TestEnvironment(oObj);
103 return tEnv;
104 } // finish method getTestEnvironment
106 } // finish class ScConsolidationDescriptor