tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _fwk / LayoutManager.java
blob9193fca43bf3f47d6a1853285731a097f8d0dd2e
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._fwk;
21 import com.sun.star.beans.XPropertySet;
22 import com.sun.star.frame.XFrame;
23 import com.sun.star.lang.XMultiServiceFactory;
24 import com.sun.star.uno.UnoRuntime;
25 import com.sun.star.uno.XInterface;
26 import java.io.PrintWriter;
27 import com.sun.star.text.XText;
28 import com.sun.star.text.XTextCursor;
29 import com.sun.star.text.XTextDocument;
30 import com.sun.star.util.XCloseable;
31 import lib.TestCase;
32 import lib.TestEnvironment;
33 import lib.TestParameters;
34 import util.WriterTools;
36 /**
38 public class LayoutManager extends TestCase {
39 XInterface xManager = null;
40 XTextDocument xTextDoc;
42 /**
43 * Cleanup: close the created document
44 * @param tParam The test parameters.
45 * @param log The log writer.
47 @Override
48 protected void cleanup(TestParameters tParam, PrintWriter log) {
49 log.println(" disposing xTextDoc ");
51 try {
52 XCloseable closer = UnoRuntime.queryInterface(
53 XCloseable.class, xTextDoc);
54 closer.close(true);
55 } catch (com.sun.star.util.CloseVetoException e) {
56 log.println("couldn't close document");
57 } catch (com.sun.star.lang.DisposedException e) {
58 log.println("couldn't close document");
62 /**
63 * Create test environment:
64 * <ul>
65 * <li>Create test doc</li>
66 * <li>Get the frame</li>
67 * <li>Get the LayoutManager from the frame</li>
68 * </ul>
69 * @param tParam The test parameters.
70 * @param log The log writer.
71 * @return The test environment.
73 @Override
74 protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception {
75 TestEnvironment tEnv = null;
76 XMultiServiceFactory xMSF = tParam.getMSF();
78 log.println("Creating instance...");
80 xTextDoc = WriterTools.createTextDoc(xMSF);
82 XText xText = xTextDoc.getText();
83 XTextCursor xTextCursor = xText.createTextCursor();
85 for (int i = 0; i < 11; i++) {
86 xText.insertString(xTextCursor, "A sample text and why not? ", false);
89 XFrame xFrame = xTextDoc.getCurrentController().getFrame();
90 XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xFrame);
91 Object any = xProp.getPropertyValue("LayoutManager");
92 xManager = UnoRuntime.queryInterface(XInterface.class, any);
94 // just to make sure, it's the right one.
95 log.println("TestObject: " + util.utils.getImplName(xManager));
96 tEnv = new TestEnvironment(xManager);
98 tEnv.addObjRelation("XLayoutManager.TextDoc", xTextDoc);
99 tEnv.addObjRelation("XLayoutManager.Frame",xFrame);
101 return tEnv;