bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sc / ScSortDescriptorBase.java
blobc1eecc8304b37581ff83336130f3beab13931097
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.XIndexAccess;
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.sheet.XSpreadsheets;
34 import com.sun.star.uno.UnoRuntime;
35 import com.sun.star.uno.XInterface;
36 import com.sun.star.util.XSortable;
39 /**
41 * initial description
42 * @see com.sun.star.beans.XPropertySet
43 * @see com.sun.star.sheet.SheetSortDescriptor
46 public class ScSortDescriptorBase extends TestCase {
48 private XSpreadsheetDocument xSpreadsheetDoc;
50 /**
51 * in general this method creates a testdocument
53 * @param tParam class which contains additional test parameters
54 * @param log class to log the test state and result
57 * @see TestParameters
58 * @see PrintWriter
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 xSpreadsheetDoc = 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 * in general this method disposes the testenvironment and document
78 * @param tParam class which contains additional test parameters
79 * @param log class to log the test state and result
82 * @see TestParameters
83 * @see PrintWriter
86 protected void cleanup( TestParameters tParam, PrintWriter log ) {
87 log.println( " disposing xSheetDoc " );
88 XComponent oComp = UnoRuntime.queryInterface
89 (XComponent.class, xSpreadsheetDoc) ;
90 util.DesktopTools.closeDoc(oComp);
95 /**
96 * creating a Testenvironment for the interfaces to be tested
98 * @param tParam class which contains additional test parameters
99 * @param log class to log the test state and result
101 * @return Status class
103 * @see TestParameters
104 * @see PrintWriter
106 public TestEnvironment createTestEnvironment( TestParameters tParam,
107 PrintWriter log )
108 throws StatusException {
110 XInterface oObj = null;
111 XSortable xSORT = null;
113 // creation of testobject here
114 // first we write what we are intend to do to log file
115 log.println( "creating a test environment" );
117 // create testobject here
119 log.println("getting sheets");
120 XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets();
121 if (xSpreadsheets == null) log.println("FAILED"); else log.println("OK");
123 log.println("getting a sheet");
124 XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
126 try {
127 oObj = UnoRuntime.queryInterface(XInterface.class,oIndexAccess.getByIndex(0));
128 } catch (Exception e) {
129 throw new StatusException( "Couldn't get a spreadsheet", e);
132 xSORT = UnoRuntime.queryInterface(XSortable.class,oObj);
134 TestEnvironment tEnv = new TestEnvironment(oObj);
135 tEnv.addObjRelation("xSORT",xSORT);
136 return tEnv;
138 } // finish method getTestEnvironment
140 } // finish class ScSortDescriptorBase