tdf#130857 qt weld: Introduce QtInstanceScrolledWindow
[LibreOffice.git] / qadevOOo / tests / java / mod / _sw / SwAccessibleHeaderView.java
blobb946304a048666b1dfe047d1d39df13725607c83
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._sw;
20 import java.io.PrintWriter;
22 import lib.StatusException;
23 import lib.TestCase;
24 import lib.TestEnvironment;
25 import lib.TestParameters;
26 import util.AccessibilityTools;
27 import util.WriterTools;
28 import util.utils;
30 import com.sun.star.accessibility.AccessibleRole;
31 import com.sun.star.accessibility.XAccessible;
32 import com.sun.star.awt.XWindow;
33 import com.sun.star.beans.XPropertySet;
34 import com.sun.star.container.XNameAccess;
35 import com.sun.star.frame.XModel;
36 import com.sun.star.style.XStyle;
37 import com.sun.star.style.XStyleFamiliesSupplier;
38 import com.sun.star.text.XTextDocument;
39 import com.sun.star.uno.AnyConverter;
40 import com.sun.star.uno.Type;
41 import com.sun.star.uno.UnoRuntime;
42 import com.sun.star.uno.XInterface;
44 /**
45 * Test of accessible object for a header of a text document.<p>
46 * Object implements the following interfaces :
47 * <ul>
48 * <li> <code>::com::sun::star::accessibility::XAccessible</code></li>
49 * </ul>
50 * @see com.sun.star.accessibility.XAccessible
52 public class SwAccessibleHeaderView extends TestCase {
54 XTextDocument xTextDoc = null;
56 /**
57 * Called to create an instance of <code>TestEnvironment</code>
58 * with an object to test and related objects. Obtains style
59 * <code>Standard</code> from style family <code>PageStyles</code>.
60 * Changes values of properties <code>HeaderIsOn</code> and
61 * <code>FooterIsOn</code> by <code>true</code>. Obtains accessible component
62 * for header.
64 * @param Param test parameters
65 * @param log writer to log information while testing
67 * @see TestEnvironment
68 * @see #getTestEnvironment
70 @Override
71 protected TestEnvironment createTestEnvironment(
72 TestParameters Param, PrintWriter log) throws Exception {
74 XInterface oObj = null;
75 XNameAccess PageStyles = null;
76 XStyle StdStyle = null;
78 XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc);
79 XNameAccess StyleFamNames = StyleFam.getStyleFamilies();
81 // obtains style 'Standard' from style family 'PageStyles'
82 PageStyles = (XNameAccess) AnyConverter.toObject(
83 new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles"));
84 StdStyle = (XStyle) AnyConverter.toObject(
85 new Type(XStyle.class),PageStyles.getByName("Standard"));
87 final XPropertySet PropSet = UnoRuntime.queryInterface( XPropertySet.class, StdStyle);
89 // changing/getting some properties
90 log.println( "Switching on header" );
91 PropSet.setPropertyValue("HeaderIsOn", Boolean.TRUE);
93 XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc);
95 XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel);
96 XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);
98 oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.HEADER);
100 log.println("ImplementationName " + utils.getImplName(oObj));
101 AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE));
103 TestEnvironment tEnv = new TestEnvironment(oObj);
105 tEnv.addObjRelation("EventProducer",
106 new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){
107 public void fireEvent() {
108 try {
109 PropSet.setPropertyValue("HeaderLeftMargin",
110 Integer.valueOf(1000));
111 } catch (com.sun.star.uno.Exception e) {
112 e.printStackTrace();
113 throw new StatusException("Can't change footer.", e);
118 return tEnv;
123 * Called while disposing a <code>TestEnvironment</code>.
124 * Disposes text document.
125 * @param Param test parameters
126 * @param log writer to log information while testing
128 @Override
129 protected void cleanup( TestParameters Param, PrintWriter log) {
130 log.println("dispose text document");
131 util.DesktopTools.closeDoc(xTextDoc);
135 * Called while the <code>TestCase</code> initialization.
136 * Creates a text document.
138 * @param Param test parameters
139 * @param log writer to log information while testing
141 * @see #initializeTestCase
143 @Override
144 protected void initialize(TestParameters Param, PrintWriter log) throws Exception {
145 log.println( "creating a text document" );
146 xTextDoc = WriterTools.createTextDoc(Param.getMSF());