Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwXBookmarks.java
blob3c830212e7cc4c0f195b4e9e94a36ea03f298ccd
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 concurrently.
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 ) throws Exception {
60 SOF = SOfficeFactory.getFactory( tParam.getMSF() );
61 log.println( "creating a textdocument" );
62 xTextDoc = SOF.createTextDoc( null );
65 /**
66 * Disposes text document.
68 @Override
69 protected void cleanup( TestParameters tParam, PrintWriter log ) {
70 log.println( " disposing xTextDoc " );
71 util.DesktopTools.closeDoc(xTextDoc);
74 /**
75 * Creating a TestEnvironment for the interfaces to be tested. Method
76 * creates two bookmarks and inserts them to the text document. Then bookmarks
77 * are gotten from text document using <code>XBookmarksSupplier</code>
78 * interface.
80 @Override
81 public TestEnvironment createTestEnvironment(
82 TestParameters Param, PrintWriter log ) throws StatusException {
83 XInterface oObj = null;
85 log.println( "creating a test environment" );
86 oObj = SOfficeFactory.createBookmark( xTextDoc );
87 SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj );
88 oObj = SOfficeFactory.createBookmark( xTextDoc );
89 SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj );
91 XBookmarksSupplier oBSupp = UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc);
92 XNameAccess oBookNA = oBSupp.getBookmarks();
93 oObj = oBookNA;
94 log.println( "creating a new environment for Bookmarks object" );
96 TestEnvironment tEnv = new TestEnvironment( oObj );
97 return tEnv;
98 } // finish method getTestEnvironment
100 } // finish class SwXBookmarks