bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXBookmark.java
blobd58df6ba2bced862fee83bb1576a2abcf2dd50a6
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.text.XTextContent;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
34 /**
35 * Test for object which is represented by service
36 * <code>com.sun.star.text.Bookmark</code>. <p>
37 * Object implements the following interfaces :
38 * <ul>
39 * <li> <code>com::sun::star::container::XNamed</code></li>
40 * <li> <code>com::sun::star::lang::XComponent</code></li>
41 * <li> <code>com::sun::star::text::XTextContent</code></li>
42 * <li> <code>com::sun::star::text::TextContent</code></li>
43 * </ul> <p>
44 * This object test <b> is NOT </b> designed to be run in several
45 * threads concurently.
46 * @see com.sun.star.container.XNamed
47 * @see com.sun.star.lang.XComponent
48 * @see com.sun.star.text.XTextContent
49 * @see com.sun.star.text.TextContent
50 * @see ifc.container._XNamed
51 * @see ifc.lang._XComponent
52 * @see ifc.text._XTextContent
53 * @see ifc.text._TextContent
55 public class SwXBookmark extends TestCase {
56 XTextDocument xTextDoc;
57 SOfficeFactory SOF;
59 /**
60 * Creates text document.
62 @Override
63 protected void initialize( TestParameters tParam, PrintWriter log ) {
64 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
65 try {
66 log.println( "creating a textdocument" );
67 xTextDoc = SOF.createTextDoc( null );
68 } catch ( com.sun.star.uno.Exception e ) {
69 e.printStackTrace( log );
70 throw new StatusException( "Couldn't create document", e );
74 /**
75 * Disposes text document.
77 @Override
78 protected void cleanup( TestParameters tParam, PrintWriter log ) {
79 log.println( " disposing xTextDoc " );
80 util.DesktopTools.closeDoc(xTextDoc);
83 /**
84 * Creating a Testenvironment for the interfaces to be tested. After creating
85 * a bookmark, it is inserted to the text document.
87 @Override
88 protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) {
89 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF());
90 XInterface oObj = null;
91 Object instance = null;
92 log.println( "creating a test environment" );
93 oObj = SOfficeFactory.createBookmark( xTextDoc );
94 SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj );
95 instance = SOF.createInstance(xTextDoc,"com.sun.star.text.Bookmark");
96 log.println( "creating a new environment for bodytext object" );
97 TestEnvironment tEnv = new TestEnvironment( oObj );
99 util.dbg.printInterfaces((XInterface) instance);
101 tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance));
102 tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor());
103 return tEnv;
104 } // finish method getTestEnvironment
107 } // finish class SwXBookmark