From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../tests/java/mod/_sc/ScAccessibleDocument.java | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java (limited to 'qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java') diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java new file mode 100644 index 000000000..348e8a6bc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java @@ -0,0 +1,143 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by accessible component of + * a spreadsheet document. + * + * Object implements the following interfaces : + *

+ * + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleSelection + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessibleDocument extends TestCase { + + static XComponent xSpreadsheetDoc = null; + + /** + * Called to create an instance of TestEnvironment + * with an object to test and related objects. + * Obtains accessible object for the spreadsheet document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + // get the drawpage of drawing here + log.println( "getting Drawpages" ); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT, ""); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XWindow xDocWin = xWindow; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle rect = xDocWin.getPosSize(); + xDocWin.setPosSize(rect.X,rect.Y,rect.Height,rect.Width-10,com.sun.star.awt.PosSize.POSSIZE); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a TestEnvironment. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + util.DesktopTools.closeDoc(xSpreadsheetDoc); + } + + /** + * Called while the TestCase initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all TestEnvironments. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println("creating a spreadsheetdocument"); + String url = utils.getFullTestURL("calcshapes.sxc"); + log.println("loading document "+url); + xSpreadsheetDoc = SOF.loadDocument(url); + util.utils.waitForEventIdle(Param.getMSF()); + } + +} -- cgit v1.2.3