bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdDrawPagesAccess.java
blob230e794b10426657e3d4e82a2f6821ab999572ac
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.XDrawPagesSupplier;
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.DrawPages</code>. <p>
38 * Object implements the following interfaces :
39 * <ul>
40 * <li> <code>com::sun::star::drawing::XDrawPageExpander</code></li>
41 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
42 * <li> <code>com::sun::star::drawing::XDrawPageSummarizer</code></li>
43 * <li> <code>com::sun::star::container::XElementAccess</code></li>
44 * <li> <code>com::sun::star::drawing::XDrawPages</code></li>
45 * </ul>
46 * @see com.sun.star.drawing.DrawPages
47 * @see com.sun.star.drawing.XDrawPageExpander
48 * @see com.sun.star.container.XIndexAccess
49 * @see com.sun.star.drawing.XDrawPageSummarizer
50 * @see com.sun.star.container.XElementAccess
51 * @see com.sun.star.drawing.XDrawPages
52 * @see ifc.drawing._XDrawPageExpander
53 * @see ifc.container._XIndexAccess
54 * @see ifc.drawing._XDrawPageSummarizer
55 * @see ifc.container._XElementAccess
56 * @see ifc.drawing._XDrawPages
58 public class SdDrawPagesAccess extends TestCase {
59 XComponent xDrawDoc;
61 /**
62 * Creates Drawing document.
64 @Override
65 protected void initialize(TestParameters Param, PrintWriter log) {
66 // get a soffice factory object
67 SOfficeFactory SOF = SOfficeFactory.getFactory(
68 Param.getMSF());
70 try {
71 log.println( "creating a draw document" );
72 xDrawDoc = SOF.createDrawDoc(null);
73 } catch (com.sun.star.uno.Exception e) {
74 // Some exception occurs.FAILED
75 e.printStackTrace(log);
76 throw new StatusException("Couldn't create document", e);
80 /**
81 * Disposes Drawing document.
83 @Override
84 protected void cleanup( TestParameters Param, PrintWriter log) {
85 log.println("disposing xDrawDoc");
86 util.DesktopTools.closeDoc(xDrawDoc);
89 /**
90 * Creating a Testenvironment for the interfaces to be tested.
91 * Retrieves the collection of the draw pages from the drawing document using
92 * the interface <code>XDrawPagesSupplier</code>. Inserts two new draw pages.
93 * The retrieved collection is the instance of the service
94 * <code>com.sun.star.drawing.DrawPages</code>.
95 * @see com.sun.star.drawing.DrawPages
97 @Override
98 public synchronized TestEnvironment createTestEnvironment(
99 TestParameters Param, PrintWriter log) throws StatusException {
101 // creation of testobject here
102 // first we write what we are intend to do to log file
103 log.println( "creating a test environment" );
105 // get the drawpage of drawing here
106 log.println( "getting Drawpages" );
107 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc);
108 XDrawPages oDP = oDPS.getDrawPages();
109 oDP.insertNewByIndex(1);
110 oDP.insertNewByIndex(2);
111 XInterface oObj = oDP;
113 log.println( "creating a new environment for drawpage object" );
114 TestEnvironment tEnv = new TestEnvironment( oObj );
116 return tEnv;
117 } // finish method createTestEnvironment
120 } // finish class SdDrawPagesAccess