bump product version to 5.0.4.1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXBookmarks.java
blob6ce603e8d9f5b56b682b8196c05eba64765cc690
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.container.XNameAccess;
30 import com.sun.star.text.XBookmarksSupplier;
31 import com.sun.star.text.XTextContent;
32 import com.sun.star.text.XTextDocument;
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.text.Bookmarks</code>. <p>
39 * Object implements the following interfaces :
40 * <ul>
41 * <li> <code>com::sun::star::container::XNameAccess</code></li>
42 * <li> <code>com::sun::star::container::XElementAccess</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.XNameAccess
47 * @see com.sun.star.container.XElementAccess
48 * @see ifc.container._XNameAccess
49 * @see ifc.container._XElementAccess
51 public class SwXBookmarks extends TestCase {
52 XTextDocument xTextDoc;
53 SOfficeFactory SOF;
55 /**
56 * Creates text document.
58 @Override
59 protected void initialize( TestParameters tParam, PrintWriter log ) {
60 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
61 try {
62 log.println( "creating a textdocument" );
63 xTextDoc = SOF.createTextDoc( null );
64 } catch ( com.sun.star.uno.Exception e ) {
65 e.printStackTrace( log );
66 throw new StatusException( "Couldn't create document", e );
70 /**
71 * Disposes text document.
73 @Override
74 protected void cleanup( TestParameters tParam, PrintWriter log ) {
75 log.println( " disposing xTextDoc " );
76 util.DesktopTools.closeDoc(xTextDoc);
79 /**
80 * Creating a Testenvironment for the interfaces to be tested. Method
81 * creates two bookmarks and inserts them to the text document. Then bookmarks
82 * are gotten from text document using <code>XBookmarksSupplier</code>
83 * interface.
85 @Override
86 public synchronized TestEnvironment createTestEnvironment(
87 TestParameters Param, PrintWriter log ) throws StatusException {
88 XInterface oObj = null;
90 log.println( "creating a test environment" );
91 oObj = SOfficeFactory.createBookmark( xTextDoc );
92 SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj );
93 oObj = SOfficeFactory.createBookmark( xTextDoc );
94 SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj );
96 XBookmarksSupplier oBSupp = UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc);
97 XNameAccess oBookNA = oBSupp.getBookmarks();
98 oObj = oBookNA;
99 log.println( "creating a new environment for Bookmarks object" );
101 TestEnvironment tEnv = new TestEnvironment( oObj );
102 return tEnv;
103 } // finish method getTestEnvironment
105 } // finish class SwXBookmarks