diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /qadevOOo/tests/java/mod/_sd | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qadevOOo/tests/java/mod/_sd')
27 files changed, 4732 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_sd/AccessibleDrawDocumentView.java b/qadevOOo/tests/java/mod/_sd/AccessibleDrawDocumentView.java new file mode 100644 index 000000000..42b63f593 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/AccessibleDrawDocumentView.java @@ -0,0 +1,149 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DrawTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XDrawView; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleDrawDocumentView extends TestCase { + + XComponent xDrawDoc; + + /** + * Called to create an instance of <code>TestEnvironment</code> with an + * object to test and related objects. Subclasses should implement this + * method to provide the implementation and related objects. The method is + * called from <code>getTestEnvironment()</code>. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + final XDrawPage fDP2 = oDPn.insertNewByIndex(1); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class, oDPn); + XDrawPage oDP = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //get a Shape + log.println( "inserting a Shape" ); + XShape oShape = SOF.createShape(xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow ( + aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + //com.sun.star.accessibility.AccessibleRole + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); + + log.println("ImplementationName "+utils.getImplName(oObj)); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XDrawView xView = UnoRuntime.queryInterface + (XDrawView.class, aModel.getCurrentController()) ; + final XDrawPage fDP1 = oDP; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + xView.setCurrentPage(fDP2); + xView.setCurrentPage(fDP1); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing Draw document"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + +} diff --git a/qadevOOo/tests/java/mod/_sd/AccessibleOutlineView.java b/qadevOOo/tests/java/mod/_sd/AccessibleOutlineView.java new file mode 100644 index 000000000..5765c87d1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/AccessibleOutlineView.java @@ -0,0 +1,152 @@ +/* + * 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._sd; + +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.XWindow; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +public class AccessibleOutlineView extends TestCase { + + XModel aModel = null; + XComponent xImpressDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> with an + * object to test and related objects. Subclasses should implement this + * method to provide the implementation and related objects. The method is + * called from <code>getTestEnvironment()</code>. + * + * @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; + + XWindow xWindow = AccessibilityTools.getCurrentWindow ( + aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); + + log.println("ImplementationName "+utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, aModel); + final XDrawPages oDPn = oDPS.getDrawPages(); + + tEnv.addObjRelation("EventMsg","Inserting a drawpage via API has no "+ + "effect to the outline view #101050# \r\n"+ + "Therefore the listener isn't called"); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + oDPn.insertNewByIndex(1); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log ) { + log.println("disposing Impress document"); + util.DesktopTools.closeDoc(xImpressDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + + XInterface oObj = aModel.getCurrentController(); + + //Change to Outline view + try { + String aSlotID = "slot:27010"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, oObj ); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF(). + createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0); + if( xDispatcher != null ) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + } + util.utils.waitForEventIdle(Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sd/AccessibleSlideView.java b/qadevOOo/tests/java/mod/_sd/AccessibleSlideView.java new file mode 100644 index 000000000..ea42567af --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/AccessibleSlideView.java @@ -0,0 +1,160 @@ +/* + * 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._sd; + +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.XWindow; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +public class AccessibleSlideView extends TestCase { + + XModel aModel = null; + XComponent xImpressDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> with an + * object to test and related objects. Subclasses should implement this + * method to provide the implementation and related objects. The method is + * called from <code>getTestEnvironment()</code>. + * + * @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; + + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, aModel); + XDrawPages oDPn = oDPS.getDrawPages(); + + oDPn.insertNewByIndex(0); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = AccessibilityTools.getCurrentWindow ( + aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); + + System.out.println("ImplementationName "+utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //util.dbg.printInterfaces(oObj); + log.println("Implementationname: "+util.utils.getImplName(oObj)); + + final XDrawPages DrawPages = oDPn; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + DrawPages.insertNewByIndex(2); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log ) { + log.println("disposing impress document"); + util.DesktopTools.closeDoc(xImpressDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. In the + * implementation does nothing. Subclasses can override to initialize + * objects shared among all <code>TestEnvironment</code>s. + * + * @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 an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + + util.utils.waitForEventIdle(Param.getMSF()); + + aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + + //Change to Outline view + try { + String aSlotID = "slot:27011"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, + aModel.getCurrentController() ); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF(). + createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0); + if( xDispatcher != null ) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + } + + util.utils.waitForEventIdle(Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sd/DrawController_DrawView.java b/qadevOOo/tests/java/mod/_sd/DrawController_DrawView.java new file mode 100644 index 000000000..9a1fb6d70 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/DrawController_DrawView.java @@ -0,0 +1,248 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class DrawController_DrawView extends TestCase { + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println( "creating two impress documents" ); + xDrawDoc = SOF.createDrawDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xSecondDrawDoc = SOF.createDrawDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + XController aController2 = aModel2.getCurrentController(); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class, aController2); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + Object oShapeCol1 = null; + Object oShapeCol2 = null; + oShapeCol1 = Param.getMSF(). + createInstance("com.sun.star.drawing.ShapeCollection"); + oShapeCol2 = Param.getMSF(). + createInstance("com.sun.star.drawing.ShapeCollection"); + + XShapes xShapes1 = UnoRuntime.queryInterface(XShapes.class, oShapeCol1); + XShapes xShapes2 = UnoRuntime.queryInterface(XShapes.class, oShapeCol2); + xShapes1.add(shape2); + xShapes1.add(shape3); + xShapes2.add(shape1); + util.utils.waitForEventIdle(Param.getMSF()); + + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, oShapeCol1, oShapeCol2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = aController2.getFrame(); + tEnv.addObjRelation("Frame", the_frame); + + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel2); + + tEnv.addObjRelation("SecondController", aController2); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + return tEnv; + + } // finish method getTestEnvironment + + +} + diff --git a/qadevOOo/tests/java/mod/_sd/DrawController_HandoutView.java b/qadevOOo/tests/java/mod/_sd/DrawController_HandoutView.java new file mode 100644 index 000000000..eb3144e21 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/DrawController_HandoutView.java @@ -0,0 +1,276 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* The view was switched to <b>HandoutMode</b>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class DrawController_HandoutView extends TestCase { + static XDesktop xDesktop; + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service + * <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. + * Switch to the <b>HandoutMode</b>. + * Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + XMultiServiceFactory xMSF = Param.getMSF(); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); + + log.println( "creating two impress documents" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + for (int i = 1; i < 10; i++){ + the_pages.insertNewByIndex(i); + } + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("switch to HandoutView..."); + utils.dispatchURL(xMSF, xDrawDoc, ".uno:HandoutMode"); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + log.println("bring first document to front..."); + DesktopTools.bringWindowToFront(aModel); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + Object oShapeCol1 = null; + Object oShapeCol2 = null; + oShapeCol1 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + oShapeCol2 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + + XShapes xShapes1 = UnoRuntime.queryInterface(XShapes.class, oShapeCol1); + XShapes xShapes2 = UnoRuntime.queryInterface(XShapes.class, oShapeCol2); + xShapes1.add(shape2); + xShapes1.add(shape3); + xShapes2.add(shape1); + util.utils.waitForEventIdle(Param.getMSF()); + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, oShapeCol1, oShapeCol2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + + return tEnv; + + } // finish method getTestEnvironment + + +} + diff --git a/qadevOOo/tests/java/mod/_sd/DrawController_NotesView.java b/qadevOOo/tests/java/mod/_sd/DrawController_NotesView.java new file mode 100644 index 000000000..36b57debb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/DrawController_NotesView.java @@ -0,0 +1,273 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* The view was switched to <b>NotesMode</b>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class DrawController_NotesView extends TestCase { + static XDesktop xDesktop; + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service + * <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. + * Switch to the <b>NotesMode</b>. + * Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + XMultiServiceFactory xMSF = Param.getMSF(); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); + + log.println( "creating two impress documents" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("switch to HandoutView..."); + utils.dispatchURL(xMSF, xDrawDoc, ".uno:NotesMode"); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + log.println("bring first document to front..."); + DesktopTools.bringWindowToFront(aModel); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + Object oShapeCol1 = null; + Object oShapeCol2 = null; + oShapeCol1 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + oShapeCol2 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + + XShapes xShapes1 = UnoRuntime.queryInterface(XShapes.class, oShapeCol1); + XShapes xShapes2 = UnoRuntime.queryInterface(XShapes.class, oShapeCol2); + xShapes1.add(shape2); + xShapes1.add(shape3); + xShapes2.add(shape1); + util.utils.waitForEventIdle(Param.getMSF()); + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, oShapeCol1, oShapeCol2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + + return tEnv; + + } // finish method getTestEnvironment + + +} + diff --git a/qadevOOo/tests/java/mod/_sd/DrawController_OutlineView.java b/qadevOOo/tests/java/mod/_sd/DrawController_OutlineView.java new file mode 100644 index 000000000..85bea8bc5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/DrawController_OutlineView.java @@ -0,0 +1,273 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* The view was switched to <b>OutlineMode</b>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class DrawController_OutlineView extends TestCase { + static XDesktop xDesktop; + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service + * <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. + * Switch to the <b>OutlineMode</b>. + * Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + XMultiServiceFactory xMSF = Param.getMSF(); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); + + log.println( "creating two impress documents" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("switch to HandoutView..."); + utils.dispatchURL(xMSF, xDrawDoc, ".uno:OutlineMode"); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + log.println("bring first document to front..."); + DesktopTools.bringWindowToFront(aModel); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + Object oShapeCol1 = null; + Object oShapeCol2 = null; + oShapeCol1 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + oShapeCol2 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + + XShapes xShapes1 = UnoRuntime.queryInterface(XShapes.class, oShapeCol1); + XShapes xShapes2 = UnoRuntime.queryInterface(XShapes.class, oShapeCol2); + xShapes1.add(shape2); + xShapes1.add(shape3); + xShapes2.add(shape1); + util.utils.waitForEventIdle(Param.getMSF()); + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, oShapeCol1, oShapeCol2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + + return tEnv; + + } // finish method getTestEnvironment + + +} + diff --git a/qadevOOo/tests/java/mod/_sd/DrawController_PresentationView.java b/qadevOOo/tests/java/mod/_sd/DrawController_PresentationView.java new file mode 100644 index 000000000..07609f22a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/DrawController_PresentationView.java @@ -0,0 +1,273 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* The view was switched to <b>DiaMode</b>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class DrawController_PresentationView extends TestCase { + static XDesktop xDesktop; + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service + * <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. + * Switch to the <b>DiaMode</b>. + * Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + XMultiServiceFactory xMSF = Param.getMSF(); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(xMSF); + + log.println( "creating two impress documents" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("switch to PresentationView..."); + utils.dispatchURL(xMSF, xDrawDoc, ".uno:DiaMode"); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + log.println("bring first document to front..."); + DesktopTools.bringWindowToFront(aModel); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + Object oShapeCol1 = null; + Object oShapeCol2 = null; + oShapeCol1 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + oShapeCol2 = xMSF. + createInstance("com.sun.star.drawing.ShapeCollection"); + + XShapes xShapes1 = UnoRuntime.queryInterface(XShapes.class, oShapeCol1); + XShapes xShapes2 = UnoRuntime.queryInterface(XShapes.class, oShapeCol2); + xShapes1.add(shape2); + xShapes1.add(shape3); + xShapes2.add(shape1); + util.utils.waitForEventIdle(Param.getMSF()); + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, oShapeCol1, oShapeCol2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + + return tEnv; + + } // finish method getTestEnvironment + + +} + diff --git a/qadevOOo/tests/java/mod/_sd/SdDocLinkTargets.java b/qadevOOo/tests/java/mod/_sd/SdDocLinkTargets.java new file mode 100644 index 000000000..e3ca75539 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdDocLinkTargets.java @@ -0,0 +1,96 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XLinkTargetSupplier; +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 service +* <code>com.sun.star.document.LinkTargets</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* </ul> +* @see com.sun.star.document.LinkTargets +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XElementAccess +* @see ifc.container._XNameAccess +* @see ifc.container._XElementAccess +*/ +public class SdDocLinkTargets extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the possible links to children of the drawing document using + * the interface <code>XLinkTargetSupplier</code>. The retrieved collection + * is the instance of the service <code>com.sun.star.document.LinkTargets</code>. + * @see com.sun.star.document.XLinkTargetSupplier + * @see com.sun.star.document.LinkTargets + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws StatusException { + + // get the Links here + log.println( "getting Links" ); + XLinkTargetSupplier oLTS = UnoRuntime.queryInterface(XLinkTargetSupplier.class,xDrawDoc); + XInterface oObj = oLTS.getLinks(); + + log.println( "creating a new environment for drawpage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdDocLinkTargets + diff --git a/qadevOOo/tests/java/mod/_sd/SdDrawPage.java b/qadevOOo/tests/java/mod/_sd/SdDrawPage.java new file mode 100644 index 000000000..bcf8f9630 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdDrawPage.java @@ -0,0 +1,186 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XMasterPagesSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawPage</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::GenericDrawPage</code></li> +* <li> <code>com::sun::star::drawing::XShapeBinder</code></li> +* <li> <code>com::sun::star::drawing::XShapeGrouper</code></li> +* <li> <code>com::sun::star::drawing::XShapes</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::drawing::XMasterPageTarget</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::drawing::XShapeCombiner</code></li> +* </ul> +* @see com.sun.star.drawing.DrawPage +* @see com.sun.star.drawing.GenericDrawPage +* @see com.sun.star.drawing.XShapeBinder +* @see com.sun.star.drawing.XShapeGrouper +* @see com.sun.star.drawing.XShapes +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.drawing.XMasterPageTarget +* @see com.sun.star.container.XNamed +* @see com.sun.star.drawing.XShapeCombiner +* @see ifc.drawing._GenericDrawPage +* @see ifc.drawing._XShapeBinder +* @see ifc.drawing._XShapeGrouper +* @see ifc.drawing._XShapes +* @see ifc.lang._XServiceInfo +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.drawing._XMasterPageTarget +* @see ifc.container._XNamed +* @see ifc.drawing._XShapeCombiner +*/ +public class SdDrawPage extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the draw pages from the drawing document using + * the interface <code>XDrawPagesSupplier</code> and take one of them. + * The retrieved draw page is the instance of the service + * <code>com.sun.star.drawing.DrawPage</code>. Inserts some shapes + * into the draw page. Obtains the MasterPages collection. Creates + * the rectangle shape. + * Object relations created : + * <ul> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes}( the created rectangle shape )</li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper}, + * {@link ifc.drawing._XShapeCombiner}( the retrieved draw page )</li> + * <li> <code>'MasterPageSupplier'</code> for + * {@link ifc.drawing._XMasterPageTarget}(the obtained master pages + * collection)</li> + * </ul> + * @see com.sun.star.drawing.DrawPage + * @see com.sun.star.drawing.XDrawPagesSupplier + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,oDPn); + oObj = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface + (XShapes.class,oObj); + oShapes.add(SOF.createShape + (xDrawDoc, 2000, 1500, 1000, 1000, "Line")); + oShapes.add(SOF.createShape + (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse")); + oShapes.add(SOF.createShape + (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle")); + + //get the XMasterPagesSupplier + log.println("get XMasterPagesSupplier"); + XMasterPagesSupplier oMPS = UnoRuntime.queryInterface(XMasterPagesSupplier.class, xDrawDoc); + XDrawPages oGroup = oMPS.getMasterPages(); + + log.println( "creating a new environment for drawpage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XControlShape aShape = FormTools.createControlShape( + xDrawDoc,3000,4500,15000,10000,"CommandButton"); + + oShapes.add(aShape); + + ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator( xDrawDoc, sDsc)); + tEnv.addObjRelation("DrawPage", oObj); + tEnv.addObjRelation("MasterPageSupplier",oGroup); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdDrawPage + diff --git a/qadevOOo/tests/java/mod/_sd/SdDrawPagesAccess.java b/qadevOOo/tests/java/mod/_sd/SdDrawPagesAccess.java new file mode 100644 index 000000000..20e69e34b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdDrawPagesAccess.java @@ -0,0 +1,109 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +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 service +* <code>com.sun.star.drawing.DrawPages</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::drawing::XDrawPages</code></li> +* </ul> +* @see com.sun.star.drawing.DrawPages +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.drawing.XDrawPages +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.drawing._XDrawPages +*/ +public class SdDrawPagesAccess extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the draw pages from the drawing document using + * the interface <code>XDrawPagesSupplier</code>. Inserts two new draw pages. + * The retrieved collection is the instance of the service + * <code>com.sun.star.drawing.DrawPages</code>. + * @see com.sun.star.drawing.DrawPages + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws StatusException { + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // get the drawpage of drawing here + log.println( "getting Drawpages" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages oDP = oDPS.getDrawPages(); + oDP.insertNewByIndex(1); + oDP.insertNewByIndex(2); + XInterface oObj = oDP; + + log.println( "creating a new environment for drawpage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method createTestEnvironment + + +} // finish class SdDrawPagesAccess + diff --git a/qadevOOo/tests/java/mod/_sd/SdGenericDrawPage.java b/qadevOOo/tests/java/mod/_sd/SdGenericDrawPage.java new file mode 100644 index 000000000..6190b3693 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdGenericDrawPage.java @@ -0,0 +1,169 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.GenericDrawPage</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::GenericDrawPage</code></li> +* <li> <code>com::sun::star::drawing::XShapeBinder</code></li> +* <li> <code>com::sun::star::drawing::XShapeGrouper</code></li> +* <li> <code>com::sun::star::drawing::XShapes</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::drawing::XShapeCombiner</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* </ul> +* @see com.sun.star.drawing.GenericDrawPage +* @see com.sun.star.drawing.XShapeBinder +* @see com.sun.star.drawing.XShapeGrouper +* @see com.sun.star.drawing.XShapes +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.drawing.XShapeCombiner +* @see com.sun.star.container.XNamed +* @see ifc.drawing._GenericDrawPage +* @see ifc.drawing._XShapeBinder +* @see ifc.drawing._XShapeGrouper +* @see ifc.drawing._XShapes +* @see ifc.lang._XServiceInfo +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.drawing._XShapeCombiner +* @see ifc.container._XNamed +*/ +public class SdGenericDrawPage extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the draw pages from the drawing document using + * the interface <code>XDrawPagesSupplier</code> and take one of them. + * The retrieved draw page is the instance of the service + * <code>com.sun.star.drawing.DrawPage</code>. Inserts some shapes + * into the draw page. Creates the rectangle shape. + * Object relations created : + * <ul> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes}( the created rectangle shape )</li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper}, + * {@link ifc.drawing._XShapeCombiner}( the retrieved draw page )</li> + * </ul> + * @see com.sun.star.drawing.DrawPage + * @see com.sun.star.drawing.XDrawPagesSupplier + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShapes oShapes = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDrawDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface + (XIndexAccess.class,oDPn); + oObj = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + oShapes = UnoRuntime.queryInterface(XShapes.class,oObj); + oShapes.add(SOF.createShape + (xDrawDoc, 2000, 1500, 1000, 1000, "Line")); + oShapes.add(SOF.createShape + (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse")); + oShapes.add(SOF.createShape + (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle")); + + log.println( "creating a new environment for drawpage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator( xDrawDoc, sDsc)); + + // adding relation for XShapeGrouper + tEnv.addObjRelation("DrawPage", oObj); + + return tEnv; + } // finish method createTestEnvironment + + +} // finish class SdGenericDrawPage + diff --git a/qadevOOo/tests/java/mod/_sd/SdLayer.java b/qadevOOo/tests/java/mod/_sd/SdLayer.java new file mode 100644 index 000000000..1c1019abc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdLayer.java @@ -0,0 +1,111 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.drawing.XLayer; +import com.sun.star.drawing.XLayerManager; +import com.sun.star.drawing.XLayerSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.Layer</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::Layer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.drawing.Layer +* @see com.sun.star.beans.XPropertySet +* @see ifc.drawing._Layer +* @see ifc.beans._XPropertySet +*/ +public class SdLayer extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the layer manager from the document and takes one of the layer. + * The obtained layer is the instance of the service + * <code>com.sun.star.drawing.Layer</code>. + * @see com.sun.star.drawing.Layer + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + XLayerManager oLM = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // get the drawpage of drawing here + log.println( "getting LayerManager" ); + XLayerSupplier oLS = UnoRuntime.queryInterface(XLayerSupplier.class, xDrawDoc); + XNameAccess oNA = oLS.getLayerManager(); + oLM = UnoRuntime.queryInterface(XLayerManager.class, oNA); + XIndexAccess oIA = UnoRuntime.queryInterface(XIndexAccess.class,oLM); + log.println( "getting LayerManager" ); + oObj = (XLayer) AnyConverter.toObject( + new Type(XLayer.class),oIA.getByIndex(0)); + + log.println( "creating a new environment for drawpage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdLayer + diff --git a/qadevOOo/tests/java/mod/_sd/SdLayerManager.java b/qadevOOo/tests/java/mod/_sd/SdLayerManager.java new file mode 100644 index 000000000..8d42ce8a9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdLayerManager.java @@ -0,0 +1,140 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XLayerSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.LayerManager</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::XLayerManager</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* </ul> +* @see com.sun.star.drawing.LayerManager +* @see com.sun.star.drawing.XLayerManager +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see ifc.drawing._XLayerManager +* @see ifc.container._XNameAccess +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +*/ +public class SdLayerManager extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the layer manager using the interface <code>XLayerSupplier</code>. + * The manager is the instance of the service + * <code>com.sun.star.drawing.LayerManager</code>. Creates a rectangle shape. + * Retrieves the collection of the draw pages and take one of them. + * <ul> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XLayerManager}(the created shape)</li> + * <li> <code>'Shapes'</code> for + * {@link ifc.drawing._XLayerManager}(the shape collection of + * the retrieved draw page)</li> + * </ul> + * @see com.sun.star.drawing.XLayerSupplier + * @see com.sun.star.drawing.LayerManager + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + XLayerSupplier oLS = UnoRuntime.queryInterface(XLayerSupplier.class, xDrawDoc); + XInterface oObj = oLS.getLayerManager(); + + log.println( "creating a new environment for XLayerManager object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator(xDrawDoc, sDsc)); + + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xDrawDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,oDPn); + + XDrawPage oDP = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDP); + + log.println( "adding Shapes as mod relation to environment" ); + tEnv.addObjRelation("Shapes", oShapes); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SdLayerManager + diff --git a/qadevOOo/tests/java/mod/_sd/SdMasterPage.java b/qadevOOo/tests/java/mod/_sd/SdMasterPage.java new file mode 100644 index 000000000..d23c1d5d0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdMasterPage.java @@ -0,0 +1,165 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XMasterPagesSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.MasterPage</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::GenericDrawPage</code></li> +* <li> <code>com::sun::star::drawing::XShapeBinder</code></li> +* <li> <code>com::sun::star::drawing::XShapeGrouper</code></li> +* <li> <code>com::sun::star::drawing::XShapes</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::drawing::XShapeCombiner</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* </ul> +* @see com.sun.star.drawing.MasterPage +* @see com.sun.star.drawing.GenericDrawPage +* @see com.sun.star.drawing.XShapeBinder +* @see com.sun.star.drawing.XShapeGrouper +* @see com.sun.star.drawing.XShapes +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.drawing.XShapeCombiner +* @see com.sun.star.container.XNamed +* @see ifc.drawing._GenericDrawPage +* @see ifc.drawing._XShapeBinder +* @see ifc.drawing._XShapeGrouper +* @see ifc.drawing._XShapes +* @see ifc.lang._XServiceInfo +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.drawing._XShapeCombiner +* @see ifc.container._XNamed +*/ +public class SdMasterPage extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the master pages from the document using the + * interface <code>XMasterPagesSupplier</code> and takes + * one of them. Inserts some shapes into the document. Creates a rectangle + * shape. The retrieved master page is the instance of the service + * <code>com.sun.star.drawing.MasterPage</code>. + * Object relations created : + * <ul> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeBinder}, {@link ifc.drawing._XShapeGrouper}, + * {@link ifc.drawing._XShapeCombiner}( the draw page of the retrieved + * master page)</li> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes}(the created rectangle shape)</li> + * </ul> + * @see com.sun.star.drawing.XMasterPagesSupplier + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get the MasterPages here + log.println( "getting MasterPages" ); + XMasterPagesSupplier oMPS = UnoRuntime.queryInterface(XMasterPagesSupplier.class, xDrawDoc); + XDrawPages oMPn = oMPS.getMasterPages(); + XIndexAccess oMPi = UnoRuntime.queryInterface(XIndexAccess.class, oMPn); + + log.println( "getting MasterPage" ); + XInterface oObj = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oMPi.getByIndex(0)); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + //put something on the masterpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oObj); + oShapes.add(SOF.createShape(xDrawDoc, 2000, 1500, 1000, 1000, "Line")); + oShapes.add(SOF.createShape + (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse")); + oShapes.add(SOF.createShape + (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle")); + + log.println( "creating a new environment for MasterPage object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding DrawPage as mod relation to environment" ); + tEnv.addObjRelation("DrawPage", oObj); + + ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator( xDrawDoc, sDsc)); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdMasterPage + diff --git a/qadevOOo/tests/java/mod/_sd/SdMasterPagesAccess.java b/qadevOOo/tests/java/mod/_sd/SdMasterPagesAccess.java new file mode 100644 index 000000000..647762087 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdMasterPagesAccess.java @@ -0,0 +1,107 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XMasterPagesSupplier; +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 service +* <code>com.sun.star.drawing.MasterPages</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::drawing::XDrawPages</code></li> +* </ul> +* @see com.sun.star.drawing.MasterPages +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.drawing.XDrawPages +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.drawing._XDrawPages +*/ +public class SdMasterPagesAccess extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the master pages from the document using the + * interface <code>XMasterPagesSupplier</code>. Inserts two new draw pages. + * The retrieved collection is the instance of the service + * <code>com.sun.star.drawing.MasterPages</code>. + * @see com.sun.star.drawing.XMasterPagesSupplier + * @see com.sun.star.drawing.MasterPages + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws StatusException { + + log.println( "creating a test environment" ); + + // get the MasterPages here + log.println( "getting MasterPages" ); + XMasterPagesSupplier oMPS = UnoRuntime.queryInterface( XMasterPagesSupplier.class, xDrawDoc); + XDrawPages oMP = oMPS.getMasterPages(); + log.println( "insert MasterPages" ); + oMP.insertNewByIndex(1); + oMP.insertNewByIndex(2); + XInterface oObj = oMP; + + log.println( "creating a new environment for MasterPagesAccess object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdMasterPagesAccess + diff --git a/qadevOOo/tests/java/mod/_sd/SdPageLinkTargets.java b/qadevOOo/tests/java/mod/_sd/SdPageLinkTargets.java new file mode 100644 index 000000000..7d314645e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdPageLinkTargets.java @@ -0,0 +1,121 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XLinkTargetSupplier; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +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 service +* <code>com.sun.star.document.LinkTargets</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* </ul> +* @see com.sun.star.document.LinkTargets +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XElementAccess +* @see ifc.container._XNameAccess +* @see ifc.container._XElementAccess +*/ +public class SdPageLinkTargets extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of draw pages and take one of them. + * Obtains the collection of possible links using the interface + * <code>XLinkTargetSupplier</code>. The obtained collection is + * the instance of the service <code>com.sun.star.document.LinkTargets</code>. + * Inserts some shapes into the document. + * @see com.sun.star.document.XLinkTargetSupplier + * @see com.sun.star.document.LinkTargets + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + // create testobject here + XDrawPage the_page = DrawTools.getDrawPage(xDrawDoc, 0); + XLinkTargetSupplier oLTS = UnoRuntime.queryInterface(XLinkTargetSupplier.class, the_page); + XInterface oObj = oLTS.getLinks(); + + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class,the_page); + XShape oShape = + SOF.createShape(xDrawDoc, 15000, 13500, 5000, 5000, "OLE2"); + oShapes.add(oShape); + + XPropertySet shape_props = UnoRuntime.queryInterface(XPropertySet.class,oShape); + + log.println("Inserting a Chart"); + + shape_props. + setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e"); + + log.println( "creating a new environment for LinkTargets object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdPageLinkTargets + diff --git a/qadevOOo/tests/java/mod/_sd/SdUnoDrawView.java b/qadevOOo/tests/java/mod/_sd/SdUnoDrawView.java new file mode 100644 index 000000000..fc4bd27c1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdUnoDrawView.java @@ -0,0 +1,249 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class SdUnoDrawView extends TestCase { + static XDesktop xDesktop; + static XComponent xDrawDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service + * <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing draw documents"); + util.DesktopTools.closeDoc(xDrawDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating + * of the documents makes short + * wait to allow frames to be loaded. Retrieves + * the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._DrawingDocumentDrawView}(the draw page which will + * be new current page) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + public lib.TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println( "creating two draw documents" ); + xDrawDoc = SOF.createDrawDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xSecondDrawDoc = SOF.createDrawDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + XShape shape2 = SOF.createShape( + xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + XShape shape3 = SOF.createShape( + xDrawDoc, 3000, 500, 5000, 1000, "Line"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XInterface oObj = aModel.getCurrentController(); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + + tEnv.addObjRelation("Selections", new Object[] { + shape1, shape2, shape3}); + + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27009"); + + //Adding relations for DrawingDocumentDrawView + XDrawPage new_page = the_pages.insertNewByIndex(1); + tEnv.addObjRelation("DrawPage", new_page); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xDrawDoc); + + tEnv.addObjRelation("Modifiable",modify); + + tEnv.addObjRelation("XComponent.DisposeThis", xDrawDoc); + + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + + return tEnv; + + } // finish method getTestEnvironment + + +} // finish class SdUnoDrawView + diff --git a/qadevOOo/tests/java/mod/_sd/SdUnoOutlineView.java b/qadevOOo/tests/java/mod/_sd/SdUnoOutlineView.java new file mode 100644 index 000000000..ee4aa536d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdUnoOutlineView.java @@ -0,0 +1,209 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; +/** +* Test for object which is represented by service +* <code>com.sun.star.present.OutlineView</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::presentation::OutlineView</code></li> +* <li> <code>com::sun::star::frame::XDispatchProvider</code></li> +* <li> <code>com::sun::star::awt::XWindow</code></li> +* </ul> +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.presentation.OutlineView +* @see com.sun.star.awt.XWindow +* @see com.sun.star.frame.XDispatchProvider +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.awt._XWindow +* @see ifc.presentation._OutlineView +* @see ifc.frame._XDispatchProvider +*/ +public class SdUnoOutlineView extends TestCase { + XDesktop xDesktop; + XComponent xImpressDoc; + XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xImpressDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating of the documents makes short + * wait to allow frames to be loaded. Retrieves the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service <code>com.sun.star.presentation.OutlineView</code>. + * Object relations created : + * <ul> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * </ul> + * @see com.sun.star.frame.XModel + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + + XInterface oObj = aModel.getCurrentController(); + + //Change to Outline view + try { + String aSlotID = "slot:27010"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, oObj ); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF().createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0); + if( xDispatcher != null ) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + } + + log.println( "creating a second impress document" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + oObj = aModel.getCurrentController(); + + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + } + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27069"); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + + } // finish method getTestEnvironment + + +} // finish class SdUnoOutlineView + diff --git a/qadevOOo/tests/java/mod/_sd/SdUnoPresView.java b/qadevOOo/tests/java/mod/_sd/SdUnoPresView.java new file mode 100644 index 000000000..f8860c876 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdUnoPresView.java @@ -0,0 +1,249 @@ +/* + * 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._sd; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XModifiable; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::DrawingDocumentDrawView</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::frame::XController</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::drawing::XDrawView</code></li> +* </ul> +* @see com.sun.star.drawing.DrawingDocumentDrawView +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.frame.XController +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.drawing.XDrawView +* @see ifc.drawing._DrawingDocumentDrawView +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.frame._XController +* @see ifc.beans._XPropertySet +* @see ifc.view._XSelectionSupplier +* @see ifc.drawing._XDrawView +*/ +public class SdUnoPresView extends TestCase { + static XDesktop xDesktop; + static XComponent xImpressDoc; + static XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xImpressDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a Test environment for the interfaces to be tested. + * Creates two impress documents. After creating of the documents makes short + * wait to allow frames to be loaded. Retrieves the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service + * <code>com.sun.star.drawing.DrawingDocumentDrawView</code>. + * Object relations created : + * <ul> + * <li> <code>'First'</code> for + * {@link ifc.view._XSelectionSupplier}(the first created shape) </li> + * <li> <code>'Second'</code> for + * {@link ifc.view._XSelectionSupplier}(the second created shape) </li> + * <li> <code>'Pages'</code> for + * {@link ifc.drawing._XDrawView}(the retrieved collection of the draw + * pages) </li> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.drawing.DrawingDocumentDrawView + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println( "creating two impress documents" ); + xImpressDoc = SOF.createImpressDoc(null); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages the_pages = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class,the_pages); + + XDrawPage oDrawPage = null; + XDrawPage secondDrawPage = null; + oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + the_pages.insertNewByIndex(0); + the_pages.insertNewByIndex(0); + the_pages.insertNewByIndex(0); + the_pages.insertNewByIndex(0); + secondDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(3)); + + //put something on the drawpage + log.println( "inserting some Shapes" ); + XShapes oShapes = UnoRuntime.queryInterface(XShapes.class, oDrawPage); + XShape shape1 = SOF.createShape( + xImpressDoc, 5000, 3500, 7500, 5000, "Rectangle"); + oShapes.add(shape1); + + oShapes = UnoRuntime.queryInterface(XShapes.class, secondDrawPage); + shape1 = SOF.createShape( + xImpressDoc, 3000, 4500, 15000, 1000, "Ellipse"); + oShapes.add(shape1); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + + XInterface oObj = aModel.getCurrentController(); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + log.println( "creating a new environment for impress view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow",anotherWindow); + } + + tEnv.addObjRelation("Selections", new Object[] { + oDrawPage, secondDrawPage}); + + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + if (indAc1 == null || indAc2 == null) return -1; + if (indAc1.getCount() == indAc2.getCount()) { + return 0; + } + return 1; + }}); + + tEnv.addObjRelation("FirstPage", oDrawPage); + tEnv.addObjRelation("SecondPage", secondDrawPage); + + tEnv.addObjRelation("Pages", the_pages); + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + aModel = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel); + + XController secondController = aModel.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27010"); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + XModifiable modify = UnoRuntime.queryInterface(XModifiable.class,xImpressDoc); + + tEnv.addObjRelation("Modifiable",modify); + + + tEnv.addObjRelation("XComponent.DisposeThis", xImpressDoc); + + return tEnv; + + } // finish method getTestEnvironment + + +} // finish class SdUnoDrawView + diff --git a/qadevOOo/tests/java/mod/_sd/SdUnoSlideView.java b/qadevOOo/tests/java/mod/_sd/SdUnoSlideView.java new file mode 100644 index 000000000..25016309a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdUnoSlideView.java @@ -0,0 +1,189 @@ +/* + * 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._sd; + +import com.sun.star.drawing.XDrawPages; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.DrawTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +public class SdUnoSlideView extends TestCase { + XDesktop xDesktop; + XComponent xImpressDoc; + XComponent xSecondDrawDoc; + + /** + * Creates the instance of the service <code>com.sun.star.frame.Desktop</code>. + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress documents. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing impress documents"); + util.DesktopTools.closeDoc(xImpressDoc); + util.DesktopTools.closeDoc(xSecondDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two impress documents. After creating of the documents makes short + * wait to allow frames to be loaded. Retrieves the collection of the draw pages + * from the first document and takes one of them. Inserts some shapes to the + * retrieved draw page. Obtains a current controller from the first document + * using the interface <code>XModel</code>. The obtained controller is the + * instance of the service <code>com.sun.star.presentation.OutlineView</code>. + * Object relations created : + * <ul> + * <li> <code>'FirstModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the first created document) </li> + * <li> <code>'Frame'</code> for + * {@link ifc.frame._XController}(the frame of the created + * document) </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController}(the interface <code>XModel</code> of + * the second created document) </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController}(the current controller of the second + * created document) </li> + * </ul> + * @see com.sun.star.frame.XModel + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + XDrawPages xDP = null; + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xDP = DrawTools.getDrawPages(xImpressDoc); + xDP.insertNewByIndex(0); + xDP.insertNewByIndex(0); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + + XInterface oObj = aModel.getCurrentController(); + + //Change to Slide view + try { + String aSlotID = "slot:27011"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, oObj ); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF().createInstance("com.sun.star.util.URLTransformer")); + // Because it's an in/out parameter we must use an array of URL objects. + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch( aURL,"",0); + if( xDispatcher != null ) + xDispatcher.dispatch( aURL, null ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change to slide view"); + } + + log.println( "creating a second impress document" ); + xSecondDrawDoc = SOF.createImpressDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel2 = UnoRuntime.queryInterface(XModel.class, xSecondDrawDoc); + + XWindow anotherWindow = UnoRuntime.queryInterface( + XWindow.class,aModel2.getCurrentController()); + + oObj = aModel.getCurrentController(); + + log.println( "creating a new environment for slide view object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + if (anotherWindow != null) { + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + } + + //Adding ObjRelations for XController + tEnv.addObjRelation("FirstModel", aModel); + + XFrame the_frame = xDesktop.getCurrentFrame(); + tEnv.addObjRelation("Frame", the_frame); + + //Adding ObjRelations for XController + tEnv.addObjRelation("SecondModel", aModel2); + + XController secondController = aModel2.getCurrentController(); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("XDispatchProvider.URL", + "slot:27069"); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + //creating obj-relation for the XSelectionSupplier + try { + Object[] selections = + new Object[]{xDP.getByIndex(0),xDP.getByIndex(1),xDP.getByIndex(2)}; + tEnv.addObjRelation("Selections", selections); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + } + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + + } // finish method getTestEnvironment + + +} // finish class SdUnoOutlineView + diff --git a/qadevOOo/tests/java/mod/_sd/SdXCustomPresentation.java b/qadevOOo/tests/java/mod/_sd/SdXCustomPresentation.java new file mode 100644 index 000000000..a969aab0f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdXCustomPresentation.java @@ -0,0 +1,170 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexContainer; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.presentation.XCustomPresentationSupplier; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.presentation.CustomPresentation</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::container::XIndexReplace</code></li> +* </ul> +* @see com.sun.star.presentation.CustomPresentation +* @see com.sun.star.container.XNamed +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XIndexReplace +* @see ifc.container._XNamed +* @see ifc.container._XIndexContainer +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XIndexReplace +*/ +public class SdXCustomPresentation extends TestCase { + XComponent xImpressDoc; + + /** + * Creates Impress document. + */ + @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 draw document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Disposes Impress document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xImpressDoc"); + util.DesktopTools.closeDoc(xImpressDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the CustomPresentation from the document + * using the interface <code>XCustomPresentationSupplier</code>. Creates and + * inserts new instance of the presentation to the collection. The created + * instance is the instance of the service + * <code>com.sun.star.presentation.CustomPresentation</code>. Obtains + * the collection of draw pages from the document and takes one of them. + * Inserts the obtained draw page to the created instance. Inserts some new + * draw pages. + * Object relations created : + * <ul> + * <li> <code>'XIndexContainerINDEX'</code> for + * {@link ifc.container._XIndexContainer}(the string representation of + * the zero)</li> + * <li> <code>'INSTANCE1', ..., 'INSTANCEN'</code> for + * {@link ifc.container._XIndexContainer}(the new inserted draw pages)</li> + * </ul> + * @see com.sun.star.presentation.XCustomPresentationSupplier + * @see com.sun.star.presentation.CustomPresentation + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + + log.println( "creating a test environment" ); + + log.println( "get presentation" ); + XCustomPresentationSupplier oPS = UnoRuntime.queryInterface( + XCustomPresentationSupplier.class, xImpressDoc); + XInterface oObj = oPS.getCustomPresentations(); + + XSingleServiceFactory oSingleMSF = UnoRuntime.queryInterface(XSingleServiceFactory.class, oObj); + + XInterface oInstance = (XInterface) oSingleMSF.createInstance(); + + XNameContainer aContainer = UnoRuntime.queryInterface(XNameContainer.class, oObj); + + aContainer.insertByName("FirstPresentation", oInstance); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class, oDPn); + + XDrawPage oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + XIndexContainer aIContainer = UnoRuntime.queryInterface(XIndexContainer.class,oInstance); + + aIContainer.insertByIndex(0, oDrawPage); + + log.println( "creating a new environment for XPresentation object" ); + TestEnvironment tEnv = new TestEnvironment( oInstance ); + + int THRCNT=1; + if ((String)Param.get("THRCNT") != null) { + THRCNT = Integer.parseInt((String)Param.get("THRCNT")); + } + + // INDEX : _XNameContainer + log.println( "adding XIndexContainerINDEX as mod relation to environment" ); + tEnv.addObjRelation("XIndexContainerINDEX", "0"); + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println( "adding INSTANCEn as mod relation to environment" ); + for (int n = 1; n < (2*THRCNT+1) ;n++ ) { + log.println( "adding INSTANCE" + n + +" as mod relation to environment" ); + oDPn.insertNewByIndex(0); + oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + tEnv.addObjRelation("INSTANCE" + n, oDrawPage); + } + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SdXCustomPresentation diff --git a/qadevOOo/tests/java/mod/_sd/SdXCustomPresentationAccess.java b/qadevOOo/tests/java/mod/_sd/SdXCustomPresentationAccess.java new file mode 100644 index 000000000..99dc87240 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdXCustomPresentationAccess.java @@ -0,0 +1,169 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.presentation.XCustomPresentationSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.presentation.CustomPresentationAccess</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li> +* <li> <code>com::sun::star::container::XNameContainer</code></li> +* </ul> +* @see com.sun.star.presentation.CustomPresentationAccess +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.lang.XSingleServiceFactory +* @see com.sun.star.container.XNameContainer +* @see ifc.container._XNameAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XNameReplace +* @see ifc.lang._XSingleServiceFactory +* @see ifc.container._XNameContainer +*/ +public class SdXCustomPresentationAccess extends TestCase { + XComponent xImpressDoc; + + /** + * Creates Impress document. + */ + @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 draw document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Disposes Impress document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xImpressDoc"); + util.DesktopTools.closeDoc(xImpressDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the CustomPresentation from the document + * using the interface <code>XCustomPresentationSupplier</code>. + * The retrieved collection is the instance of the service + * <code>com.sun.star.presentation.CustomPresentationAccess</code>. + * Creates two new instances of the custom presentation using the interface + * <code>XSingleServiceFactory</code>. Inserts one of them to the + * retrieved collection. Creates and inserts several instances of + * the presentation. + * Object relations created : + * <ul> + * <li> <code>'SecondInstance'</code> for + * {@link ifc.container._XNameContainer}(the second created instance + * of the custom presentation)</li> + * <li> <code>'XNameContainerINDEX'</code> for + * {@link ifc.container._XNameContainer}(the number of current running + * threads)</li> + * <li> <code>'INSTANCE1', ..., 'INSTANCEN'</code> for + * {@link ifc.container._XNameReplace}, + * {@link ifc.container._XNameContainer}(the created instances of + * the presentation)</li> + * </ul> + * @see com.sun.star.presentation.XCustomPresentationSupplier + * @see com.sun.star.lang.XSingleServiceFactory + * @see com.sun.star.presentation.CustomPresentationAccess + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + + log.println( "creating a test environment" ); + + log.println( "get presentation" ); + XCustomPresentationSupplier oPS = UnoRuntime.queryInterface( + XCustomPresentationSupplier.class, xImpressDoc); + XInterface oObj = oPS.getCustomPresentations(); + + + XSingleServiceFactory oSingleMSF = UnoRuntime.queryInterface(XSingleServiceFactory.class, oObj); + + XInterface oInstance = null; + XInterface oSecondInstance = null; + oInstance = (XInterface) oSingleMSF.createInstance(); + oSecondInstance = (XInterface) oSingleMSF.createInstance(); + + XNameContainer aContainer = UnoRuntime.queryInterface(XNameContainer.class, oObj); + + if (aContainer.hasByName("FirstPresentation")) { + aContainer.removeByName("FirstPresentation"); + } + + aContainer.insertByName("FirstPresentation",oInstance); + + log.println( "creating a new environment for XPresentation object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding an instance for insertByName ('XNameContainer') + tEnv.addObjRelation("SecondInstance", oSecondInstance); + + int THRCNT = 1; + if ((String)Param.get("THRCNT") != null) { + THRCNT = Integer.parseInt((String)Param.get("THRCNT")); + } + + // INDEX : _XNameContainer + log.println( "adding XNameContainerINDEX as mod relation to environment" ); + tEnv.addObjRelation("XNameContainerINDEX", Integer.valueOf(THRCNT).toString()); + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println( "adding INSTANCEn as mod relation to environment" ); + try { + for (int n = 1; n < (2*THRCNT+1) ;n++ ) { + log.println( "adding INSTANCE" + n + +" as mod relation to environment" ); + oInstance = (XInterface) oSingleMSF.createInstance(); + tEnv.addObjRelation("INSTANCE" + n, oInstance); + } + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't adding INSTANCEn: " + e); + } + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SdXCustomPresentationAccess + diff --git a/qadevOOo/tests/java/mod/_sd/SdXImpressDocument.java b/qadevOOo/tests/java/mod/_sd/SdXImpressDocument.java new file mode 100644 index 000000000..12519fc03 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdXImpressDocument.java @@ -0,0 +1,170 @@ +/* + * 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._sd; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.view.XSelectionSupplier; +import ifc.view._XPrintJobBroadcaster; +import java.io.File; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.DrawTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.presentation.PresentationDocument</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li> + * <li> <code>com::sun::star::drawing::XMasterPagesSupplier</code></li> + * <li> <code>com::sun::star::presentation::XCustomPresentationSupplier</code></li> + * <li> <code>com::sun::star::document::XLinkTargetSupplier</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::drawing::XLayerSupplier</code></li> + * <li> <code>com::sun::star::presentation::XPresentationSupplier</code></li> + * <li> <code>com::sun::star::style::XStyleFamiliesSupplier</code></li> + * <li> <code>com::sun::star::drawing::DrawingDocument</code></li> + * <li> <code>com::sun::star::drawing::XDrawPageDuplicator</code></li> + * <li> <code>com::sun::star::drawing::XDrawPagesSupplier</code></li> + * </ul> + * @see com.sun.star.presentation.PresentationDocument + * @see com.sun.star.lang.XMultiServiceFactory + * @see com.sun.star.drawing.XMasterPagesSupplier + * @see com.sun.star.presentation.XCustomPresentationSupplier + * @see com.sun.star.document.XLinkTargetSupplier + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.drawing.XLayerSupplier + * @see com.sun.star.presentation.XPresentationSupplier + * @see com.sun.star.style.XStyleFamiliesSupplier + * @see com.sun.star.drawing.DrawingDocument + * @see com.sun.star.drawing.XDrawPageDuplicator + * @see com.sun.star.drawing.XDrawPagesSupplier + * @see ifc.lang._XMultiServiceFactory + * @see ifc.drawing._XMasterPagesSupplier + * @see ifc.presentation._XCustomPresentationSupplier + * @see ifc.document._XLinkTargetSupplier + * @see ifc.beans._XPropertySet + * @see ifc.drawing._XLayerSupplier + * @see ifc.presentation._XPresentationSupplier + * @see ifc.style._XStyleFamiliesSupplier + * @see ifc.drawing._DrawingDocument + * @see ifc.drawing._XDrawPageDuplicator + * @see ifc.drawing._XDrawPagesSupplier + */ +public class SdXImpressDocument extends TestCase { + XComponent xImpressDoc; + XComponent xImpressDoc2; + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes Impress document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xImpressDoc"); + util.DesktopTools.closeDoc(xImpressDoc); + util.DesktopTools.closeDoc(xImpressDoc2); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates new impress document that is the instance of the service + * <code>com.sun.star.presentation.PresentationDocument</code>. + * @see com.sun.star.presentation.PresentationDocument + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws Exception { + log.println("creating a test environment"); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating two impress documents"); + xImpressDoc2 = SOF.createImpressDoc(null); + xImpressDoc = SOF.createImpressDoc(null); + + XModel xModel1 = UnoRuntime.queryInterface(XModel.class, + xImpressDoc); + XModel xModel2 = UnoRuntime.queryInterface(XModel.class, + xImpressDoc2); + + XController cont1 = xModel1.getCurrentController(); + XController cont2 = xModel2.getCurrentController(); + + cont1.getFrame().setName("cont1"); + cont2.getFrame().setName("cont2"); + + XSelectionSupplier sel = UnoRuntime.queryInterface( + XSelectionSupplier.class, cont1); + + XShape aShape = SOF.createShape(xImpressDoc, 5000, 3500, 7500, 5000, + "Rectangle"); + + + XPropertySet xShapeProps = UnoRuntime.queryInterface(XPropertySet.class, aShape); + + xShapeProps.setPropertyValue("FillStyle", com.sun.star.drawing.FillStyle.SOLID); + xShapeProps.setPropertyValue("FillTransparence", Integer.valueOf(50)); + + DrawTools.getDrawPage(xImpressDoc, 0).add(aShape); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(xImpressDoc); + + log.println("adding Controller as ObjRelation for XModel"); + tEnv.addObjRelation("CONT2", cont2); + + log.println("Adding SelectionSupplier and Shape to select for XModel"); + tEnv.addObjRelation("SELSUPP", sel); + tEnv.addObjRelation("TOSELECT", aShape); + + // create object relation for XPrintJobBroadcaster + String fileName = utils.getOfficeTempDirSys(Param.getMSF())+"printfile.prt" ; + File f = new File(fileName); + if (f.exists()) { + boolean bDeleteOk = f.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + _XPrintJobBroadcaster.MyPrintJobListener listener = new _XPrintJobBroadcaster.MyPrintJobListener(xImpressDoc, fileName); + tEnv.addObjRelation("XPrintJobBroadcaster.XPrintJobListener", listener); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SdDrawPage diff --git a/qadevOOo/tests/java/mod/_sd/SdXPresentation.java b/qadevOOo/tests/java/mod/_sd/SdXPresentation.java new file mode 100644 index 000000000..344eb205b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdXPresentation.java @@ -0,0 +1,131 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.presentation.XCustomPresentationSupplier; +import com.sun.star.presentation.XPresentationSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.presentation.Presentation</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::presentation::Presentation</code></li> +* <li> <code>com::sun::star::presentation::XPresentation</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.presentation.Presentation +* @see com.sun.star.presentation.XPresentation +* @see com.sun.star.beans.XPropertySet +* @see ifc.presentation._Presentation +* @see ifc.presentation._XPresentation +* @see ifc.beans._XPropertySet +*/ +public class SdXPresentation extends TestCase { + XComponent xImpressDoc; + + /** + * Creates Impress document. + */ + @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 draw document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Disposes Impress document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xImpressDoc"); + util.DesktopTools.closeDoc(xImpressDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the presentation from the document using the interface + * <code>XPresentationSupplier</code>. The retrieved presentation is the + * instance of the service <code>com.sun.star.presentation.Presentation</code>. + * Retrieves the collection of the customized presentations from the document + * using the interface <code>XCustomPresentationSupplier</code>. + * Creates and inserts two new instances of presentation to the retrieved + * collection. + * Object relations created : + * <ul> + * <li> <code>'Presentation'</code> for + * {@link ifc.presentation._Presentation}(the retrieved presentation)</li> + * </ul> + * @see com.sun.star.presentation.XCustomPresentationSupplier + * @see com.sun.star.presentation.Presentation + * @see com.sun.star.presentation.XCustomPresentationSupplier + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + log.println( "get presentation" ); + XPresentationSupplier oPS = UnoRuntime.queryInterface(XPresentationSupplier.class, xImpressDoc); + XInterface oObj = oPS.getPresentation(); + + log.println( "get custom presentation" ); + XCustomPresentationSupplier oCPS = UnoRuntime.queryInterface( + XCustomPresentationSupplier.class, xImpressDoc); + XNameContainer xCP = oCPS.getCustomPresentations(); + + XInterface oInstance = null; + XInterface oInstance2 = null; + + XSingleServiceFactory oSingleMSF = UnoRuntime.queryInterface(XSingleServiceFactory.class, xCP); + + oInstance = (XInterface) oSingleMSF.createInstance(); + oInstance2 = (XInterface) oSingleMSF.createInstance(); + + xCP.insertByName("FirstPresentation",oInstance); + xCP.insertByName("SecondPresentation", oInstance2); + + log.println( "creating a new environment for XPresentation object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("Presentation",oObj); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SdPresentation + diff --git a/qadevOOo/tests/java/mod/_sd/SdXShape.java b/qadevOOo/tests/java/mod/_sd/SdXShape.java new file mode 100644 index 000000000..049adedf0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/SdXShape.java @@ -0,0 +1,165 @@ +/* + * 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._sd; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.lang.XComponent; +import com.sun.star.style.XStyle; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.drawing.Shape</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::drawing::XShape</code></li> +* <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::drawing::Shape</code></li> +* </ul> +* @see com.sun.star.lang.XComponent +* @see com.sun.star.drawing.XShape +* @see com.sun.star.drawing.XShapeDescriptor +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.drawing.Shape +* @see ifc.lang._XComponent +* @see ifc.drawing._XShape +* @see ifc.drawing._XShapeDescriptor +* @see ifc.beans._XPropertySet +* @see ifc.drawing._Shape +*/ +public class SdXShape extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @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 draw document" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Drawing document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("disposing xDrawDoc"); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of the draw pages from the drawing document using + * the interface <code>XDrawPagesSupplier</code>. Creates a rectangle shape + * that is the instance of the service <code>com.sun.star.drawing.Shape</code>. + * Creates and adds several new rectangle shapes and one ellipse shape to + * the retrieved draw page. Sets and gets some properties of the created + * rectangle shape. + * Object relations created : + * <ul> + * <li> <code>'Style1'</code> for + * {@link ifc.drawing._XShapeDescriptor}, {@link ifc.drawing._XShape} + * (the value of the property 'Style' that was retrieved from the created + * rectangle shape) </li> + * <li> <code>'Style2'</code> for + * {@link ifc.drawing._XShapeDescriptor}, {@link ifc.drawing._XShape} + * (the value of the property 'Style' that was retrieved from the created + * ellipse shape) </li> + * </ul> + * @see com.sun.star.drawing.XDrawPagesSupplier + * @see com.sun.star.drawing.Shape + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + // get the drawpage of drawing here + log.println( "getting Drawpage" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages oDPn = oDPS.getDrawPages(); + XIndexAccess oDPi = UnoRuntime.queryInterface(XIndexAccess.class, oDPn); + XDrawPage oDP = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDPi.getByIndex(0)); + + //get a Shape + log.println( "getting Shape" ); + XShapes oShapes = UnoRuntime.queryInterface + (XShapes.class, oDP); + XInterface oObj = SOF.createShape + (xDrawDoc, 5000, 3500, 7500, 5000, "Rectangle"); + for (int i=0; i < 10; i++) { + oShapes.add( + SOF.createShape(xDrawDoc, + 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle")); + } + XShape oShape = SOF.createShape + (xDrawDoc, 3000, 4500, 15000, 1000, "Ellipse"); + oShapes.add((XShape) oObj); + oShapes.add(oShape); + + log.println( "creating a new environment for XShape object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding two style as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oObj); + XStyle aStyle = null; + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + oShapeProps.setPropertyValue("ZOrder", Integer.valueOf(1)); + + tEnv.addObjRelation("Style1", aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape); + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + + tEnv.addObjRelation("Style2", aStyle); + + return tEnv; + } // finish method createTestEnvironment + +} // finish class SdXShape diff --git a/qadevOOo/tests/java/mod/_sd/package.html b/qadevOOo/tests/java/mod/_sd/package.html new file mode 100644 index 000000000..cd1299cd6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sd/package.html @@ -0,0 +1,23 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<!-- + * 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 . +--> +<HTML> +<BODY> +<P>Contains all test cases for the module 'sd'.</P> +</BODY> +</HTML> |