Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXPrintSettings.java
blob8e5690f8b7e7b7ff210c863239998eb6602f3b7e
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._sw;
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.XMultiServiceFactory;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
33 import com.sun.star.view.XPrintSettingsSupplier;
35 /**
36 * Test for object which is represented by service
37 * <code>com.sun.star.text.PrintSettings</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::text::PrintSettings</code></li>
41 * </ul> <p>
42 * This object test <b> is NOT </b> designed to be run in several
43 * threads concurently.
44 * @see com.sun.star.text.PrintSettings
45 * @see ifc.text._PrintSettings
47 public class SwXPrintSettings extends TestCase {
48 XTextDocument xTextDoc;
50 /**
51 * Creates text document.
53 @Override
54 protected void initialize( TestParameters tParam, PrintWriter log ) {
55 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
56 try {
57 log.println( "creating a textdocument" );
58 xTextDoc = SOF.createTextDoc( null );
59 } catch ( com.sun.star.uno.Exception e ) {
60 e.printStackTrace( log );
61 throw new StatusException( "Couldn't create document", e );
65 /**
66 * Disposes text document.
68 @Override
69 protected void cleanup( TestParameters tParam, PrintWriter log ) {
70 log.println( " disposing xTextDoc " );
71 util.DesktopTools.closeDoc(xTextDoc);
74 /**
75 * Creating a Testenvironment for the interfaces to be tested.
76 * Creates an instance of the service
77 * <code>com.sun.star.text.GlobalSettings</code>, then print settings are
78 * gotten using <code>XPrintSettingsSupplier</code> interface.
80 @Override
81 public TestEnvironment createTestEnvironment(
82 TestParameters tParam, PrintWriter log ) throws StatusException {
83 XInterface oObj = null;
84 Object oInst = null;
86 log.println( "creating a test environment" );
87 try {
88 XMultiServiceFactory myMSF = tParam.getMSF();
89 oInst = myMSF.createInstance("com.sun.star.text.GlobalSettings");
90 } catch ( com.sun.star.uno.Exception e ){
91 log.println("Couldn't create instance!" + e);
92 e.printStackTrace( log );
93 throw new StatusException( "Couldn't create instance!", e );
95 XPrintSettingsSupplier xPSS = UnoRuntime.queryInterface(XPrintSettingsSupplier.class, oInst);
96 oObj = xPSS.getPrintSettings();
98 TestEnvironment tEnv = new TestEnvironment(oObj);
99 return tEnv;
100 } // finish method getTestEnvironment
102 } // finish class SwXPrintSettings