bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdMasterPagesAccess.java
blob33662cc3283be5afae092c4d9847a395583f505c
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._sd;
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.drawing.XDrawPages;
30 import com.sun.star.drawing.XMasterPagesSupplier;
31 import com.sun.star.lang.XComponent;
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.drawing.MasterPages</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
41 * <li> <code>com::sun::star::container::XElementAccess</code></li>
42 * <li> <code>com::sun::star::drawing::XDrawPages</code></li>
43 * </ul>
44 * @see com.sun.star.drawing.MasterPages
45 * @see com.sun.star.container.XIndexAccess
46 * @see com.sun.star.container.XElementAccess
47 * @see com.sun.star.drawing.XDrawPages
48 * @see ifc.container._XIndexAccess
49 * @see ifc.container._XElementAccess
50 * @see ifc.drawing._XDrawPages
52 public class SdMasterPagesAccess extends TestCase {
53 XComponent xDrawDoc;
55 /**
56 * Creates Drawing document.
58 @Override
59 protected void initialize(TestParameters Param, PrintWriter log) {
60 // get a soffice factory object
61 SOfficeFactory SOF = SOfficeFactory.getFactory(
62 Param.getMSF());
64 try {
65 log.println( "creating a draw document" );
66 xDrawDoc = SOF.createDrawDoc(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 );
74 /**
75 * Disposes Drawing document.
77 @Override
78 protected void cleanup( TestParameters Param, PrintWriter log) {
79 log.println("disposing xDrawDoc");
80 util.DesktopTools.closeDoc(xDrawDoc);
83 /**
84 * Creating a Testenvironment for the interfaces to be tested.
85 * Retrieves the collection of the master pages from the document using the
86 * interface <code>XMasterPagesSupplier</code>. Inserts two new draw pages.
87 * The retrieved collection is the instance of the service
88 * <code>com.sun.star.drawing.MasterPages</code>.
89 * @see com.sun.star.drawing.XMasterPagesSupplier
90 * @see com.sun.star.drawing.MasterPages
92 @Override
93 public synchronized TestEnvironment createTestEnvironment(
94 TestParameters Param, PrintWriter log) throws StatusException {
96 log.println( "creating a test environment" );
98 // get the MasterPages here
99 log.println( "getting MasterPages" );
100 XMasterPagesSupplier oMPS = UnoRuntime.queryInterface( XMasterPagesSupplier.class, xDrawDoc);
101 XDrawPages oMP = oMPS.getMasterPages();
102 log.println( "insert MasterPages" );
103 oMP.insertNewByIndex(1);
104 oMP.insertNewByIndex(2);
105 XInterface oObj = oMP;
107 log.println( "creating a new environment for MasterPagesAccess object" );
108 TestEnvironment tEnv = new TestEnvironment( oObj );
110 return tEnv;
111 } // finish method createTestEnvironment
113 } // finish class SdMasterPagesAccess