bump product version to 4.2.0.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sd / SdDrawPagesAccess.java
blob539f3f365aa66c6ebab82e75b09045123f3f92ab
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.lang.XMultiServiceFactory;
33 import com.sun.star.uno.UnoRuntime;
34 import com.sun.star.uno.XInterface;
36 /**
37 * Test for object which is represented by service
38 * <code>com.sun.star.drawing.DrawPages</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::drawing::XDrawPageExpander</code></li>
42 * <li> <code>com::sun::star::container::XIndexAccess</code></li>
43 * <li> <code>com::sun::star::drawing::XDrawPageSummarizer</code></li>
44 * <li> <code>com::sun::star::container::XElementAccess</code></li>
45 * <li> <code>com::sun::star::drawing::XDrawPages</code></li>
46 * </ul>
47 * @see com.sun.star.drawing.DrawPages
48 * @see com.sun.star.drawing.XDrawPageExpander
49 * @see com.sun.star.container.XIndexAccess
50 * @see com.sun.star.drawing.XDrawPageSummarizer
51 * @see com.sun.star.container.XElementAccess
52 * @see com.sun.star.drawing.XDrawPages
53 * @see ifc.drawing._XDrawPageExpander
54 * @see ifc.container._XIndexAccess
55 * @see ifc.drawing._XDrawPageSummarizer
56 * @see ifc.container._XElementAccess
57 * @see ifc.drawing._XDrawPages
59 public class SdDrawPagesAccess extends TestCase {
60 XComponent xDrawDoc;
62 /**
63 * Creates Drawing document.
65 protected void initialize(TestParameters Param, PrintWriter log) {
66 // get a soffice factory object
67 SOfficeFactory SOF = SOfficeFactory.getFactory(
68 (XMultiServiceFactory)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 protected void cleanup( TestParameters Param, PrintWriter log) {
84 log.println("disposing xDrawDoc");
85 util.DesktopTools.closeDoc(xDrawDoc);
88 /**
89 * Creating a Testenvironment for the interfaces to be tested.
90 * Retrieves the collection of the draw pages from the drawing document using
91 * the interface <code>XDrawPagesSupplier</code>. Inserts two new draw pages.
92 * The retrieved collection is the instance of the service
93 * <code>com.sun.star.drawing.DrawPages</code>.
94 * @see com.sun.star.drawing.DrawPages
96 public synchronized TestEnvironment createTestEnvironment(
97 TestParameters Param, PrintWriter log) throws StatusException {
99 // creation of testobject here
100 // first we write what we are intend to do to log file
101 log.println( "creating a test environment" );
103 // get the drawpage of drawing here
104 log.println( "getting Drawpages" );
105 XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc);
106 XDrawPages oDP = oDPS.getDrawPages();
107 oDP.insertNewByIndex(1);
108 oDP.insertNewByIndex(2);
109 XInterface oObj = oDP;
111 log.println( "creating a new environment for drawpage object" );
112 TestEnvironment tEnv = new TestEnvironment( oObj );
114 return tEnv;
115 } // finish method createTestEnvironment
118 } // finish class SdDrawPagesAccess