Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _qadevOOo / SelfTest.java
blobbc7b0d9fa01b93555a699ee78d629217d6c81cbf
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 .
18 package mod._qadevOOo;
20 import com.sun.star.uno.XInterface;
22 import java.io.PrintWriter;
24 import lib.StatusException;
25 import lib.TestCase;
26 import lib.TestEnvironment;
27 import lib.TestParameters;
29 import util.SOfficeFactory;
31 import com.sun.star.text.XSimpleText;
32 import com.sun.star.text.XTextCursor;
33 import com.sun.star.text.XTextDocument;
35 public class SelfTest extends TestCase
37 private XTextDocument xTextDoc = null;
39 @Override
40 protected void initialize(TestParameters tParam, PrintWriter log)
42 // get a soffice factory object
43 SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());
45 log.println("initialize the selftest");
46 try
48 log.println("creating a textdocument");
49 xTextDoc = SOF.createTextDoc(null);
51 catch (com.sun.star.uno.Exception e)
53 e.printStackTrace(log);
54 throw new StatusException("Couldn't create document", e);
58 /**
59 * Disposes text document.
61 @Override
62 protected void cleanup(TestParameters tParam, PrintWriter log)
64 log.println(" cleanup selftest");
65 util.DesktopTools.closeDoc(xTextDoc);
68 @Override
69 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log)
71 XInterface oObj = null;
72 log.println("creating a test environment");
74 // get the bodytext of textdocument here
75 log.println("getting the TextCursor");
77 final XSimpleText aText = xTextDoc.getText();
78 final XTextCursor textCursor = aText.createTextCursor();
79 oObj = textCursor;
81 TestEnvironment tEnv = new TestEnvironment(oObj);
83 return tEnv;