diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /qadevOOo/tests/java/mod | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qadevOOo/tests/java/mod')
601 files changed, 80669 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/mod/_acceptor/Acceptor.java b/qadevOOo/tests/java/mod/_acceptor/Acceptor.java new file mode 100644 index 000000000..0985a6aff --- /dev/null +++ b/qadevOOo/tests/java/mod/_acceptor/Acceptor.java @@ -0,0 +1,115 @@ +/* + * 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._acceptor; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** +* Here <code>com.sun.star.connection.Acceptor</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.connection.Acceptor +* @see com.sun.star.connection.XAcceptor +* @see com.sun.star.connection.XConnector +* @see ifc.connection._XAcceptor +*/ +public class Acceptor extends TestCase { + + + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 10000; + private int curPort ; + private String sOfficeHost = null ; + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + public void initialize( TestParameters tParam, PrintWriter log ) { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. <p> + * Creates <code>Acceptor</code> service and passed as relation + * connection string where port for accepting is unique among + * different object test threads. <p> + * The following object relations are created : + * <ul> + * <li> <code>'XAcceptor.connectStr'</code> : String variable for + * <code>XAcceptor</code> interface test. Has the following format : + * <code>'socket,host=<SOHost>,port=<UniquePort>' where <SOHost> is + * the host where StarOffice is started. </li> + * <li> <code>'Acceptor.Port'</code> : Integer value which specifies + * port on which Acceptor must listen, and which is required + * when disposing environment, to free this port number. </li> + * <ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = null; + XInterface acceptor = null; + + acceptor = (XInterface) + Param.getMSF().createInstance + ("com.sun.star.connection.Acceptor"); + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + oObj = acceptor; + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + // adding connection string as relation + tEnv.addObjRelation("XAcceptor.connectStr", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Acceptor.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + + curPort = ((Integer)tEnv.getObjRelation("Acceptor.Port")).intValue(); + } +} + + diff --git a/qadevOOo/tests/java/mod/_acceptor/package.html b/qadevOOo/tests/java/mod/_acceptor/package.html new file mode 100644 index 000000000..2f8205d1c --- /dev/null +++ b/qadevOOo/tests/java/mod/_acceptor/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 'acceptor'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_acceptor/uno/Acceptor.java b/qadevOOo/tests/java/mod/_acceptor/uno/Acceptor.java new file mode 100644 index 000000000..6cff44ff5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_acceptor/uno/Acceptor.java @@ -0,0 +1,104 @@ +/* + * 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._acceptor.uno; + +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** +* Here <code>com.sun.star.connection.Acceptor</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.connection.Acceptor +* @see com.sun.star.connection.XAcceptor +* @see com.sun.star.connection.XConnector +* @see ifc.connection._XAcceptor +*/ +public class Acceptor extends TestCase { + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 10000; + private int curPort ; + private String sOfficeHost = null ; + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + public void initialize( TestParameters tParam, PrintWriter log ) { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. <p> + * Creates <code>Acceptor</code> service and passed as relation + * connection string where port for accepting is unique among + * different object test threads. <p> + * The following object relations are created : + * <ul> + * <li> <code>'XAcceptor.connectStr'</code> : String variable for + * <code>XAcceptor</code> interface test. Has the following format : + * <code>'socket,host=<SOHost>,port=<UniquePort>' where <SOHost> is + * the host where StarOffice is started. </li> + * <li> <code>'Acceptor.Port'</code> : Integer value which specifies + * port on which Acceptor must listen, and which is required + * when disposing environment, to free this port number. </li> + * <ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface acceptor = (XInterface) + Param.getMSF().createInstance + ("com.sun.star.connection.Acceptor"); + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + + TestEnvironment tEnv = new TestEnvironment(acceptor) ; + + // adding connection string as relation + tEnv.addObjRelation("XAcceptor.connectStr", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Acceptor.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + + curPort = ((Integer)tEnv.getObjRelation("Acceptor.Port")).intValue(); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_ado/ODriver.java b/qadevOOo/tests/java/mod/_ado/ODriver.java new file mode 100644 index 000000000..de3de8cbb --- /dev/null +++ b/qadevOOo/tests/java/mod/_ado/ODriver.java @@ -0,0 +1,89 @@ +/* + * 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._ado; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + +/** +* Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.sdbc.Driver +* @see com.sun.star.sdbc.XDriver +* @see com.sun.star.sdbcx.XCreateCatalog +* @see com.sun.star.sdbcx.XDropCatalog +* @see ifc.sdbc._XDriver +* @see ifc.sdbcx._XCreateCatalog +* @see ifc.sdbcx._XDropCatalog +*/ +public class ODriver extends TestCase { + /** + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the database to which to connect. + * The URL is obtained from the parameter <code>ado.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments. + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF(). + createInstance("com.sun.star.comp.sdbc.ado.ODriver"); + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String adoURL = (String) Param.get("ado.url"); + if (adoURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'ado.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "sdbc:ado:" + adoURL); + + PropertyValue[] info = new PropertyValue[0]; + tEnv.addObjRelation("XDriver.INFO", info); + + String jdbcUrl = (String) Param.get("jdbc.url"); + if (jdbcUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_basctl/AccessibleShape.java b/qadevOOo/tests/java/mod/_basctl/AccessibleShape.java new file mode 100644 index 000000000..8a2bd9917 --- /dev/null +++ b/qadevOOo/tests/java/mod/_basctl/AccessibleShape.java @@ -0,0 +1,135 @@ +/* + * 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._basctl; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XDispatchHelper; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.WriterTools; +import util.utils; + +public class AccessibleShape extends TestCase { + + XTextDocument xTextDoc = null; + XInterface oObj = null; + + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("Cleaning up"); + DesktopTools.closeDoc(xTextDoc); + try { + XMultiServiceFactory xMSF = Param.getMSF(); + Object o = xMSF.createInstance("com.sun.star.frame.Desktop"); + XDesktop xDesk = UnoRuntime.queryInterface(XDesktop.class, o); + DesktopTools.closeDoc(xDesk.getCurrentFrame()); + } catch (Exception e) { + log.println("Couldn't close IDE"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(final TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + log.println( "creating a test environment" ); + String aURL=utils.getFullTestURL("basDialog.odt"); + xTextDoc = WriterTools.loadTextDoc(xMSF,aURL); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + XFrame xFrame = xModel.getCurrentController().getFrame(); + XDispatchProvider xDPP = UnoRuntime.queryInterface(XDispatchProvider.class, xFrame); + + log.println( "opening the basic dialog editor" ); + Object o = xMSF.createInstance("com.sun.star.frame.DispatchHelper"); + XDispatchHelper xDPH = UnoRuntime.queryInterface(XDispatchHelper.class, o); + PropertyValue[] aArgs = new PropertyValue[4]; + aArgs[0] = new PropertyValue(); + aArgs[0].Name = "Document"; + aArgs[0].Value = aURL; + aArgs[1] = new PropertyValue(); + aArgs[1].Name = "LibName"; + aArgs[1].Value = "basctl"; + aArgs[2] = new PropertyValue(); + aArgs[2].Name = "Name"; + aArgs[2].Value = "Dialog1"; + aArgs[3] = new PropertyValue(); + aArgs[3].Name = "Type"; + aArgs[3].Value = "Dialog"; + xDPH.executeDispatch(xDPP, ".uno:BasicIDEAppear", "", 0, aArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + oObj = (XInterface) tParam.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + final XWindow basicIDE = xFrame.getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(basicIDE); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + tEnv.addObjRelation("Destroy", Boolean.TRUE); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle oldPosSize = basicIDE.getPosSize(); + Rectangle newPosSize = new Rectangle(); + newPosSize.Width = oldPosSize.Width/2; + newPosSize.Height = oldPosSize.Height/2; + newPosSize.X = oldPosSize.X + 20; + newPosSize.Y = oldPosSize.Y + 20; + basicIDE.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, + newPosSize.Height, PosSize.POSSIZE); + util.utils.waitForEventIdle(tParam.getMSF()); + basicIDE.setPosSize(oldPosSize.X, oldPosSize.Y, oldPosSize.Width, + oldPosSize.Height, PosSize.POSSIZE); + } + }); + + return tEnv; + } + + + +} diff --git a/qadevOOo/tests/java/mod/_brdgfctr/BridgeFactory.java b/qadevOOo/tests/java/mod/_brdgfctr/BridgeFactory.java new file mode 100644 index 000000000..1957f9d6b --- /dev/null +++ b/qadevOOo/tests/java/mod/_brdgfctr/BridgeFactory.java @@ -0,0 +1,101 @@ +/* + * 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._brdgfctr; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** +* Tests <code>com.sun.star.bridge.BridgeFactory</code> +* service. <p> +* @see com.sun.star.bridge.XBridgeFactory +* @see com.sun.star.lang.XComponent +* @see ifc.bridge._XBridgeFactory +* @see ifc.lang._XComponent +*/ +public class BridgeFactory extends TestCase { + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + } + + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 50003 ; + private int curPort ; + private static String sOfficeHost = null ; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Just creates <code>com.sun.star.bridge.BridgeFactory</code> + * service as object to be tested. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface) Param.getMSF().createInstance + ("com.sun.star.bridge.BridgeFactory") ; + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + + // adding connection string as relation + tEnv.addObjRelation("CNNCTSTR", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue() ; + } +} + + diff --git a/qadevOOo/tests/java/mod/_brdgfctr/package.html b/qadevOOo/tests/java/mod/_brdgfctr/package.html new file mode 100644 index 000000000..40dbd15bd --- /dev/null +++ b/qadevOOo/tests/java/mod/_brdgfctr/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 'brdgfctr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_bridgefac/uno/BridgeFactory.java b/qadevOOo/tests/java/mod/_bridgefac/uno/BridgeFactory.java new file mode 100644 index 000000000..1860e3638 --- /dev/null +++ b/qadevOOo/tests/java/mod/_bridgefac/uno/BridgeFactory.java @@ -0,0 +1,97 @@ +/* + * 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._bridgefac.uno; + +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** +* Tests <code>com.sun.star.bridge.BridgeFactory</code> +* service. <p> +* @see com.sun.star.bridge.XBridgeFactory +* @see com.sun.star.lang.XComponent +* @see ifc.bridge._XBridgeFactory +* @see ifc.lang._XComponent +*/ +public class BridgeFactory extends TestCase { + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + } + + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 50003 ; + private int curPort ; + private static String sOfficeHost = null ; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Just creates <code>com.sun.star.bridge.BridgeFactory</code> + * service as object to be tested. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface) + Param.getMSF().createInstance + ("com.sun.star.bridge.BridgeFactory") ; + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + + // adding connection string as relation + tEnv.addObjRelation("CNNCTSTR", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue() ; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_bridgefac/uno/package.html b/qadevOOo/tests/java/mod/_bridgefac/uno/package.html new file mode 100644 index 000000000..40dbd15bd --- /dev/null +++ b/qadevOOo/tests/java/mod/_bridgefac/uno/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 'brdgfctr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_cached/CachedContentResultSetFactory.java b/qadevOOo/tests/java/mod/_cached/CachedContentResultSetFactory.java new file mode 100644 index 000000000..89d57f1e9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cached/CachedContentResultSetFactory.java @@ -0,0 +1,148 @@ +/* + * 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._cached; + +import com.sun.star.beans.Property; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.NumberedSortingInfo; +import com.sun.star.ucb.OpenCommandArgument2; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCachedContentResultSetStubFactory; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.ucb.XDynamicResultSet; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; +import com.sun.star.uno.AnyConverter; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.CachedContentResultSetFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XCachedContentResultSetFactory</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XCachedContentResultSetFactory +* @see com.sun.star.ucb.CachedContentResultSetFactory +* @see ifc.ucb._XCachedContentResultSetFactory +*/ +public class CachedContentResultSetFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.CachedContentResultSetFactory</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'CachedContentResultSetStub'</code> for + * {@link ifc.ucb._XCachedContentResultSetFactory} : the destination + * interface requires as its parameter an instance of + * <code>CachedContentResultSetStub</code> service. It is created + * using <code>UniversalContentBroker</code> and querying it for + * <code>PackageContent</code> which represents JAR file mentioned + * above. Then the dynamic list of file contents (entries) is retrieved, + * and a static list is created from it. Using + * <code>CachedContentResultSetStubFactory</code> service a stub of + * Cached result set is created which is relation required. + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.CachedContentResultSetFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // creating relation for XCachedContentResultSetFactory + XResultSet resSetStub = null ; + Object oUCB = xMSF.createInstanceWithArguments + ("com.sun.star.ucb.UniversalContentBroker", + new Object[0]) ; + + XContentIdentifierFactory ciFac = UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB) ; + + String url = util.utils.getFullTestURL("SwXTextEmbeddedObject.sxw") ; + StringBuilder escUrl = new StringBuilder(); + + // In base URL of a JAR file in content URL all directory + // separators ('/') must be replaced with escape symbol '%2F'. + int idx = url.indexOf("/") ; + int lastIdx = -1 ; + while (idx >= 0) { + escUrl.append(url.substring(lastIdx + 1, idx)).append("%2F"); + lastIdx = idx ; + idx = url.indexOf("/", idx + 1) ; + } + escUrl.append(url.substring(lastIdx + 1)); + String cntUrl = "vnd.sun.star.pkg://" + escUrl.toString() + "/" ; + + XContentIdentifier CI = ciFac.createContentIdentifier(cntUrl) ; + + XContentProvider cntProv = UnoRuntime.queryInterface(XContentProvider.class, oUCB) ; + + XContent cnt = cntProv.queryContent(CI) ; + + XCommandProcessor cmdProc = UnoRuntime.queryInterface(XCommandProcessor.class, cnt) ; + + Property prop = new Property() ; + prop.Name = "Title" ; + + Command cmd = new Command("open", -1, new OpenCommandArgument2 + (OpenMode.ALL, 10000, null, new Property[] {prop}, + new NumberedSortingInfo[0])) ; + + XDynamicResultSet dynResSet = (XDynamicResultSet) + AnyConverter.toObject(new Type(XDynamicResultSet.class), + cmdProc.execute(cmd, 0, null)); + + XResultSet resSet = dynResSet.getStaticResultSet() ; + + Object oStubFactory = xMSF.createInstance + ("com.sun.star.ucb.CachedContentResultSetStubFactory") ; + + XCachedContentResultSetStubFactory xStubFactory = + UnoRuntime.queryInterface + (XCachedContentResultSetStubFactory.class, oStubFactory) ; + + resSetStub = xStubFactory.createCachedContentResultSetStub(resSet) ; + + tEnv.addObjRelation("CachedContentResultSetStub", resSetStub) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_cached/CachedContentResultSetStubFactory.java b/qadevOOo/tests/java/mod/_cached/CachedContentResultSetStubFactory.java new file mode 100644 index 000000000..9e7a557d1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cached/CachedContentResultSetStubFactory.java @@ -0,0 +1,138 @@ +/* + * 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._cached; + +import com.sun.star.beans.Property; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.NumberedSortingInfo; +import com.sun.star.ucb.OpenCommandArgument2; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.ucb.XDynamicResultSet; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; +import com.sun.star.uno.AnyConverter; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.CachedContentResultSetStubFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XCachedContentResultSetStubFactory</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XCachedContentResultSetStubFactory +* @see com.sun.star.ucb.CachedContentResultSetStubFactory +* @see ifc.ucb._XCachedContentResultSetStubFactory +*/ +public class CachedContentResultSetStubFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.CachedContentResultSetStubFactory</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'ContentResultSet'</code> for + * {@link ifc.ucb._XCachedContentResultSetStubFactory} : the destination + * interface requires as its parameter an instance of + * <code>ContentResultSet</code> service. It is created + * using <code>UniversalContentBroker</code> and querying it for + * <code>PackageContent</code> which represents JAR file mentioned + * above. Then the dynamic list of file contents (entries) is retrieved, + * and a static list is created from it. It represents + * <code>ContentResultSet</code> service instance required. + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.CachedContentResultSetStubFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // creating relation for XCachedContentResultSetStubFactory + XResultSet resSet = null ; + Object oUCB = xMSF.createInstanceWithArguments + ("com.sun.star.ucb.UniversalContentBroker", + new Object[0]) ; + + XContentIdentifierFactory ciFac = UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB) ; + + String url = util.utils.getFullTestURL("SwXTextEmbeddedObject.sxw") ; + StringBuilder escUrl = new StringBuilder(); + + // In base URL of a JAR file in content URL all directory + // separators ('/') must be replaced with escape symbol '%2F'. + int idx = url.indexOf("/") ; + int lastIdx = -1 ; + while (idx >= 0) { + escUrl.append(url.substring(lastIdx + 1, idx)).append("%2F"); + lastIdx = idx ; + idx = url.indexOf("/", idx + 1) ; + } + escUrl.append(url.substring(lastIdx + 1)); + String cntUrl = "vnd.sun.star.pkg://" + escUrl.toString() + "/" ; + log.println("Getting Content of '" + cntUrl + "'") ; + + XContentIdentifier CI = ciFac.createContentIdentifier(cntUrl) ; + + XContentProvider cntProv = UnoRuntime.queryInterface(XContentProvider.class, oUCB) ; + + XContent cnt = cntProv.queryContent(CI) ; + + XCommandProcessor cmdProc = UnoRuntime.queryInterface(XCommandProcessor.class, cnt) ; + + Property prop = new Property() ; + prop.Name = "Title" ; + + Command cmd = new Command("open", -1, new OpenCommandArgument2 + (OpenMode.ALL, 10000, null, new Property[] {prop}, + new NumberedSortingInfo[0])) ; + + XDynamicResultSet dynResSet = (XDynamicResultSet) + AnyConverter.toObject(new Type(XDynamicResultSet.class), + cmdProc.execute(cmd, 0, null)); + + resSet = dynResSet.getStaticResultSet() ; + + tEnv.addObjRelation("ContentResultSet", resSet) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetFactory.java b/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetFactory.java new file mode 100644 index 000000000..87d13d6d3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetFactory.java @@ -0,0 +1,145 @@ +/* + * 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._cached; + +import com.sun.star.beans.Property; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.NumberedSortingInfo; +import com.sun.star.ucb.OpenCommandArgument2; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCachedDynamicResultSetStubFactory; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.ucb.XDynamicResultSet; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; +import com.sun.star.uno.AnyConverter; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.CachedDynamicResultSetFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XCachedDynamicResultSetFactory</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XCachedDynamicResultSetFactory +* @see com.sun.star.ucb.CachedDynamicResultSetFactory +* @see ifc.ucb._XCachedDynamicResultSetFactory +*/ +public class CachedDynamicResultSetFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.CachedDynamicResultSetFactory</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'CachedDynamicResultSetStub'</code> for + * {@link ifc.ucb._XCachedDynamicResultSetFactory} : the destination + * interface requires as its parameter an instance of + * <code>CachedDynamicResultSetStub</code> service. It is created + * using <code>UniversalContentBroker</code> and querying it for + * <code>PackageContent</code> which represents JAR file mentioned + * above. Then the dynamic list of file contents (entries) is retrieved. + * Using <code>CachedDynamicResultSetStubFactory</code> service a stub of + * Cached result set is created which is relation required. + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.CachedDynamicResultSetFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // creating relation for XCachedDynamicResultSetFactory + XDynamicResultSet resSetStub = null ; + Object oUCB = xMSF.createInstanceWithArguments + ("com.sun.star.ucb.UniversalContentBroker", + new Object[0]) ; + + XContentIdentifierFactory ciFac = UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB) ; + + String url = util.utils.getFullTestURL("SwXTextEmbeddedObject.sxw") ; + StringBuilder escUrl = new StringBuilder(); + + // In base URL of a JAR file in content URL all directory + // separators ('/') must be replaced with escape symbol '%2F'. + int idx = url.indexOf("/") ; + int lastIdx = -1 ; + while (idx >= 0) { + escUrl.append(url.substring(lastIdx + 1, idx)).append("%2F"); + lastIdx = idx ; + idx = url.indexOf("/", idx + 1) ; + } + escUrl.append(url.substring(lastIdx + 1)); + String cntUrl = "vnd.sun.star.pkg://" + escUrl.toString() + "/" ; + + XContentIdentifier CI = ciFac.createContentIdentifier(cntUrl) ; + + XContentProvider cntProv = UnoRuntime.queryInterface(XContentProvider.class, oUCB) ; + + XContent cnt = cntProv.queryContent(CI) ; + + XCommandProcessor cmdProc = UnoRuntime.queryInterface(XCommandProcessor.class, cnt) ; + + Property prop = new Property() ; + prop.Name = "Title" ; + + Command cmd = new Command("open", -1, new OpenCommandArgument2 + (OpenMode.ALL, 10000, null, new Property[] {prop}, + new NumberedSortingInfo[0])) ; + + XDynamicResultSet dynResSet = (XDynamicResultSet) + AnyConverter.toObject(new Type(XDynamicResultSet.class), + cmdProc.execute(cmd, 0, null)); + + Object oStubFactory = xMSF.createInstance + ("com.sun.star.ucb.CachedDynamicResultSetStubFactory") ; + + XCachedDynamicResultSetStubFactory xStubFactory = + UnoRuntime.queryInterface + (XCachedDynamicResultSetStubFactory.class, oStubFactory) ; + + resSetStub = + xStubFactory.createCachedDynamicResultSetStub(dynResSet) ; + + tEnv.addObjRelation("CachedDynamicResultSetStub", resSetStub) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetStubFactory.java b/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetStubFactory.java new file mode 100644 index 000000000..5249b8e26 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cached/CachedDynamicResultSetStubFactory.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._cached; + +import com.sun.star.beans.Property; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.NumberedSortingInfo; +import com.sun.star.ucb.OpenCommandArgument2; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.ucb.XContent; +import com.sun.star.ucb.XContentIdentifier; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.ucb.XContentProvider; +import com.sun.star.ucb.XDynamicResultSet; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.Type; +import com.sun.star.uno.AnyConverter; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.CachedDynamicResultSetStubFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XCachedDynamicResultSetStubFactory</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XCachedDynamicResultSetStubFactory +* @see com.sun.star.ucb.CachedDynamicResultSetStubFactory +* @see ifc.ucb._XCachedDynamicResultSetStubFactory +*/ +public class CachedDynamicResultSetStubFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.CachedDynamicResultSetStubFactory</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'DynamicResultSet'</code> for + * {@link ifc.ucb._XCachedDynamicResultSetStubFactory} : the destination + * interface requires as its parameter an instance of + * <code>DynamicResultSet</code> service. It is created + * using <code>UniversalContentBroker</code> and querying it for + * <code>PackageContent</code> which represents JAR file mentioned + * above. Then the dynamic list of file contents (entries) is retrieved. + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.CachedDynamicResultSetStubFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // creating relation for XCachedDynamicResultSetStubFactory + XDynamicResultSet dynResSet = null ; + Object oUCB = xMSF.createInstanceWithArguments + ("com.sun.star.ucb.UniversalContentBroker", + new Object[0]) ; + + XContentIdentifierFactory ciFac = UnoRuntime.queryInterface(XContentIdentifierFactory.class, oUCB) ; + + String url = util.utils.getFullTestURL("SwXTextEmbeddedObject.sxw") ; + StringBuilder escUrl = new StringBuilder(); + + // In base URL of a JAR file in content URL all directory + // separators ('/') must be replaced with escape symbol '%2F'. + int idx = url.indexOf("/") ; + int lastIdx = -1 ; + while (idx >= 0) { + escUrl.append(url.substring(lastIdx + 1, idx)).append("%2F"); + lastIdx = idx ; + idx = url.indexOf("/", idx + 1) ; + } + escUrl.append(url.substring(lastIdx + 1)); + String cntUrl = "vnd.sun.star.pkg://" + escUrl.toString() + "/" ; + + XContentIdentifier CI = ciFac.createContentIdentifier(cntUrl) ; + + XContentProvider cntProv = UnoRuntime.queryInterface(XContentProvider.class, oUCB) ; + + XContent cnt = cntProv.queryContent(CI) ; + + XCommandProcessor cmdProc = UnoRuntime.queryInterface(XCommandProcessor.class, cnt) ; + + Property prop = new Property() ; + prop.Name = "Title" ; + + Command cmd = new Command("open", -1, new OpenCommandArgument2 + (OpenMode.ALL, 10000, null, new Property[] {prop}, + new NumberedSortingInfo[0])) ; + + dynResSet = (XDynamicResultSet) + AnyConverter.toObject(new Type(XDynamicResultSet.class), + cmdProc.execute(cmd, 0, null)); + + tEnv.addObjRelation("DynamicResultSet", dynResSet) ; + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_cmdmail/SimpleCommandMail.java b/qadevOOo/tests/java/mod/_cmdmail/SimpleCommandMail.java new file mode 100644 index 000000000..046557645 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cmdmail/SimpleCommandMail.java @@ -0,0 +1,52 @@ +/* + * 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._cmdmail; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class SimpleCommandMail extends TestCase { + + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.comp.system.SimpleCommandMail" ); + + if (oInterface == null) log.println("!!! NULL !!!") ; + XInterface oObj = (XInterface) oInterface; + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java b/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java new file mode 100644 index 000000000..3d8338077 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cnt/ChaosContentProvider.java @@ -0,0 +1,89 @@ +/* + * 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._cnt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.cnt.ChaosContentProvider</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XContentProvider</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XContentProvider +* @see com.sun.star.ucb.ChaosContentProvider +* @see ifc.ucb._XContentProvider +*/ +public class ChaosContentProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.cnt.ChaosContentProvider</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FACTORY'</code> for + * {@link ifc.ucb._XContentProvider} factory for + * content identifiers. Here it is + * <code>UniversalContentBroker</code> service.</li> + * <li> <code>'CONTENT1'</code> for + * {@link ifc.ucb._XContentProvider}: suitable + * content URL for this provider </li> + * <li> <code>'CONTENT2'</code> for + * {@link ifc.ucb._XContentProvider}: another suitable + * content URL for this provider </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.ChaosContentProvider" ); + Object cntFactory = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XContentProvider + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class, cntFactory); + + tEnv.addObjRelation("FACTORY", CIF) ; + tEnv.addObjRelation("CONTENT1", "ftp://localhost") ; + tEnv.addObjRelation("CONTENT2", "ftp://sva.dorms.spbu.ru") ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java b/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java new file mode 100644 index 000000000..8fc8cd0d9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cnt/CntUnoDataContainer.java @@ -0,0 +1,112 @@ +/* + * 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._cnt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.container.XIndexContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::ucb::XDataContainer</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> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XActiveDataSink +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.ucb.XDataContainer +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XIndexReplace +* @see ifc.io._XActiveDataSink +* @see ifc.container._XIndexContainer +* @see ifc.ucb._XDataContainer +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XIndexReplace +*/ +public class CntUnoDataContainer extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.cnt.CntUnoDataContainer</code> and adds + * to it one <code>CntUnoDataContainer</code> instance. <p> + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1'</code> for + * {@link ifc.container._XIndexContainer}, + * {@link ifc.container._XIndexReplace} : for this object + * elements contained in it are <code>CntUnoDataContainer</code> + * instances. (only one relation for one interface thread is now + * passed).</li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink} : a stream to set and get. + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); + + // adding one child container + XIndexContainer xIC = UnoRuntime.queryInterface + (XIndexContainer.class, oInterface) ; + + Object child = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); + xIC.insertByIndex(0, child) ; + + Object relationContainer = xMSF.createInstance + ( "com.sun.star.ucb.DataContainer" ); + + Object xIn = xMSF.createInstance + ( "com.sun.star.io.DataInputStream" ); + + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("INSTANCE1", relationContainer) ; + tEnv.addObjRelation("InputStream", xIn) ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class BreakIterator + diff --git a/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java b/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java new file mode 100644 index 000000000..93807fe5f --- /dev/null +++ b/qadevOOo/tests/java/mod/_cnt/PropertyMatcherFactory.java @@ -0,0 +1,65 @@ +/* + * 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._cnt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.cnt.CntUnoDataContainer</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XPropertyMatcherFactory</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XPropertyMatcherFactory +* @see com.sun.star.ucb.PropertyMatcherFactory +* @see ifc.ucb._XPropertyMatcherFactory +*/ +public class PropertyMatcherFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.cnt.PropertyMatcherFactory</code>. <p> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ucb.PropertyMatcherFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_configmgr/ConfigurationProvider.java b/qadevOOo/tests/java/mod/_configmgr/ConfigurationProvider.java new file mode 100644 index 000000000..dc114804e --- /dev/null +++ b/qadevOOo/tests/java/mod/_configmgr/ConfigurationProvider.java @@ -0,0 +1,44 @@ +/* + * 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._configmgr; + +import com.sun.star.beans.NamedValue; +import com.sun.star.uno.XComponentContext; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import java.io.PrintWriter; + +public final class ConfigurationProvider extends TestCase { + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception + { + // Create a non-default ConfigurationProvider instance, so that testing + // its XComponent.dispose does not accidentally dispose the + // DefaultProvider: + XComponentContext ctxt = tParam.getComponentContext(); + return ProviderTestEnvironment.create( + ctxt.getServiceManager().createInstanceWithArgumentsAndContext( + "com.sun.star.configuration.ConfigurationProvider", + new Object[] { new NamedValue("Locale", "*") }, + ctxt)); + } +} diff --git a/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java b/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java new file mode 100644 index 000000000..2a11a9b51 --- /dev/null +++ b/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java @@ -0,0 +1,40 @@ +/* + * 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._configmgr; + +import com.sun.star.configuration.theDefaultProvider; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.XInterface; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import java.io.PrintWriter; + +public final class DefaultProvider extends TestCase { + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) + { + return ProviderTestEnvironment.create( + AnyConverter.toObject( + XInterface.class, + theDefaultProvider.get(tParam.getComponentContext()))); + } +} diff --git a/qadevOOo/tests/java/mod/_configmgr/ProviderTestEnvironment.java b/qadevOOo/tests/java/mod/_configmgr/ProviderTestEnvironment.java new file mode 100644 index 000000000..7e0eb2f96 --- /dev/null +++ b/qadevOOo/tests/java/mod/_configmgr/ProviderTestEnvironment.java @@ -0,0 +1,42 @@ +/* + * 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._configmgr; + +import com.sun.star.beans.NamedValue; +import com.sun.star.uno.XInterface; +import lib.TestEnvironment; + +final class ProviderTestEnvironment { + private ProviderTestEnvironment() {} + + public static TestEnvironment create(Object provider) { + TestEnvironment env = new TestEnvironment((XInterface) provider); + env.addObjRelation( + "XMSF.serviceNamesWithArgs", + new String[] { + "com.sun.star.configuration.ConfigurationAccess", + "com.sun.star.configuration.ConfigurationUpdateAccess" }); + Object[] args = new Object[] { + new NamedValue("nodepath", "/org.openoffice.Setup") }; + env.addObjRelation("XMSF.Args", new Object[][] { args, args }); + env.addObjRelation( + "needArgs", "com.sun.star.configuration.ConfigurationProvider"); + return env; + } +} diff --git a/qadevOOo/tests/java/mod/_connector/uno/Connector.java b/qadevOOo/tests/java/mod/_connector/uno/Connector.java new file mode 100644 index 000000000..17b0c4e73 --- /dev/null +++ b/qadevOOo/tests/java/mod/_connector/uno/Connector.java @@ -0,0 +1,104 @@ +/* + * 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._connector.uno; + +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** +* Test for object which is represented by service +* <code>com.sun.star.connection.Connector</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::connection::XConnector</code></li> +* </ul> +* Can be run in several threads. +* @see com.sun.star.connection.XConnector +* @see ifc.connection._XConnector +*/ +public class Connector extends TestCase { + + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 10000 ; + private int curPort ; + private static String sOfficeHost = null ; + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + /** + * Does nothing. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Just creates service <code>com.sun.star.connection.Connector</code> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface connector = (XInterface) + Param.getMSF().createInstance + ("com.sun.star.connection.Connector") ; + + TestEnvironment tEnv = new TestEnvironment(connector) ; + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + + // adding connection string as relation + tEnv.addObjRelation("XConnector.connectStr", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + + curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue(); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_connector/uno/package.html b/qadevOOo/tests/java/mod/_connector/uno/package.html new file mode 100644 index 000000000..c9ff7b2b5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_connector/uno/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 'connector'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_connectr/Connector.java b/qadevOOo/tests/java/mod/_connectr/Connector.java new file mode 100644 index 000000000..3128ef468 --- /dev/null +++ b/qadevOOo/tests/java/mod/_connectr/Connector.java @@ -0,0 +1,108 @@ +/* + * 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._connectr; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.connection.Connector</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::connection::XConnector</code></li> +* </ul> +* Can be run in several threads. +* @see com.sun.star.connection.XConnector +* @see ifc.connection._XConnector +*/ +public class Connector extends TestCase { + + /** + * Acceptor chooses the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 10000 ; + private int curPort ; + private static String sOfficeHost = null ; + + /** + * Retrieves host name where StarOffice is started from test + * parameter <code>'CONNECTION_STRING'</code>. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + sOfficeHost = cncstr.substring(idx, cncstr.indexOf(",", idx)) ; + } + + /** + * Does nothing. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Just creates service <code>com.sun.star.connection.Connector</code> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + XInterface connector = (XInterface) + Param.getMSF().createInstance + ("com.sun.star.connection.Connector") ; + + TestEnvironment tEnv = new TestEnvironment(connector) ; + + // select the port + curPort = utils.getNextFreePort(basePort); + log.println("Choose Port nr: " + curPort); + + // adding connection string as relation + tEnv.addObjRelation("XConnector.connectStr", + "socket,host=" + sOfficeHost + ",port=" + curPort) ; + + // adding port number for freeing it. + tEnv.addObjRelation("Connector.Port", Integer.valueOf(curPort)) ; + + return tEnv ; + } + + /** + * Just clears flag which indicates that port is free now. + */ + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam) { + + curPort = ((Integer)tEnv.getObjRelation("Connector.Port")).intValue(); + } +} + + diff --git a/qadevOOo/tests/java/mod/_connectr/package.html b/qadevOOo/tests/java/mod/_connectr/package.html new file mode 100644 index 000000000..c9ff7b2b5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_connectr/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 'connector'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_corefl/CoreReflection.java b/qadevOOo/tests/java/mod/_corefl/CoreReflection.java new file mode 100644 index 000000000..880a47c17 --- /dev/null +++ b/qadevOOo/tests/java/mod/_corefl/CoreReflection.java @@ -0,0 +1,61 @@ +/* + * 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._corefl; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.CoreReflection</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::reflection::XIdlReflection</code></li> +* </ul> +* @see com.sun.star.reflection.XIdlReflection +* @see ifc.reflection._XIdlReflection +*/ +public class CoreReflection extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.reflection.CoreReflection</code> service. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ("com.sun.star.reflection.CoreReflection"); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for CoreReflection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class CoreReflection + diff --git a/qadevOOo/tests/java/mod/_corefl/package.html b/qadevOOo/tests/java/mod/_corefl/package.html new file mode 100644 index 000000000..9d604ba75 --- /dev/null +++ b/qadevOOo/tests/java/mod/_corefl/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 'corefl'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_corereflection/uno/CoreReflection.java b/qadevOOo/tests/java/mod/_corereflection/uno/CoreReflection.java new file mode 100644 index 000000000..7b291e743 --- /dev/null +++ b/qadevOOo/tests/java/mod/_corereflection/uno/CoreReflection.java @@ -0,0 +1,58 @@ +/* + * 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._corereflection.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.CoreReflection</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::reflection::XIdlReflection</code></li> +* </ul> +* @see com.sun.star.reflection.XIdlReflection +* @see ifc.reflection._XIdlReflection +*/ +public class CoreReflection extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.reflection.CoreReflection</code> service. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ("com.sun.star.reflection.CoreReflection"); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for CoreReflection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class CoreReflection
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_corereflection/uno/package.html b/qadevOOo/tests/java/mod/_corereflection/uno/package.html new file mode 100644 index 000000000..9d604ba75 --- /dev/null +++ b/qadevOOo/tests/java/mod/_corereflection/uno/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 'corefl'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_cpld/DLLComponentLoader.java b/qadevOOo/tests/java/mod/_cpld/DLLComponentLoader.java new file mode 100644 index 000000000..fa254bbdc --- /dev/null +++ b/qadevOOo/tests/java/mod/_cpld/DLLComponentLoader.java @@ -0,0 +1,94 @@ +/* + * 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._cpld; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p> +* Files which are used : +* <ul> +* <li> <code>XImpReg.dll</code> : DLL which will be loaded in +* <code>XImplementationLoader</code> interface test. </li> +* <ul> +* Multithread testing compliant. +* @see com.sun.star.loader.XImplementationLoader +* @see com.sun.star.lang.XServiceInfo +* @see ifc.loader._XImplementationLoader +* @see ifc.lang._XServiceInfo +*/ +public class DLLComponentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code> + * service. <p> + * The following object relations created : + * <ul> + * <li> <code>'ImplementationLoader'</code> : service which is + * responsible for loading DLL implementations. </li> + * <li> <code>'ImplementationUrl'</code> : DLL file location. </li> + * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.DLLComponentLoader" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for DLLComponentLoader object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding object relation for XImplementationLoader ifc test + tEnv.addObjRelation("ImplementationLoader", + "com.sun.star.loader.SharedLibrary") ; + String os = (String) Param.get("OS"); + if (os == null || os.equals("")) + throw new StatusException( + "Couldn't determine operating system for naming convention.", + new NullPointerException()); + String name = "javaloader"; + if (!os.equals("wntmsci")) + name = "lib" + name + ".so"; + else + name += ".dll"; + String implURL = utils.getFullTestURL(os + "/" + name); + tEnv.addObjRelation("ImplementationUrl", implURL) ; + log.println("looking for shared lib: " + implURL); + tEnv.addObjRelation("ImplementationName", + "com.sun.star.comp.stoc.JavaComponentLoader") ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class DLLComponentLoader + diff --git a/qadevOOo/tests/java/mod/_cpld/package.html b/qadevOOo/tests/java/mod/_cpld/package.html new file mode 100644 index 000000000..1bc7bf117 --- /dev/null +++ b/qadevOOo/tests/java/mod/_cpld/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 'cpld'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java new file mode 100644 index 000000000..3cded65a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ConnectionLineAccessibility.java @@ -0,0 +1,261 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdb.XQueryDefinitionsSupplier; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XIsolatedConnection; +import com.sun.star.sdbc.XStatement; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import util.DesktopTools; +import util.utils; + + +/** + * Object implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessible</code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul><p> + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + */ +public class ConnectionLineAccessibility extends TestCase +{ + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password=""; + + /** + * Creates a new DataSource and stores it. + * Creates a connection and using it + * creates two tables in database. + * Creates a new query and adds it to DefinitionContainer. + * Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role UNKNOWN and the implementation + * name that contains ConnectionLine + * @param Param test parameters + * @param log writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception + { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF().createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance("com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get("mysql.url"); + + if (mysqlURL == null) + { + throw new StatusException(Status.failed( + "Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get("jdbc.user"); + password = (String) Param.get("jdbc.password"); + + if ((user == null) || (password == null)) + { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue(); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue(); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue("URL", mysqlURL); + propSetDBSource.setPropertyValue("Info", info); + + log.println("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + + aFile = utils.getOfficeTemp(Param.getMSF())+"ConnectionLine.odb"; + log.println("... filename will be "+aFile); + store.storeAsURL(aFile,new PropertyValue[]{}); + log.println("... done"); + + isolConnection = UnoRuntime.queryInterface( + XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + + XConnection connection = isolConnection.getIsolatedConnection(user, password); + XStatement statement = connection.createStatement(); + statement.executeUpdate("drop table if exists " + tbl_name1); + statement.executeUpdate("drop table if exists " + tbl_name2); + statement.executeUpdate("create table " + tbl_name1 + " (" + + col_name1 + " int)"); + statement.executeUpdate("create table " + tbl_name2 + " (" + + col_name2 + " int)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface( + XQueryDefinitionsSupplier.class, + oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions(); + + XPropertySet queryProp = UnoRuntime.queryInterface( + XPropertySet.class, newQuery); + + final String query = "select * from " + tbl_name1 + ", " + + tbl_name2 + " where " + tbl_name1 + "." + + col_name1 + "=" + tbl_name2 + "." + + col_name2; + queryProp.setPropertyValue("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface( + XNameContainer.class, + defContainer); + + queryContainer.insertByName("Query1", newQuery); + store.store(); + connection.close(); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue(); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue(); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc(Param.getMSF(),".component:DB/QueryDesign",loadProps); + + util.utils.waitForEventIdle(Param.getMSF()); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRoleIgnoreShowing(xRoot, AccessibleRole.UNKNOWN, "", "ConnectionLine"); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + final XWindow queryWin = xWindow; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() + { + public void fireEvent() + { + Rectangle rect = queryWin.getPosSize(); + queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE); + } + }); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes the DatasourceAdministration dialog and Query Dialog. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) + { + try + { + + log.println("closing QueryComponent ..."); + DesktopTools.closeDoc(QueryComponent); + log.println("... done"); + XMultiServiceFactory xMSF = Param.getMSF(); + Object sfa = xMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface(XSimpleFileAccess.class, sfa); + log.println("deleting database file"); + xSFA.kill(aFile); + log.println("Could delete file "+aFile+": "+!xSFA.exists(aFile)); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java b/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java new file mode 100644 index 000000000..b37389759 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/DBContentLoader.java @@ -0,0 +1,82 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.ContentLoader</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::frame::FrameLoader</code></li> +* <li> <code>com::sun::star::frame::XFrameLoader</code></li> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.frame.FrameLoader +* @see com.sun.star.frame.XSynchronousFrameLoader +* @see com.sun.star.lang.XInitialization +* @see ifc.beans._XPropertySet +* @see ifc.frame._FrameLoader +* @see ifc.frame._XSynchronousFrameLoader +* @see ifc.lang._XInitialization +*/ +public class DBContentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.ContentLoader</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FrameLoader.URL"'</code> for + * {@link ifc.frame._XFrameLoader} </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.sdb.ContentLoader"); + XInterface oObj = (XInterface) oInterface ; + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XFrameLoader + tEnv.addObjRelation("FrameLoader.URL", ".component:DB/DataSourceBrowser") ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java new file mode 100644 index 000000000..499779ebf --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/JoinViewAccessibility.java @@ -0,0 +1,254 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdb.XQueryDefinitionsSupplier; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XIsolatedConnection; +import com.sun.star.sdbc.XStatement; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import util.DesktopTools; +import util.utils; + + +/** +* Object implements the following interfaces : +* <ul> +* <li><code>::com::sun::star::accessibility::XAccessible</code></li> +* <li><code>::com::sun::star::accessibility::XAccessibleContext +* </code></li> +* <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster +* </code></li> +* </ul><p> +* @see com.sun.star.accessibility.XAccessible +* @see com.sun.star.accessibility.XAccessibleContext +* @see com.sun.star.accessibility.XAccessibleEventBroadcaster +* @see ifc.accessibility._XAccessible +* @see ifc.accessibility._XAccessibleContext +* @see ifc.accessibility._XAccessibleEventBroadcaster +*/ +public class JoinViewAccessibility extends TestCase { + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password=""; + + /** + * Creates a new DataSource and stores it. + * Creates a connection and using it + * creates two tables in database. + * Creates a new query and adds it to DefinitionContainer. + * Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role UNKNOWN and the implementation + * name that contains ConnectionLine + * @param Param test parameters + * @param log writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment (TestParameters Param, + PrintWriter log) throws Exception + { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF() + .createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance( + "com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get ("mysql.url"); + + if (mysqlURL == null) + { + throw new StatusException (Status.failed ( + "Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get ("jdbc.user"); + password = (String) Param.get ("jdbc.password"); + + if ((user == null) || (password == null)) + { + throw new StatusException (Status.failed ( + "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue (); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue (); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface ( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue ("URL", mysqlURL); + propSetDBSource.setPropertyValue ("Info", info); + + log.println ("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + aFile = utils.getOfficeTemp (Param.getMSF ())+"JoinView.odb"; + log.println ("... filename will be "+aFile); + store.storeAsURL (aFile,new PropertyValue[]{}); + log.println ("... done"); + + isolConnection = UnoRuntime.queryInterface ( + XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + XConnection connection = isolConnection.getIsolatedConnection (user, password); + XStatement statement = connection.createStatement (); + statement.executeUpdate ("drop table if exists " + tbl_name1); + statement.executeUpdate ("drop table if exists " + tbl_name2); + statement.executeUpdate ("create table " + tbl_name1 + " (" + + col_name1 + " int)"); + statement.executeUpdate ("create table " + tbl_name2 + " (" + + col_name2 + " int)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface ( + XQueryDefinitionsSupplier.class, + oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions (); + + XPropertySet queryProp = UnoRuntime.queryInterface ( + XPropertySet.class, newQuery); + + final String query = "select * from " + tbl_name1 + ", " + + tbl_name2 + " where " + tbl_name1 + "." + + col_name1 + "=" + tbl_name2 + "." + + col_name2; + queryProp.setPropertyValue ("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface ( + XNameContainer.class, + defContainer); + + queryContainer.insertByName ("Query1", newQuery); + store.store (); + connection.close (); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue (); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue (); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue (); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc (Param.getMSF (),".component:DB/QueryDesign",loadProps); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject (xWindow); + + AccessibilityTools.printAccessibleTree (log,xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.VIEW_PORT); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + final XWindow queryWin = xWindow; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle rect = queryWin.getPosSize(); + queryWin.setPosSize(rect.X, rect.Y, rect.Height-5, rect.Width-5, PosSize.POSSIZE); + } + }); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes the DatasourceAdministration dialog and Query Dialog. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try + { + + log.println ("closing QueryComponent ..."); + DesktopTools.closeDoc (QueryComponent); + log.println ("... done"); + XMultiServiceFactory xMSF = Param.getMSF (); + Object sfa = xMSF.createInstance ("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface (XSimpleFileAccess.class, sfa); + log.println ("deleting database file"); + xSFA.kill (aFile); + log.println ("Could delete file "+aFile+": "+!xSFA.exists (aFile)); + } catch (Exception e) + { + e.printStackTrace (); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java b/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java new file mode 100644 index 000000000..895df264f --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OCommandDefinition.java @@ -0,0 +1,65 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.QueryDefinition</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sdb::QueryDefinition</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* This object test <b> can </b> be run in several +* threads concurrently. +* @see com.sun.star.sdb.QueryDefinition +* @see com.sun.star.beans.XPropertySet +* @see ifc.sdb._QueryDefinition +* @see ifc.beans._XPropertySet +*/ +public class OCommandDefinition extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.sdb.QueryDefinition</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.QueryDefinition" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java new file mode 100644 index 000000000..24b69854b --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseContext.java @@ -0,0 +1,106 @@ +/* + * 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._dbaccess; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XNamingService; +import com.sun.star.frame.XStorable; +import com.sun.star.sdb.XDocumentDataSource; +import util.utils; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DatabaseContext</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::uno::XNamingService</code></li> +* </ul> +* +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.uno.XNamingService +* @see com.sun.star.sdb.DatabaseContext +* @see ifc.container._XNameAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.container._XElementAccess +* @see ifc.uno._XNamingService +*/ +public class ODatabaseContext extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.sdb.DatabaseContext</code>. + * Needed object relations : + * <ul> + * <li> <code>'XNamingService.RegisterObject'</code> for + * {@link ifc.uno._XNamingService} as an + * instance of <code>com.sun.star.sdb.DataSource</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding obj relation for XNamingService + oInterface = xMSF.createInstance( "com.sun.star.sdb.DataSource" ); + + XPropertySet xDSProps = UnoRuntime.queryInterface(XPropertySet.class, oInterface) ; + + xDSProps.setPropertyValue("URL", "sdbc:dbase:file:///.") ; + + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oInterface); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument ()); + String aFile = utils.getOfficeTemp (Param.getMSF ())+"DatabaseContext.odb"; + log.println("store to '" + aFile + "'"); + store.storeAsURL(aFile,new PropertyValue[]{}); + + tEnv.addObjRelation("XNamingService.RegisterObject", oInterface) ; + + tEnv.addObjRelation("INSTANCE", oInterface); + + tEnv.addObjRelation("XContainer.Container", + UnoRuntime.queryInterface( + XNamingService.class, oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java new file mode 100644 index 000000000..1976f5711 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatabaseSource.java @@ -0,0 +1,175 @@ +/* + * 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._dbaccess; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XStorable; + + +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XNamingService; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XOfficeDatabaseDocument; +import com.sun.star.task.XInteractionHandler; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DataSource</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sdb::XQueryDefinitionsSupplier</code></li> +* <li> <code>com::sun::star::sdb::DataSource</code></li> +* <li> <code>com::sun::star::sdb::XCompletedConnection</code></li> +* <li> <code>com::sun::star::util::XFlushable</code></li> +* <li> <code>com::sun::star::sdb::XBookmarksSupplier</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* +* @see com.sun.star.sdb.XQueryDefinitionsSupplier +* @see com.sun.star.sdb.XFormDocumentsSupplier +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.sdb.DataSource +* @see com.sun.star.sdb.XCompletedConnection +* @see com.sun.star.util.XFlushable +* @see com.sun.star.sdb.XReportDocumentsSupplier +* @see ifc.sdb._XQueryDefinitionsSupplier +* @see ifc.sdb._XFormDocumentsSupplier +* @see ifc.beans._XPropertySet +* @see ifc.sdb._DataSource +* @see ifc.sdb._XCompletedConnection +* @see ifc.util._XFlushable +* @see ifc.sdb._XReportDocumentsSupplier +*/ +public class ODatabaseSource extends TestCase { + + private static int uniqueSuffixStat = 0 ; + + private int uniqueSuffix = 0 ; + private XOfficeDatabaseDocument xDBDoc = null; + + /** + * Assigns database's name unique suffix for this object depending + * on static field. For names differs in different object threads. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + uniqueSuffix = uniqueSuffixStat++ ; + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing no longer needed docs... "); + DesktopTools.closeDoc(xDBDoc); + } + + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates new <code>DataSource</code> which represents DBase database + * located in temporary directory, and then registers it in service + * <code>com.sun.star.sdb.DatabaseContext</code>. + * + * Created object relations : + * <ul> + * <li> <code>'XCompletedConnection.Handler'</code> for interface test + * <code>XCompletedConnection</code> </li> + * </ul> + * <li> <code>'UserAndPassword'</code> for interface test + * <code>XIsolatedConnection</code> </li> + * </ul> + * @see com.sun.star.sdb.DatabaseContext + * @see com.sun.star.sdb.DataSource + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + XNamingService xDBContextNameServ = UnoRuntime.queryInterface(XNamingService.class, oInterface) ; + + // retrieving temp directory for database + String tmpDatabaseUrl = utils.getOfficeTempDir(Param.getMSF()); + + tmpDatabaseUrl = "sdbc:dbase:file:///" + tmpDatabaseUrl ; + + XInterface oDatabaseDoc = (XInterface) xMSF.createInstance + ("com.sun.star.sdb.OfficeDatabaseDocument") ; + + if (oDatabaseDoc == null) + throw new StatusException("Could not get service 'com.sun.star.sdb.OfficeDatabaseDocument'", new Exception()); + + xDBDoc = UnoRuntime.queryInterface( + XOfficeDatabaseDocument.class, + oDatabaseDoc); + XInterface oObj = xDBDoc.getDataSource(); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + // Creating new DBase data source in the TEMP directory + + XPropertySet xSrcProp = UnoRuntime.queryInterface(XPropertySet.class, oObj); + + xSrcProp.setPropertyValue("URL", tmpDatabaseUrl) ; + + String databaseName = "NewDatabaseSource" + uniqueSuffix ; + + // make sure that the DatabaseContext isn't already registered + try { + xDBContextNameServ.revokeObject(databaseName) ; + } catch (Exception e) { + log.println("Nothing to be removed - OK"); + } + + // registering source in DatabaseContext + XStorable store = UnoRuntime.queryInterface(XStorable.class, xDBDoc); + String aFile = utils.getOfficeTemp (Param.getMSF ())+"DataSource.odb"; + store.storeAsURL(aFile,new PropertyValue[]{}); + + xDBContextNameServ.registerObject(databaseName, oObj) ; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding obj relation for interface XCompletedConnection + Object handler = Param.getMSF().createInstance + ("com.sun.star.sdb.InteractionHandler") ; + + // dbase does not need user and password + tEnv.addObjRelation("UserAndPassword", new String[]{"",""}) ; + + tEnv.addObjRelation("XCompletedConnection.Handler", + UnoRuntime.queryInterface(XInteractionHandler.class, handler)) ; + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java new file mode 100644 index 000000000..d229d3eb9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceAdministrationDialog.java @@ -0,0 +1,75 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.DatasourceAdministrationDialog</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* <li> <code>com::sun::star::ui::dialogs::XExecutableDialog</code></li> +* <li> <code>com::sun::star::sdb::DatasourceAdministrationDialog</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> <p> +* +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.ui.dialogs.XExecutableDialog +* @see com.sun.star.sdb.DatasourceAdministrationDialog +* @see com.sun.star.beans.XPropertySet +* @see ifc.lang._XInitialization +* @see ifc.ui.dialogs._XExecutableDialog +* @see ifc.sdb._DatasourceAdministrationDialog +* @see ifc.beans._XPropertySet +*/ +public class ODatasourceAdministrationDialog extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.DatasourceAdministrationDialog</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.sdb.DatasourceAdministrationDialog" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ODataSourceAdministrationDialog + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java new file mode 100644 index 000000000..1ccccf532 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ODatasourceBrowser.java @@ -0,0 +1,297 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +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.XInitialization; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.DataSourceBrowser</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::util::XModifyBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XTabController</code></li> + * <li> <code>com::sun::star::form::XFormController</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::frame::XDispatchProvider</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::frame::XController</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.container.XChild + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.util.XModifyBroadcaster + * @see com.sun.star.awt.XTabController + * @see com.sun.star.form.XFormController + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.frame.XDispatchProvider + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.frame.XController + * @see com.sun.star.lang.XComponent + * @see ifc.container._XChild + * @see ifc.lang._XInitialization + * @see ifc.util._XModifyBroadcaster + * @see ifc.awt._XTabController + * @see ifc.form._XFormController + * @see ifc.container._XElementAccess + * @see ifc.frame._XDispatchProvider + * @see ifc.container._XEnumerationAccess + * @see ifc.frame._XController + * @see ifc.lang._XComponent + */ +public class ODatasourceBrowser extends TestCase { + XDesktop xDesktop; + XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + System.setProperty("hideMe", "false"); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + System.setProperty("hideMe", "true"); + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates a new text document disposing the old one if it was + * created. Using <code>Desktop</code> service get the frame + * of the document and with its help creates + * <code>DataSourceBrowser</code> dispatching the URL + * <code>'.component:DB/DataSourceBrowser'</code>. The + * component for testing is the controller of the + * <code>Browser</code> and it's got by searching its + * frame with the help of TextDocument frame, and obtaining + * the frame's controller. <p> + * + * <b>Note</b>: after creating the text document a short + * pause is needed to give a possibility to a frame to be + * created for the document. Else + * <code>Desktop.getCurrentFrame()</code> method can return + * <code>null</code> value. <p> + * + * Object relations created : + * <ul> + * <li> <code>'XDispatchProvider.URL'</code> for + * {@link ifc.frame._XDispatchProvider} </li> + * <li> <code>'SecondModel'</code> for + * {@link ifc.frame._XController} : the model of + * the TextDocument. </li> + * <li> <code>'otherWindow'</code> for + * {@link ifc.frame._XController} : the window of + * the added shape. </li> + * <li> <code>'SecondController'</code> for + * {@link ifc.frame._XController} : the controller of + * the TextDocument. </li> + * <li> <code>'HasViewData'</code> for + * {@link ifc.frame._XController} : the + * <code>DataSourceBrowser</code> has no view data. </li> + * <li> <code>'XInitialization.args'</code> for + * {@link ifc.lang._XInitialization} : the arguments for + * the initialization</li> + * </ul> + * + * @see com.sun.star.frame.Desktop + * @see com.sun.star.frame.XModel + * @see com.sun.star.frame.XFrame + * @see com.sun.star.frame.XController + * @see com.sun.star.frame.XDispatchProvider + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, the_frame1); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = the_frame2.getController(); + + Object[] params = new Object[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + XInitialization xInit = UnoRuntime.queryInterface( + XInitialization.class, oObj); + xInit.initialize(params); + + util.utils.waitForEventIdle(Param.getMSF()); + + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel shapeModel = aShape.getControl(); + + XControlAccess xCtrlAccess = UnoRuntime.queryInterface( + XControlAccess.class, + secondController); + XControl xCtrl = null; + + try { + xCtrl = xCtrlAccess.getControl(shapeModel); + } catch (com.sun.star.uno.Exception e) { + // Some exception occurs.FAILED + e.printStackTrace(log); + } + + XWindow docWindow = UnoRuntime.queryInterface(XWindow.class, + xCtrl); + log.println("creating a new environment for ODatasourceBrowser object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelations for XInitialization + tEnv.addObjRelation("XInitialization.args", params); + + + //Adding ObjRelations for XController + tEnv.addObjRelation("Frame", the_frame1); + tEnv.addObjRelation("SecondModel", aModel1); + tEnv.addObjRelation("otherWindow", docWindow); + tEnv.addObjRelation("SecondController", secondController); + tEnv.addObjRelation("HasViewData", Boolean.FALSE); + + + //Adding relation for XDispatchProvider + tEnv.addObjRelation("XDispatchProvider.URL", + ".uno:DataSourceBrowser/FormLetter"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class oDatasourceBrowser diff --git a/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java b/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java new file mode 100644 index 000000000..a5ec54f9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OInteractionHandler.java @@ -0,0 +1,90 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.sdbc.SQLException; +import com.sun.star.task.XInteractionContinuation; +import com.sun.star.task.XInteractionRequest; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdb.InteractionHandler</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::task::XInteractionHandler</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.task.XInteractionHandler +* @see com.sun.star.sdb.InteractionHandler +* @see ifc.task._XInteractionHandler +*/ +public class OInteractionHandler extends TestCase { + + + private static class TestRequest implements XInteractionRequest { + public Object getRequest() { + return new SQLException("Test exception") ; + } + + public XInteractionContinuation[] getContinuations() { + return new XInteractionContinuation[0] ; + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdb.InteractionHandler</code>. + * Object relations created : + * <ul> + * <li> <code>'XInteractionHandler.Request'</code> for + * {@link ifc.task._XInteractionHandler} : this relation + * is <code>com.sun.star.task.XInteractionRequest</code> + * interface implementation which depends on the component + * tested. In this case it emulates SQL error by returning + * <code>SQLException</code> object. </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + Object oInterface = Param.getMSF().createInstance( + "com.sun.star.sdb.InteractionHandler" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XInteractionHandler.Request", new TestRequest()) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java b/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java new file mode 100644 index 000000000..1124d12f9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OQueryDesign.java @@ -0,0 +1,224 @@ +/* + * 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._dbaccess; + +import com.sun.star.sdbc.XConnection; +import com.sun.star.uno.Exception; +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +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.XInitialization; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import util.SOfficeFactory; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdbc.XDataSource; + +public class OQueryDesign extends TestCase { + + private static XDesktop xDesk; + private static XFrame xFrame; + private static final String sDataSourceName = "Bibliography"; + private static XConnection xConn; + private static XTextDocument xTextDoc; + + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesk = DesktopTools.createDesktop(Param.getMSF()); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,xDesk); + XMultiServiceFactory xMSF = Param.getMSF(); + + // we use the first datasource + XNameAccess xNameAccess = UnoRuntime.queryInterface( + XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + XDataSource xDS = UnoRuntime.queryInterface( + XDataSource.class, xNameAccess.getByName( "Bibliography" )); + + log.println("check XMultiServiceFactory"); + + xConn = xDS.getConnection("", ""); + + log.println( "opening QueryDesign" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/QueryDesign"; + XDispatch getting = aProv.queryDispatch(the_url,"Query",12); + PropertyValue[] Args = new PropertyValue[2]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + Args[0] = param1; + PropertyValue param2 = new PropertyValue(); + param2.Name = "QueryDesignView"; + param2.Value = Boolean.FALSE; + Args[1] = param2; + param1.Name = "ActiveConnection"; + param1.Value = xConn; + Args[1] = param2; + getting.dispatch(the_url,Args); + + util.utils.waitForEventIdle(Param.getMSF()); + + Object oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + Object oDataSource = null; + XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); + + xFrame = DesktopTools.getCurrentFrame(xMSF); + + SOfficeFactory SOF = null; + + SOF = SOfficeFactory.getFactory( xMSF ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + XModel xDocMod = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XFrame xTextFrame = xDocMod.getCurrentController().getFrame(); + + Object[] params = new Object[3]; + param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + param2 = new PropertyValue(); + param2.Name = "Frame"; + param2.Value = xTextFrame; + params[1] = param2; + PropertyValue param3 = new PropertyValue(); + param3.Name = "QueryDesignView"; + param3.Value = Boolean.TRUE; + params[2] = param3; + + + XInterface oObj = xFrame.getController(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //Adding ObjRelations for XInitialization + tEnv.addObjRelation("XInitialization.args", params); + + Object[] ExceptionParams = new Object[3]; + PropertyValue ExceptionParam1 = new PropertyValue(); + ExceptionParam1.Name = "DataSourceName"; + ExceptionParam1.Value = "Bibliography2"; + ExceptionParams[0] = ExceptionParam1; + PropertyValue ExceptionParam2 = new PropertyValue(); + ExceptionParam2.Name = "Frame"; + ExceptionParam2.Value = null; + ExceptionParams[1] = ExceptionParam2; + PropertyValue ExceptionParam3 = new PropertyValue(); + ExceptionParam3.Name = "QueryDesignView"; + ExceptionParam3.Value = Integer.valueOf(17);//Boolean.TRUE; + ExceptionParams[2] = ExceptionParam3; + + tEnv.addObjRelation("XInitialization.ExceptionArgs", ExceptionParams); + + tEnv.addObjRelation("Frame", xFrame); + + tEnv.addObjRelation("XInitialization.xIni", getUninitializedObj(Param)); + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + return tEnv; + + } // finish method getTestEnvironment + + private XInitialization getUninitializedObj(TestParameters Param) throws Exception { + // creating an object which ist not initialized + + // get a model of a DataSource + Object oDBC = null; + XMultiServiceFactory xMSF; + + xMSF = Param.getMSF(); + oDBC = xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + Object oDataSource = null; + XNameAccess xNA = UnoRuntime.queryInterface(XNameAccess.class, oDBC); + oDataSource = xNA.getByName(sDataSourceName); + + XDocumentDataSource xDDS = UnoRuntime.queryInterface(XDocumentDataSource.class, oDataSource); + XModel xMod = UnoRuntime.queryInterface(XModel.class, xDDS.getDatabaseDocument ()); + + // get an instance of QueryDesign + Object oQueryDesign = xMSF.createInstance("com.sun.star.sdb.QueryDesign"); + + XController xCont = UnoRuntime.queryInterface(XController.class, oQueryDesign); + + // marry them all + boolean bSuccess = xCont.attachModel(xMod); + if (!bSuccess) + { + throw new StatusException (Status.failed ( + "Couldn't attach model")); + } + + xMod.connectController(xCont); + xMod.setCurrentController(xCont); + + return UnoRuntime.queryInterface(XInitialization.class, oQueryDesign); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + try { + xConn.close() ; + DesktopTools.closeDoc(xFrame); + DesktopTools.closeDoc(xTextDoc); + } catch (com.sun.star.uno.Exception e) { + log.println("Can't close the connection") ; + e.printStackTrace(log) ; + } catch (com.sun.star.lang.DisposedException e) { + log.println("Connection was already closed. It's OK.") ; + } + + } + +} // finish class oDatasourceBrowser + diff --git a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java new file mode 100644 index 000000000..6e0a758e0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java @@ -0,0 +1,608 @@ +/* + * 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._dbaccess; + +import ifc.sdb._XCompletedExecution; + +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.utils; +import util.db.DataSource; +import util.db.DataSourceDescriptor; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.ParametersRequest; +import com.sun.star.sdb.RowChangeEvent; +import com.sun.star.sdb.XInteractionSupplyParameters; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XParameters; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.task.XInteractionAbort; +import com.sun.star.task.XInteractionContinuation; +import com.sun.star.task.XInteractionRequest; +import com.sun.star.ucb.AuthenticationRequest; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.RowSet</code>. <p> + * + * The following files used by this test : + * <ul> + * <li><b> TestDB/TestDB.dbf </b> : the database file with some + * predefined fields described in <code>util.DBTools</code>. + * The copy of this file is always made in temp directory for + * testing purposes.</li> + * </ul> + * The following parameters in ini-file used by this test: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. + * For example: <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * + * @see com.sun.star.sdbc.RowSet + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.util.XCancellable + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.sdbc.ResultSet + * @see ifc.sdbc._RowSet + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.util._XCancellable + * @see ifc.sdbc._XParameters + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XResultSetAccess + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XColumnLocate + * @see ifc.sdbc._XRowSet + * @see ifc.sdb._RowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.lang._XComponent + * @see ifc.sdbcx._ResultSet + * @see ifc.sdbc._ResultSet + */ +public class ORowSet extends TestCase { + + private static int uniqueSuffix = 0 ; + private DBTools dbTools = null ; + private static String origDB = null ; + String tableName = null; + DataSourceDescriptor srcInf = null; + boolean isMySQLDB = false; + protected static final String dbSourceName = "ORowSetDataSource"; + public XConnection m_connection = null; + private Object m_rowSet = null; + private DataSource m_dataSource; + private String m_tableFile; + + /** + * Initializes some class fields. Then creates DataSource, which serves + * as a single source for all tables created in the test. + * This DataSource then registered in the global + * <code>DatabaseContext</code> service. This data source's URL + * points to SOffice temp directory where tables are copied from + * <code>TestDocuments</code> directory on every environment + * creation. + * To create DataSource for MySQL database next parameters required + * in ini-file: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. + * For example: <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * + * @throws StatusException if DataSource can not be created or + * registered. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter _log) + throws StatusException + { + XMultiServiceFactory orb = Param.getMSF(); + + String tmpDir = utils.getOfficeTemp( orb ); + + origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); + + dbTools = new DBTools( orb ); + + // creating DataSource and registering it in DatabaseContext + String dbURL = (String) Param.get("test.db.url"); + String dbUser = (String) Param.get("test.db.user"); + String dbPassword = (String) Param.get("test.db.password"); + + log.println("Creating and registering DataSource ..."); + srcInf = new DataSourceDescriptor( orb ); + if (dbURL != null && dbUser != null && dbPassword != null) + { + isMySQLDB = true; + log.println("dbURL = " + dbURL); + log.println("dbUSER = " + dbUser); + log.println("dbPASSWORD = " + dbPassword); + //DataSource for mysql db + tableName = "soffice_test_table"; + srcInf.URL = "jdbc:" + dbURL; + srcInf.IsPasswordRequired = Boolean.TRUE; + srcInf.Password = dbPassword; + srcInf.User = dbUser; + PropertyValue[] propInfo = new PropertyValue[1]; + propInfo[0] = new PropertyValue(); + propInfo[0].Name = "JavaDriverClass"; + propInfo[0].Value = "org.gjt.mm.mysql.Driver"; + srcInf.Info = propInfo; + } + else + { + srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + } + m_dataSource = srcInf.createDataSource(); + m_dataSource.registerAs( dbSourceName, true ); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * The database (DBF) file is copied from test document directory + * into SOffice temp dir with unique name for each environment + * creation. If the file can't be copied (is not released) + * then another unique name is used (file name suffix incremented + * by 1).<p> + * + * <code>com.sun.star.sdb.RowSet</code> service created and its + * source is all rows from the current copy of the table. Then + * row set command ("select all rows from a table") is executed + * and cursor is positioned to the first row. <p> + * + * Object relations created : + * <ul> + * <li> <code>'ORowSet.Connection'</code> for + * internal component test usage. Is used for + * closing connection when cleaning up environment. </li> + * <li> <code>'XRowSetApproveBroadcaster.ApproveChecker'</code> for + * {@link ifc.sdb._XRowSetApproveBroadcaster} interface + * implementation which made actions required </li> + * <li> <code>'CurrentRowData'</code> for + * {@link ifc.sdbc._XRow}, {@link ifc.sdbc._XRowUpdate} : + * exports types and values of the current row data.</li> + * <li> <code>'XColumnLocate.ColumnName'</code> for + * {@link ifc.sdbc._XColumnLocate} : + * the name of the first column of the table.</li> + * <li> <code>'XParameters.ParamValues'</code> for + * {@link ifc.sdbc._XParameters} : + * Collection of parameter types presented in the query. </li> + * <li> <code>'XRowUpdate.XRow'</code> for + * {@link ifc.sdbc._XRowUpdate} : + * <code>XRow</code> interface of the current component.</li> + * <li> <code>'XResultSetUpdate.UpdateTester'</code> for + * {@link ifc.sdbc._XResultSetUpdate} </li> + * </ul> + * + * @see com.sun.star.sdb.DatabaseContext + * @see com.sun.star.sdb.DataSource + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception + { + XMultiServiceFactory orb = Param.getMSF(); + uniqueSuffix++; + boolean envCreatedOK = false ; + + //initialize test table + if (isMySQLDB) + { + DBTools.DataSourceInfo legacyDescriptor = dbTools.newDataSourceInfo(); + legacyDescriptor.Name = null; + legacyDescriptor.User = srcInf.User; + legacyDescriptor.Password = srcInf.Password; + legacyDescriptor.Info = srcInf.Info; + legacyDescriptor.URL = srcInf.URL; + legacyDescriptor.IsPasswordRequired = srcInf.IsPasswordRequired; + dbTools.initTestTableUsingJDBC(tableName, legacyDescriptor); + } + else + { + String oldF = null ; + String newF = null ; + String tempFolder = utils.getOfficeTemp( orb ); + do + { + tableName = "ORowSet_tmp" + uniqueSuffix ; + oldF = utils.getFullURL(origDB); + newF = tempFolder + tableName + ".dbf"; + } + while ( !utils.tryOverwriteFile( orb, oldF, newF ) ); + m_tableFile = newF; + } + + try + { + m_rowSet = orb.createInstance("com.sun.star.sdb.RowSet"); + + XPropertySet rowSetProps = UnoRuntime.queryInterface( XPropertySet.class, m_rowSet ); + + log.println("Trying to open: " + tableName); + + rowSetProps.setPropertyValue("DataSourceName", dbSourceName); + rowSetProps.setPropertyValue("Command", tableName); + rowSetProps.setPropertyValue("CommandType", + Integer.valueOf(CommandType.TABLE)); + + final XRowSet rowSet = UnoRuntime.queryInterface( XRowSet.class, m_rowSet); + rowSet.execute(); + m_connection = UnoRuntime.queryInterface( XConnection.class, rowSetProps.getPropertyValue("ActiveConnection") ); + + XResultSet xRes = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + xRes.first(); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( (XInterface)m_rowSet ); + + // Adding obj relation for XRowSetApproveBroadcaster test + { + final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + final XResultSetUpdate resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet ); + final XRowUpdate rowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, m_rowSet ); + final PrintWriter logF = log ; + tEnv.addObjRelation( "XRowSetApproveBroadcaster.ApproveChecker", + new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() + { + public void moveCursor() + { + try + { + resultSet.beforeFirst(); + resultSet.afterLast(); + resultSet.first(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.moveCursor() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.moveCursor failed", e ); + } + } + public RowChangeEvent changeRow() + { + try + { + resultSet.first(); + rowUpdate.updateString(1, "ORowSetTest2"); + resultSetUpdate.updateRow(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRow() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.changeRow failed", e ); + } + RowChangeEvent ev = new RowChangeEvent(); + ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE ; + ev.Rows = 1 ; + + return ev ; + } + public void changeRowSet() + { + try + { + // since we gave the row set a parametrized statement, we need to ensure the + // parameter is actually filled, otherwise we would get an empty result set, + // which would imply some further tests failing + XParameters rowSetParams = UnoRuntime.queryInterface( XParameters.class, resultSet ); + rowSetParams.setString( 1, "String2" ); + rowSet.execute(); + resultSet.first(); + } + catch (com.sun.star.sdbc.SQLException e) + { + logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRowSet() :"); + e.printStackTrace(logF); + throw new StatusException( "RowSetApproveChecker.changeRowSet failed", e ); + } + } + } + ); + } + // Adding relations for XRow as a Vector with all data + // of current row of RowSet. + + ArrayList<Object> rowData = new ArrayList<Object>(); + + for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) { + rowData.add(DBTools.TST_TABLE_VALUES[0][i]); + } + + // here XRef must be added + // here XBlob must be added + // here XClob must be added + // here XArray must be added + + tEnv.addObjRelation("CurrentRowData", rowData); + + // Adding relation for XColumnLocate ifc test + tEnv.addObjRelation( "XColumnLocate.ColumnName", DBTools.TST_STRING_F ); + + // Adding relation for XCompletedExecution + tEnv.addObjRelation( "InteractionHandlerChecker", new InteractionHandlerImpl() ); + String sqlCommand = isMySQLDB + ? "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )" + : "SELECT \"_TEXT\" FROM \"" + tableName + "\" WHERE ( ( \"_TEXT\" = :param1 ) )"; + rowSetProps.setPropertyValue( "DataSourceName", dbSourceName ); + rowSetProps.setPropertyValue( "Command", sqlCommand ); + rowSetProps.setPropertyValue( "CommandType", Integer.valueOf(CommandType.COMMAND) ); + + // Adding relation for XParameters ifc test + tEnv.addObjRelation( "XParameters.ParamValues", new ArrayList<String>() ); + + // Adding relation for XRowUpdate + final XRow row = UnoRuntime.queryInterface( XRow.class, m_rowSet ); + tEnv.addObjRelation("XRowUpdate.XRow", row); + + // Adding relation for XResultSetUpdate + { + final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet ); + final XRowUpdate rowUpdate = UnoRuntime.queryInterface( XRowUpdate.class, m_rowSet ); + + tEnv.addObjRelation("XResultSetUpdate.UpdateTester", + new ifc.sdbc._XResultSetUpdate.UpdateTester() + { + String lastUpdate = null ; + + public int rowCount() throws SQLException + { + int prevPos = resultSet.getRow(); + resultSet.last(); + int count = resultSet.getRow(); + resultSet.absolute(prevPos); + + return count ; + } + + public void update() throws SQLException + { + lastUpdate = row.getString(1); + lastUpdate += "_" ; + rowUpdate.updateString(1, lastUpdate); + } + + public boolean wasUpdated() throws SQLException + { + String getStr = row.getString(1); + return lastUpdate.equals(getStr); + } + + public int currentRow() throws SQLException + { + return resultSet.getRow(); + } + } + ); + } + + envCreatedOK = true ; + return tEnv; + + } + finally + { + if (!envCreatedOK) + { + try + { + m_connection.close(); + } + catch(Exception ex) + { + System.out.println("caught exception: " + ex); + } + } + } + + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) + { + String doing = null; + try + { + doing = "revoking data source registration"; + log.println( doing ); + m_dataSource.revokeRegistration(); + + doing = "closing database document"; + log.println( doing ); + XModel databaseDocModel = UnoRuntime.queryInterface( XModel.class, + m_dataSource.getDatabaseDocument().getDatabaseDocument() ); + String documentFile = databaseDocModel.getURL(); + + XCloseable closeModel = UnoRuntime.queryInterface( XCloseable.class, + m_dataSource.getDatabaseDocument().getDatabaseDocument() ); + closeModel.close( true ); + + if ( m_rowSet != null ) + { + doing = "disposing row set"; + log.println( doing ); + XComponent rowSetComponent = UnoRuntime.queryInterface( XComponent.class, m_rowSet ); + rowSetComponent.dispose(); + } + + try + { + doing = "closing connection"; + log.println( doing ); + m_connection.close(); + } + catch (com.sun.star.lang.DisposedException e) + { + log.println( "already closed - okay." ); + } + + doing = "deleting database file (" + documentFile + ")"; + log.println( doing ); + impl_deleteFile( documentFile ); + + if ( m_tableFile != null ) + { + doing = "deleting dBase table file (" + m_tableFile + ")"; + log.println( doing ); + impl_deleteFile( m_tableFile ); + } + } + catch (com.sun.star.uno.Exception e) + { + log.println( "error: "); + e.printStackTrace(log); + } + } + + private final void impl_deleteFile( final String _file ) + { + java.io.File file = new java.io.File( _file ); + + boolean bDeleteOk = file.delete(); + if (!bDeleteOk && file.exists()) + file.deleteOnExit(); + } + + /** + * Implementation of interface _XCompletedExecution.CheckInteractionHandler + * for the XCompletedExecution test + * @see ifc.sdb._XCompletedExecution + */ + private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { + + private boolean handlerWasUsed = false; + private PrintWriter log; + + InteractionHandlerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + public boolean checkInteractionHandler() { + return handlerWasUsed; + } + + public void handle(XInteractionRequest xInteractionRequest) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called."); + boolean abort = false; + + Object o = xInteractionRequest.getRequest(); + if (o instanceof ParametersRequest) { + } + else if (o instanceof AuthenticationRequest) { + log.println("### The request in XCompletedExecution is of type 'AuthenticationRequest'"); + log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort."); + abort = true; + } + else { + log.println("### Unknown request:" + o.toString()); + log.println("### This is not implemented in ORowSet.InteractionHandlerImpl test -> abort."); + abort = true; + } + + XInteractionContinuation[]xCont = xInteractionRequest.getContinuations(); + XInteractionSupplyParameters xParamCallback = null; + for(int i=0; i<xCont.length; i++) { + if (abort) { + XInteractionAbort xAbort = null; + xAbort = UnoRuntime.queryInterface(XInteractionAbort.class, xCont[i]); + if (xAbort != null) + xAbort.select(); + return; + } + else { + xParamCallback = UnoRuntime.queryInterface(XInteractionSupplyParameters.class, xCont[i]); + if (xParamCallback != null) + break; + } + } + if (xParamCallback != null) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: supplying parameters."); + handlerWasUsed = true; + PropertyValue[] prop = new PropertyValue[1]; + prop[0] = new PropertyValue(); + prop[0].Name = "param1"; + prop[0].Value = "Hi."; + + xParamCallback.setParameters(prop); + xParamCallback.select(); + } + else { // we should never reach this: abort has to be true first. + log.println("### _XCompletedExecution.InteractionHandlerImpl: Got no " + + "'XInteractionSupplyParameters' and no 'XInteractionAbort'."); + } + } + + public void setLog(PrintWriter log) { + this.log = log; + } + + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java b/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java new file mode 100644 index 000000000..2fe02240c --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OSQLMessageDialog.java @@ -0,0 +1,127 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.sdb.ErrorMessageDialog</code>. + * <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::sdb::ErrorMessageDialog</code></li> + * <li> <code>com::sun::star::ui::dialogs::XExecutableDialog</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.sdb.ErrorMessageDialog + * @see com.sun.star.ui.dialogs.XExecutableDialog + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.sdb._ErrorMessageDialog + * @see ifc.ui.dialogs._XExecutableDialog + * @see ifc.beans._XPropertySet + */ +public class OSQLMessageDialog extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Creates an instance of the service + * <code>com.sun.star.sdb.ErrorMessageDialog</code>. Object relations + * created : + * <ul> + * <li> <code>'ERR1', 'ERR2'</code> for {@link ifc.sdb._ErrorMessageDialog}</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null; + + Object err1 = null; + Object err2 = null; + + oInterface = Param.getMSF().createInstance( + "com.sun.star.sdb.ErrorMessageDialog"); + + err1 = new com.sun.star.sdbc.SQLException("err1"); + err2 = new com.sun.star.sdbc.SQLException("err2"); + + oObj = (XInterface) oInterface; + + // create XWindow for Object relations... + com.sun.star.awt.XToolkit xToolkit = UnoRuntime.queryInterface( + com.sun.star.awt.XToolkit.class, + Param.getMSF().createInstance("com.sun.star.awt.Toolkit")); + + // Describe the properties of the container window. + com.sun.star.awt.WindowDescriptor aDescriptor = new com.sun.star.awt.WindowDescriptor(); + + aDescriptor.Type = com.sun.star.awt.WindowClass.TOP; + aDescriptor.WindowServiceName = "window"; + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = null; + aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0, 0, 0, 0); + + aDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.BORDER + | com.sun.star.awt.WindowAttribute.MOVEABLE + | com.sun.star.awt.WindowAttribute.SIZEABLE + | com.sun.star.awt.WindowAttribute.CLOSEABLE; + + com.sun.star.awt.XWindowPeer xPeer = xToolkit.createWindow(aDescriptor); + + com.sun.star.awt.XWindow xWindow = UnoRuntime.queryInterface( + com.sun.star.awt.XWindow.class, xPeer); + + log.println(" creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("add ObjectRelations err1 and err2 for 'ErrorMessageDialog'"); + tEnv.addObjRelation("ERR1", err1); + tEnv.addObjRelation("ERR2", err2); + tEnv.addObjRelation("ERR_XWindow", xWindow); + + return tEnv; + } // finish method getTestEnvironment + + @Override public void disposeTestEnvironment( + TestEnvironment tEnv, TestParameters tParam) + { + UnoRuntime.queryInterface( + com.sun.star.lang.XComponent.class, + (com.sun.star.awt.XWindow) tEnv.getObjRelation("ERR_XWindow")) + .dispose(); + super.disposeTestEnvironment(tEnv, tParam); + } +} // finish class OSQLMessageDialog + diff --git a/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java new file mode 100644 index 000000000..272688f8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/OSingleSelectQueryComposer.java @@ -0,0 +1,245 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.XSingleSelectQueryAnalyzer; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdbc.XDataSource; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbcx.XColumnsSupplier; +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.sdb.DataSource</code>. + * <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::sdbc::RowSet</code></li> + * <li> <code>com::sun::star::sdbcx::XRowLocate</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li> + * <li> <code>com::sun::star::util::XCancellable</code></li> + * <li> <code>com::sun::star::sdbc::XParameters</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li> + * <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li> + * <li> <code>com::sun::star::sdbc::XCloseable</code></li> + * <li> <code>com::sun::star::sdbcx::XColumnsSupplier</code></li> + * <li> <code>com::sun::star::sdb::XResultSetAccess</code></li> + * <li> <code>com::sun::star::sdbc::XResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XColumnLocate</code></li> + * <li> <code>com::sun::star::sdbc::XRowSet</code></li> + * <li> <code>com::sun::star::sdb::RowSet</code></li> + * <li> <code>com::sun::star::sdbc::XRowUpdate</code></li> + * <li> <code>com::sun::star::sdb::XRowSetApproveBroadcaster</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::sdbc::XRow</code></li> + * <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::sdbcx::ResultSet</code></li> + * <li> <code>com::sun::star::sdbc::ResultSet</code></li> + * </ul> + * <p> + * The following files used by this test : + * <ul> + * <li><b> TestDB/TestDB.dbf </b> : the database file with some predefined + * fields described in <code>util.DBTools</code>. The copy of this file is + * always made in temp directory for testing purposes.</li> + * </ul> + * <p> + * The following parameters in ini-file used by this test: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. For example: + * <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul> + * <p> + * + * @see com.sun.star.sdbc.RowSet + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.util.XCancellable + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.sdbc.ResultSet + * @see ifc.sdbc._RowSet + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.util._XCancellable + * @see ifc.sdbc._XParameters + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XResultSetAccess + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XColumnLocate + * @see ifc.sdbc._XRowSet + * @see ifc.sdb._RowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.lang._XComponent + * @see ifc.sdbcx._ResultSet + * @see ifc.sdbc._ResultSet + */ +public class OSingleSelectQueryComposer extends TestCase { + + protected static final String dbSourceName = "OSingleSelectQueryComposerDataSource"; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Object relations created : + * <ul>SingleSelectQueryAnalyzer + + * <li> <code>'xComposer'</code> for + * {@link ifc.sdb._XSingleSelectQueryAnalyzer} interface + * <li> <code>'xQueryAna'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'xProp'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'colName'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * <li> <code>'xResultSet'</code> for + * {@link ifc.sdb._XSingleSelectQueryComposer} interface + * </ul> + * + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + XMultiServiceFactory xMSF = null; + xMSF = Param.getMSF(); + + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, + xMSF.createInstance("com.sun.star.sdb.DatabaseContext")); + // we use the first datasource + XDataSource xDS = UnoRuntime.queryInterface(XDataSource.class, + xNameAccess.getByName("Bibliography")); + + log.println("check XMultiServiceFactory"); + XMultiServiceFactory xConn = UnoRuntime.queryInterface( + XMultiServiceFactory.class, xDS.getConnection("", "")); + + log.println("check getAvailableServiceNames"); + String[] sServiceNames = xConn.getAvailableServiceNames(); + if (!sServiceNames[0] + .equals("com.sun.star.sdb.SingleSelectQueryComposer")) { + log.println("Service 'SingleSelectQueryComposer' not supported"); + } + + oInterface = xConn.createInstance(sServiceNames[0]); + Object oRowSet = xMSF.createInstance("com.sun.star.sdb.RowSet"); + + XPropertySet xSetProp = UnoRuntime.queryInterface(XPropertySet.class, + oRowSet); + + xSetProp.setPropertyValue("DataSourceName", "Bibliography"); + xSetProp.setPropertyValue("Command", "biblio"); + xSetProp.setPropertyValue("CommandType", + Integer.valueOf(CommandType.TABLE)); + + com.sun.star.sdbc.XRowSet xORowSet = UnoRuntime.queryInterface( + com.sun.star.sdbc.XRowSet.class, oRowSet); + + xORowSet.execute(); + + XColumnsSupplier xColSup = UnoRuntime.queryInterface( + XColumnsSupplier.class, oRowSet); + + XNameAccess xCols = xColSup.getColumns(); + + XPropertySet xCol = (XPropertySet) AnyConverter.toObject(new Type( + XPropertySet.class), + xCols.getByName(xCols.getElementNames()[0])); + + XSingleSelectQueryAnalyzer xQueryAna = UnoRuntime.queryInterface( + XSingleSelectQueryAnalyzer.class, oInterface); + + // XSingleSelectQueryComposer + XSingleSelectQueryComposer xComposer = UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, xQueryAna); + xQueryAna.setQuery("SELECT * FROM \"biblio\""); + + oObj = (XInterface) oInterface; + log.println("ImplementationName: " + utils.getImplName(oObj)); + + log.println(" creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + // for XSingleSelectQueryAnalyzer + tEnv.addObjRelation("xComposer", xComposer); + + // for XSingleSelectQueryComposer + tEnv.addObjRelation("xQueryAna", xQueryAna); + + tEnv.addObjRelation("xProp", xCol); + tEnv.addObjRelation("colName", xCols.getElementNames()[0]); + + XResultSet xResultSet = UnoRuntime.queryInterface(XResultSet.class, + oRowSet); + tEnv.addObjRelation("xResultSet", xResultSet); + + return tEnv; + + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java b/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java new file mode 100644 index 000000000..dafdd9eaf --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/SbaXGridControl.java @@ -0,0 +1,426 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** +* Test for object which represents the control of the Grid model. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::util::XModifyBroadcaster</code></li> +* <li> <code>com::sun::star::form::XGridFieldDataSupplier</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::form::XGrid</code></li> +* <li> <code>com::sun::star::awt::XControl</code></li> +* <li> <code>com::sun::star::util::XModeSelector</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::awt::XWindow</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::frame::XDispatch</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::frame::XDispatchProviderInterception</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::awt::XView</code></li> +* <li> <code>com::sun::star::container::XContainer</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.util.XModifyBroadcaster +* @see com.sun.star.form.XGridFieldDataSupplier +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.form.XGrid +* @see com.sun.star.awt.XControl +* @see com.sun.star.util.XModeSelector +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.awt.XWindow +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.frame.XDispatch +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.frame.XDispatchProviderInterception +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.lang.XComponent +* @see com.sun.star.awt.XView +* @see com.sun.star.container.XContainer +* @see ifc.util._XModifyBroadcaster +* @see ifc.form._XGridFieldDataSupplier +* @see ifc.view._XSelectionSupplier +* @see ifc.form._XGrid +* @see ifc.awt._XControl +* @see ifc.util._XModeSelector +* @see ifc.container._XElementAccess +* @see ifc.awt._XWindow +* @see ifc.form._XUpdateBroadcaster +* @see ifc.frame._XDispatch +* @see ifc.container._XEnumerationAccess +* @see ifc.form._XBoundComponent +* @see ifc.frame._XDispatchProviderInterception +* @see ifc.container._XIndexAccess +* @see ifc.lang._XComponent +* @see ifc.awt._XView +* @see ifc.container._XContainer +*/ +public class SbaXGridControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates Writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + //closing the appearing dialog before disposing the document + XInterface toolkit = null; + + try { + toolkit = (XInterface) tParam.getMSF() + .createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't get toolkit"); + e.printStackTrace(log); + throw new StatusException("Couldn't get toolkit", e); + } + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XInterface button = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON); + + XAccessibleAction action = UnoRuntime.queryInterface( + XAccessibleAction.class, button); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException iob) { + log.println("couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close dialog"); + } + + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * For object creation first a + * <code>com.sun.star.form.component.GridControl<code> instance + * is added to the <code>ControlShape</code>. Then this model's + * control is retrieved. + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} test : <code>XGraphics</code> + * object different that belong to the object tested.</li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} </li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} for switching focus.</li> + * <li> <code>'XDispatch.URL'</code> for + * {@link ifc.frame._XDispatch} the url which moves + * DB cursor to the next row (".uno:FormSlots/moveToNext").</li> + * <li> <code>'XContainer.Container'</code> for + * {@link ifc.container._XContainer} as the component created + * doesn't support <code>XContainer</code> itself, but + * it is supported by its model. So this model is passed.</li> + * <li> <code>'INSTANCE'</code> for + * {@link ifc.container._XContainer} the instance to be + * inserted into collection. Is a column instance.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XGridColumnFactory columns = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = createGrid(xTextDoc, 3000, 4500, 15000, 10000); + + XControlModel the_Model = aShape.getControl(); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XLoadable formLoader = FormTools.bindForm(xTextDoc); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + columns = UnoRuntime.queryInterface( + XGridColumnFactory.class, the_Model); + aControl = columns.createColumn("TextField"); + aControl.setPropertyValue("DataField", "Identifier"); + aControl.setPropertyValue("Label", "Identifier"); + aControl2 = columns.createColumn("TextField"); + aControl2.setPropertyValue("DataField", "Publisher"); + aControl2.setPropertyValue("Label", "Publisher"); + aControl3 = columns.createColumn("TextField"); + aControl3.setPropertyValue("DataField", "Author"); + aControl3.setPropertyValue("Label", "Author"); + aControl4 = columns.createColumn("TextField"); + aControl4.setPropertyValue("DataField", "Title"); + aControl4.setPropertyValue("Label", "Title"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, the_Model); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //now get the OGridControl + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + + // creating another window + aShape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 10000, "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + the_Model = aShape.getControl(); + + + //Try to query XControlAccess + the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the TextControl + XWindow win = null; + Object cntrl = null; + + cntrl = the_access.getControl(the_Model); + win = UnoRuntime.queryInterface(XWindow.class, cntrl); + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", + new Object[] { + new Object[] { Integer.valueOf(0) }, new Object[] { Integer.valueOf(1) } + }); + tEnv.addObjRelation("Comparer", + new Comparator<Integer>() { + public int compare(Integer o1, Integer o2) { + return o1.compareTo(o2); + } + }); + + + //Relation for XContainer + tEnv.addObjRelation("XContainer.Container", aContainer); + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE2", aControl4); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + + // Adding relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", win); + + // Adding relation for XDispatch + URL url = new URL(); + url.Complete = ".uno:FormSlots/moveToNext"; + + + //url.Complete = ".uno:GridSlots/RowHeight"; + //url.Complete = ".uno:GridSlots/RowHeight" ; + tEnv.addObjRelation("XDispatch.URL", url); + + log.println("ImplName: " + utils.getImplName(oObj)); + + FormTools.switchDesignOf(Param.getMSF(), xTextDoc); + + // adding relation for XUpdateBroadcaster + final XInterface ctrl = oObj; + final XLoadable formLoaderF = formLoader; + final XPropertySet ps = UnoRuntime.queryInterface( + XPropertySet.class, aControl2); + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new ifc.form._XUpdateBroadcaster.UpdateChecker() { + private String lastText = ""; + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + lastText = "_" + ps.getPropertyValue("Text"); + ps.setPropertyValue("Text", lastText); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + String getS = (String) ps.getPropertyValue("Text"); + + return lastText.equals(getS); + } + }); + + return tEnv; + } // finish method getTestEnvironment + + public static XControlShape createGrid(XComponent oDoc, int height, + int width, int x, int y) throws Exception { + Size size = new Size(); + Point position = new Point(); + XControlShape oCShape = null; + XControlModel aControl = null; + + //get MSF + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + oDoc); + + Object oInt = oDocMSF.createInstance( + "com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance( + "com.sun.star.form.component.GridControl"); + XPropertySet model_props = UnoRuntime.queryInterface( + XPropertySet.class, aCon); + model_props.setPropertyValue("DefaultControl", + "com.sun.star.form.control.InteractionGridControl"); + aControl = UnoRuntime.queryInterface( + XControlModel.class, aCon); + oCShape = UnoRuntime.queryInterface( + XControlShape.class, oInt); + size.Height = height; + size.Width = width; + position.X = x; + position.Y = y; + oCShape.setSize(size); + oCShape.setPosition(position); + + oCShape.setControl(aControl); + + return oCShape; + } // finish createGrid +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java b/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java new file mode 100644 index 000000000..384edb85b --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/TableWindowAccessibility.java @@ -0,0 +1,267 @@ +/* + * 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._dbaccess; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.awt.Point; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.frame.XModel; +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.sdb.XQueryDefinitionsSupplier; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XIsolatedConnection; +import com.sun.star.sdbc.XStatement; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.awt.Robot; +import java.awt.event.InputEvent; +import util.DesktopTools; +import util.utils; + +/** + * Object implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessible</code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> + * <p> + * + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + */ +public class TableWindowAccessibility extends TestCase { + XWindow xWindow = null; + String aFile = ""; + XIsolatedConnection isolConnection = null; + XComponent QueryComponent = null; + String user = ""; + String password = ""; + + /** + * Creates a new DataSource and stores it. Creates a connection and using it + * creates two tables in database. Creates a new query and adds it to + * DefinitionContainer. Opens the QueryComponent.with loadComponentFromURL + * and gets the object with the role PANEL and the implementation name that + * contains TabelViewAccessibility + * + * @param Param + * test parameters + * @param log + * writer to log information while testing + * @return + * @throws StatusException + * @see TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + Param.getMSF().createInstance("com.sun.star.sdb.DatabaseContext"); + Object oDBSource = Param.getMSF() + .createInstance("com.sun.star.sdb.DataSource"); + Object newQuery = Param.getMSF().createInstance( + "com.sun.star.sdb.QueryDefinition"); + Param.getMSF().createInstance("com.sun.star.awt.Toolkit"); + + String mysqlURL = (String) Param.get("mysql.url"); + + if (mysqlURL == null) { + throw new StatusException( + Status.failed("Couldn't get 'mysql.url' from ini-file")); + } + + user = (String) Param.get("jdbc.user"); + password = (String) Param.get("jdbc.password"); + + if ((user == null) || (password == null)) { + throw new StatusException( + Status.failed("Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + + PropertyValue[] info = new PropertyValue[2]; + info[0] = new PropertyValue(); + info[0].Name = "user"; + info[0].Value = user; + info[1] = new PropertyValue(); + info[1].Name = "password"; + info[1].Value = password; + + XPropertySet propSetDBSource = UnoRuntime.queryInterface( + XPropertySet.class, oDBSource); + + propSetDBSource.setPropertyValue("URL", mysqlURL); + propSetDBSource.setPropertyValue("Info", info); + + log.println("writing database file ..."); + XDocumentDataSource xDDS = UnoRuntime.queryInterface( + XDocumentDataSource.class, oDBSource); + XStorable store = UnoRuntime.queryInterface(XStorable.class, + xDDS.getDatabaseDocument()); + aFile = utils.getOfficeTemp(Param.getMSF()) + "TableWindow.odb"; + log.println("... filename will be " + aFile); + store.storeAsURL(aFile, new PropertyValue[] {}); + log.println("... done"); + + isolConnection = UnoRuntime.queryInterface(XIsolatedConnection.class, + oDBSource); + + final String tbl_name1 = "tst_table1"; + final String tbl_name2 = "tst_table2"; + final String col_name1 = "id1"; + final String col_name2 = "id2"; + + util.utils.waitForEventIdle(Param.getMSF()); + XConnection connection = isolConnection.getIsolatedConnection(user, password); + XStatement statement = connection.createStatement(); + statement.executeUpdate("drop table if exists " + tbl_name1); + statement.executeUpdate("drop table if exists " + tbl_name2); + statement.executeUpdate("create table " + tbl_name1 + " (" + + col_name1 + " int)"); + statement.executeUpdate("create table " + tbl_name2 + " (" + + col_name2 + " int)"); + + XQueryDefinitionsSupplier querySuppl = UnoRuntime.queryInterface( + XQueryDefinitionsSupplier.class, oDBSource); + + XNameAccess defContainer = querySuppl.getQueryDefinitions(); + + XPropertySet queryProp = UnoRuntime.queryInterface(XPropertySet.class, + newQuery); + + final String query = "select * from " + tbl_name1 + ", " + tbl_name2 + + " where " + tbl_name1 + "." + col_name1 + "=" + tbl_name2 + + "." + col_name2; + queryProp.setPropertyValue("Command", query); + + XNameContainer queryContainer = UnoRuntime.queryInterface( + XNameContainer.class, defContainer); + + queryContainer.insertByName("Query1", newQuery); + store.store(); + connection.close(); + + PropertyValue[] loadProps = new PropertyValue[3]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "QueryDesignView"; + loadProps[0].Value = Boolean.TRUE; + + loadProps[1] = new PropertyValue(); + loadProps[1].Name = "CurrentQuery"; + loadProps[1].Value = "Query1"; + + loadProps[2] = new PropertyValue(); + loadProps[2].Name = "DataSource"; + loadProps[2].Value = oDBSource; + + QueryComponent = DesktopTools.loadDoc(Param.getMSF(), + ".component:DB/QueryDesign", loadProps); + + xWindow = UnoRuntime.queryInterface(XModel.class, QueryComponent) + .getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, + Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PANEL, "", "TableWindowAccessibility"); + + log.println("ImplementationName " + util.utils.getImplName(oObj)); + + log.println("creating TestEnvironment ... done"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XAccessibleComponent accComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + final Point point = accComp.getLocationOnScreen(); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Robot rob = new Robot(); + rob.mouseMove(point.X + 2, point.Y + 7); + rob.mousePress(InputEvent.BUTTON1_MASK); + rob.mouseMove(point.X + 400, point.Y); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + System.out.println("desired child doesn't exist"); + } + } + }); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes all open documents. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + + log.println("closing QueryComponent ..."); + DesktopTools.closeDoc(QueryComponent); + log.println("... done"); + XMultiServiceFactory xMSF = Param.getMSF(); + Object sfa = xMSF + .createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + XSimpleFileAccess xSFA = UnoRuntime.queryInterface( + XSimpleFileAccess.class, sfa); + log.println("deleting database file"); + xSFA.kill(aFile); + log.println("Could delete file " + aFile + ": " + + !xSFA.exists(aFile)); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_dbaccess/package.html b/qadevOOo/tests/java/mod/_dbaccess/package.html new file mode 100644 index 000000000..d6411c05e --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbaccess/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 'dbaccess'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_dbpool/OConnectionPool.java b/qadevOOo/tests/java/mod/_dbpool/OConnectionPool.java new file mode 100644 index 000000000..5e0d6517d --- /dev/null +++ b/qadevOOo/tests/java/mod/_dbpool/OConnectionPool.java @@ -0,0 +1,101 @@ +/* + * 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._dbpool; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sdbc.ConnectionPool</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sdbc::XDriverManager</code></li> +* </ul> +* @see com.sun.star.sdbc.XDriverManager +* @see ifc.sdbc._XDriverManager +*/ +public class OConnectionPool extends TestCase { + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = null; + + oObj = (XInterface) + xMSF.createInstance("com.sun.star.sdbc.ConnectionPool"); + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //adding relations for XDriverManager + String dbaseURL = (String) Param.get("dbase.url"); + if (dbaseURL == null) { + throw new StatusException( + Status.failed("Couldn't get parameter 'dbase.url'")); + } + + tEnv.addObjRelation("SDBC.URL", "sdbc:dbase:" + dbaseURL); + + String jdbcURL = (String) Param.get("jdbc.url"); + if (jdbcURL == null) { + throw new StatusException( + Status.failed("Couldn't get parameter 'jdbc.url'")); + } + + tEnv.addObjRelation("JDBC.URL", "jdbc:" + jdbcURL); + + String jdbcUser = (String) Param.get("jdbc.user"); + if (jdbcUser == null) { + throw new StatusException( + Status.failed("Couldn't get parameter 'jdbc.user'")); + } + + String jdbcPassword = (String) Param.get("jdbc.password"); + if (jdbcPassword == null) { + throw new StatusException( + Status.failed("Couldn't get parameter 'jdbc.password'")); + } + + PropertyValue[] jdbcInfo = new PropertyValue[3]; + jdbcInfo[0] = new PropertyValue(); + jdbcInfo[0].Name = "user"; + jdbcInfo[0].Value = jdbcUser; + jdbcInfo[1] = new PropertyValue(); + jdbcInfo[1].Name = "password"; + jdbcInfo[1].Value = jdbcPassword; + jdbcInfo[2] = new PropertyValue(); + jdbcInfo[2].Name = "JavaDriverClass"; + jdbcInfo[2].Value = DBTools.TST_JDBC_DRIVER; + + tEnv.addObjRelation("JDBC.INFO", jdbcInfo); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_defreg/NestedRegistry.java b/qadevOOo/tests/java/mod/_defreg/NestedRegistry.java new file mode 100644 index 000000000..a571c7e2c --- /dev/null +++ b/qadevOOo/tests/java/mod/_defreg/NestedRegistry.java @@ -0,0 +1,201 @@ +/* + * 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._defreg; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.RegistryTools; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.registry.NestedRegistry</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::registry::XSimpleRegistry</code></li> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> XSimpleRegistry.rdb </b> : Registry file created before. </li> +* <li><b> XSimpleRegistry_open#.rdb </b> : Temporary registry file as copy of +* <b> XSimpleRegistry.rdb </b> in the SOffice temp directory. +* ('#' - is an ordinary number) </li> +* <li><b> XSimpleRegistry_merge#.rdb </b> : Temporary registry file as copy of +* <b> XSimpleRegistry.rdb </b> in the SOffice temp directory. +* ('#' - is an ordinary number) </li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.registry.XSimpleRegistry +* @see com.sun.star.lang.XInitialization +* @see ifc.registry._XSimpleRegistry +* @see ifc.lang._XInitialization +*/ +public class NestedRegistry extends TestCase { + + protected static int uniq = 0 ; + XSimpleRegistry reg1; + XSimpleRegistry reg2; + + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam ) { + try { + reg1.destroy(); + reg2.destroy(); + } + catch (com.sun.star.registry.InvalidRegistryException e) { + System.out.println("caught exception: " + e); + } + } + + /** + * Creates a temporary copy of file, which is deleted when VM exits. + * @param src Source file path. + * @param dst Destination file path. + * @throws java.io.IOException If any problems occur during copying. + */ + protected void copyFile(String src, String dst, PrintWriter log) + throws java.io.IOException { + log.println("Copy File "+src+" to "+dst); + File srcF = new File(src) ; + File dstF = new File(dst) ; + + if (dstF.exists()) { + boolean bDeleteOk = dstF.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + + boolean bCreateOk = dstF.createNewFile(); + if (!bCreateOk) { + System.out.println("create failed"); + } + + dstF.deleteOnExit() ; + + FileInputStream fIn = new FileInputStream(srcF) ; + FileOutputStream fOut = new FileOutputStream(dstF) ; + + byte[] buf = new byte[1024] ; + int bytesRead = 0 ; + while ((bytesRead = fIn.read(buf)) > 0) { + fOut.write(buf, 0, bytesRead) ; + } + + fIn.close() ; + fOut.close() ; + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two temporary copies of registry file created before, opens + * them, and creates service <code>com.sun.star.comp.stoc.NestedRegistry</code> + * with these two registries. <p> + * Object relations created : + * <ul> + * <li> <code>'NR'</code> for {@link ifc.registry._XSimpleRegistry} : + * Just informs interface test that <code>NestedRegistry</code> + * service is tested. If this relation exists, then some methods + * are not supported. The relation is a <code>String</code> with + * object name.</li> + * <li> <code>'XSimpleRegistry.open'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * <li> <code>'XSimpleRegistry.destroy'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * <li> <code>'XSimpleRegistry.merge'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + + final String tmpDir = utils.getOfficeTempDirSys(Param.getMSF()) ; + final String openF = tmpDir + "XSimpleRegistry_open" + uniq + ".rdb" ; + final String destroyF = tmpDir + + "XSimpleRegistry_destroy" + uniq + ".rdb" ; + final String mergeF = tmpDir + "XSimpleRegistry_merge" + uniq + ".rdb" ; + uniq++ ; + + log.println("creating copies of the registry for XSimpleRegistry"); + String source = utils.getFullTestDocName("XSimpleRegistry.rdb"); + copyFile(source, openF, log) ; + copyFile(source, mergeF, log) ; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + reg1 = RegistryTools. + createRegistryService(xMSF) ; + reg1.open(mergeF, false, true) ; + reg2 = RegistryTools. + createRegistryService(xMSF) ; + reg2.open(openF, false, true) ; + XSimpleRegistry[] arg = new XSimpleRegistry[2]; + arg[0]=reg1; + arg[1]=reg2; + oInterface = xMSF.createInstanceWithArguments + ( "com.sun.star.comp.stoc.NestedRegistry", arg ); + } + catch( Exception e ) { + log.println("Introspection Service not available" ); + } + oObj = (XInterface) oInterface; + + + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("NR","NestedRegistry"); + + tEnv.addObjRelation("XSimpleRegistry.open", openF) ; + tEnv.addObjRelation("XSimpleRegistry.merge", mergeF) ; + tEnv.addObjRelation("XSimpleRegistry.destroy", destroyF) ; + + return tEnv; + } // finish method getTestEnvironment + + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + + } + +} // finish class NestedRegistry + diff --git a/qadevOOo/tests/java/mod/_defreg/package.html b/qadevOOo/tests/java/mod/_defreg/package.html new file mode 100644 index 000000000..bee4740a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_defreg/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 'defreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_dtrans/generic.java b/qadevOOo/tests/java/mod/_dtrans/generic.java new file mode 100644 index 000000000..9a61fe39a --- /dev/null +++ b/qadevOOo/tests/java/mod/_dtrans/generic.java @@ -0,0 +1,60 @@ +/* + * 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._dtrans; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.datatransfer.generic</code>. + * <p> + */ +public class generic extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.datatransfer.generic</code>. + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface) xMSF + .createInstance("com.sun.star.datatransfer.clipboard.GenericClipboard"); + + if (oObj == null) { + log.println("[ERROR!] System type is *nix, unable to create object..."); + } + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: " + Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_dynamicloader/Dynamic.java b/qadevOOo/tests/java/mod/_dynamicloader/Dynamic.java new file mode 100644 index 000000000..f022f0762 --- /dev/null +++ b/qadevOOo/tests/java/mod/_dynamicloader/Dynamic.java @@ -0,0 +1,78 @@ +/* + * 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._dynamicloader; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.loader.Dynamic</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::loader::XImplementationLoader</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.loader.XImplementationLoader +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.loader.Dynamic +* @see ifc.loader._XImplementationLoader +* @see ifc.lang._XServiceInfo +*/ +public class Dynamic extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service + * <code>com.sun.star.loader.Dynamic</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.loader.Dynamic" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relations for XImplementationLoader + + String loader = "com.sun.star.loader.SharedLibrary"; + tEnv.addObjRelation("ImplementationLoader", loader) ; + + String url = "servicename=com.sun.star.loader.SharedLibrary,link=mylink"; + tEnv.addObjRelation("ImplementationUrl", url) ; + + tEnv.addObjRelation("ImplementationName", "com.sun.star.io.Pipe") ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_file/calc/ODriver.java b/qadevOOo/tests/java/mod/_file/calc/ODriver.java new file mode 100644 index 000000000..8d07e6f03 --- /dev/null +++ b/qadevOOo/tests/java/mod/_file/calc/ODriver.java @@ -0,0 +1,95 @@ +/* + * 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._file.calc; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + + +/** +* Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.sdbc.Driver +* @see com.sun.star.sdbc.XDriver +* @see com.sun.star.sdbcx.XCreateCatalog +* @see com.sun.star.sdbcx.XDropCatalog +* @see ifc.sdbc._XDriver +* @see ifc.sdbcx._XCreateCatalog +* @see ifc.sdbcx._XDropCatalog +*/ +public class ODriver extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the Spreadsheet document to which to connect. + * The URL is obtained from the parameter <code>calc.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for + * {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments + * </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.sdbc.calc.ODriver"); + + log.println("creating a new environment for calc.ODriver object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String calcURL = (String) Param.get("calc.url"); + if (calcURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'calc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "sdbc:calc:" + calcURL); + + PropertyValue[] info = new PropertyValue[0]; + tEnv.addObjRelation("XDriver.INFO", info); + + String jdbcUrl = (String) Param.get("jdbc.url"); + if (jdbcUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); + + tEnv.addObjRelation("NoBadURL", "TRUE"); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_file/dbase/ODriver.java b/qadevOOo/tests/java/mod/_file/dbase/ODriver.java new file mode 100644 index 000000000..659b6e9a4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_file/dbase/ODriver.java @@ -0,0 +1,92 @@ +/* + * 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._file.dbase; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + +/** +* Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.sdbc.Driver +* @see com.sun.star.sdbc.XDriver +* @see com.sun.star.sdbcx.XCreateCatalog +* @see com.sun.star.sdbcx.XDropCatalog +* @see ifc.sdbc._XDriver +* @see ifc.sdbcx._XCreateCatalog +* @see ifc.sdbcx._XDropCatalog +*/ +public class ODriver extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the database to which to connect. + * The URL is obtained from the parameter <code>dbase.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for + * {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.sdbc.dbase.ODriver"); + + log.println("creating a new environment for dbase.ODriver object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String dBaseURL = (String) Param.get("dbase.url"); + if (dBaseURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'dbase.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "sdbc:dbase:" + dBaseURL); + + PropertyValue[] info = new PropertyValue[0]; + tEnv.addObjRelation("XDriver.INFO", info); + + String jdbcUrl = (String) Param.get("jdbc.url"); + if (jdbcUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_file/flat/ODriver.java b/qadevOOo/tests/java/mod/_file/flat/ODriver.java new file mode 100644 index 000000000..7fac2ae03 --- /dev/null +++ b/qadevOOo/tests/java/mod/_file/flat/ODriver.java @@ -0,0 +1,90 @@ +/* + * 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._file.flat; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + +/** +* Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.sdbc.Driver +* @see com.sun.star.sdbc.XDriver +* @see com.sun.star.sdbcx.XCreateCatalog +* @see com.sun.star.sdbcx.XDropCatalog +* @see ifc.sdbc._XDriver +* @see ifc.sdbcx._XCreateCatalog +* @see ifc.sdbcx._XDropCatalog +*/ +public class ODriver extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the database to which to connect. + * The URL is obtained from the parameter <code>flat.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for + * {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.sdbc.flat.ODriver"); + + log.println("creating a new environment for flat.ODriver object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String flatURL = (String) Param.get("flat.url"); + if (flatURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'flat.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "sdbc:flat:" + flatURL); + + PropertyValue[] info = new PropertyValue[0]; + tEnv.addObjRelation("XDriver.INFO", info); + + String jdbcUrl = (String) Param.get("jdbc.url"); + if (jdbcUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_fileacc/SimpleFileAccess.java b/qadevOOo/tests/java/mod/_fileacc/SimpleFileAccess.java new file mode 100644 index 000000000..2abff7ee6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fileacc/SimpleFileAccess.java @@ -0,0 +1,69 @@ +/* + * 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._fileacc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.SimpleFileAccess</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li><code>com::sun::star::ucb.XSimpleFileAccess</code></li> +* </ul> +* This object test <b> can </b> be run in several +* threads concurrently. +* @see com.sun.star.ucb.XSimpleFileAccess +* @see com.sun.star.ucb.SimpleFileAccess +* @see ifc.ucb._XSimpleFileAccess +*/ +public class SimpleFileAccess extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.ucb.SimpleFileAccess</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ("com.sun.star.comp.ucb.SimpleFileAccess"); + Object oIH = xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for CoreReflection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("InteractionHandler", oIH); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SimpleFileAccess + diff --git a/qadevOOo/tests/java/mod/_fileacc/package.html b/qadevOOo/tests/java/mod/_fileacc/package.html new file mode 100644 index 000000000..d590b8399 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fileacc/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 'fileacc'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_fop/FolderPicker.java b/qadevOOo/tests/java/mod/_fop/FolderPicker.java new file mode 100644 index 000000000..3405319e2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fop/FolderPicker.java @@ -0,0 +1,80 @@ +/* + * 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._fop; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.fop.FolderPicker</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ui::XExecutableDialog</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::ui::XFolderPickerNotifier</code></li> +* <li> <code>com::sun::star::ui::XFolderPicker</code></li> +* <li> <code>com::sun::star::lang::XTypeProvider</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ui.XExecutableDialog +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.ui.XFolderPickerNotifier +* @see com.sun.star.ui.XFolderPicker +* @see com.sun.star.lang.XTypeProvider +* @see com.sun.star.ui.FolderPicker +* @see ifc.ui.dialogs._XExecutableDialog +* @see ifc.lang._XComponent +* @see ifc.lang._XServiceInfo +* @see ifc.ui._XFolderPickerNotifier +* @see ifc.ui.dialogs._XFolderPicker +* @see ifc.lang._XTypeProvider +*/ +public class FolderPicker extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.fop.FolderPicker</code>. <p> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.ui.dialogs.FolderPicker" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class BreakIterator + diff --git a/qadevOOo/tests/java/mod/_forms/GenericModelTest.java b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java new file mode 100644 index 000000000..c5ffe1ee5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/GenericModelTest.java @@ -0,0 +1,526 @@ +/* + * 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._forms; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.FormTools; +import util.WriterTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XForm; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdb.XDocumentDataSource; +import com.sun.star.text.XTextDocument; +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.XCloseable; +import java.util.ArrayList; +import lib.Status; +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DateField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlDateFieldModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::DateField</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlDateFieldModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.DateField +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlDateFieldModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._DateField +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class GenericModelTest extends TestCase { + private XTextDocument m_xTextDoc; + private Object m_dbSrc = null; + /** + * This is the name of the Data Base which the test uses: "APITestDatabase" + */ + private static final String m_dbSourceName = "APITestDatabase"; + private static final String m_TestDB = "TestDB"; + private DBTools m_dbTools = null; + + private boolean m_ConnectionClosed = false; + + /** + * describes the kind of the shape which should be created. + * Example: m_kindOfshape=DateFilled + */ + protected String m_kindOfControl = null; + + /** + * If your object needs some special property values you can specify them with this + * <CODE>ArrayList</CODE>. You have to add a <CODE>NamedValue</CODE> to this list. + * Example: + * NamedValue myProp = new NamedValue(); + * myProp.Name = "Test"; + * myProp.Value = "My special Value"; + * m_propertiesToSet.add(myProp); + */ + protected ArrayList<NamedValue> m_propertiesToSet = new ArrayList<NamedValue>(); + + /** + * This variable contains the name of the property which should be changed while + * interface <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> is tested. The + * interface test needs the <CODE>ObjectRelation</CODE> + * "XUpdateBroadcaster.Checker" which is a <CODE>ifc.form._XUpdateBroadcaster.UpdateChecker</CODE>. + * @see ifc.form._XUpdateBroadcaster.UpdateChecker + * @see ifc.form._XUpdateBroadcaster + */ + protected String m_ChangePropertyName = null; + /** + * This variable contains the value the property should be set while + * interface <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> is tested. + * The interface test needs the <CODE>ObjectRelation</CODE> + * "XUpdateBroadcaster.Checker" which is a <CODE>ifc.form._XUpdateBroadcaster.UpdateChecker</CODE>. + * Normally the <CODE>Checker</CODE> uses <CODE>util.ValueChanger</CODE> to change + * the value of the property. If the current of this property is NULL the + * <CODE>ValueChanger</CODE> is unable to change the value. In this case the value + * of this variable was used. + */ + protected Object m_ChangePropertyValue = null; + + /** + * This variable contains the implementation name of the object. + */ + protected String m_ObjectName = null; + + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>FormLoader</CODE> + */ + protected XLoadable m_XFormLoader = null; + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>XPropertySet</CODE> + */ + protected XPropertySet m_XPS = null; + /** + * For local implementations of <CODE>Checker</CODE> this variable contains the + * <CODE>Control</CODE> + */ + protected XInterface m_XCtrl = null; + /** + * The interface test of <CODE>ifc.form._DataWareControlModel</CODE> expects an + * object relation <CODE>'LC'</CODE>. This is a <CODE>XControlModel</CODE> of a shape. + * This variable contains the kind of shape to create for the interface test, + * f.e. "FixedText" + * @see ifc.form._DataAwareControlModel + */ + protected String m_LCShape_Type = null; + + /** + * If this variable is true some more debug info was logged. It was set by the parameter variable + * <code>debug_is_active</code> + */ + private boolean debug = false; + + /** + * Creates Writer document where controls are placed. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + m_xTextDoc = WriterTools.createTextDoc(tParam.getMSF()); + m_ConnectionClosed = false; + debug = tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE); + m_propertiesToSet.clear(); + } + + /** + * close the connection + * close the data source + * close the document + * revoke the data source + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println("closing connection..."); + + // some interface tests call cleanup to reset the environment. If such + // a test is the last one cleanup was called twice. The second call + // causes then nasty exceptions... + if (m_ConnectionClosed) return; + + try { + XIndexAccess forms = UnoRuntime.queryInterface( XIndexAccess.class, + FormTools.getForms( WriterTools.getDrawPage( m_xTextDoc ) ) ); + XForm myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), + forms.getByIndex(0)); + + if (debug){ + if (myForm == null){ + log.println("ERROR: could not get 'Standard' from drawpage!"); + } + log.println("the draw page contains following elements:"); + String[] elements = FormTools.getForms(WriterTools.getDrawPage(m_xTextDoc)).getElementNames(); + for (int i = 0; i< elements.length; i++){ + log.println("Element[" + i + "] :" + elements[i]); + } + + } + + XPropertySet xSetProp = UnoRuntime.queryInterface( XPropertySet.class, myForm ); + XConnection connection = UnoRuntime.queryInterface( XConnection.class, xSetProp.getPropertyValue( "ActiveConnection" ) ); + if ( connection == null ) + { + if ( debug ) + log.println("ERROR: could not get property 'ActiveConnection' from the XForm"); + } + else + { + connection.close(); + } + } catch (Exception e) { + log.println("ERROR: Can't close the connection: " + e.toString()); + e.printStackTrace( log ); + } + + log.println("closing data source..."); + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, m_dbSrc); + if ( closer == null ) + { + XDocumentDataSource dataSource = UnoRuntime.queryInterface( + XDocumentDataSource.class, m_dbSrc); + if ( dataSource != null ) + closer = UnoRuntime.queryInterface( + XCloseable.class, dataSource.getDatabaseDocument() ); + } + if (debug && closer==null){ + log.println("ERROR: couldn't get 'XCloseable' from DataSource"); + } + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } catch (Exception e) { + log.println("ERROR: couldn't close data source: " + e.toString()); + } + + log.println("disposing data source..."); + try { + XComponent dataSourceComp = UnoRuntime.queryInterface( + XComponent.class, m_dbSrc); + dataSourceComp.dispose(); + } + catch (Exception e) { + log.println("couldn't dispose the data source"); + } + + log.println("closing document..."); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, m_xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } catch (Exception e) { + log.println("ERROR: couldn't close document: " + e.toString()); + } + + log.println("revoking data source..."); + try { + m_dbTools.revokeDB(m_dbSourceName); + } catch (com.sun.star.container.NoSuchElementException e){ + } catch (com.sun.star.uno.Exception e) { + log.println("ERROR: Error while object test cleaning up: " + e.toString()); + } + + m_ConnectionClosed = true; + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * First <code>TestDB</code> database is registered. + * Creates DateField in the Form, then binds it to TestDB + * database and returns Field's control. <p> + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * <li> <code>'LC'</code> for {@link ifc.form._DataAwareControlModel}. + * Specifies the value for LabelControl property. It is + * <code>FixedText</code> component added to the document.</li> + * <li> <code>'FL'</code> for + * {@link ifc.form._DataAwareControlModel} interface. + * Specifies XLoadable implementation which connects form to + * the data source.</li> + * <li> <code>'XUpdateBroadcaster.Checker'</code> : <code> + * _XUpdateBroadcaster.UpdateChecker</code> interface implementation + * which can update, commit data and check if the data was successfully + * committed.</li> + * <li> <code>'DataAwareControlModel.NewFieldName'</code> : for + * <code>com.sun.star.form.DataAwareControlModel</code> service + * which contains new name of the field ('_DATE') to bind control to. + * </li> + * <li> <code>'XFastPropertySet.ExcludeProps'</code> : for + * <code>com.sun.star.beans.XFastPropertySet</code> interface + * the property FormatKey can have only restricted set of values. + * </li> + * </ul> + * @see ifc.form._XUpdateBroadcaster + * @param Param the test parameter + * @param log the log writer + * @return a test environment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XControlShape aShape = null; + XMultiServiceFactory xMSF = Param.getMSF(); + + log.println("adding control shape '" + m_kindOfControl + "'"); + aShape = FormTools.createControlShape(m_xTextDoc, 3000, + 4500, 15000, 10000, + m_kindOfControl); + + WriterTools.getDrawPage(m_xTextDoc).add(aShape); + oObj = aShape.getControl(); + + log.println("Implementation name: " + util.utils.getImplName(oObj)); + + String sourceTestDB = utils.getFullURL(utils.getFullTestDocName("TestDB/testDB.dbf")); + String destTestDB = utils.getOfficeTemp(xMSF); + destTestDB = utils.getFullURL(destTestDB + "testDB.dbf"); + + log.println("copy '"+sourceTestDB + "' -> '" + destTestDB + "'"); + utils.copyFile(xMSF, sourceTestDB, destTestDB); + + m_dbTools = new DBTools( xMSF ); + String tmpDir = utils.getOfficeTemp(xMSF); + + DBTools.DataSourceInfo srcInf = m_dbTools.newDataSourceInfo(); + srcInf.URL = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + log.println("data source: " + srcInf.URL); + + m_dbSrc = srcInf.getDataSourceService(); + m_dbTools.reRegisterDB(m_dbSourceName, m_dbSrc); + + m_XFormLoader = FormTools.bindForm(m_xTextDoc, m_dbSourceName, + m_TestDB); + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", m_ObjectName); + + log.println("adding shape '" + m_LCShape_Type +"' for DataAwareControlModel test"); + aShape = FormTools.createControlShape(m_xTextDoc, 6000, 4500, 15000, + 10000, m_LCShape_Type); + WriterTools.getDrawPage(m_xTextDoc).add(aShape); + + m_XPS = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + int i = 0; + NamedValue prop = null; + for (i = 0; i < m_propertiesToSet.size(); i++){ + prop = m_propertiesToSet.get(i); + + log.println("setting property: '"+prop.Name+"' to value '"+prop.Value.toString()+"'"); + + m_XPS.setPropertyValue(prop.Name, prop.Value); + } + + // added LabelControl for 'DataAwareControlModel' + tEnv.addObjRelation("LC", aShape.getControl()); + + // added FormLoader for 'DataAwareControlModel' + tEnv.addObjRelation("FL", m_XFormLoader); + + // adding relation for XUpdateBroadcaster + m_XCtrl = oObj; + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName, m_ChangePropertyValue)); + + // adding relation for DataAwareControlModel service + tEnv.addObjRelation("DataAwareControlModel.NewFieldName", + DBTools.TST_DATE_F); + + //adding ObjRelation for XPersistObject + tEnv.addObjRelation("PSEUDOPERSISTENT", Boolean.TRUE); + + // adding relation for XFastPropertySet + java.util.HashSet<String> exclude = new java.util.HashSet<String>(); + exclude.add("FormatKey"); + tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclude); + + PropertyValue propVal = new PropertyValue(); + propVal.Name = "HelpText"; + propVal.Value = "Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + + return tEnv; + } // finish method getTestEnvironment + + + private static class Checker implements ifc.form._XUpdateBroadcaster.UpdateChecker { + private Object lastValue = null; + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + private String ChangePropertyName = null; + Object ChangePropertyValue = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName, Object ChangePropertyValue) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + this.ChangePropertyValue=ChangePropertyValue; + } + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + lastValue = util.ValueChanger.changePValue(ps.getPropertyValue(ChangePropertyName)); + + if (lastValue == null){ + + if (ChangePropertyValue != null){ + + lastValue = ChangePropertyValue; + + } else { + + String msg = "The initial value of the property '" + ChangePropertyName + "' is NULL\n"; + msg += "The member variable 'm_ChangePropertyValue' is NULL\n"; + msg += "Could not change Property."; + + throw new StatusException(Status.failed(msg)); + } + } + ps.setPropertyValue(ChangePropertyName, lastValue); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + formLoaderF.reload(); + + Object newValue = ps.getPropertyValue(ChangePropertyName); + + return (newValue != null) && (util.ValueComparer.equalValue(lastValue, newValue)); + } + } +} // finish class GenericModelTest diff --git a/qadevOOo/tests/java/mod/_forms/OButtonControl.java b/qadevOOo/tests/java/mod/_forms/OButtonControl.java new file mode 100644 index 000000000..82f905931 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonControl.java @@ -0,0 +1,202 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CommandButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XApproveActionBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XButton</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XApproveActionBroadcaster + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XButton + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XApproveActionBroadcaster + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XButton + * @see ifc.awt._XView + */ +public class OButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CommandButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OButtonModel.java b/qadevOOo/tests/java/mod/_forms/OButtonModel.java new file mode 100644 index 000000000..c54b24184 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OButtonModel.java @@ -0,0 +1,106 @@ +/* + * 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._forms; + +import java.io.PrintWriter; +import lib.TestParameters; + +/** + * Test for object which is represented by service + * <code>com.sun.star.com.sun.star.form.component.CommandButton</code>. + * <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::awt::UnoControlButtonModel</code></li> + * <li> <code>com::sun::star::form::component::CommandButton</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @see com.sun.star.form.XImageProducerSupplier + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.awt.UnoControlButtonModel + * @see com.sun.star.form.component.CommandButton + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form._XImageProducerSupplier + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.awt._UnoControlButtonModel + * @see ifc.form.component._CommandButton + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="CommandButton"; + + super.m_ObjectName = "stardiv.one.form.component.CommandButton"; + + super.m_LCShape_Type = "CommandButton"; + + } + + +} // finish class OButtonModelold diff --git a/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java b/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java new file mode 100644 index 000000000..f95a2340d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxControl.java @@ -0,0 +1,214 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CheckBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XItemListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XCheckBox</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XItemListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XCheckBox + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XItemListener + * @see ifc.awt._XWindow + * @see ifc.awt._XCheckBox + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + */ +public class OCheckBoxControl extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CheckBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'TestItemListener'</code> for + * {@link ifc.awt._XItemListener} : listener implementation is + * registered here and passed as relation. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"CheckBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OButtonControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200,200); + aGraphic = aDevice.createGraphics(); + + log.println( "creating a new environment for OCheckBoxControl object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS",aGraphic); + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT",xTextDoc); + tEnv.addObjRelation("WINPEER",the_win); + tEnv.addObjRelation("TOOLKIT",the_kit); + tEnv.addObjRelation("MODEL",the_Model); + + // Adding relation for XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener() ; + XCheckBox box = UnoRuntime.queryInterface + (XCheckBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class,aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow",forObjRel); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class OButtonControl + + diff --git a/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java b/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.java new file mode 100644 index 000000000..edec240f9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCheckBoxModel.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._forms; + +import java.io.PrintWriter; + +import lib.TestParameters; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.CheckBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::CheckBox</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlCheckBoxModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.CheckBox +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.awt.UnoControlCheckBoxModel +* @see com.sun.star.container.XNamed +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.beans._XFastPropertySet +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._FormComponent +* @see ifc.form.component._CheckBox +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._DataAwareControlModel +* @see ifc.form._XUpdateBroadcaster +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.awt._UnoControlCheckBoxModel +* @see ifc.container._XNamed +* @see ifc.form._XBoundComponent +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OCheckBoxModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CheckBox"; + * super.m_ObjectName = "stardiv.one.form.component.CheckBox"; + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl= "CheckBox"; + + super.m_ObjectName = "stardiv.one.form.component.CheckBox"; + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OCheckBoxModel + diff --git a/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java b/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java new file mode 100644 index 000000000..1b5fe16d6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxControl.java @@ -0,0 +1,223 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.ComboBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XComboBox</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XComboBox + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XComboBox + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OComboBoxControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.ComboBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "ComboBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OComboBoxControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java b/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java new file mode 100644 index 000000000..963e996ed --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OComboBoxModel.java @@ -0,0 +1,135 @@ +/* + * 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._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; + +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.ComboBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::awt::UnoControlComboBoxModel</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseComboBox</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::component::ComboBox</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.FormComponent +* @see com.sun.star.awt.UnoControlComboBoxModel +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.form.component.DatabaseComboBox +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.component.ComboBox +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.beans._XFastPropertySet +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._FormComponent +* @see ifc.awt._UnoControlComboBoxModel +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.form.component._DatabaseComboBox +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.form._XBoundComponent +* @see ifc.form.component._ComboBox +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OComboBoxModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="ComboBox"; + * super.m_ObjectName = "stardiv.one.form.component.ComboBox"; + * + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(DataField); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="ComboBox"; + + super.m_ObjectName = "stardiv.one.form.component.ComboBox"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OComboBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java b/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java new file mode 100644 index 000000000..571401aba --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyControl.java @@ -0,0 +1,230 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.CurrencyField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XCurrencyField</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XCurrencyField + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.awt._XCurrencyField + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OCurrencyControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CurrencyField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'XTextComponent.onlyNumbers'</code> for + * {@link ifc.awt._XTextComponent} : as the currency field + * can have only numeric values the relation must be specified. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CurrencyField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OCurrencyControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OCurrencyControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + + // Adding relation for XTextComponent + tEnv.addObjRelation("XTextComponent.onlyNumbers", new Object()); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OCurrencyControl diff --git a/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java b/qadevOOo/tests/java/mod/_forms/OCurrencyModel.java new file mode 100644 index 000000000..fed0b5d57 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OCurrencyModel.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._forms; +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.CurrencyField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlCurrencyFieldModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::form::component::CurrencyField</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.awt.UnoControlCurrencyFieldModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see com.sun.star.form.component.CurrencyField +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.awt._UnoControlCurrencyFieldModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +* @see ifc.form.component._CurrencyField +*/ +public class OCurrencyModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Value"; + * super.m_kindOfControl="CurrencyField"; + * super.m_ObjectName = "stardiv.one.form.component.CurrencyField"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = "Identifier"; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ObjectName = "stardiv.one.form.component.CurrencyField"; + + super.m_kindOfControl="CurrencyField"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = "Identifier"; + super.m_propertiesToSet.add(myProp); + + super.m_ChangePropertyName = "Value"; + super.m_ChangePropertyValue = new Double(0); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OCurrencyModel diff --git a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java new file mode 100644 index 000000000..0683ab01c --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java @@ -0,0 +1,863 @@ +/* + * 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._forms; + +import ifc.form._XDatabaseParameterBroadcaster; +import ifc.sdb._XCompletedExecution; + +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; +import util.DrawTools; +import util.FormTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XControlShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.form.DatabaseParameterEvent; +import com.sun.star.form.XForm; +import com.sun.star.form.XLoadable; +import com.sun.star.lang.EventObject; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.ParametersRequest; +import com.sun.star.sdb.RowChangeEvent; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.sdbc.XRow; +import com.sun.star.sdbc.XRowSet; +import com.sun.star.sdbc.XRowUpdate; +import com.sun.star.task.XInteractionRequest; +import com.sun.star.text.XTextDocument; +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.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.DatabaseForm</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::script::XEventAttacherManager</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::sdbcx::ResultSet</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li> + * <li> <code>com::sun::star::sdb::XResultSetAccess</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::form::component::DataForm</code></li> + * <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li> + * <li> <code>com::sun::star::sdb::RowSet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::sdbc::XRowSet</code></li> + * <li> <code>com::sun::star::sdbc::XRowUpdate</code></li> + * <li> <code>com::sun::star::form::XLoadable</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::container::XIndexReplace</code></li> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XNameReplace</code></li> + * <li> <code>com::sun::star::container::XIndexContainer</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::sdbc::XParameters</code></li> + * <li> <code>com::sun::star::util::XCancellable</code></li> + * <li> <code>com::sun::star::form::XReset</code></li> + * <li> <code>com::sun::star::sdbc::XCloseable</code></li> + * <li> <code>com::sun::star::sdbcx::XColumnsSupplier</code></li> + * <li> <code>com::sun::star::sdb::XRowSetApproveBroadcaster</code></li> + * <li> <code>com::sun::star::sdbc::ResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XResultSet</code></li> + * <li> <code>com::sun::star::sdbc::XRow</code></li> + * <li> <code>com::sun::star::sdbc::XColumnLocate</code></li> + * <li> <code>com::sun::star::awt::XTabControllerModel</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::form::XSubmit</code></li> + * <li> <code>com::sun::star::form::component::HTMLForm</code></li> + * <li> <code>com::sun::star::sdbcx::XRowLocate</code></li> + * <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li> + * <li> <code>com::sun::star::container::XNameContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::sdbc::RowSet</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * The following parameters in ini-file used by this test: + * <ul> + * <li><code>test.db.url</code> - URL to MySQL database. + * For example: <code>mysql://mercury:3306/api_current</code></li> + * <li><code>test.db.user</code> - user for MySQL database</li> + * <li><code>test.db.password</code> - password for MySQL database</li> + * </ul><p> + * + * @see com.sun.star.script.XEventAttacherManager + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.sdbcx.ResultSet + * @see com.sun.star.container.XChild + * @see com.sun.star.sdbc.XResultSetUpdate + * @see com.sun.star.sdb.XResultSetAccess + * @see com.sun.star.form.FormComponent + * @see com.sun.star.form.component.DataForm + * @see com.sun.star.sdbc.XResultSetMetaDataSupplier + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.sdbcx.XDeleteRows + * @see com.sun.star.sdb.RowSet + * @see com.sun.star.lang.XComponent + * @see com.sun.star.sdbc.XRowSet + * @see com.sun.star.sdbc.XRowUpdate + * @see com.sun.star.form.XLoadable + * @see com.sun.star.container.XNamed + * @see com.sun.star.container.XIndexReplace + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XNameReplace + * @see com.sun.star.container.XIndexContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.sdbc.XParameters + * @see com.sun.star.util.XCancellable + * @see com.sun.star.form.XReset + * @see com.sun.star.sdbc.XCloseable + * @see com.sun.star.sdbcx.XColumnsSupplier + * @see com.sun.star.sdb.XRowSetApproveBroadcaster + * @see com.sun.star.sdbc.ResultSet + * @see com.sun.star.sdbc.XResultSet + * @see com.sun.star.sdbc.XRow + * @see com.sun.star.sdbc.XColumnLocate + * @see com.sun.star.awt.XTabControllerModel + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.form.XSubmit + * @see com.sun.star.form.component.HTMLForm + * @see com.sun.star.sdbcx.XRowLocate + * @see com.sun.star.sdbc.XWarningsSupplier + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.sdbc.RowSet + * @see ifc.script._XEventAttacherManager + * @see ifc.container._XElementAccess + * @see ifc.sdbcx._ResultSet + * @see ifc.container._XChild + * @see ifc.sdbc._XResultSetUpdate + * @see ifc.sdb._XResultSetAccess + * @see ifc.form._FormComponent + * @see ifc.form.component._DataForm + * @see ifc.sdbc._XResultSetMetaDataSupplier + * @see ifc.container._XEnumerationAccess + * @see ifc.sdbcx._XDeleteRows + * @see ifc.sdb._RowSet + * @see ifc.lang._XComponent + * @see ifc.sdbc._XRowSet + * @see ifc.sdbc._XRowUpdate + * @see ifc.form._XLoadable + * @see ifc.container._XNamed + * @see ifc.container._XIndexReplace + * @see ifc.io._XPersistObject + * @see ifc.container._XNameReplace + * @see ifc.container._XIndexContainer + * @see ifc.container._XNameAccess + * @see ifc.sdbc._XParameters + * @see ifc.util._XCancellable + * @see ifc.form._XReset + * @see ifc.sdbc._XCloseable + * @see ifc.sdbcx._XColumnsSupplier + * @see ifc.sdb._XRowSetApproveBroadcaster + * @see ifc.sdbc._ResultSet + * @see ifc.sdbc._XResultSet + * @see ifc.sdbc._XRow + * @see ifc.sdbc._XColumnLocate + * @see ifc.awt._XTabControllerModel + * @see ifc.container._XIndexAccess + * @see ifc.form._XSubmit + * @see ifc.form.component._HTMLForm + * @see ifc.sdbcx._XRowLocate + * @see ifc.sdbc._XWarningsSupplier + * @see ifc.container._XNameContainer + * @see ifc.beans._XPropertyAccess + * @see ifc.beans._XPropertyContainer + * @see ifc.beans._XPropertySet + * @see ifc.sdbc._RowSet + */ +public class ODatabaseForm extends TestCase { + protected static final String dbSourceName = "ODatabaseFormDataSource"; + private static int uniqueSuffix = 0; + private static String origDB = null; + private static String tmpDir = null; + protected XTextDocument xTextDoc = null; + private DBTools dbTools = null; + String tableName = null; + DBTools.DataSourceInfo srcInf = null; + boolean isMySQLDB = false; + protected XConnection conn = null; + private Object dbSrc = null; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + tmpDir = utils.getOfficeTemp(tParam.getMSF()); + + origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf"); + + dbTools = new DBTools( tParam.getMSF() ); + + // creating DataSource and registering it in DatabaseContext + String dbURL = (String) tParam.get("test.db.url"); + String dbUser = (String) tParam.get("test.db.user"); + String dbPassword = (String) tParam.get("test.db.password"); + + log.println("Creating and registering DataSource ..."); + srcInf = dbTools.newDataSourceInfo(); + + if ((dbURL != null) && (dbUser != null) && (dbPassword != null)) { + isMySQLDB = true; + log.println("dbURL = " + dbURL); + log.println("dbUSER = " + dbUser); + log.println("dbPASSWORD = " + dbPassword); + + //DataSource for mysql db + try { + tableName = "soffice_test_table"; + srcInf.URL = "jdbc:" + dbURL; + srcInf.IsPasswordRequired = Boolean.TRUE; + srcInf.Password = dbPassword; + srcInf.User = dbUser; + + PropertyValue[] propInfo = new PropertyValue[1]; + propInfo[0] = new PropertyValue(); + propInfo[0].Name = "JavaDriverClass"; + propInfo[0].Value = "util.dddriver.Driver"; + srcInf.Info = propInfo; + + dbSrc = srcInf.getDataSourceService(); + dbTools.reRegisterDB(dbSourceName, dbSrc); + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test initialization :"); + e.printStackTrace(log); + throw new StatusException("Error while object test" + + " initialization", e); + } + } else { + //DataSource for sdbc db + try { + String myDbUrl = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir); + srcInf.URL = myDbUrl; + + log.println("try to register '"+myDbUrl+"' as '"+dbSourceName+"'"); + + dbSrc = srcInf.getDataSourceService(); + dbTools.reRegisterDB(dbSourceName, dbSrc); + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test initialization :"); + e.printStackTrace(log); + throw new StatusException( + "Error while object test initialization", e); + } + + String oldF = null; + String newF = null; + + do { + tableName = "ODatabaseForm_tmp" + uniqueSuffix; + oldF = utils.getFullURL(origDB); + newF = utils.getOfficeTemp(tParam.getMSF()) + tableName + + ".dbf"; + } while (!utils.tryOverwriteFile(tParam.getMSF(), oldF, newF) && + (uniqueSuffix++ < 50)); + } + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + if (xTextDoc != null) { + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + + log.println("Existing document disposed"); + } + + log.println("creating a text document"); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + + //initialize test table + if (isMySQLDB) { + dbTools.initTestTableUsingJDBC(tableName, srcInf); + } + + XInterface oObj = null; + XShapes oShapes = null; + XInterface oInstance = null; + XConnection connection = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + XNameContainer forms = FormTools.getForms(WriterTools.getDrawPage( + xTextDoc)); + + try { + String[] formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println("Removing form '" + formNames[i] + "' ..."); + forms.removeByName(formNames[i]); + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + } + + String[] formNames = forms.getElementNames(); + FormTools.insertForm(xTextDoc, forms, "MyForm"); + formNames = forms.getElementNames(); + + XLoadable formLoader = null; + + formLoader = FormTools.bindForm(xTextDoc, "MyForm", dbSourceName, + tableName); + + + // DEBUG + log.println("Forms before adding controls : "); + formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println(" '" + formNames[i] + "'"); + } + + XControlShape shape1 = null; + XControlShape shape2 = null; + + try { + + log.println("Elements in the 'MyForm' :"); + + XIndexAccess formElements1 = UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = UnoRuntime.queryInterface( + XNamed.class, + formElements1.getByIndex(i)); + log.println(" '" + elemName.getName() + "'"); + } + + + // END DEBUG + //put something on the drawpage + log.println("inserting some ControlShapes"); + oShapes = DrawTools.getShapes(WriterTools.getDrawPage(xTextDoc)); + shape1 = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 1000, "CommandButton"); + shape2 = FormTools.createControlShape(xTextDoc, 5000, 3500, 7500, + 5000, "TextField"); + + XControlShape shape3 = FormTools.createControlShape(xTextDoc, 2000, + 1500, 1000, + 1000, + "CheckBox"); + oShapes.add(shape1); + oShapes.add(shape2); + oShapes.add(shape3); + } catch (Exception e) { + e.printStackTrace(log); + } + + log.println("Forms after adding controls : "); + formNames = forms.getElementNames(); + + for (int i = 0; i < formNames.length; i++) { + log.println(" '" + formNames[i] + "'"); + } + + try { + log.println("Elements in the 'MyForm' :"); + + XIndexAccess formElements1 = UnoRuntime.queryInterface( + XIndexAccess.class, + forms.getByName("MyForm")); + + for (int i = 0; i < formElements1.getCount(); i++) { + XNamed elemName = UnoRuntime.queryInterface( + XNamed.class, + formElements1.getByIndex(i)); + log.println(" '" + elemName.getName() + "'"); + } + } catch (Exception e) { + e.printStackTrace(log); + } + + formLoader.load(); + + try { + Object temp1 = FormTools.getForms( WriterTools.getDrawPage(xTextDoc) ).getByName("MyForm"); + oObj = (XForm) AnyConverter.toObject(new Type(XForm.class), temp1); + + XPropertySet xSetProp = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + connection = (XConnection) AnyConverter.toObject( + new Type(XConnection.class), + xSetProp.getPropertyValue("ActiveConnection")); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't get Form"); + e.printStackTrace(log); + } + + + // get a control + oInstance = FormTools.createControl(xTextDoc, "TextField"); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + // adding relation for closing connection while environment disposing. + this.conn = connection; + + // adding relation for XSubmit + XControlModel the_Model = shape2.getControl(); + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + XControl cntrl = null; + + //now get the OEditControl + cntrl = the_access.getControl(the_Model); + log.println(cntrl.getClass().getName()); + + XResultSet the_set = UnoRuntime.queryInterface( + XResultSet.class, oObj); + + the_set.first(); + + tEnv.addObjRelation("Model1", shape1.getControl()); + tEnv.addObjRelation("Model2", shape2.getControl()); + + + // adding an object for XNameReplace testing + log.println("adding oInstance as obj relation to environment"); + tEnv.addObjRelation("INSTANCE", oInstance); + + + // INDEX : _XNameContainer + log.println("adding INDEX as obj relation to environment"); + tEnv.addObjRelation("INDEX", "0"); + + + // INDEX : _XNameReplace + log.println("adding NameReplaceIndex as obj relation to environment"); + tEnv.addObjRelation("XNameReplaceINDEX", "2"); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + String tc = (String) Param.get("THRCNT"); + int THRCNT = 1; + + if (tc != null) { + THRCNT = Integer.parseInt(tc); + } + + for (int n = 1; n < (2 * (THRCNT + 1)); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + tEnv.addObjRelation("INSTANCE" + n, + FormTools.createControl(xTextDoc, "CheckBox")); + } + + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + + // adding relation for XPersistObject + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Form"); + + // Adding obj relation for XRowSetApproveBroadcaster test + final XResultSet xResSet = UnoRuntime.queryInterface( + XResultSet.class, oObj); + final XResultSetUpdate xResSetUpdate = UnoRuntime.queryInterface( + XResultSetUpdate.class, + oObj); + final XRowSet xRowSet = UnoRuntime.queryInterface( + XRowSet.class, oObj); + final PrintWriter logF = log; + tEnv.addObjRelation("XRowSetApproveBroadcaster.ApproveChecker", + new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() { + public void moveCursor() { + try { + xResSet.beforeFirst(); + xResSet.afterLast(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.moveCursor() :"); + e.printStackTrace(logF); + } + } + + public RowChangeEvent changeRow() { + try { + xResSet.first(); + + XRowUpdate row = UnoRuntime.queryInterface( + XRowUpdate.class, xResSet); + row.updateString(1, "1"); + xResSetUpdate.updateRow(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRow() :"); + e.printStackTrace(logF); + } + + RowChangeEvent ev = new RowChangeEvent(); + ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE; + ev.Rows = 1; + + return ev; + } + + public void changeRowSet() { + try { + xRowSet.execute(); + } catch (com.sun.star.sdbc.SQLException e) { + logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRowSet() :"); + e.printStackTrace(logF); + } + } + }); + + + // Adding relation for XColumnLocate test + tEnv.addObjRelation("XColumnLocate.ColumnName", DBTools.TST_STRING_F); + + // Adding relation for XParameters ifc test + ArrayList<Object> params = new ArrayList<Object>(); + + + /***** statement parameter types and their initial + values must be added here as relation. */ + params.add("SAU99") ; + params.add(Boolean.FALSE) ; + params.add(Byte.valueOf((byte) 123)) ; + params.add(Short.valueOf((short) 234)) ; + params.add(Integer.valueOf(12345)) ; + params.add(Long.valueOf(23456)) ; + params.add(new Float(1.234)) ; + params.add(new Double(2.345)) ; + params.add(new byte[] {1, 2, 3}) ; + Date d = new Date(); + d.Day = 26; d.Month = 1; d.Year = 2001; + params.add(d) ; + Time t = new Time(); + t.Hours = 1; t.NanoSeconds = 123456789; t.Minutes = 25; t.Seconds = 14; + params.add(t) ; + DateTime dt = new DateTime(); + dt.Day = 26; dt.Month = 1; dt.Year = 2001; dt.Hours = 1; + dt.NanoSeconds = 123456789; dt.Minutes = 25; dt.Seconds = 14; + params.add(dt) ; + tEnv.addObjRelation("XParameters.ParamValues", params); + + // Adding relation for XCompletedExecution + tEnv.addObjRelation("InteractionHandlerChecker", new InteractionHandlerImpl()); + + // Adding for XWarningSupplier + tEnv.addObjRelation("CheckWarningsSupplier", Boolean.valueOf(isMySQLDB)); + + // Adding relation for XDatabaseParameterBroadcaster + tEnv.addObjRelation("ParameterListenerChecker", new ODatabaseForm.ParameterListenerImpl()); + XPropertySet xSetProp = UnoRuntime.queryInterface + (XPropertySet.class, oObj) ; + try { + xSetProp.setPropertyValue("DataSourceName", dbSourceName) ; + if(isMySQLDB) { + xSetProp.setPropertyValue("Command", "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )"); + } + else { + xSetProp.setPropertyValue("Command", "SELECT \"_TEXT\" FROM \"ODatabaseForm_tmp0\" WHERE ( ( \"_TEXT\" = :param1 ) )"); + } + + xSetProp.setPropertyValue("CommandType", + Integer.valueOf(CommandType.COMMAND)) ; + } + catch(Exception e) { + } + + // Adding relation for XResultSetUpdate + final XRowUpdate xRowUpdate = UnoRuntime.queryInterface( + XRowUpdate.class, oObj); + final XRow xRow = UnoRuntime.queryInterface(XRow.class, oObj); + + tEnv.addObjRelation("XResultSetUpdate.UpdateTester", + new ifc.sdbc._XResultSetUpdate.UpdateTester() { + String lastUpdate = null; + + public int rowCount() throws SQLException { + int prevPos = xResSet.getRow(); + xResSet.last(); + + int count = xResSet.getRow(); + xResSet.absolute(prevPos); + + return count; + } + + public void update() throws SQLException { + lastUpdate = xRow.getString(1); + lastUpdate += "_"; + xRowUpdate.updateString(1, lastUpdate); + } + + public boolean wasUpdated() throws SQLException { + String getStr = xRow.getString(1); + + return lastUpdate.equals(getStr); + } + + public int currentRow() throws SQLException { + return xResSet.getRow(); + } + }); + + // Adding relations for XRow as a Vector with all data + // of current row of RowSet. + + ArrayList<Object> rowData = new ArrayList<Object>(); + + for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) { + rowData.add(DBTools.TST_TABLE_VALUES[0][i]); + } + + tEnv.addObjRelation("CurrentRowData", rowData); + + // Adding relation for XRowUpdate + XRow row = UnoRuntime.queryInterface(XRow.class, oObj); + tEnv.addObjRelation("XRowUpdate.XRow", row); + + + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "Cycle"); + + PropertyValue propVal = new PropertyValue(); + propVal.Name = "Name"; + propVal.Value = "Text since XPropertyAccess"; + + tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Closes connection of <code>RowSet</code> instance created. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("closing connection..."); + try { + conn.close(); + } catch (com.sun.star.uno.Exception e) { + log.println("Can't close the connection"); + e.printStackTrace(log); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Connection was already closed. It's OK."); + } + + + log.println("closing data source..."); + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, dbSrc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close data source"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close data source"); + } + + + log.println("closing document..."); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + + log.println("revoking data source..."); + try { + dbTools.revokeDB(dbSourceName); + } catch (com.sun.star.container.NoSuchElementException e){ + } catch (com.sun.star.uno.Exception e) { + log.println("Error while object test cleaning up :"); + e.printStackTrace(log); + throw new StatusException("Error while object test cleaning up", e); + } + } + + /** + * Implementation of interface _XDatabaseParameterBroadcaster.CheckParameterListener + * for the XDatabaseParameterBroadcaster test + * @see ifc.form._XDatabaseParameterBroadcaster + */ + private static class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener { + private boolean listenerWasCalled = false; + + private PrintWriter log; + + ParameterListenerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + /** + * Return true, if the listener was called, false otherwise. + * @return True, if any other method of the listener was called. + */ + public boolean checkListener() { + return listenerWasCalled; + } + + /** + * Take the DataBaseParameterEvent and fill it with a meaningful value. + * @param e The database parameter that will be filled with a value. + * @return True, if the value could be filled. + */ + public boolean approveParameter(DatabaseParameterEvent e) { + log.println("### ParameterListenerImpl: approve called."); + XIndexAccess params = e.Parameters; + int count = params.getCount(); + try { + for(int i=0; i<count; i++) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter "+i+": "+params.getByIndex(i)); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", Integer.valueOf(1)); + listenerWasCalled = true; + } + } + catch(Exception eI) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Exception!"); + eI.printStackTrace(log); + return false; + } + return true; + } + + /** + * Dummy implementation. Do nothing, just log + * @param o Ignore. + */ + public void disposing(EventObject o) { + log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: disposing"); + } + + /** + * Set a log writer, so messages go to log instead of Standard.out + * @param log The log messages get printed to. + */ + public void setLog(PrintWriter log) { + this.log = log; + } + + } + + + /** + * Implementation of interface _XCompletedExecution.CheckInteractionHandler + * for the XCompletedExecution test + * @see ifc.sdb._XCompletedExecution + */ + private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { + private boolean handlerWasUsed = false; + private PrintWriter log; + + InteractionHandlerImpl() throws UnsupportedEncodingException { + log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")); + } + + public boolean checkInteractionHandler() { + return handlerWasUsed; + } + + public void handle(XInteractionRequest xInteractionRequest) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called."); + handlerWasUsed = true; + + Object o = xInteractionRequest.getRequest(); + ParametersRequest req = (ParametersRequest)o; + XIndexAccess params = req.Parameters; + int count = params.getCount(); + try { + for(int i=0; i<count; i++) { + params.getByIndex(i); + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter "+i+": "+params.getByIndex(i)); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i)); + log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'"); + xProp.setPropertyValue("Value", Integer.valueOf(1)); + handlerWasUsed = true; + } + } + catch(Exception eI) { + log.println("### _XCompletedExecution.InteractionHandlerImpl: Exception!"); + eI.printStackTrace(log); + } + } + + public void setLog(PrintWriter log) { + this.log = log; + } + + } +} // finish class ODatabaseForm diff --git a/qadevOOo/tests/java/mod/_forms/ODateControl.java b/qadevOOo/tests/java/mod/_forms/ODateControl.java new file mode 100644 index 000000000..7d4dfc9e4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateControl.java @@ -0,0 +1,222 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.DateField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XDateField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XDateField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XDateField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class ODateControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.DateField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "DateField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ODateControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for ODateControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ODateControl diff --git a/qadevOOo/tests/java/mod/_forms/ODateModel.java b/qadevOOo/tests/java/mod/_forms/ODateModel.java new file mode 100644 index 000000000..0d4c75800 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ODateModel.java @@ -0,0 +1,150 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DateField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlDateFieldModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::DateField</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlDateFieldModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.DateField +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlDateFieldModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._DateField +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ODateModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Date"; + * super.m_kindOfControl="DateField"; + * super.m_ObjectName = "stardiv.one.form.component.DateField"; + * + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_DATE_F; + * super.m_propertiesToSet.add(DataField); + * + * NamedValue Date = new NamedValue(); + * Date.Name = "Date"; + * Date.Value = Integer.valueOf(DBTools.TST_DATE); + * super.m_propertiesToSet.add(Date); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Date"; + + super.m_kindOfControl="DateField"; + + super.m_ObjectName = "stardiv.one.form.component.DateField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_DATE_F; + super.m_propertiesToSet.add(DataField); + + NamedValue Date = new NamedValue(); + Date.Name = "Date"; + Date.Value = new com.sun.star.util.Date(); + super.m_propertiesToSet.add(Date); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class ODateModel diff --git a/qadevOOo/tests/java/mod/_forms/OEditControl.java b/qadevOOo/tests/java/mod/_forms/OEditControl.java new file mode 100644 index 000000000..ae231ace5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditControl.java @@ -0,0 +1,240 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.TextField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::form::XChangeBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.form.XChangeBroadcaster + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.form._XChangeBroadcaster + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OEditControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.TextField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * <li> <code>'Win1'</code> for + * {@link ifc.form._XChangeBroadcaster} : the window (controller) + * of the tested component. </li> + * <li> <code>'Win2'</code> for + * {@link ifc.form._XChangeBroadcaster} : the window (controller) + * of another component. </li> + * <li> <code>'CONTROL'</code> for + * {@link ifc.form._XChangeBroadcaster} : the controller + * of another component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XControl aControl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OEditControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OEditControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // relations for XChangeBroadcaster + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("Win1", + UnoRuntime.queryInterface(XWindow.class, + oObj)); + tEnv.addObjRelation("Win2", forObjRel); + tEnv.addObjRelation("CONTROL", aControl); + + + // relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OEditControl diff --git a/qadevOOo/tests/java/mod/_forms/OEditModel.java b/qadevOOo/tests/java/mod/_forms/OEditModel.java new file mode 100644 index 000000000..b672cbd9c --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OEditModel.java @@ -0,0 +1,142 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.TextField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::component::TextField</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::awt::UnoControlEditModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseTextField</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.component.TextField +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.awt.UnoControlEditModel +* @see com.sun.star.form.component.DatabaseTextField +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form.component._TextField +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.awt._UnoControlEditModel +* @see ifc.form.component._DatabaseTextField +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OEditModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * <super.m_ChangePropertyName</CODE> = "Text"; + * super.m_kindOfControl</CODE>="TextField"; + * super.m_ObjectName</CODE> = "Edit"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="TextField"; + + super.m_ObjectName = "stardiv.one.form.component.Edit"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(myProp); + + super.m_LCShape_Type = "FixedText"; + + super.m_ChangePropertyName = "Text"; + } + +} // finish class OEditModel diff --git a/qadevOOo/tests/java/mod/_forms/OFileControlModel.java b/qadevOOo/tests/java/mod/_forms/OFileControlModel.java new file mode 100644 index 000000000..994e62123 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFileControlModel.java @@ -0,0 +1,188 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.FileControl</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::awt::UnoControlFileControlModel</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::form::component::FileControl</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @see com.sun.star.awt.UnoControlFileControlModel + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see com.sun.star.form.component.FileControl + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.awt._UnoControlFileControlModel + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + * @see ifc.form.component._FileControl + */ +public class OFileControlModel extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Draw document where controls are placed. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes Draw document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates FileControl in the Form. <p> + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * </ul> + */ + @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"); + + //get FileControlModel + String objName = "FileControl"; + + XControlShape aShape = null; + + Size size = new Size(); + Point position = new Point(); + XControlModel aControl = null; + + //get MSF + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xDrawDoc); + + Object oInt = oDocMSF.createInstance( + "com.sun.star.drawing.ControlShape"); + Object aCon = oDocMSF.createInstance( + "com.sun.star.form.component." + objName); + aControl = UnoRuntime.queryInterface( + XControlModel.class, aCon); + aShape = UnoRuntime.queryInterface( + XControlShape.class, oInt); + size.Height = 1500; + size.Width = 3000; + position.X = 1000; + position.Y = 1000; + aShape.setSize(size); + aShape.setPosition(position); + + aShape.setControl(aControl); + + DrawTools.getDrawPage(xDrawDoc, 0).add(aShape); + oObj = aShape.getControl(); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component." + + objName); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFileControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java b/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java new file mode 100644 index 000000000..2b8469144 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFixedTextModel.java @@ -0,0 +1,99 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.FixedText</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlFixedTextModel</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.form +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.container.XNamed +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.awt.UnoControlFixedTextModel +* @see com.sun.star.lang.XComponent +* @see ifc.io._XPersistObject +* @see ifc.container._XChild +* @see ifc.form._FormControlModel +* @see ifc.form._FormComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XPropertyState +* @see ifc.container._XNamed +* @see ifc.beans._XMultiPropertySet +* @see ifc.awt._UnoControlFixedTextModel +* @see ifc.lang._XComponent +*/ + +public class OFixedTextModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="FixedText"; + + super.m_ObjectName = "stardiv.one.form.component.FixedText"; + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OFixedTextModel diff --git a/qadevOOo/tests/java/mod/_forms/OFormattedControl.java b/qadevOOo/tests/java/mod/_forms/OFormattedControl.java new file mode 100644 index 000000000..11793b31d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedControl.java @@ -0,0 +1,219 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.FormattedField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OFormattedControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.FormattedField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "FormattedField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OFormattedControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OFormattedControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFormattedControl diff --git a/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java b/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java new file mode 100644 index 000000000..4a5334044 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormattedFieldWrapper.java @@ -0,0 +1,135 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; + +import util.DBTools; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.FormattedField</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::form::XReset</code></li> + * <li> <code>com::sun::star::form::XBoundComponent</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::form::DataAwareControlModel</code></li> + * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> + * <li> <code>com::sun::star::form::component::DatabaseFormattedField</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::form::XLoadListener</code></li> + * <li> <code>com::sun::star::awt::UnoControlFormattedFieldModel</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.form.XReset + * @see com.sun.star.form.XBoundComponent + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.form.DataAwareControlModel + * @see com.sun.star.form.XUpdateBroadcaster + * @see com.sun.star.form.component.DatabaseFormattedField + * @see com.sun.star.form + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.form.XLoadListener + * @see com.sun.star.awt.UnoControlFormattedFieldModel + * @see com.sun.star.container.XChild + * @see ifc.io._XPersistObject + * @see ifc.form._XReset + * @see ifc.form._XBoundComponent + * @see ifc.form._FormComponent + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XMultiPropertySet + * @see ifc.form._DataAwareControlModel + * @see ifc.form._XUpdateBroadcaster + * @see ifc.form.component._DatabaseFormattedField + * @see ifc.form._FormControlModel + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + * @see ifc.beans._XPropertyAccess + * @see ifc.beans._XPropertyContainer + * @see ifc.beans._XPropertySet + * @see ifc.form._XLoadListener + * @see ifc.awt._UnoControlFormattedFieldModel + * @see ifc.container._XChild + */ +public class OFormattedFieldWrapper extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + ' super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="DatabaseImageControl"; + * super.m_ObjectName = "stardiv.one.form.component.DatabaseImageControl"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_BINARY_STREAM_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="DatabaseFormattedField"; + + super.m_ObjectName = "stardiv.one.form.component.Edit"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OFormattedFieldWrapper diff --git a/qadevOOo/tests/java/mod/_forms/OFormsCollection.java b/qadevOOo/tests/java/mod/_forms/OFormsCollection.java new file mode 100644 index 000000000..00bc2e21b --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OFormsCollection.java @@ -0,0 +1,179 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; + +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.Forms</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::container::XIndexReplace</code></li> +* <li> <code>com::sun::star::container::XNameContainer</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::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* </ul> +* +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.container.XIndexReplace +* @see com.sun.star.container.XNameContainer +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.container.XNameAccess +* @see ifc.container._XNameReplace +* @see ifc.container._XIndexReplace +* @see ifc.container._XNameContainer +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.container._XIndexContainer +* @see ifc.container._XNameAccess +*/ +public class OFormsCollection extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a draw document"); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Adds some controls to the 'Standard' form of a draw page, + * then adds an empty form to a collection of forms. Then + * returns the collection as a test object. <p> + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1' ... 'INSTANCEN'</code> for + * <code>XNameReplace, XNameContainer, XIndexReplace, + * XIndexContainer </code> : objects to be inserted + * or replaced with in interface tests. Number of relations + * depends on number of interface test threads. For each + * thread there must be an individual element. </li> + * <li> <code>'XNameContainer.AllowDuplicateNames'</code> : + * if this relation exists then container elements can have duplicate + * names. In case of forms' collection forms can have equal names.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws com.sun.star.uno.Exception + { + XInterface oObj = null; + XDrawPage oDP = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + oDP = DrawTools.getDrawPage(xDrawDoc, 0); + + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 2000, 1500, 1000, 1000, + "CheckBox")); + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 3000, 4500, 15000, + 1000, "CommandButton")); + (DrawTools.getShapes(oDP)) + .add(FormTools.createControlShape(xDrawDoc, 5000, 3500, 7500, 5000, + "TextField")); + + oObj = FormTools.getForms(oDP); + FormTools.insertForm(xDrawDoc, (XNameContainer) oObj, "SecondForm"); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + XComponent xComp = UnoRuntime.queryInterface( + XComponent.class, xDrawDoc); + int THRCNT = 1; + if (Param.get("THRCNT")!= null) { + THRCNT = Integer.parseInt((String) Param.get("THRCNT")); + } + + for (int n = 1; n < (THRCNT + 1); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + tEnv.addObjRelation("INSTANCE" + n, + FormTools.createControl(xComp, "Form")); + } + + + // adding indicator that this collection can have duplicate + // elements with the same names for XNameContainer test. + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + tEnv.addObjRelation("INSTANCE", FormTools.createControl(xComp, "Form")); + tEnv.addObjRelation("INSTANCE2", + FormTools.createControl(xComp, "Form")); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OFormsCollection diff --git a/qadevOOo/tests/java/mod/_forms/OGridControlModel.java b/qadevOOo/tests/java/mod/_forms/OGridControlModel.java new file mode 100644 index 000000000..b440f24ce --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGridControlModel.java @@ -0,0 +1,347 @@ +/* + * 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._forms; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.GridControl</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::script::XEventAttacherManager</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::form::component::GridControl</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XIndexReplace</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::container::XIndexAccess</code></li> +* <li> <code>com::sun::star::container::XNameContainer</code></li> +* <li> <code>com::sun::star::form::XGridColumnFactory</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XIndexContainer</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::container::XContainer</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.form.XReset +* @see com.sun.star.script.XEventAttacherManager +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.form.component.GridControl +* @see com.sun.star.view.XSelectionSupplier +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XIndexReplace +* @see com.sun.star.container.XNamed +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XNameContainer +* @see com.sun.star.form.XGridColumnFactory +* @see com.sun.star.lang.XComponent +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexContainer +* @see com.sun.star.container.XChild +* @see com.sun.star.container.XContainer +* @see ifc.io._XPersistObject +* @see ifc.container._XNameReplace +* @see ifc.form._XReset +* @see ifc.script._XEventAttacherManager +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.container._XElementAccess +* @see ifc.form.component._GridControl +* @see ifc.view._XSelectionSupplier +* @see ifc.container._XEnumerationAccess +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XIndexReplace +* @see ifc.container._XNamed +* @see ifc.container._XIndexAccess +* @see ifc.container._XNameContainer +* @see ifc.form._XGridColumnFactory +* @see ifc.lang._XComponent +* @see ifc.container._XNameAccess +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexContainer +* @see ifc.container._XChild +* @see ifc.container._XContainer +*/ + +public class OGridControlModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="CommandButton"; + * super.m_ObjectName = "com.sun.star.form.component.CommandButton"; + * super.m_LCShape_Type = "CommandButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="GridControl"; + + super.m_ObjectName = "stardiv.one.form.component.Grid"; + + super.m_LCShape_Type = "GridControl"; + + } + + + /** + * calls <CODE>createTestEnvironment()</CODE> from its super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + XInterface oObj = tEnv.getTestObject(); + + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XPropertySet aControl5 = null; + + XGridColumnFactory columns = UnoRuntime.queryInterface( + XGridColumnFactory.class, oObj); + aControl = columns.createColumn("TextField"); + aControl2 = columns.createColumn("DateField"); + aControl3 = columns.createColumn("TextField"); + aControl4 = columns.createColumn("TextField"); + aControl5 = columns.createColumn("TextField"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", new Object[] { aControl, aControl2 }); + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + + // adding relation for XContainer + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE1", aControl4); + tEnv.addObjRelation("INSTANCE2", aControl5); + + + tEnv.addObjRelation("Comparer", + new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XNamed named1 = UnoRuntime.queryInterface( + XNamed.class, o1); + XNamed named2 = UnoRuntime.queryInterface( + XNamed.class, o2); + + if (named1.getName().equals(named2.getName())) { + return 0; + } + + return -1; + } + }); + + + return tEnv; + } + +} // finish class OButtonModelold + + +class OGridControlModelold extends TestCase { + XComponent xDrawDoc = null; + + /** + * Creates Drawing document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * <code>GridControl</code> component created and added to the draw + * page. Then two columns are created and added to the grid. + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1' ... 'INSTANCEN'</code> for + * <code>XNameReplace, XNameContainer, XIndexReplace, + * XIndexContainer </code> : objects to be inserted + * or replaced with in interface tests. Number of relations + * depends on number of interface test threads. For each + * thread there must be an individual element. </li> + * <li> <code>'XNameContainer.AllowDuplicateNames'</code> : + * if this relation exists then container elements can have duplicate + * names. <code>GridControl</code> can have.</li> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * <li> <code>'INSTANCE'</code> for + * {@link ifc.container._XContainer} : a column instance. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XInterface oInstance = null; + XPropertySet aControl = null; + XPropertySet aControl2 = null; + XPropertySet aControl3 = null; + XPropertySet aControl4 = null; + XGridColumnFactory columns = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + XControlShape shape = FormTools.insertControlShape(xDrawDoc, 5000, + 7000, 2000, 2000, + "GridControl"); + oObj = shape.getControl(); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + columns = UnoRuntime.queryInterface( + XGridColumnFactory.class, oObj); + aControl = columns.createColumn("TextField"); + aControl2 = columns.createColumn("DateField"); + aControl3 = columns.createColumn("TextField"); + aControl4 = columns.createColumn("TextField"); + columns.createColumn("TextField"); + + XNameContainer aContainer = UnoRuntime.queryInterface( + XNameContainer.class, oObj); + + aContainer.insertByName("First", aControl); + aContainer.insertByName("Second", aControl2); + + //Relations for XSelectionSupplier + tEnv.addObjRelation("Selections", new Object[] { aControl, aControl2 }); + + // COMPARER + + int THRCNT = 1; + String count = (String)Param.get("THRCNT"); + if (count != null) + THRCNT = Integer.parseInt(count); + + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println("adding INSTANCEn as obj relation to environment"); + + for (int n = 1; n < (3 * THRCNT + 1); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + oInstance = columns.createColumn("TextField"); + tEnv.addObjRelation("INSTANCE" + n, oInstance); + } + + + // adding relation for XNameContainer + tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object()); + + // adding relation for XContainer + tEnv.addObjRelation("INSTANCE", aControl3); + tEnv.addObjRelation("INSTANCE2", aControl4); + + + return tEnv; + } // finish method getTestEnvironment +} // finish class OGridControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java b/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java new file mode 100644 index 000000000..dea7c0058 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxControl.java @@ -0,0 +1,193 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.GroupBox</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.awt._XControl + * @see ifc.awt._XView + */ +public class OGroupBoxControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.GroupBox</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 5000, + 7000, 2000, 2000, + "GroupBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OGroupBoxControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OGroupBoxControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + + // Adding relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", + UnoRuntime.queryInterface(XWindow.class, + anotherCtrl)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OGroupBoxControl diff --git a/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java b/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java new file mode 100644 index 000000000..dcc810bd6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OGroupBoxModel.java @@ -0,0 +1,99 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestParameters; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.GroupBox</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::UnoControlGroupBoxModel</code></li> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyContainer</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.awt.UnoControlGroupBoxModel + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess + * @see com.sun.star.beans.XPropertyContainer + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.awt._UnoControlGroupBoxModel + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OGroupBoxModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * <super.m_ChangePropertyName</CODE> = "Text"; + * super.m_kindOfControl</CODE>="GroupBox"; + * super.m_ObjectName</CODE> = "GroupBox"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="GroupBox"; + + super.m_ObjectName = "stardiv.one.form.component.GroupBox"; + + super.m_LCShape_Type = "FixedText"; + + super.m_ChangePropertyName = "Text"; + } + +} // finish class OGroupBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/OHiddenModel.java b/qadevOOo/tests/java/mod/_forms/OHiddenModel.java new file mode 100644 index 000000000..388447f50 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OHiddenModel.java @@ -0,0 +1,175 @@ +/* + * 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._forms; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; +import util.SOfficeFactory; + +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +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.XCloseable; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.HiddenControl</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::form::component::HiddenControl</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.container.XChild + * @see com.sun.star.form + * @see com.sun.star.form.component.HiddenControl + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.lang.XComponent + * @see ifc.io._XPersistObject + * @see ifc.container._XChild + * @see ifc.form._FormControlModel + * @see ifc.form.component._HiddenControl + * @see ifc.form._FormComponent + * @see ifc.beans._XPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.beans._XMultiPropertySet + * @see ifc.lang._XComponent + */ +public class OHiddenModel extends TestCase { + XComponent xDrawDoc; + + /** + * Creates Drawing document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Disposes drawing document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDrawDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates hidden component, then adds Form into draw page, + * and inserts the component into Form components' collection. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} : name of service which is + * represented by this object. </li> + * </ul> + */ + @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"); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + String objName = "HiddenControl"; + XInterface ctrl = SOF.createControl(xDrawDoc, objName); + + XDrawPage oDP = DrawTools.getDrawPage(xDrawDoc, 0); + + XNameContainer nc = FormTools.getForms(oDP); + FormTools.insertForm(xDrawDoc, nc, "OHiddenModelForm"); + + Object frm = nc.getByName("OHiddenModelForm"); + + XNameContainer frmNC = UnoRuntime.queryInterface( + XNameContainer.class, frm); + + frmNC.insertByName("OHiddenModel", ctrl); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), + frmNC.getByName("OHiddenModel")); + + log.println("creating a new environment for drawpage object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.dbg.getSuppServices(oObj); + + log.println("adding DrawDocument as obj relation to environment"); + tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Hidden"); + + PropertyValue prop = new PropertyValue(); + prop.Name = "Name"; + prop.Value = "new Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "Name"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OHiddenModel diff --git a/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java b/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java new file mode 100644 index 000000000..1f55ac59e --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonControl.java @@ -0,0 +1,198 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.ImageButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XApproveActionBroadcaster</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XApproveActionBroadcaster + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XApproveActionBroadcaster + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class OImageButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.ImageButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "ImageButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageButtonControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for OImageButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OImageButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java b/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java new file mode 100644 index 000000000..0c93ba70f --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageButtonModel.java @@ -0,0 +1,103 @@ +/* + * 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._forms; + +import java.io.PrintWriter; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.ImageButton</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* <li> <code>com::sun::star::awt::UnoControlImageControlModel</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::component::ImageButton</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.container.XChild +* @see com.sun.star.awt.UnoControlImageControlModel +* @see com.sun.star.form +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.XImageProducerSupplier +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.component.ImageButton +* @see com.sun.star.container.XNamed +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.lang.XComponent +* @see ifc.io._XPersistObject +* @see ifc.container._XChild +* @see ifc.awt._UnoControlImageControlModel +* @see ifc.form._FormControlModel +* @see ifc.form._FormComponent +* @see ifc.form._XImageProducerSupplier +* @see ifc.beans._XPropertySet +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XPropertyState +* @see ifc.form.component._ImageButton +* @see ifc.container._XNamed +* @see ifc.beans._XMultiPropertySet +* @see ifc.lang._XComponent +*/ + +public class OImageButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="ImageButton"; + * super.m_ObjectName = "stardiv.one.form.component.ImageButton"; + * super.m_LCShape_Type = "ImageButton"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="ImageButton"; + + super.m_ObjectName = "stardiv.one.form.component.ImageButton"; + + super.m_LCShape_Type = "ImageButton"; + + } + +} // finish class OImageButtonModel diff --git a/qadevOOo/tests/java/mod/_forms/OImageControlControl.java b/qadevOOo/tests/java/mod/_forms/OImageControlControl.java new file mode 100644 index 000000000..d859264e1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlControl.java @@ -0,0 +1,199 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.DatabaseImageControl</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class OImageControlControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.DatabaseImageControl</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShapeWithDefaultControl( + xTextDoc, 3000, 4500, 15000, 10000, + "DatabaseImageControl"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OImageControlControl + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + aControl = the_access.getControl(the_Model2); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for OImageControlControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OImageControlControl diff --git a/qadevOOo/tests/java/mod/_forms/OImageControlModel.java b/qadevOOo/tests/java/mod/_forms/OImageControlModel.java new file mode 100644 index 000000000..174bcd54d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OImageControlModel.java @@ -0,0 +1,134 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DatabaseImageControl</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::form::XImageProducerSupplier</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlImageControlModel</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code> +* <b>(currently nonavailable)</b></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::form::component::DatabaseImageControl</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* +* @see com.sun.star.form.XImageProducerSupplier +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.awt.UnoControlImageControlModel +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.form.component.DatabaseImageControl +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.form._XImageProducerSupplier +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.awt._UnoControlImageControlModel +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.form.component._DatabaseImageControl +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OImageControlModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="DatabaseImageControl"; + * super.m_ObjectName = "stardiv.one.form.component.DatabaseImageControl"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_BINARY_STREAM_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl= "DatabaseImageControl"; + + super.m_ObjectName = "stardiv.one.form.component.ImageControl"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_BINARY_STREAM_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OImageControlModel diff --git a/qadevOOo/tests/java/mod/_forms/OListBoxControl.java b/qadevOOo/tests/java/mod/_forms/OListBoxControl.java new file mode 100644 index 000000000..03dac5b1a --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxControl.java @@ -0,0 +1,156 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + +public class OListBoxControl extends TestCase { + + XTextDocument xTextDoc; + + @Override + protected void initialize ( TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null ; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"ListBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape( + xTextDoc,3000,4500,5000,10000,"TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class,xTextDoc.getCurrentController()); + + //now get the OListBoxControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200,200); + aGraphic = aDevice.createGraphics(); + + log.println( "creating a new environment for OListBoxControl object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS",aGraphic); + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT",xTextDoc); + tEnv.addObjRelation("WINPEER",the_win); + tEnv.addObjRelation("TOOLKIT",the_kit); + tEnv.addObjRelation("MODEL",the_Model); + + // Adding relation for XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener() ; + final XListBox box = UnoRuntime.queryInterface(XListBox.class, oObj) ; + box.addItemListener(listener) ; + tEnv.addObjRelation("TestItemListener", listener) ; + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, anotherCtrl); + + XWindow objWin = UnoRuntime.queryInterface(XWindow.class, oObj); + + tEnv.addObjRelation("XWindow.AnotherWindow",forObjRel); + tEnv.addObjRelation("XWindow.ControlShape",aShape); + + tEnv.addObjRelation("Win1",objWin); + tEnv.addObjRelation("Win2",forObjRel); + + tEnv.addObjRelation("CONTROL",anotherCtrl); + + // adding relation for XChangeBroadcaster + box.addItem("Item1", (short) 0); + box.addItem("Item2", (short) 1); + + tEnv.addObjRelation("XChangeBroadcaster.Changer", + new ifc.form._XChangeBroadcaster.Changer() { + public void change(){ + box.addItem("Item1", (short) 0); + box.addItem("Item2", (short) 1); + box.selectItemPos((short) 0, true); + box.selectItemPos((short) 1, true); + } + } + ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class OListBoxControl + diff --git a/qadevOOo/tests/java/mod/_forms/OListBoxModel.java b/qadevOOo/tests/java/mod/_forms/OListBoxModel.java new file mode 100644 index 000000000..f829da701 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OListBoxModel.java @@ -0,0 +1,217 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XLoadable; + + +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import ifc.form._XUpdateBroadcaster.UpdateChecker; +import java.io.PrintWriter; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.DatabaseListBox</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::awt::UnoControlListBoxModel</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::form::component::ListBox</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::form::component::DatabaseListBox</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.awt.UnoControlListBoxModel +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.form.component.ListBox +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.form.component.DatabaseListBox +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.awt._UnoControlListBoxModel +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.form.component._ListBox +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.form.component._DatabaseListBox +* @see ifc.container._XChild +*/ +public class OListBoxModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Date"; + * super.m_kindOfControl="DateField"; + * super.m_ObjectName = "stardiv.one.form.component.DateField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_DATE_F; + * super.m_propertiesToSet.add(DataField); + * + * NamedValue ListSource = new NamedValue(); + * ListSource.Name = "ListSource"; + * ListSource.Value = new String[] { + * "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"}; + * super.m_propertiesToSet.add(ListSource); + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "SelectedItems"; + + super.m_kindOfControl="ListBox"; + + super.m_ObjectName = "stardiv.one.form.component.ListBox"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + NamedValue ListSource = new NamedValue(); + ListSource.Name = "ListSource"; + ListSource.Value = new String[] { + "OListBoxModel1", "OListBoxModel2", "OListBoxModel3"}; + super.m_propertiesToSet.add(ListSource); + + super.m_LCShape_Type = "FixedText"; + + } + + /** + * calls <CODE>createTestEnvironment()</CODE> from its super class + * This test uses not the generic implementation of <CODE>checker()</CODE> of its + * super class. This tests uses its own implementation of <CODE>checker()</CODE> + * to test <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl, m_ChangePropertyName)); + return tEnv; + } + + private static class Checker implements UpdateChecker { + private short lastItem = (short) 0; + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + private String ChangePropertyName = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl, String ChangePropertyName) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + this.ChangePropertyName=ChangePropertyName; + } + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + lastItem = (short) (1 - lastItem); + ps.setPropertyValue(ChangePropertyName, new short[] { lastItem }); + } + + public void commit() throws SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + formLoaderF.reload(); + + short[] getS = (short[]) ps.getPropertyValue(ChangePropertyName); + + return (getS.length > 0) && (lastItem == getS[0]); + } + } + +} // finish class OListBoxModel diff --git a/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java b/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java new file mode 100644 index 000000000..cec4696cd --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarControl.java @@ -0,0 +1,159 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; +import util.DesktopTools; + +public class ONavigationBarControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.CommandButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "NavigationToolBar"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OButtonControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for ONavigationBarControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ONavigationBarControl diff --git a/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java b/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java new file mode 100644 index 000000000..030a9b011 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONavigationBarModel.java @@ -0,0 +1,52 @@ +/* + * 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._forms; + +import java.io.PrintWriter; +import lib.TestParameters; + +public class ONavigationBarModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_kindOfControl="NavigationToolBar"; + * super.m_ObjectName = "om.sun.star.form.component.NavigationToolBar"; + * super.m_LCShape_Type = "NavigationToolBar"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_kindOfControl="NavigationToolBar"; + + super.m_ObjectName = "com.sun.star.form.component.NavigationToolBar"; + + super.m_LCShape_Type = "NavigationToolBar"; + + } + +} // finish class ONavigationBarModel + diff --git a/qadevOOo/tests/java/mod/_forms/ONumericControl.java b/qadevOOo/tests/java/mod/_forms/ONumericControl.java new file mode 100644 index 000000000..843e5c8a9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericControl.java @@ -0,0 +1,224 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.NumericField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XNumericField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XNumericField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XNumericField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class ONumericControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.NumericField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "NumericField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ONumericControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for ONumericControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + tEnv.addObjRelation("XTextComponent.onlyNumbers", Boolean.TRUE); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ONumericControl diff --git a/qadevOOo/tests/java/mod/_forms/ONumericModel.java b/qadevOOo/tests/java/mod/_forms/ONumericModel.java new file mode 100644 index 000000000..23f26b0e5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ONumericModel.java @@ -0,0 +1,133 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.for.component.NumericField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::component::NumericField</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::awt::UnoControlNumericFieldModel</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form.component.NumericField +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.awt.UnoControlNumericFieldModel +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form.component._NumericField +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.awt._UnoControlNumericFieldModel +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ONumericModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Time"; + * super.m_kindOfControl="TimeField"; + * super.m_ObjectName = "stardiv.one.form.component.TimeField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_INT_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Value"; + + super.m_kindOfControl="NumericField"; + + super.m_ObjectName = "stardiv.one.form.component.NumericField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_DOUBLE_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class ONumericModel diff --git a/qadevOOo/tests/java/mod/_forms/OPatternControl.java b/qadevOOo/tests/java/mod/_forms/OPatternControl.java new file mode 100644 index 000000000..4c67dabd9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternControl.java @@ -0,0 +1,222 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.PatternField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::awt::XPatternField</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.awt.XPatternField + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.awt._XPatternField + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OPatternControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.PatternField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + Object anotherCtrl = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "PatternField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OPatternControl + oObj = the_access.getControl(the_Model); + anotherCtrl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OPatternControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // Adding relation for XWindow + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + anotherCtrl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OPatternControl diff --git a/qadevOOo/tests/java/mod/_forms/OPatternModel.java b/qadevOOo/tests/java/mod/_forms/OPatternModel.java new file mode 100644 index 000000000..0bec8f499 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OPatternModel.java @@ -0,0 +1,138 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestParameters; +import util.DBTools; + + + +/** + * Test for object which is represented by service + * <code>com.sun.star.form.component.PatternField</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::io::XPersistObject</code></li> + * <li> <code>com::sun::star::form::XReset</code></li> + * <li> <code>com::sun::star::form::XBoundComponent</code></li> + * <li> <code>com::sun::star::form::FormComponent</code></li> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * <li> <code>com::sun::star::form::component::PatternField</code></li> + * <li> <code>com::sun::star::form::DataAwareControlModel</code></li> + * <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> + * <li> <code>com::sun::star::awt::UnoControlPatternFieldModel</code></li> + * <li> <code>com::sun::star::form::component::DatabasePatternField</code></li> + * <li> <code>com::sun::star::form::FormControlModel</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::form::XLoadListener</code></li> + * <li> <code>com::sun::star::container::XChild</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.io.XPersistObject + * @see com.sun.star.form.XReset + * @see com.sun.star.form.XBoundComponent + * @see com.sun.star.form.FormComponent + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XMultiPropertySet + * @see com.sun.star.form.component.PatternField + * @see com.sun.star.form.DataAwareControlModel + * @see com.sun.star.form.XUpdateBroadcaster + * @see com.sun.star.awt.UnoControlPatternFieldModel + * @see com.sun.star.form.component.DatabasePatternField + * @see com.sun.star.form + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XEventListener + * @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet + * @see com.sun.star.form.XLoadListener + * @see com.sun.star.container.XChild + * @see ifc.io._XPersistObject + * @see ifc.form._XReset + * @see ifc.form._XBoundComponent + * @see ifc.form._FormComponent + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XMultiPropertySet + * @see ifc.form.component._PatternField + * @see ifc.form._DataAwareControlModel + * @see ifc.form._XUpdateBroadcaster + * @see ifc.awt._UnoControlPatternFieldModel + * @see ifc.form.component._DatabasePatternField + * @see ifc.form._FormControlModel + * @see ifc.beans._XPropertyState + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.lang._XEventListener + * @see ifc.beans._XPropertySet + * @see ifc.form._XLoadListener + * @see ifc.container._XChild + */ +public class OPatternModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Text"; + * super.m_kindOfControl="PatternField"; + * super.m_ObjectName = "stardiv.one.form.component.PatternField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Text"; + + super.m_kindOfControl="PatternField"; + + super.m_ObjectName = "stardiv.one.form.component.PatternField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + +} // finish class OPatternModel diff --git a/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java b/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java new file mode 100644 index 000000000..0fd3ce626 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonControl.java @@ -0,0 +1,201 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.RadioButton</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XRadioButton</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XView</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XWindow + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XRadioButton + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XView + * @see ifc.lang._XComponent + * @see ifc.awt._XWindow + * @see ifc.form._XBoundControl + * @see ifc.awt._XRadioButton + * @see ifc.awt._XControl + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XView + */ +public class ORadioButtonControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.RadioButton</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "RadioButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the ORadioButtonControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for ORadioButtonControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ORadioButtonControl diff --git a/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java b/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java new file mode 100644 index 000000000..d65c07064 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/ORadioButtonModel.java @@ -0,0 +1,157 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.RadioButton</code>. <p> +* +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::component::RadioButton</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::awt::UnoControlRadioButtonModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.component.RadioButton +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.awt.UnoControlRadioButtonModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.io._XPersistObject +* @see ifc.form.component._RadioButton +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.awt._UnoControlRadioButtonModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class ORadioButtonModel extends GenericModelTest { + + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName</CODE> = "State"; + * super.m_kindOfControl</CODE>="RadioButton"; + * super.m_ObjectName</CODE> = "RadioButton"; + * NamedValue myProp = new NamedValue(); + * myProp.Name = "DataField"; + * myProp.Value = DBTools.TST_STRING_F; + * super.m_propertiesToSet.add(myProp); + * super.m_LCShape_Type = "GroupBox"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + super.m_ChangePropertyName = "State"; + + super.m_kindOfControl="RadioButton"; + + super.m_ObjectName = "stardiv.one.form.component.RadioButton"; + + NamedValue myProp = new NamedValue(); + myProp.Name = "DataField"; + myProp.Value = DBTools.TST_STRING_F; + super.m_propertiesToSet.add(myProp); + + super.m_LCShape_Type = "GroupBox"; + + } + + /** + * calls <CODE>createTestEnvironment()</CODE> from its super class + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + tEnv.addObjRelation("DataAwareControlModel.NewFieldName", + DBTools.TST_INT_F); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + return tEnv; + } + +} // finish class ORadioButtonModel diff --git a/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java b/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java new file mode 100644 index 000000000..cd6c24161 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java @@ -0,0 +1,93 @@ +/* + * 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._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; + +public class OScrollBarModel extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates Writer document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(tParam.getMSF()); + } + + /** + * Disposes the Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) + throws com.sun.star.uno.Exception + { + + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"ScrollBar"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + oObj = aShape.getControl(); + log.println( "creating a new environment for OScrollBarModel object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + System.out.println("Implementation Name: "+util.utils.getImplName(oObj)); + + String objName = "ScrollBar"; + tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component." + objName); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java b/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java new file mode 100644 index 000000000..d4864f285 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OSpinButtonModel.java @@ -0,0 +1,95 @@ +/* + * 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._forms; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; + +public class OSpinButtonModel extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates a Writer document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + log.println( "creating a textdocument" ); + xTextDoc = WriterTools.createTextDoc(tParam.getMSF()); + } + + /** + * Disposes the Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Adds spin button into text and retrieves it's control model. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) + throws com.sun.star.uno.Exception + { + XInterface oObj = null; + + XControlShape aShape = FormTools.createControlShape( + xTextDoc,3000,4500,15000,10000,"SpinButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + oObj = aShape.getControl(); + log.println( "creating a new environment for OButtonModel object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component.SpinButton"); + PropertyValue prop = new PropertyValue(); + prop.Name = "HelpText"; + prop.Value = "new Help Text since XPropertyAccess"; + tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop); + tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText"); + + System.out.println("Implementation name: "+util.utils.getImplName(oObj)); + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_forms/OTimeControl.java b/qadevOOo/tests/java/mod/_forms/OTimeControl.java new file mode 100644 index 000000000..01c8f17b4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeControl.java @@ -0,0 +1,224 @@ +/* + * 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._forms; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +/** + * Test for object which is represented by default controller + * of the <code>com.sun.star.form.component.TimeField</code> + * component. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::awt::XView</code></li> + * <li> <code>com::sun::star::form::XBoundControl</code></li> + * <li> <code>com::sun::star::awt::XControl</code></li> + * <li> <code>com::sun::star::awt::XTextComponent</code></li> + * <li> <code>com::sun::star::awt::XLayoutConstrains</code></li> + * <li> <code>com::sun::star::awt::XTimeField</code></li> + * <li> <code>com::sun::star::awt::XTextListener</code></li> + * <li> <code>com::sun::star::awt::XWindow</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::awt::XTextLayoutConstrains</code></li> + * <li> <code>com::sun::star::lang::XEventListener</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.awt.XView + * @see com.sun.star.form.XBoundControl + * @see com.sun.star.awt.XControl + * @see com.sun.star.awt.XTextComponent + * @see com.sun.star.awt.XLayoutConstrains + * @see com.sun.star.awt.XTimeField + * @see com.sun.star.awt.XTextListener + * @see com.sun.star.awt.XWindow + * @see com.sun.star.lang.XComponent + * @see com.sun.star.awt.XTextLayoutConstrains + * @see com.sun.star.lang.XEventListener + * @see ifc.awt._XView + * @see ifc.form._XBoundControl + * @see ifc.awt._XControl + * @see ifc.awt._XTextComponent + * @see ifc.awt._XLayoutConstrains + * @see ifc.awt._XTimeField + * @see ifc.awt._XTextListener + * @see ifc.awt._XWindow + * @see ifc.lang._XComponent + * @see ifc.awt._XTextLayoutConstrains + * @see ifc.lang._XEventListener + */ +public class OTimeControl extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates a new text document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes the text document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Creates two components and inserts them to the form of + * text document. One component + * (<code>com.sun.star.form.component.TimeField</code>) is created + * for testing, another to be passed as relation. Using a controller + * of the text document the controller of the first component is + * obtained and returned in environment as a test object. <p> + * + * Object relations created : + * <ul> + * <li> <code>'GRAPHICS'</code> for + * {@link ifc.awt._XView} : a graphics component + * created using screen device of the window peer of + * the controller tested. </li> + * <li> <code>'CONTEXT'</code> for + * {@link ifc.awt._XControl} : the text document + * where the component is inserted. </li> + * <li> <code>'WINPEER'</code> for + * {@link ifc.awt._XControl} : Window peer of the + * controller tested. </li> + * <li> <code>'TOOLKIT'</code> for + * {@link ifc.awt._XControl} : toolkit of the component.</li> + * <li> <code>'MODEL'</code> for + * {@link ifc.awt._XControl} : the model of the controller.</li> + * <li> <code>'XWindow.AnotherWindow'</code> for + * {@link ifc.awt._XWindow} : the controller of another + * component. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "TimeField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //now get the OTimeControl + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for OTimeControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + FormTools.switchDesignOf(Param.getMSF(), xTextDoc); + + return tEnv; + } // finish method getTestEnvironment +} // finish class OTimeControl diff --git a/qadevOOo/tests/java/mod/_forms/OTimeModel.java b/qadevOOo/tests/java/mod/_forms/OTimeModel.java new file mode 100644 index 000000000..7ceb1510d --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/OTimeModel.java @@ -0,0 +1,213 @@ +/* + * 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._forms; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.form.XBoundComponent; +import com.sun.star.form.XLoadable; +import com.sun.star.sdbc.XResultSetUpdate; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import ifc.form._XUpdateBroadcaster.UpdateChecker; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + + + +/** +* Test for object which is represented by service +* <code>com.sun.star.form.component.TimeField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlTimeFieldModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::form::component::TimeField</code></li> +* <li> <code>com::sun::star::form::XReset</code></li> +* <li> <code>com::sun::star::form::XBoundComponent</code></li> +* <li> <code>com::sun::star::form::FormComponent</code></li> +* <li> <code>com::sun::star::beans::XFastPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* <li> <code>com::sun::star::form::XUpdateBroadcaster</code></li> +* <li> <code>com::sun::star::form::DataAwareControlModel</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::form::FormControlModel</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::lang::XEventListener</code></li> +* <li> <code>com::sun::star::beans::XPropertyAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyContainer</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::form::XLoadListener</code></li> +* <li> <code>com::sun::star::container::XChild</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TestDB </b> (directory) : directory with test database </li> +* <li><b> TestDB/TestDB.dbf </b> : table file. See +* {@link util.DBTools DBTools} class for more information.</li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.awt.UnoControlTimeFieldModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.form.component.TimeField +* @see com.sun.star.form.XReset +* @see com.sun.star.form.XBoundComponent +* @see com.sun.star.form.FormComponent +* @see com.sun.star.beans.XFastPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see com.sun.star.form.XUpdateBroadcaster +* @see com.sun.star.form.DataAwareControlModel +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.form +* @see com.sun.star.container.XNamed +* @see com.sun.star.lang.XComponent +* @see com.sun.star.lang.XEventListener +* @see com.sun.star.beans.XPropertyAccess +* @see com.sun.star.beans.XPropertyContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.form.XLoadListener +* @see com.sun.star.container.XChild +* @see ifc.awt._UnoControlTimeFieldModel +* @see ifc.io._XPersistObject +* @see ifc.form.component._TimeField +* @see ifc.form._XReset +* @see ifc.form._XBoundComponent +* @see ifc.form._FormComponent +* @see ifc.beans._XFastPropertySet +* @see ifc.beans._XMultiPropertySet +* @see ifc.form._XUpdateBroadcaster +* @see ifc.form._DataAwareControlModel +* @see ifc.beans._XPropertyState +* @see ifc.form._FormControlModel +* @see ifc.container._XNamed +* @see ifc.lang._XComponent +* @see ifc.lang._XEventListener +* @see ifc.beans._XPropertySet +* @see ifc.form._XLoadListener +* @see ifc.container._XChild +*/ +public class OTimeModel extends GenericModelTest { + /** + * Set some member variable of the super class <CODE>GenericModelTest</CODE>: + * <pre> + * super.m_ChangePropertyName = "Time"; + * super.m_kindOfControl="TimeField"; + * super.m_ObjectName = "stardiv.one.form.component.TimeField"; + * NamedValue DataField = new NamedValue(); + * DataField.Name = "DataField"; + * DataField.Value = DBTools.TST_INT_F; + * super.m_propertiesToSet.add(DataField); + * + * super.m_LCShape_Type = "FixedText"; + * </pre> + * Then <CODE>super.initialize()</CODE> was called. + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + + super.initialize(tParam, log); + + super.m_ChangePropertyName = "Time"; + + super.m_kindOfControl="TimeField"; + + super.m_ObjectName = "stardiv.one.form.component.TimeField"; + + NamedValue DataField = new NamedValue(); + DataField.Name = "DataField"; + DataField.Value = DBTools.TST_INT_F; + super.m_propertiesToSet.add(DataField); + + super.m_LCShape_Type = "FixedText"; + + } + + /** + * calls <CODE>createTestEnvironment()</CODE> from its super class + * This test uses not the generic implementation of <CODE>checker()</CODE> of its + * super class. This tests uses its own implementation of <CODE>checker()</CODE> + * to test <CODE>com::sun::star::form::XUpdateBroadcaster</CODE> + * @param Param the test parameter + * @param log the log writer + * @return lib.TestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + TestEnvironment tEnv = super.createTestEnvironment(Param, log); + + tEnv.addObjRelation("XUpdateBroadcaster.Checker", + new Checker(m_XFormLoader, m_XPS, m_XCtrl)); + return tEnv; + } + + private static class Checker implements UpdateChecker { + private XLoadable formLoaderF = null; + private XPropertySet ps = null; + private XInterface ctrl = null; + + public Checker(XLoadable xl, XPropertySet ps, XInterface ctrl) { + formLoaderF = xl; + this.ps = ps; + this.ctrl = ctrl; + } + + private int lastTime = 0; + + public void update() throws com.sun.star.uno.Exception { + if (!formLoaderF.isLoaded()) { + formLoaderF.load(); + } + + Integer time = (Integer) ps.getPropertyValue("Time"); + + if (time != null) { + lastTime = time.intValue() + 150000; + } + + ps.setPropertyValue("Time", Integer.valueOf(lastTime)); + } + + public void commit() throws com.sun.star.sdbc.SQLException { + XBoundComponent bound = UnoRuntime.queryInterface( + XBoundComponent.class, ctrl); + XResultSetUpdate update = UnoRuntime.queryInterface( + XResultSetUpdate.class, + formLoaderF); + + bound.commit(); + update.updateRow(); + } + + public boolean wasCommited() throws com.sun.star.uno.Exception { + formLoaderF.reload(); + + Integer getT = (Integer) ps.getPropertyValue("Time"); + + return (getT != null) && + (Math.abs(getT.intValue() - lastTime) < 100); + } + } +} // finish class OTimeModel diff --git a/qadevOOo/tests/java/mod/_forms/package.html b/qadevOOo/tests/java/mod/_forms/package.html new file mode 100644 index 000000000..895d60e46 --- /dev/null +++ b/qadevOOo/tests/java/mod/_forms/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 'forms'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_fps/FilePicker.java b/qadevOOo/tests/java/mod/_fps/FilePicker.java new file mode 100644 index 000000000..885bef0ef --- /dev/null +++ b/qadevOOo/tests/java/mod/_fps/FilePicker.java @@ -0,0 +1,119 @@ +/* + * 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._fps; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ui.FilePicker</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ui::XFilePicker</code></li> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::lang::XTypeProvider</code></li> +* <li> <code>com::sun::star::ui::XExecutableDialog</code></li> +* <li> <code>com::sun::star::ui::XFilePickerControlAccess</code></li> +* <li> <code>com::sun::star::ui::XFilterManager</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::ui::XFilePickerNotifier</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ui.XFilePicker +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.lang.XTypeProvider +* @see com.sun.star.ui.XExecutableDialog +* @see com.sun.star.ui.XFilePickerControlAccess +* @see com.sun.star.ui.XFilterManager +* @see com.sun.star.lang.XComponent +* @see com.sun.star.ui.XFilePickerNotifier +* @see com.sun.star.ui.XFilePicker +* @see ifc.ui.dialogs._XFilePicker +* @see ifc.lang._XInitialization +* @see ifc.lang._XServiceInfo +* @see ifc.lang._XTypeProvider +* @see ifc.ui.dialogs._XExecutableDialog +* @see ifc.ui.dialogs._XFilePickerControlAccess +* @see ifc.ui.dialogs._XFilterManager +* @see ifc.lang._XComponent +* @see ifc.ui.dialogs._XFilePickerNotifier +*/ +public class FilePicker extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ui.FilePicker</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XInitialization.args'</code> for + * {@link ifc.lang._XInitialization} : argument + * for creating dialog from template. </li> + * <li> <code>'XFilePickerControlAccess.ControlID'</code> for + * {@link ifc.ui.dialogs._XFilePickerControlAccess} : here + * it is identifier of check box.</li> + * <li> <code>'XFilePickerControlAccess.ControlValue'</code> for + * {@link ifc.ui.dialogs._XFilePickerControlAccess} : + * The value for control to set (since the initial value + * of the control is empty) .</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + XMultiServiceFactory xMSF = Param.getMSF(); + + Object[] iniArgs = new Object[] { Short.valueOf + (com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_READONLY_VERSION)}; + short ctrlId = + com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_READONLY; + oInterface = xMSF.createInstance + ( "com.sun.star.ui.dialogs.FilePicker" ); + + oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XInitialization + tEnv.addObjRelation("XInitialization.args", iniArgs) ; + + // adding relation for XFilePickerControlAccess + tEnv.addObjRelation("XFilePickerControlAccess.ControlID", + Short.valueOf(ctrlId)) ; + tEnv.addObjRelation("XFilePickerControlAccess.ControlValue", + Boolean.FALSE) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_ftransl/DataFormatTranslator.java b/qadevOOo/tests/java/mod/_ftransl/DataFormatTranslator.java new file mode 100644 index 000000000..75f81b222 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ftransl/DataFormatTranslator.java @@ -0,0 +1,83 @@ +/* + * 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._ftransl; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.datatransfer.DataFormatTranslator</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::datatransfer::XDataFormatTranslator</code></li> + * <li> <code>com::sun::star::lang::XTypeProvider</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.datatransfer.XDataFormatTranslator + * @see com.sun.star.lang.XTypeProvider + * @see ifc.lang._XServiceInfo + * @see ifc.datatransfer._XDataFormatTranslator + * @see ifc.lang._XTypeProvider + */ +public class DataFormatTranslator extends TestCase { + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.datatransfer.DataFormatTranslator</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.datatransfer.DataFormatTranslator" ); + } + catch( com.sun.star.uno.Exception e ) { + log.println("DataFormatTranslator Service not available" ); + } + oObj = (XInterface) oInterface; + + log.println( "creating a new environment for DataFormatTranslator object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class DataFormatTranslator + diff --git a/qadevOOo/tests/java/mod/_fwk/ControlMenuController.java b/qadevOOo/tests/java/mod/_fwk/ControlMenuController.java new file mode 100644 index 000000000..9863c4cc3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ControlMenuController.java @@ -0,0 +1,47 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + + +/** + */ +public class ControlMenuController extends TestCase { + XInterface oObj = null; + + /** + * Create test environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ControlMenuController"); + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/Desktop.java b/qadevOOo/tests/java/mod/_fwk/Desktop.java new file mode 100644 index 000000000..89a2ab451 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/Desktop.java @@ -0,0 +1,112 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.frame.XDesktop; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.frame.Desktop</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li><code>com::sun::star::beans::XPropertySet</code></li> +* <li><code>com::sun::star::frame::XComponentLoader</code></li> +* <li><code>com::sun::star::frame::XDesktop</code></li> +* <li><code>com::sun::star::frame::XDispatchProvider</code></li> +* <li><code>com::sun::star::frame::XFrame</code></li> +* <li><code>com::sun::star::frame::XFramesSupplier</code></li> +* <li><code>com::sun::star::frame::XTasksSupplier</code></li> +* <li><code>com::sun::star::lang::XComponent</code></li> +* <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li> +* </ul><p> +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.frame.XComponentLoader +* @see com.sun.star.frame.XDesktop +* @see com.sun.star.frame.XDispatchProvider +* @see com.sun.star.frame.XFrame +* @see com.sun.star.frame.XFramesSupplier +* @see com.sun.star.frame.XTasksSupplier +* @see com.sun.star.lang.XComponent +* @see com.sun.star.task.XStatusIndicatorFactory +* @see ifc.beans._XPropertySet +* @see ifc.frame._XComponentLoader +* @see ifc.frame._XDesktop +* @see ifc.frame._XDispatchProvider +* @see ifc.frame._XFrame +* @see ifc.frame._XFramesSupplier +* @see ifc.frame._XTasksSupplier +* @see ifc.lang._XComponent +* @see ifc.task._XStatusIndicatorFactory +*/ +public class Desktop extends TestCase { + + XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + try { + xTextDoc.dispose(); + } catch (com.sun.star.lang.DisposedException de) {} + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.frame.Desktop</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.Desktop"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XDispatchProvider.URL", ".uno:Open"); + + tEnv.addObjRelation("Desktop",UnoRuntime.queryInterface(XDesktop.class,oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwk/DispatchRecorder.java b/qadevOOo/tests/java/mod/_fwk/DispatchRecorder.java new file mode 100644 index 000000000..25c31fdff --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/DispatchRecorder.java @@ -0,0 +1,156 @@ +/* + * 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._fwk; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XModel; +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.frame.DispatchStatement; +import com.sun.star.frame.XDispatchRecorder; +import com.sun.star.frame.XDispatchRecorderSupplier; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.util.URL; +import util.utils; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::container::XElementAccess</code></li> +* <li><code>com::sun::star::container::XIndexAccess</code></li> +* <li><code>com::sun::star::container::XIndexReplace</code></li> +* <li><code>com::sun::star::frame::XDispatchRecorder</code></li> +* </ul><p> +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XIndexReplace +* @see com.sun.star.frame.XDispatchRecorder +* @see ifc.container._XElementAccess +* @see ifc.container._XIndexAccess +* @see ifc.container._XIndexReplace +* @see ifc.frame._XDispatchRecorder +*/ +public class DispatchRecorder extends TestCase { + XComponent oDoc = null; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.frame.Desktop</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = null; + XFrame xFrame = null; + XDispatchRecorder xDR = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + oDoc = SOF.createTextDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + + XModel model = UnoRuntime.queryInterface(XModel.class, oDoc); + xFrame = model.getCurrentController().getFrame(); + + XPropertySet xFramePS = UnoRuntime.queryInterface + (XPropertySet.class, xFrame); + XDispatchRecorderSupplier xDRS = null; + xDRS = (XDispatchRecorderSupplier) AnyConverter.toObject( + new Type(XDispatchRecorderSupplier.class), + xFramePS.getPropertyValue("DispatchRecorderSupplier")); + if (xDRS == null) { + + Object oDRS = Param.getMSF().createInstance( + "com.sun.star.comp.framework.DispatchRecorderSupplier"); + xFramePS.setPropertyValue("DispatchRecorderSupplier", oDRS); + xDRS = UnoRuntime.queryInterface(XDispatchRecorderSupplier.class,oDRS); + } + + xDR = xDRS.getDispatchRecorder(); + if (xDR != null) { + oObj = xDR; + } else { + oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.DispatchRecorder"); + xDR = UnoRuntime.queryInterface + (XDispatchRecorder.class, oObj); + xDRS.setDispatchRecorder(xDR); + } + + + // fill recorder with content. It's needed for XIndexReplace + URL dispURL = utils.parseURL(Param.getMSF(), ".uno:InsertDateField"); + PropertyValue prop = new PropertyValue(); + prop.Name = "Text"; + prop.Value = "XDispatchRecorder.recordDispatch()"; + PropertyValue[] dispArgs = new PropertyValue[] {prop}; + xDR.recordDispatch(dispURL, dispArgs); + + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // INSTANCEn : _XIndexReplace + log.println("adding INSTANCEn as obj relation to environment"); + + int THRCNT = 1; + if (Param.get("THRCNT")!= null) { + THRCNT = Integer.parseInt((String) Param.get("THRCNT")); + } + + URL instanceURL = null; + DispatchStatement instance = new DispatchStatement(); + PropertyValue dispProp = new PropertyValue(); + + for (int n = 1; n < (THRCNT + 1); n++) { + log.println("adding INSTANCE" + n + + " as obj relation to environment"); + instanceURL = utils.parseURL(Param.getMSF(), ".uno:InsertText"); + dispProp.Name = "Text"; + dispProp.Value = "Instance " + n; + dispArgs = new PropertyValue[] {dispProp}; + instance.aCommand = instanceURL.Complete; + instance.aArgs = dispArgs; + instance.aTarget = "_top"; + instance.nFlags = com.sun.star.frame.FrameSearchFlag.ALL; + + tEnv.addObjRelation("INSTANCE" + n, instance); + } + + tEnv.addObjRelation("XDispatchRecorder.Frame", xFrame); + log.println("Object created: TRUE"); + return tEnv; + } // finish method getTestEnvironment + + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(oDoc); + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/DispatchRecorderSupplier.java b/qadevOOo/tests/java/mod/_fwk/DispatchRecorderSupplier.java new file mode 100644 index 000000000..0d2b2d0b4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/DispatchRecorderSupplier.java @@ -0,0 +1,55 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::frame::XDispatchRecorderSupplier</code></li> +* </ul><p> +* @see com.sun.star.frame.XDispatchRecorderSupplier +* @see ifc.frame._XDispatchRecorderSupplier +*/ +public class DispatchRecorderSupplier extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates instance of + * <code>com.sun.star.comp.framework.DispatchRecorderSupplier</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.DispatchRecorderSupplier"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_fwk/FontMenuController.java b/qadevOOo/tests/java/mod/_fwk/FontMenuController.java new file mode 100644 index 000000000..3f8d1a687 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/FontMenuController.java @@ -0,0 +1,44 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** + */ +public class FontMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.FontMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/FontSizeMenuController.java b/qadevOOo/tests/java/mod/_fwk/FontSizeMenuController.java new file mode 100644 index 000000000..b662b5f07 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/FontSizeMenuController.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class FontSizeMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.FontSizeMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/FooterMenuController.java b/qadevOOo/tests/java/mod/_fwk/FooterMenuController.java new file mode 100644 index 000000000..99e9207bd --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/FooterMenuController.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class FooterMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.FooterMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/FormatMenuController.java b/qadevOOo/tests/java/mod/_fwk/FormatMenuController.java new file mode 100644 index 000000000..be3cb17d4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/FormatMenuController.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class FormatMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.FormatMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/Frame.java b/qadevOOo/tests/java/mod/_fwk/Frame.java new file mode 100644 index 000000000..cb18c9659 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/Frame.java @@ -0,0 +1,104 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.frame.XFrame; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::frame::XDispatchProvider</code></li> +* <li><code>com::sun::star::frame::XFrame</code></li> +* <li><code>com::sun::star::frame::XFramesSupplier</code></li> +* <li><code>com::sun::star::task::XStatusIndicatorFactory</code></li> +* <li><code>com::sun::star::lang::XComponent</code></li> +* </ul><p> +* @see com.sun.star.frame.XDispatchProvider +* @see com.sun.star.frame.XFrame +* @see com.sun.star.frame.XFramesSupplier +* @see com.sun.star.task.XStatusIndicatorFactory +* @see com.sun.star.lang.XComponent +* @see ifc.frame._XDispatchProvider +* @see ifc.frame._XFrame +* @see ifc.frame._XFramesSupplier +* @see ifc.task._XStatusIndicatorFactory +* @see ifc.lang._XComponent +*/ +public class Frame extends TestCase { + + XTextDocument xTextDoc; + XFrame frame = null; + + + /** + * Creates a text document and obtains a frame of current controller. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = null; + + log.println( "creating a test environment" ); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + frame = xTextDoc.getCurrentController().getFrame(); + oObj = UnoRuntime.queryInterface(XInterface.class, frame); + + log.println(util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XDispatchProvider.URL", + ".uno:SwitchControlDesignMode"); + + return tEnv; + } // finish method getTestEnvironment + + + /** + * Disposes the document created and finally disposes + * the frame containing the document (for case when the frame + * contains no model after some interface manipulations). + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + try { + XCloseable xTextClose = UnoRuntime.queryInterface(XCloseable.class, xTextDoc); + xTextClose.close(true); + } catch(Exception e){} + + } +} diff --git a/qadevOOo/tests/java/mod/_fwk/HeaderMenuController.java b/qadevOOo/tests/java/mod/_fwk/HeaderMenuController.java new file mode 100644 index 000000000..16342de71 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/HeaderMenuController.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class HeaderMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.HeaderMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/JobExecutor.java b/qadevOOo/tests/java/mod/_fwk/JobExecutor.java new file mode 100644 index 000000000..61dee42e9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/JobExecutor.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._fwk; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XHierarchicalNameAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNameReplace; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XTypeProvider; +import com.sun.star.task.XJob; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XChangesBatch; +import com.sun.star.uno.AnyConverter; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code>com::sun::star::task::XJobExecutor</code></li> + * </ul><p> + * The following files are needed for testcase creation : + * <ul> + * <li> <code>qadevlibs/JobExecutor.jar</code> : + * this is java component <code>test.Job</code> which + * should be registered before or during this testcase + * creation. This component must implement + * <code>com.sun.star.task.XJob</code> interface and count + * <code>execute</code> method calls. It also should + * implement <code>container.XNamed</code> interface and + * <code>getName</code> method must return string with number + * of calls.</li> + * <ul> <p> + * + * Also <b>important prerequicity</b>: if Job and Event is not yet + * added to configuration or <code>test.Job</code> component is + * not yet registered, the SOffice <b>must be destroyed</b> during + * testcase initialization. <p> + * + * @see com.sun.star.task.XJobExecutor + * @see ifc.task._XJobExecutor + */ +public class JobExecutor extends TestCase { + + static Job job = new Job(); + XNamed xNamed = null; + Object oRootCfg = null; + + /** + * For testcase initializing : + * <ol> + * <li> Implementation <code>test.Job</code> must be registered in + * SOffice registry. </li> + * <li> Configuration in package <code>org.OpenOffice.Office.Jobs</code> + * must be updated. <code>TestJob</code> must be registered for + * service <code>test.Job</code> and event for this job named + * <code>TextEvent</code> must be registered. </li> + * </ol>. <p> + * + * First these two conditions are checked. If job and event are not + * registered they are inserted into configuration and committed. + * After what SOffice must be destroyed for proper initialization + * of <code>JobExecutor</code> after startup. <p> + * + * Then if the implementation was not registered before it is + * registered in soffice <code>applicat.rbd</code> file (registering + * the component in currently running Java environment has no effect + * for <code>JobExecutor</code> in some reasons). <p> + * + * Note: SOffice is started again while the next + * <code>(XMultiServiceFactory)SOLink.getMSF()</code> call. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + boolean configured = false; + + try { + Param.getMSF().createInstance("test.Job"); + } catch(com.sun.star.uno.Exception e) { + log.println("Service test.Job is not yet registered."); + String message = "You have to register 'test.Job' before office is started.\n"; + message += "Please run '$OFFICEPATH/program/pkgchk $DOCPTH/qadevlibs/JobExecutor.jar'"; + throw new StatusException(message, e); + } + + + + XNameAccess jobs = null; + XNameAccess events = null; + Object obj = Param.getMSF().createInstance + ("com.sun.star.configuration.ConfigurationProvider"); + XMultiServiceFactory xConfigMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, obj); + PropertyValue[] args = new PropertyValue[1]; + args[0] = new PropertyValue(); + args[0].Name = "nodepath"; + args[0].Value = "org.openoffice.Office.Jobs"; + oRootCfg = xConfigMSF.createInstanceWithArguments( + "com.sun.star.configuration.ConfigurationUpdateAccess", args); + XHierarchicalNameAccess xHNA = UnoRuntime.queryInterface(XHierarchicalNameAccess.class, oRootCfg); + obj = xHNA.getByHierarchicalName("Jobs"); + jobs = UnoRuntime.queryInterface + (XNameAccess.class, obj); + obj = xHNA.getByHierarchicalName("Events"); + events = UnoRuntime.queryInterface + (XNameAccess.class, obj); + + configured = jobs.hasByName("TestJob") && events.hasByName("TestEvent"); + + log.println("Test job and event is " + + (configured ? "already" : "not yet") + " configured."); + + if (!configured) { + log.println("Adding configuration to Jobs ..."); + XSingleServiceFactory jobsFac = UnoRuntime.queryInterface(XSingleServiceFactory.class, jobs); + Object oNewJob = jobsFac.createInstance(); + XNameReplace xNewJobNR = UnoRuntime.queryInterface(XNameReplace.class, oNewJob); + xNewJobNR.replaceByName("Service", "test.Job"); + XNameContainer xJobsNC = UnoRuntime.queryInterface(XNameContainer.class, jobs); + xJobsNC.insertByName("TestJob", oNewJob); + + log.println("Adding configuration to Events ..."); + XSingleServiceFactory eventsFac = UnoRuntime.queryInterface(XSingleServiceFactory.class, events); + Object oNewEvent = eventsFac.createInstance(); + + XNameAccess xNewEventNA = UnoRuntime.queryInterface(XNameAccess.class, oNewEvent); + Object oJobList = xNewEventNA.getByName("JobList"); + XSingleServiceFactory jobListFac = (XSingleServiceFactory) + AnyConverter.toObject(new Type(XSingleServiceFactory.class), + oJobList); + XNameContainer jobListNC = (XNameContainer) + AnyConverter.toObject(new Type(XNameContainer.class), + oJobList); + log.println("\tAdding TimeStamps to Events ..."); + Object oNewJobTimeStamps = jobListFac.createInstance(); + + jobListNC.insertByName("TestJob", oNewJobTimeStamps); + + XNameContainer xEventsNC = UnoRuntime.queryInterface(XNameContainer.class, events); + xEventsNC.insertByName("TestEvent", oNewEvent); + + XChangesBatch xCB = UnoRuntime.queryInterface(XChangesBatch.class, oRootCfg); + xCB.commitChanges(); + + util.utils.waitForEventIdle(Param.getMSF()); + } + + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * + * Service <code>com.sun.star.comp.framework.JobExecutor</code> + * is created. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.JobExecutor"); + Object job = Param.getMSF().createInstance("test.Job"); + + xNamed = UnoRuntime.queryInterface(XNamed.class, job); + log.println("Count = " + xNamed.getName()); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("CallCounter", xNamed); + + return tEnv; + } // finish method getTestEnvironment + + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + } +} + +/** + * Currently not used. + */ +class Job implements + XServiceInfo, XSingleServiceFactory { + + private static class Impl implements XServiceInfo, XTypeProvider, XJob, XNamed { + int callCount = 0; + + public byte[] getImplementationId() { + return new byte[0]; + } + + public Type[] getTypes() { + Class<?> interfaces[] = getClass().getInterfaces(); + Type types[] = new Type[interfaces.length]; + for(int i = 0; i < interfaces.length; ++ i) + types[i] = new Type(interfaces[i]); + return types; + } + + public Object execute(NamedValue[] param) { + callCount++; + + return null; + } + + public String getName() { + return String.valueOf(callCount); + } + + public void setName(String n) {} + + public boolean supportsService(String name) { + return __serviceName.equals(name); + } + + public String[] getSupportedServiceNames() { + return new String[] {__serviceName}; + } + + public String getImplementationName() { + return getClass().getName(); + } + } + + private static final String __serviceName = "test.Job"; + private static Impl impl = new Impl(); + + public Object createInstanceWithArguments(Object[] args) { + return impl; + } + + public Object createInstance() { + return createInstanceWithArguments(null); + } + + public boolean supportsService(String name) { + return __serviceName.equals(name); + } + + public String[] getSupportedServiceNames() { + return new String[] {__serviceName}; + } + + public String getImplementationName() { + return getClass().getName(); + } +} diff --git a/qadevOOo/tests/java/mod/_fwk/JobHandler.java b/qadevOOo/tests/java/mod/_fwk/JobHandler.java new file mode 100644 index 000000000..ed86cfb73 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/JobHandler.java @@ -0,0 +1,73 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::frame::XDispatchProvider</code></li> +* <li><code>com::sun::star::lang::XInitialization</code></li> +* </ul><p> +* @see com.sun.star.frame.XDispatchProvider +* @see com.sun.star.lang.XInitialization +* @see ifc.frame._XDispatchProvider +* @see ifc.lang._XInitialization +*/ +public class JobHandler extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + boolean serviceRegistered = false; + + try { + Object obj = Param.getMSF().createInstance("test.Job"); + serviceRegistered = obj != null; + } catch(com.sun.star.uno.Exception e) {} + + log.println("Service test.Job is " + + (serviceRegistered ? "already" : "not yet") + " registered."); + if (! serviceRegistered){ + String message = "You have to register 'test.Job' before office is started.\n"; + message += "Please run '$OFFICEPATH/program/pkgchk $DOCPTH/qadevlibs/JobExecutor.jar'"; + throw new StatusException(message, new Exception()); + } + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.jobs.JobDispatch"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XDispatchProvider.URL", "vnd.sun.star.job:alias=TestJob"); + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwk/LayoutManager.java b/qadevOOo/tests/java/mod/_fwk/LayoutManager.java new file mode 100644 index 000000000..9193fca43 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/LayoutManager.java @@ -0,0 +1,105 @@ +/* + * 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._fwk; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.util.XCloseable; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; + +/** + */ +public class LayoutManager extends TestCase { + XInterface xManager = null; + XTextDocument xTextDoc; + + /** + * Cleanup: close the created document + * @param tParam The test parameters. + * @param log The log writer. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Create test environment: + * <ul> + * <li>Create test doc</li> + * <li>Get the frame</li> + * <li>Get the LayoutManager from the frame</li> + * </ul> + * @param tParam The test parameters. + * @param log The log writer. + * @return The test environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XMultiServiceFactory xMSF = tParam.getMSF(); + + log.println("Creating instance..."); + + xTextDoc = WriterTools.createTextDoc(xMSF); + + XText xText = xTextDoc.getText(); + XTextCursor xTextCursor = xText.createTextCursor(); + + for (int i = 0; i < 11; i++) { + xText.insertString(xTextCursor, "A sample text and why not? ", false); + } + + XFrame xFrame = xTextDoc.getCurrentController().getFrame(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xFrame); + Object any = xProp.getPropertyValue("LayoutManager"); + xManager = UnoRuntime.queryInterface(XInterface.class, any); + + // just to make sure, it's the right one. + log.println("TestObject: " + util.utils.getImplName(xManager)); + tEnv = new TestEnvironment(xManager); + + tEnv.addObjRelation("XLayoutManager.TextDoc", xTextDoc); + tEnv.addObjRelation("XLayoutManager.Frame",xFrame); + + return tEnv; + } +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/MacrosMenuController.java b/qadevOOo/tests/java/mod/_fwk/MacrosMenuController.java new file mode 100644 index 000000000..e68494417 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/MacrosMenuController.java @@ -0,0 +1,41 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class MacrosMenuController extends TestCase{ + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.MacrosMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/MailToDispatcher.java b/qadevOOo/tests/java/mod/_fwk/MailToDispatcher.java new file mode 100644 index 000000000..ac04229aa --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/MailToDispatcher.java @@ -0,0 +1,61 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::lang::XInitialization</code></li> +* <li><code>com::sun::star::frame::XDispatchProvider</code></li> +* </ul><p> +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.frame.XDispatchProvider +* @see ifc.lang._XInitialization +* @see ifc.frame._XDispatchProvider +*/ +public class MailToDispatcher extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.framework.MailToDispatcher</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.MailToDispatcher"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XDispatchProvider.URL", + "mailto:soffice@sparc.spb.su"); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwk/MenuBarFactory.java b/qadevOOo/tests/java/mod/_fwk/MenuBarFactory.java new file mode 100644 index 000000000..ff75db88d --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/MenuBarFactory.java @@ -0,0 +1,41 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class MenuBarFactory extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.MenuBarFactory"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/ModuleManager.java b/qadevOOo/tests/java/mod/_fwk/ModuleManager.java new file mode 100644 index 000000000..a700bffaf --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ModuleManager.java @@ -0,0 +1,227 @@ +/* + * 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._fwk; + +import com.sun.star.beans.PropertyValue; +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 lib.*; +import util.DesktopTools; +import util.SOfficeFactory; + + +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.text.XTextDocument; + +/** Test for object that implements the following interfaces : + * <ul> + * <li><code>com::sun::star::frame::XModuleManager</code></li> + * <li><code>com::sun::star::container::XNameAccess</code></li> + * <li><code>com::sun::star::container::XElementAccess</code></li> + * </ul><p> + * @see com.sun.star.frame.XModuleManager + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.frame._XModuleManager + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + */ +public class ModuleManager extends TestCase { + + XTextDocument xTextDoc = null; + XComponent xWebDoc = null; + XComponent xGlobalDoc = null; + XSpreadsheetDocument xSheetDoc = null; + XComponent xDrawDoc = null; + XComponent xImpressDoc = null; + XComponent xMathDoc = null; + + /** Creating a TestEnvironment for the interfaces to be tested. + * @param Param test parameters + * @param log simple logger + * @throws StatusException was thrown on error + * @return the test environment + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.ModuleManager"); + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + // get text document interfaces + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + XModel xTextMode1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + XController xTextController = xTextMode1.getCurrentController(); + XFrame xTextFrame = xTextController.getFrame(); + + + // get webdoc interfaces + log.println("creating a web document"); + xWebDoc = SOF.loadDocument("private:factory/swriter/web"); + XModel xWebMode1 = UnoRuntime.queryInterface(XModel.class, + xWebDoc); + XController xWebController = xWebMode1.getCurrentController(); + XFrame xWebFrame = xWebController.getFrame(); + + // get global document interfaces + log.println("creating a global document"); + xGlobalDoc = SOF.loadDocument("private:factory/swriter/GlobalDocument"); + XModel xGlobalMode1 = UnoRuntime.queryInterface(XModel.class, + xGlobalDoc); + XController xGlobalController = xGlobalMode1.getCurrentController(); + XFrame xGlobalFrame = xGlobalController.getFrame(); + + // get clac interfaces + log.println("creating a spreadsheetdocument"); + xSheetDoc = SOF.createCalcDoc(null); + XModel xSheetMode1 = UnoRuntime.queryInterface(XModel.class, + xSheetDoc); + + XController xSheetController = xSheetMode1.getCurrentController(); + XFrame xSheetFrame = xSheetController.getFrame(); + // get draw interfaces + log.println("creating a draw document"); + xDrawDoc = SOF.createDrawDoc(null); + XModel xDrawMode1 = UnoRuntime.queryInterface(XModel.class, + xDrawDoc); + XController xDrawController = xDrawMode1.getCurrentController(); + XFrame xDrawFrame = xDrawController.getFrame(); + + // get impress interfaces + log.println("creating an impress document"); + xImpressDoc = SOF.createImpressDoc(null); + XModel xImpressMode1 = UnoRuntime.queryInterface(XModel.class, + xImpressDoc); + XController xImpressController = xImpressMode1.getCurrentController(); + XFrame xImpressFrame = xImpressController.getFrame(); + + // get math interfaces + log.println("creating a math document"); + xMathDoc = SOF.createMathDoc(null); + XModel xMathMode1 = UnoRuntime.queryInterface(XModel.class, + xMathDoc); + XController xMathController = xMathMode1.getCurrentController(); + XFrame xMathFrame = xMathController.getFrame(); + + PropertyValue[] xFrameSeq = new PropertyValue[7]; + xFrameSeq[0] = new PropertyValue(); + xFrameSeq[0].Name = "com.sun.star.text.TextDocument"; + xFrameSeq[0].Value = xTextFrame; + xFrameSeq[1] = new PropertyValue(); + xFrameSeq[1].Name = "com.sun.star.text.WebDocument"; + xFrameSeq[1].Value = xWebFrame; + xFrameSeq[2] = new PropertyValue(); + xFrameSeq[2].Name = "com.sun.star.text.GlobalDocument"; + xFrameSeq[2].Value = xGlobalFrame; + xFrameSeq[3] = new PropertyValue(); + xFrameSeq[3].Name = "com.sun.star.sheet.SpreadsheetDocument"; + xFrameSeq[3].Value = xSheetFrame; + xFrameSeq[4] = new PropertyValue(); + xFrameSeq[4].Name = "com.sun.star.drawing.DrawingDocument"; + xFrameSeq[4].Value = xDrawFrame; + xFrameSeq[5] = new PropertyValue(); + xFrameSeq[5].Name = "com.sun.star.formula.FormulaProperties"; + xFrameSeq[5].Value = xMathFrame; + xFrameSeq[6] = new PropertyValue(); + xFrameSeq[6].Name = "com.sun.star.presentation.PresentationDocument"; + xFrameSeq[6].Value = xImpressFrame; + + PropertyValue[] xControllerSeq = new PropertyValue[7]; + xControllerSeq[0] = new PropertyValue(); + xControllerSeq[0].Name = "com.sun.star.text.TextDocument"; + xControllerSeq[0].Value = xTextController; + xControllerSeq[1] = new PropertyValue(); + xControllerSeq[1].Name = "com.sun.star.text.WebDocument"; + xControllerSeq[1].Value = xWebController; + xControllerSeq[2] = new PropertyValue(); + xControllerSeq[2].Name = "com.sun.star.text.GlobalDocument"; + xControllerSeq[2].Value = xGlobalController; + xControllerSeq[3] = new PropertyValue(); + xControllerSeq[3].Name = "com.sun.star.sheet.SpreadsheetDocument"; + xControllerSeq[3].Value = xSheetController; + xControllerSeq[4] = new PropertyValue(); + xControllerSeq[4].Name = "com.sun.star.drawing.DrawingDocument"; + xControllerSeq[4].Value = xDrawController; + xControllerSeq[5] = new PropertyValue(); + xControllerSeq[5].Name = "com.sun.star.formula.FormulaProperties"; + xControllerSeq[5].Value = xMathController; + xControllerSeq[6] = new PropertyValue(); + xControllerSeq[6].Name = "com.sun.star.presentation.PresentationDocument"; + xControllerSeq[6].Value = xImpressController; + + PropertyValue[] xModelSeq = new PropertyValue[7]; + xModelSeq[0] = new PropertyValue(); + xModelSeq[0].Name = "com.sun.star.text.TextDocument"; + xModelSeq[0].Value = xTextMode1; + xModelSeq[1] = new PropertyValue(); + xModelSeq[1].Name = "com.sun.star.text.WebDocument"; + xModelSeq[1].Value = xWebMode1; + xModelSeq[2] = new PropertyValue(); + xModelSeq[2].Name = "com.sun.star.text.GlobalDocument"; + xModelSeq[2].Value = xGlobalMode1; + xModelSeq[3] = new PropertyValue(); + xModelSeq[3].Name = "com.sun.star.sheet.SpreadsheetDocument"; + xModelSeq[3].Value = xSheetMode1; + xModelSeq[4] = new PropertyValue(); + xModelSeq[4].Name = "com.sun.star.drawing.DrawingDocument"; + xModelSeq[4].Value = xDrawMode1; + xModelSeq[5] = new PropertyValue(); + xModelSeq[5].Name = "com.sun.star.presentation.PresentationDocument"; + xModelSeq[5].Value = xImpressMode1; + xModelSeq[6] = new PropertyValue(); + xModelSeq[6].Name = "com.sun.star.formula.FormulaProperties"; + xModelSeq[6].Value = xMathMode1; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + tEnv.addObjRelation("XModuleManager.XFrame", xFrameSeq); + tEnv.addObjRelation("XModuleManager.XController", xControllerSeq); + tEnv.addObjRelation("XModuleManager.XModel", xModelSeq); + return tEnv; + } // finish method getTestEnvironment + + /** Disposes text document. + * @param tParam test parameters + * @param log simple logger + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " closing all documents " ); + DesktopTools.closeDoc(xTextDoc); + DesktopTools.closeDoc(xWebDoc); + DesktopTools.closeDoc(xGlobalDoc); + DesktopTools.closeDoc(xSheetDoc); + DesktopTools.closeDoc(xDrawDoc); + DesktopTools.closeDoc(xImpressDoc); + DesktopTools.closeDoc(xMathDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManager.java b/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManager.java new file mode 100644 index 000000000..c4a826b49 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManager.java @@ -0,0 +1,188 @@ +/* + * 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._fwk; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexContainer; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.ui.XModuleUIConfigurationManagerSupplier; +import ifc.ui._XUIConfiguration; +import java.io.PrintWriter; +import com.sun.star.lang.EventObject; +import com.sun.star.text.XTextDocument; +import com.sun.star.util.XCloseable; +import com.sun.star.ui.ConfigurationEvent; +import com.sun.star.ui.XUIConfigurationManager; +import ifc.ui._XUIConfigurationManager; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; +import util.utils; + +/** + */ +public class ModuleUIConfigurationManager extends TestCase { + XInterface oObj = null; + XMultiServiceFactory xMSF = null; + XTextDocument xTextDoc = null; + + /** + * Cleanup: close the created document + * @param tParam The test parameters. + * @param log The log writer. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + if (xTextDoc != null) { + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + log.println(" disposing storage"); + } + + /** + * Create environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + + xMSF = tParam.getMSF(); + + log.println("Creating instance..."); + xTextDoc = WriterTools.createTextDoc(xMSF); + + Object o = xMSF.createInstance("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"); + XModuleUIConfigurationManagerSupplier xMUICMS = UnoRuntime.queryInterface(XModuleUIConfigurationManagerSupplier.class, o); + + util.dbg.printInterfaces(xMUICMS); + oObj = xMUICMS.getUIConfigurationManager("com.sun.star.text.TextDocument"); + + log.println("TestObject: " + utils.getImplName(oObj)); + tEnv = new TestEnvironment(oObj); + + XNameAccess xMM = UnoRuntime.queryInterface(XNameAccess.class, xMSF.createInstance("com.sun.star.comp.framework.ModuleManager")); + xMM.getElementNames(); + + // the short cut manager service name + // 2do: correct the service name when it's no longer in + tEnv.addObjRelation("XConfigurationManager.ShortCutManager", + "com.sun.star.ui.ModuleAcceleratorConfiguration"); + + // the resourceURL + tEnv.addObjRelation("XModuleUIConfigurationManager.ResourceURL", + "private:resource/menubar/menubar"); + tEnv.addObjRelation("XUIConfiguration.XUIConfigurationListenerImpl", + new ConfigurationListener(log, + UnoRuntime.queryInterface( + XUIConfigurationManager.class, oObj), xMSF)); + tEnv.addObjRelation("XModuleUIConfigurationManagerSupplier.ConfigManagerImplementationName", + "com.sun.star.comp.framework.ModuleUIConfigurationManager"); + return tEnv; + } + + /** + * An implementation of the _XUIConfiguration.XUIConfigurationListenerImpl + * interface to trigger the event for a listener call. + * @see ifc.ui._XUIConfiguration + */ + private static class ConfigurationListener implements _XUIConfiguration.XUIConfigurationListenerImpl { + private boolean triggered = false; + private final PrintWriter log; + private final XUIConfigurationManager xUIManager; + private final XMultiServiceFactory xMSF; + + private ConfigurationListener(PrintWriter _log, XUIConfigurationManager xUIManager, XMultiServiceFactory xMSF) { + log = _log; + this.xUIManager = xUIManager; + this.xMSF = xMSF; + } + public void reset(){ + triggered = false; + } + public void fireEvent() { + try { + XIndexAccess xMenuBarSettings = xUIManager.getSettings( + "private:resource/menubar/menubar", true); + + PropertyValue[]prop = _XUIConfigurationManager.createMenuBarEntry( + "Trigger Event", xMenuBarSettings, xMSF, log); + _XUIConfigurationManager.createMenuBarItem("Click for Macro", + UnoRuntime.queryInterface( + XIndexContainer.class, prop[3].Value), log); + XIndexContainer x = UnoRuntime.queryInterface(XIndexContainer.class, xMenuBarSettings); + x.insertByIndex(x.getCount(), prop); + xUIManager.replaceSettings("private:resource/menubar/menubar", xMenuBarSettings); + xUIManager.reset(); + } + catch(com.sun.star.container.NoSuchElementException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalAccessException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + } + public boolean actionWasTriggered(){ + return triggered; + } + public void disposing(EventObject e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.disposing the listener."); + } + public void elementInserted(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementInserted."); + } + public void elementRemoved(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementRemoved."); + } + public void elementReplaced(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementReplaced."); + } + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManagerSupplier.java b/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManagerSupplier.java new file mode 100644 index 000000000..a43f4d924 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ModuleUIConfigurationManagerSupplier.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class ModuleUIConfigurationManagerSupplier extends TestCase{ + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"); + TestEnvironment tEnv = new TestEnvironment(oObj); + tEnv.addObjRelation("XModuleUIConfigurationManagerSupplier.ConfigurationManager", + "com.sun.star.frame.StartModule"); + tEnv.addObjRelation("XModuleUIConfigurationManagerSupplier.ConfigManagerImplementationName", "com.sun.star.comp.framework.ModuleUIConfigurationManager"); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/PopupMenuControllerFactory.java b/qadevOOo/tests/java/mod/_fwk/PopupMenuControllerFactory.java new file mode 100644 index 000000000..60dee1adf --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/PopupMenuControllerFactory.java @@ -0,0 +1,99 @@ +/* + * 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._fwk; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.XCloseable; +import com.sun.star.frame.XUIControllerRegistration; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; + +/** + */ +public class PopupMenuControllerFactory extends TestCase { + XTextDocument xTextDoc; + + /** + * Cleanup: close the created document + * @param tParam The test parameters. + * @param log The log writer. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + + /** + * Create test environment: + * @param tParam The test parameters. + * @param log The log writer. + * @return The test environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface xInst = null; + + log.println("Creating instance..."); + + xTextDoc = WriterTools.createTextDoc(xMSF); + util.dbg.printInterfaces(xTextDoc); + + xInst = (XInterface)xMSF.createInstance( + "com.sun.star.comp.framework.PopupMenuControllerFactory"); + + log.println("TestObject: " + util.utils.getImplName(xInst)); + tEnv = new TestEnvironment(xInst); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xMSF); + Object o = xProp.getPropertyValue("DefaultContext"); + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, o); + tEnv.addObjRelation("DC", xContext); + + // register one controller, so it can be instantiated + XUIControllerRegistration xReg = UnoRuntime.queryInterface(XUIControllerRegistration.class, xInst); + + xReg.registerController(".uno:MyCommandUrl", "", "com.sun.star.comp.framework.FooterMenuController"); + tEnv.addObjRelation("XUIControllerRegistration.RegisteredController", ".uno:MyCommandUrl"); + tEnv.addObjRelation("XMultiComponentFactory.ServiceNames", new String[]{".uno:MyCommandUrl"}); + + return tEnv; + } +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/ServiceHandler.java b/qadevOOo/tests/java/mod/_fwk/ServiceHandler.java new file mode 100644 index 000000000..fdf637161 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ServiceHandler.java @@ -0,0 +1,61 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::lang::XInitialization</code></li> +* <li><code>com::sun::star::frame::XDispatchProvider</code></li> +* </ul><p> +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.frame.XDispatchProvider +* @see ifc.lang._XInitialization +* @see ifc.frame._XDispatchProvider +*/ +public class ServiceHandler extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.framework.ServiceHandler</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.ServiceHandler"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XDispatchProvider.URL", + "service:com.sun.star.io.Pipe"); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwk/SoundHandler.java b/qadevOOo/tests/java/mod/_fwk/SoundHandler.java new file mode 100644 index 000000000..04f1fce1d --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/SoundHandler.java @@ -0,0 +1,62 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import util.utils; +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::frame::XDispatch</code></li> +* <li><code>com::sun::star::frame::XNotifyingDispatch</code></li> +* </ul><p> +* @see com.sun.star.frame.XDispatch +* @see com.sun.star.frame.XNotifyingDispatch +* @see ifc.frame._XDispatch +* @see ifc.frame._XNotifyingDispatch +*/ +public class SoundHandler extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.frame.ContentHandler"); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + URL dispURL = utils.parseURL(Param.getMSF(), + utils.getFullTestURL("ok.wav")); + System.out.println("DISPATCHURL: "+ dispURL.Complete); + + tEnv.addObjRelation("XDispatch.URL", dispURL); + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwk/StatusBarControllerFactory.java b/qadevOOo/tests/java/mod/_fwk/StatusBarControllerFactory.java new file mode 100644 index 000000000..c3451125e --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/StatusBarControllerFactory.java @@ -0,0 +1,47 @@ +/* + * 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._fwk; +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class StatusBarControllerFactory extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.StatusBarControllerFactory"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xMSF); + Object o = xProp.getPropertyValue("DefaultContext"); + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, o); + tEnv.addObjRelation("DC", xContext); + return tEnv; + } +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/ToolBarsMenuController.java b/qadevOOo/tests/java/mod/_fwk/ToolBarsMenuController.java new file mode 100644 index 000000000..1c88d936c --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/ToolBarsMenuController.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class ToolBarsMenuController extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.ToolBarsMenuController"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/UICategoryDescription.java b/qadevOOo/tests/java/mod/_fwk/UICategoryDescription.java new file mode 100644 index 000000000..fab3759cb --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/UICategoryDescription.java @@ -0,0 +1,42 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class UICategoryDescription extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.comp.framework.UICategoryDescription"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/UICommandDescription.java b/qadevOOo/tests/java/mod/_fwk/UICommandDescription.java new file mode 100644 index 000000000..15e64baf8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/UICommandDescription.java @@ -0,0 +1,41 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +public class UICommandDescription extends TestCase { + XInterface oObj = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + oObj = (XInterface)xMSF.createInstance("com.sun.star.frame.UICommandDescription"); + + log.println("TestObject: " + utils.getImplName(oObj)); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_fwk/UIConfigurationManager.java b/qadevOOo/tests/java/mod/_fwk/UIConfigurationManager.java new file mode 100644 index 000000000..d32fb8d23 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/UIConfigurationManager.java @@ -0,0 +1,196 @@ +/* + * 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._fwk; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexContainer; +import com.sun.star.embed.ElementModes; +import com.sun.star.embed.XStorage; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.uno.UnoRuntime; +import ifc.ui._XUIConfiguration; +import java.io.PrintWriter; +import com.sun.star.lang.EventObject; +import com.sun.star.ui.ConfigurationEvent; +import com.sun.star.ui.UIElementType; +import com.sun.star.ui.XUIConfigurationManager; +import com.sun.star.ui.XUIConfigurationStorage; +import ifc.ui._XUIConfigurationManager; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** + */ +public class UIConfigurationManager extends TestCase { + XUIConfigurationManager xManager = null; + + + /** + * Create test environment: + * <ul> + * <li>create a text doc</li> + * <li>get the model from the text doc</li> + * <li>query model for XUIConfigurationManagerSupplier interface</li> + * <li>get the manager from the supplier</li> + * </ul> + * @param tParam The test parameters. + * @param log The log writer. + * @return The test environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + TestEnvironment tEnv = null; + XMultiServiceFactory xMSF = tParam.getMSF(); + + log.println("Creating instance..."); + + try { + xManager = UnoRuntime.queryInterface( + XUIConfigurationManager.class, xMSF.createInstance( + "com.sun.star.comp.framework.UIConfigurationManager")); + } + catch(com.sun.star.uno.Exception e) { + } + // just to make sure, it's the right one. + log.println("TestObject: " + utils.getImplName(xManager)); + tEnv = new TestEnvironment(xManager); + + // create a configuration storage + try { + String sourceDeleteCfg = util.utils.getFullTestURL("delete.cfg"); + String deleteCfg = util.utils.getFullURL(util.utils.getOfficeTemp(xMSF) + "delete.cfg"); + util.utils.copyFile(xMSF, sourceDeleteCfg, deleteCfg); + XStorage xSubStorage = null; + Object o = xMSF.createInstance("com.sun.star.embed.StorageFactory"); + XSingleServiceFactory xSSF = UnoRuntime.queryInterface( + XSingleServiceFactory.class, o); + Object[] props = new Object[2]; + props[0] = deleteCfg; + props[1] = Integer.valueOf(ElementModes.READWRITE); + XStorage xRootStorage = UnoRuntime.queryInterface(XStorage.class, xSSF.createInstanceWithArguments(props)); + xSubStorage = xRootStorage.openStorageElement("Configurations2", ElementModes.READWRITE); + + XUIConfigurationStorage xConfigStorage =UnoRuntime.queryInterface(XUIConfigurationStorage.class, xManager); + xConfigStorage.setStorage(xSubStorage); + tEnv.addObjRelation("XUIConfigurationStorage.Storage", xSubStorage); + } + catch(com.sun.star.uno.Exception e) { + log.println("Could not create storage: " + e.toString()); + } + util.dbg.printInterfaces(xManager); + + tEnv.addObjRelation("XUIConfiguration.XUIConfigurationListenerImpl", + new ConfigurationListener(log, xManager, xMSF)); + + // the short cut manager service name + // 2do: correct the service name when it's no longer in + tEnv.addObjRelation("XConfigurationManager.ShortCutManager", + "com.sun.star.ui.DocumentAcceleratorConfiguration"); + return tEnv; + } + + /** + * An implementation of the _XUIConfiguration.XUIConfigurationListenerImpl + * interface to trigger the event for a listener call. + * @see ifc.ui._XUIConfiguration + */ + private static class ConfigurationListener implements _XUIConfiguration.XUIConfigurationListenerImpl { + private boolean triggered = false; + private final PrintWriter log; + private final XUIConfigurationManager xUIManager; + private final XMultiServiceFactory xMSF; + private static int iUniqueCounter; + + private ConfigurationListener(PrintWriter _log, XUIConfigurationManager xUIManager, XMultiServiceFactory xMSF) { + log = _log; + this.xUIManager = xUIManager; + this.xMSF = xMSF; + iUniqueCounter = 0; + } + public void reset(){ + triggered = false; + } + public void fireEvent() { + try { + if (iUniqueCounter == 0) { + iUniqueCounter++; + xUIManager.getUIElementsInfo(UIElementType.UNKNOWN); + XIndexAccess xMenuBarSettings = xUIManager.getSettings( + "private:resource/menubar/menubar", true); + + PropertyValue[]prop = _XUIConfigurationManager.createMenuBarEntry( + "Trigger Event", xMenuBarSettings, xMSF, log); + _XUIConfigurationManager.createMenuBarItem("Click for Macro", + UnoRuntime.queryInterface( + XIndexContainer.class, prop[3].Value), log); + XIndexContainer x = UnoRuntime.queryInterface(XIndexContainer.class, xMenuBarSettings); + x.insertByIndex(x.getCount(), prop); + xUIManager.replaceSettings("private:resource/menubar/menubar", xMenuBarSettings); + xUIManager.reset(); + } + } + catch(com.sun.star.container.NoSuchElementException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalAccessException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + log.println("_XUIConfiguration.XUIConfigurationListenerImpl: Exception."); + e.printStackTrace(log); + } + } + public boolean actionWasTriggered(){ + return triggered; + } + public void disposing(EventObject e) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.disposing the listener."); + } + public void elementInserted(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementInserted."); + } + public void elementRemoved(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementRemoved."); + } + public void elementReplaced(ConfigurationEvent configEvent) { + triggered = true; + log.println("_XUIConfiguration.XUIConfigurationListenerImpl.elementReplaced."); + } + } + +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/UIElementFactoryManager.java b/qadevOOo/tests/java/mod/_fwk/UIElementFactoryManager.java new file mode 100644 index 000000000..744b979b1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/UIElementFactoryManager.java @@ -0,0 +1,84 @@ +/* + * 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._fwk; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import com.sun.star.text.XTextDocument; +import com.sun.star.util.XCloseable; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; + +/** + */ +public class UIElementFactoryManager extends TestCase { + Object oObj = null; + XTextDocument xTextDoc; + + /** + * Cleanup: close the created document + * @param tParam The test parameters. + * @param log The log writer. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * Create test environment: + * <ul> + * <li>create a text doc</li> + * <li>get the model from the text doc</li> + * <li>query model for XUIConfigurationManagerSupplier interface</li> + * <li>get the manager from the supplier</li> + * </ul> + * @param tParam The test parameters. + * @param log The log writer. + * @return The test environment. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + log.println("Creating instance..."); + xTextDoc = WriterTools.createTextDoc(xMSF); + oObj = xMSF.createInstance("com.sun.star.ui.UIElementFactoryManager"); + log.println("TestObject: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment((XInterface)oObj); + return tEnv; + } +} + + diff --git a/qadevOOo/tests/java/mod/_fwk/URLTransformer.java b/qadevOOo/tests/java/mod/_fwk/URLTransformer.java new file mode 100644 index 000000000..b46f9f89d --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwk/URLTransformer.java @@ -0,0 +1,53 @@ +/* + * 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._fwk; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** +* Test for object that implements the following interfaces : +* <ul> +* <li><code>com::sun::star::util::XURLTransformer</code></li> +* </ul><p> +* @see com.sun.star.util.XURLTransformer +* @see ifc.util._XURLTransformer +*/ +public class URLTransformer extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.framework.URLTransformer"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java b/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java new file mode 100644 index 000000000..41cbd39ab --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/ContentHandlerFactory.java @@ -0,0 +1,93 @@ +/* + * 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._fwl; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.container.XNameAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.frame.FrameLoaderFactory</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::lang::XMultiServiceFactory</code></li> + * </ul> <p> + * + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.lang.XMultiServiceFactory + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.lang._XMultiServiceFactory + */ +public class ContentHandlerFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.frame.ContentHandlerFactory</code>. <p> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null ; + + //now get the OButtonControl + oInterface = Param.getMSF().createInstance + ("com.sun.star.frame.ContentHandlerFactory") ; + + oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XNameAccess xNA = UnoRuntime.queryInterface + (XNameAccess.class, oObj); + tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames()); + xNA.getElementNames(); + + // com.sun.star.container.XContainerQuery + NamedValue[] querySequenze = new NamedValue[1]; + NamedValue query = new NamedValue(); + query.Name = "Name"; + query.Value = "com.sun.star.comp.framework.SoundHandler"; + querySequenze[0] = query; + + tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", + querySequenze); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_fwl/FilterFactory.java b/qadevOOo/tests/java/mod/_fwl/FilterFactory.java new file mode 100644 index 000000000..1ed9869b1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/FilterFactory.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._fwl; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.framework.FilterFactory</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::lang::XMultiServiceFactory</code></li> + * </ul> <p> + * + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.lang.XMultiServiceFactory + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.lang._XMultiServiceFactory + */ +public class FilterFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.framework.FilterFactory</code>. + * Prepares relation for + * <code>XMultiServiceFactory.createInstanceWithArguments</code> method + * test. Only filters which have their service names can be instantiated + * in some reasons (?). For instantiation used filter type as service + * name and its name as a parameter. <p> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.document.FilterFactory") ; + XInterface oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XNameAccess xNA = UnoRuntime.queryInterface + (XNameAccess.class, oObj); + String[] filterNames = xNA.getElementNames(); + + // XNameContainer; XNameReplace + String filterName = filterNames[0]; + Object[] instance = (Object[]) xNA.getByName(filterName); + + log.println("adding INSTANCE 1 as obj relation to environment"); + + log.println("fill property 'TemplateName' with 'INSTANCE1'"); + setPropertyValueValue((PropertyValue[])instance, "TemplateName", "INSTANCE1"); + tEnv.addObjRelation("INSTANCE" +1, instance); + + + // XMSF + ArrayList<String> vFTypes = new ArrayList<String>(); + ArrayList<Object[]> vFArgs = new ArrayList<Object[]>(); + for (int i = 0; i < filterNames.length; i++) { + PropertyValue[] filterProps = null; + System.out.println(filterNames[i]); + filterProps = (PropertyValue[]) + xNA.getByName(filterNames[i]); + String filterImpl = (String) getPropertyValueValue + (filterProps, "FilterService"); + if (filterImpl != null && filterImpl.length() > 0) { + String filterType = (String) getPropertyValueValue + (filterProps, "Type"); + vFTypes.add(filterType); + PropertyValue prop = new PropertyValue(); + prop.Name = "FilterName"; + prop.Value = filterNames[i]; + vFArgs.add(new Object[] {prop}); + + log.println("Found filter '" + filterNames[i] + "', type: " + + filterType + ", service name: '" + filterImpl + "'"); + } + } + + tEnv.addObjRelation("XMSF.serviceNamesWithArgs", + vFTypes.toArray(new String[vFTypes.size()])); + tEnv.addObjRelation("XMSF.Args", + vFArgs.toArray(new Object[vFArgs.size()][])); + + // com.sun.star.container.XContainerQuery + NamedValue[] querySequenze = new NamedValue[1]; + NamedValue query = new NamedValue(); + query.Name = "Name"; + query.Value = "Rich Text Format"; + querySequenze[0] = query; + + tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", + querySequenze); + + + return tEnv; + } // finish method getTestEnvironment + + protected Object getPropertyValueValue(PropertyValue[] props, String pName) { + int i = 0; + while (i < props.length && !props[i].Name.equals(pName)) { + i++; + } + return i < props.length ? props[i].Value : null; + + } + + protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) { + int i = 0; + while (i < props.length && !props[i].Name.equals(pName)) { + i++; + } + props[i].Value = pValue; + } + + protected PropertyValue getPropertyValue(PropertyValue[] props, String pName) { + int i = 0; + while (i < props.length && !props[i].Name.equals(pName)) { + i++; + } + return i < props.length ? props[i] : null; + + } +} + diff --git a/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java b/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java new file mode 100644 index 000000000..5beaebdb5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/FrameLoaderFactory.java @@ -0,0 +1,87 @@ +/* + * 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._fwl; + +import com.sun.star.beans.NamedValue; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.container.XNameAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.frame.FrameLoaderFactory</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::lang::XMultiServiceFactory</code></li> + * </ul> <p> + * + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.lang.XMultiServiceFactory + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.lang._XMultiServiceFactory + */ +public class FrameLoaderFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.frame.FrameLoaderFactory</code>. <p> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.frame.FrameLoaderFactory") ; + XInterface oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XNameAccess xNA = UnoRuntime.queryInterface + (XNameAccess.class, oObj); + tEnv.addObjRelation("XMSF.serviceNames", xNA.getElementNames()); + + // com.sun.star.container.XContainerQuery + NamedValue[] querySequenze = new NamedValue[1]; + NamedValue query = new NamedValue(); + query.Name = "Name"; + query.Value = "com.sun.star.frame.Bibliography"; + querySequenze[0] = query; + + tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", + querySequenze); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_fwl/PathSettings.java b/qadevOOo/tests/java/mod/_fwl/PathSettings.java new file mode 100644 index 000000000..8e05a6bfb --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/PathSettings.java @@ -0,0 +1,138 @@ +/* + * 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._fwl; + +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.uno.UnoRuntime; +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.Set; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.framework.PathSettings</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::util::PathSettings</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> + * </ul> <p> + * + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.util.PathSettings + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XMultiPropertySet + * @see ifc.beans._XFastPropertySet + * @see ifc.util._PathSettings + * @see ifc.beans._XPropertySet + * @see ifc.beans._XMultiPropertySet + */ +public class PathSettings extends TestCase { + + private static NamedValue[] m_Properties; + private static XPropertySet xPS; + + /** + * restores the old values of the path settings + * @param tParam the test parameter + * @param log the log writer + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println("restore old values of path settings..."); + + for (int i=0; i < m_Properties.length; i++){ + try{ + + xPS.setPropertyValue(m_Properties[i].Name, m_Properties[i].Value); + + } catch (com.sun.star.beans.UnknownPropertyException e){ + } catch (PropertyVetoException e){ + } catch (IllegalArgumentException e){ + } catch (WrappedTargetException e){ + } + } + } + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.framework.PathSettings</code>. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + //now get the OButtonControl + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.comp.framework.PathSettings") ; + + oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + Set<String> exclProps = new HashSet<String>(); + exclProps.add("UIConfig"); + tEnv.addObjRelation("XFastPropertySet.ExcludeProps", exclProps); + tEnv.addObjRelation("XMultiPropertySet.ExcludeProps", exclProps); + + saveAllPropertyValues(oObj); + + return tEnv; + } // finish method getTestEnvironment + + private void saveAllPropertyValues(XInterface oObj){ + + xPS = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + XPropertySetInfo xPSI = xPS.getPropertySetInfo(); + + Property[] allProperties = xPSI.getProperties(); + m_Properties = new NamedValue[allProperties.length]; + + for (int i=0; i < allProperties.length; i++){ + try{ + m_Properties[i] = new NamedValue(allProperties[i].Name, + xPS.getPropertyValue(allProperties[i].Name)); + + } catch (com.sun.star.beans.UnknownPropertyException e){ + } catch (WrappedTargetException e){ + } + } + } + +} + diff --git a/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java b/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java new file mode 100644 index 000000000..f55b33a45 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/SubstituteVariables.java @@ -0,0 +1,68 @@ +/* + * 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._fwl; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.frame.FrameLoaderFactory</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::lang::XMultiServiceFactory</code></li> + * </ul> <p> + * + * @see com.sun.star.util.XStringSubstitution + * @see ifc.util._XStringSubstitution + */ +public class SubstituteVariables extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.util.PathSubstitution</code>. <p> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + //now get the OButtonControl + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.util.PathSubstitution") ; + XInterface oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_fwl/TypeDetection.java b/qadevOOo/tests/java/mod/_fwl/TypeDetection.java new file mode 100644 index 000000000..74af3b352 --- /dev/null +++ b/qadevOOo/tests/java/mod/_fwl/TypeDetection.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._fwl; + +import com.sun.star.beans.NamedValue; +import com.sun.star.container.XNameAccess; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XStorable; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import util.SOfficeFactory; + +/** + * Test for object which is represented by service + * <code>com.sun.star.document.TypeDetection</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XContainerQuery</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XNameContainer</code></li> + * <li> <code>com::sun::star::container::XNameReplace</code></li> + * <li> <code>com::sun::star::document::XTypeDetection</code></li> + * <li> <code>com::sun::star::util::XFlushable</code></li> + * </ul> <p> + * + * @see com.sun.star.container.XContainerQuery + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.container.XNameReplace + * @see com.sun.star.document.XTypeDetection + * @see com.sun.star.util.XFlushable + * @see ifc.container._XContainerQuery + * @see ifc.container._XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.container._XNameContainer + * @see ifc.container._XNameReplace + * @see ifc.document._XTypeDetection + * @see ifc.util._XFlushable + */ +public class TypeDetection extends TestCase { + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + XTextDocument xTextDoc = null; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.document.TypeDetection</code>. <p> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null ; + + oInterface = Param.getMSF().createInstance + ("com.sun.star.document.TypeDetection") ; + + oObj = (XInterface) oInterface ; + log.println("ImplName: "+utils.getImplName(oObj)); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XNameAccess xNA = UnoRuntime.queryInterface + (XNameAccess.class, oObj); + String[] elementNames = xNA.getElementNames(); + String elementName = elementNames[0]; + Object[] instance = null; + instance = (Object[]) xNA.getByName(elementName); + + log.println("adding INSTANCE 1 as obj relation to environment"); + + setPropertyValueValue((PropertyValue[])instance, "Preferred", "INSTANCE1"); + tEnv.addObjRelation("INSTANCE" +1, instance); + + // com.sun.star.container.XContainerQuery + NamedValue[] querySequenze = new NamedValue[1]; + NamedValue query = new NamedValue(); + query.Name = "Name"; + query.Value = "generic_Text"; + querySequenze[0] = query; + + + log.println("create text document with bookmarks"); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + String fileURL = null; + xTextDoc = SOF.createTextDoc( null ); + XInterface xBookMark = SOfficeFactory.createBookmark( xTextDoc ); + SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) xBookMark ); + + fileURL = utils.getOfficeTemp(Param.getMSF() ); + fileURL = fileURL + "bookmarks.oot"; + + XStorable store = UnoRuntime.queryInterface(XStorable.class, xTextDoc); + System.out.println(fileURL); + store.storeToURL(fileURL, new PropertyValue[0]); + + tEnv.addObjRelation("XContainerQuery.createSubSetEnumerationByProperties", + querySequenze); + tEnv.addObjRelation("XTypeDetection.bookmarkDoc", fileURL+"#bookmark"); + + return tEnv; + } // finish method getTestEnvironment + + + protected void setPropertyValueValue(PropertyValue[] props, String pName, Object pValue) { + int i = 0; + while (i < props.length && !props[i].Name.equals(pName)) { + i++; + } + props[i].Value = pValue; + } + +} + diff --git a/qadevOOo/tests/java/mod/_i18n/BreakIterator.java b/qadevOOo/tests/java/mod/_i18n/BreakIterator.java new file mode 100644 index 000000000..b7d0491d6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/BreakIterator.java @@ -0,0 +1,98 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.lang.Locale; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.i18n.BreakIterator</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::i18n::XBreakIterator</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.i18n._XBreakIterator +*/ +public class BreakIterator extends TestCase { + + XComponent xTextDoc; + + /** + * Loads a Text document with name 'Iterator.sxw' from test + * documents directory + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xTextDoc = SOF.loadDocument(utils.getFullTestURL("Iterator.sxw")); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.BreakIterator</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.i18n.BreakIterator" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("Locale", new Locale("en", "US", "")); + + XTextDocument xDoc = UnoRuntime.queryInterface + (XTextDocument.class, xTextDoc); + XTextRange xTextRange = xDoc.getText(); + tEnv.addObjRelation("UnicodeString", xTextRange.getString()); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Disposes the Text document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + xTextDoc.dispose(); + } + +} // finish class BreakIterator + diff --git a/qadevOOo/tests/java/mod/_i18n/CalendarImpl.java b/qadevOOo/tests/java/mod/_i18n/CalendarImpl.java new file mode 100644 index 000000000..3c7fdee7b --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/CalendarImpl.java @@ -0,0 +1,61 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.i18n.Calendar</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::i18n::Calendar</code></li> +* </ul> +* @see ifc.i18n._XCalendar +*/ +public class CalendarImpl extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.Calendar</code>. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.i18n.LocaleCalendar" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_i18n/ChapterCollator.java b/qadevOOo/tests/java/mod/_i18n/ChapterCollator.java new file mode 100644 index 000000000..4a8ecb338 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/ChapterCollator.java @@ -0,0 +1,65 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.i18n.ChapterCollator</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::i18n::XCollator</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.i18n._XCollator +* @see ifc.lang._XServiceInfo +*/ +public class ChapterCollator extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.ChapterCollator</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.i18n.ChapterCollator" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_i18n/CharacterClassification.java b/qadevOOo/tests/java/mod/_i18n/CharacterClassification.java new file mode 100644 index 000000000..a2c8b8b6c --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/CharacterClassification.java @@ -0,0 +1,68 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.i18n.CharacterClassification</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::i18n::XCharacterClassification</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.i18n.XCharacterClassification + * @see ifc.i18n._XCharacterClassification + */ +public class CharacterClassification extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.CharacterClassification</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.i18n.CharacterClassification" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for CharacterClassification object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class CharacterClassification + diff --git a/qadevOOo/tests/java/mod/_i18n/Collator.java b/qadevOOo/tests/java/mod/_i18n/Collator.java new file mode 100644 index 000000000..6738f8072 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/Collator.java @@ -0,0 +1,62 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.i18n.Collator</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::i18n::XCollator</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.i18n._XCollator +*/ +public class Collator extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.Collator</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.i18n.Collator" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_i18n/IndexEntrySupplier.java b/qadevOOo/tests/java/mod/_i18n/IndexEntrySupplier.java new file mode 100644 index 000000000..f27ed3e43 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/IndexEntrySupplier.java @@ -0,0 +1,67 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.i18n.IndexEntrySupplier</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::i18n::XIndexEntrySupplier</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.i18n.XIndexEntrySupplier + * @see ifc.i18n._XIndexEntrySupplier + */ +public class IndexEntrySupplier extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.IndexEntrySupplier</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.i18n.IndexEntrySupplier" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_i18n/LocaleData.java b/qadevOOo/tests/java/mod/_i18n/LocaleData.java new file mode 100644 index 000000000..a99fc17a2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/LocaleData.java @@ -0,0 +1,67 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.i18n.LocaleData</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::i18n::XLocaleData</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.i18n.XLocaleData + * @see ifc.i18n._XLocaleData + */ +public class LocaleData extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.LocaleData</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.i18n.LocaleData" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for LocaleData object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class LocaleData + diff --git a/qadevOOo/tests/java/mod/_i18n/NumberFormatCodeMapper.java b/qadevOOo/tests/java/mod/_i18n/NumberFormatCodeMapper.java new file mode 100644 index 000000000..92c42ac06 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/NumberFormatCodeMapper.java @@ -0,0 +1,71 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.i18n.NumberFormatCodeMapper</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::i18n::XNumberFormatCode</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.i18n.XNumberFormatCode + * @see ifc.lang._XServiceInfo + * @see ifc.i18n._XNumberFormatCode + */ +public class NumberFormatCodeMapper extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.NumberFormatCodeMapper</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.i18n.NumberFormatCodeMapper" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for NumberFormatCodeMapper object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class NumberFormatCodeMapper + diff --git a/qadevOOo/tests/java/mod/_i18n/Transliteration.java b/qadevOOo/tests/java/mod/_i18n/Transliteration.java new file mode 100644 index 000000000..64a588c43 --- /dev/null +++ b/qadevOOo/tests/java/mod/_i18n/Transliteration.java @@ -0,0 +1,62 @@ +/* + * 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._i18n; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.i18n.Transliteration</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::i18n::XTransliteration</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.i18n._XTransliteration +*/ +public class Transliteration extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.i18n.Transliteration</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( "com.sun.star.i18n.Transliteration" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_implreg/uno/ImplementationRegistration.java b/qadevOOo/tests/java/mod/_implreg/uno/ImplementationRegistration.java new file mode 100644 index 000000000..4ebdb8ac9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_implreg/uno/ImplementationRegistration.java @@ -0,0 +1,61 @@ +/* + * 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._implreg.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.registry.ImplementationRegistration</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::registry::XImplementationRegistration</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.registry.XImplementationRegistration +* @see com.sun.star.registry.ImplementationRegistration +* @see ifc.registry._XImplementationRegistration +*/ +public class ImplementationRegistration extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service + * <code>com.sun.star.registry.ImplementationRegistration</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.registry.ImplementationRegistration" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class NestedRegistry
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_implreg/uno/package.html b/qadevOOo/tests/java/mod/_implreg/uno/package.html new file mode 100644 index 000000000..a007b5cb1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_implreg/uno/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 'impreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_impreg/ImplementationRegistration.java b/qadevOOo/tests/java/mod/_impreg/ImplementationRegistration.java new file mode 100644 index 000000000..29f843bc9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_impreg/ImplementationRegistration.java @@ -0,0 +1,66 @@ +/* + * 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._impreg; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.registry.ImplementationRegistration</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::registry::XImplementationRegistration</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.registry.XImplementationRegistration +* @see com.sun.star.registry.ImplementationRegistration +* @see ifc.registry._XImplementationRegistration +*/ +public class ImplementationRegistration extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service + * <code>com.sun.star.registry.ImplementationRegistration</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.registry.ImplementationRegistration" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class NestedRegistry + diff --git a/qadevOOo/tests/java/mod/_impreg/package.html b/qadevOOo/tests/java/mod/_impreg/package.html new file mode 100644 index 000000000..a007b5cb1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_impreg/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 'impreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_insp/Introspection.java b/qadevOOo/tests/java/mod/_insp/Introspection.java new file mode 100644 index 000000000..de99047ae --- /dev/null +++ b/qadevOOo/tests/java/mod/_insp/Introspection.java @@ -0,0 +1,65 @@ +/* + * 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._insp; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.beans.Introspection</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XIntrospection</code></li> +* </ul> +* This object test can be run in several +* threads concurrently. +* @see com.sun.star.beans.XIntrospection +* @see com.sun.star.beans.Introspection +* @see ifc.beans._XIntrospection +*/ +public class Introspection extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.comp.stoc.Introspection</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.Introspection" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class Introspection + diff --git a/qadevOOo/tests/java/mod/_insp/package.html b/qadevOOo/tests/java/mod/_insp/package.html new file mode 100644 index 000000000..617c082e4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_insp/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 'insp'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_introspection/uno/Introspection.java b/qadevOOo/tests/java/mod/_introspection/uno/Introspection.java new file mode 100644 index 000000000..3a5e9ae24 --- /dev/null +++ b/qadevOOo/tests/java/mod/_introspection/uno/Introspection.java @@ -0,0 +1,61 @@ +/* + * 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._introspection.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.beans.Introspection</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::beans::XIntrospection</code></li> +* </ul> +* This object test can be run in several +* threads concurrently. +* @see com.sun.star.beans.XIntrospection +* @see com.sun.star.beans.Introspection +* @see ifc.beans._XIntrospection +*/ +public class Introspection extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.comp.stoc.Introspection</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.Introspection" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class Introspection + diff --git a/qadevOOo/tests/java/mod/_introspection/uno/package.html b/qadevOOo/tests/java/mod/_introspection/uno/package.html new file mode 100644 index 000000000..617c082e4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_introspection/uno/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 'insp'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_inv/Invocation.java b/qadevOOo/tests/java/mod/_inv/Invocation.java new file mode 100644 index 000000000..0264fef40 --- /dev/null +++ b/qadevOOo/tests/java/mod/_inv/Invocation.java @@ -0,0 +1,92 @@ +/* + * 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._inv; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.script.Invocation</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li> +* </ul> +* @see com.sun.star.script.Invocation +* @see com.sun.star.lang.XSingleServiceFactory +* @see ifc.lang._XSingleServiceFactory +*/ +public class Invocation extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.script.Invocation</code>. + * Object relations created : + * <ul> + * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> : + * for interface {@link ifc.lang._XSingleServiceFactory} ; + * <code>String</code> relation; If its value 'true' then + * <code>createInstance</code> method for the object isn't + * supported. In this case object doesn't support this method.</li> + * <li> <code>'XSingleServiceFactory.arguments'</code> : + * for interface {@link ifc.lang._XSingleServiceFactory} ; + * has <code>Object[]</code> type. This relation is used as + * a parameter for <code>createInstanceWithArguments</code> + * method call. If this relation doesn't exist test pass + * zero length array as argument. Here + * <code>com.sun.star.io.Pipe</code> instance is passed.</li> + * <li> <code>'XSingleServiceFactory.MustSupport'</code> : + * for interface {@link ifc.lang._XSingleServiceFactory}. + * Specifies that created instance must support + * <code>com.sun.star.script.XInvocation</code> interface. + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.script.Invocation"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + // the createInstance should fail according to the documentation + tEnv.addObjRelation( + "XSingleServiceFactory.createInstance.negative", "true"); + + // creating parameters to createInstanceWithArguments + Object[] args = new Object[1]; + + args[0] = xMSF.createInstance("com.suns.star.io.Pipe"); + + tEnv.addObjRelation( + "XSingleServiceFactory.arguments", args); + + tEnv.addObjRelation("XSingleServiceFactory.MustSupport", + new Class[] {com.sun.star.script.XInvocation.class}); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_inv/package.html b/qadevOOo/tests/java/mod/_inv/package.html new file mode 100644 index 000000000..ee1fd4a02 --- /dev/null +++ b/qadevOOo/tests/java/mod/_inv/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 'inv'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_invadp/InvocationAdapterFactory.java b/qadevOOo/tests/java/mod/_invadp/InvocationAdapterFactory.java new file mode 100644 index 000000000..2817acce1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_invadp/InvocationAdapterFactory.java @@ -0,0 +1,61 @@ +/* + * 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._invadp; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.script.InvocationAdapterFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::script::XInvocationAdapterFactory</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.script.XInvocationAdapterFactory +* @see com.sun.star.script.InvocationAdapterFactory +* @see ifc.script._XInvocationAdapterFactory +*/ +public class InvocationAdapterFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.script.InvocationAdapterFactory</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.script.InvocationAdapterFactory"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_invadp/package.html b/qadevOOo/tests/java/mod/_invadp/package.html new file mode 100644 index 000000000..9d1509fca --- /dev/null +++ b/qadevOOo/tests/java/mod/_invadp/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 'invadp'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_invocadapt/uno/InvocationAdapterFactory.java b/qadevOOo/tests/java/mod/_invocadapt/uno/InvocationAdapterFactory.java new file mode 100644 index 000000000..dd9753782 --- /dev/null +++ b/qadevOOo/tests/java/mod/_invocadapt/uno/InvocationAdapterFactory.java @@ -0,0 +1,60 @@ +/* + * 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._invocadapt.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.script.InvocationAdapterFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::script::XInvocationAdapterFactory</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.script.XInvocationAdapterFactory +* @see com.sun.star.script.InvocationAdapterFactory +* @see ifc.script._XInvocationAdapterFactory +*/ +public class InvocationAdapterFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.script.InvocationAdapterFactory</code>. + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.script.InvocationAdapterFactory"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_invocadapt/uno/package.html b/qadevOOo/tests/java/mod/_invocadapt/uno/package.html new file mode 100644 index 000000000..9d1509fca --- /dev/null +++ b/qadevOOo/tests/java/mod/_invocadapt/uno/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 'invadp'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_invocation/uno/Invocation.java b/qadevOOo/tests/java/mod/_invocation/uno/Invocation.java new file mode 100644 index 000000000..d83a2f927 --- /dev/null +++ b/qadevOOo/tests/java/mod/_invocation/uno/Invocation.java @@ -0,0 +1,90 @@ +/* + * 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._invocation.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.script.Invocation</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XSingleServiceFactory</code></li> +* </ul> +* @see com.sun.star.script.Invocation +* @see com.sun.star.lang.XSingleServiceFactory +* @see ifc.lang._XSingleServiceFactory +*/ +public class Invocation extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates service <code>com.sun.star.script.Invocation</code>. + * Object relations created : + * <ul> + * <li> <code>'XSingleServiceFactory.createInstance.negative'</code> : + * for interface {@link _ifc.lang.XSingleServiceFactory} ; + * <code>String</code> relation; If its value 'true' then + * <code>createInstance</code> method for the object isn't + * supported. In this case object doesn't support this method.</li> + * <li> <code>'XSingleServiceFactory.arguments'</code> : + * for interface {@link _ifc.lang.XSingleServiceFactory} ; + * has <code>Object[]</code> type. This relation is used as + * a parameter for <code>createInstanceWithArguments</code> + * method call. If this relation doesn't exist test pass + * zero length array as argument. Here + * <code>com.sun.star.io.Pipe</code> instance is passed.</li> + * <li> <code>'XSingleServiceFactory.MustSupport'</code> : + * for interface {@link _ifc.lang.XSingleServiceFactory}. + * Specifies that created instance must support + * <code>com.sun.star.script.XInvocation</code> interface. + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.script.Invocation"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + // the createInstance should fail according to the documentation + tEnv.addObjRelation( + "XSingleServiceFactory.createInstance.negative", "true"); + + // creating parameters to createInstanceWithArguments + Object[] args = new Object[1]; + + args[0] = xMSF.createInstance("com.suns.star.io.Pipe"); + + tEnv.addObjRelation( + "XSingleServiceFactory.arguments", args); + + tEnv.addObjRelation("XSingleServiceFactory.MustSupport", + new Class[] {com.sun.star.script.XInvocation.class}); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_invocation/uno/package.html b/qadevOOo/tests/java/mod/_invocation/uno/package.html new file mode 100644 index 000000000..ee1fd4a02 --- /dev/null +++ b/qadevOOo/tests/java/mod/_invocation/uno/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 'inv'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_javaloader/JavaComponentLoader.java b/qadevOOo/tests/java/mod/_javaloader/JavaComponentLoader.java new file mode 100644 index 000000000..0a40e58ca --- /dev/null +++ b/qadevOOo/tests/java/mod/_javaloader/JavaComponentLoader.java @@ -0,0 +1,83 @@ +/* + * 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._javaloader; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for <code>com.sun.star.comp.stoc.Java2</code> service <p> +* Files which are used : +* <ul> +* <li> <code>MyPersistObjectImpl.jar</code> : jar which will be loaded in +* <code>XImplementationLoader</code> interface test. </li> +* <ul> +* Multithread testing compliant. +* @see com.sun.star.loader.XImplementationLoader +* @see com.sun.star.lang.XServiceInfo +* @see ifc.loader._XImplementationLoader +* @see ifc.lang._XServiceInfo +*/ +public class JavaComponentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.comp.stoc.Java2</code> + * service. <p> + * The following object relations created : + * <ul> + * <li> <code>'ImplementationLoader'</code> : service which is + * responsible for loading jar implementations. </li> + * <li> <code>'ImplementationUrl'</code> : jar file location. </li> + * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( + "com.sun.star.comp.stoc.JavaComponentLoader" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for JavaComponentLoader object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding object relation for XImplementationLoader ifc test + tEnv.addObjRelation("ImplementationLoader", + "com.sun.star.loader.JavaComponentLoader") ; + + String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar"); + tEnv.addObjRelation("ImplementationUrl", implURL) ; + log.println("looking for shared lib: " + implURL); + tEnv.addObjRelation("ImplementationName", + "com.sun.star.cmp.MyPersistObject") ; + + return tEnv; + } // finish method createTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_javaloader/uno/JavaComponentLoader.java b/qadevOOo/tests/java/mod/_javaloader/uno/JavaComponentLoader.java new file mode 100644 index 000000000..99bdeb76a --- /dev/null +++ b/qadevOOo/tests/java/mod/_javaloader/uno/JavaComponentLoader.java @@ -0,0 +1,80 @@ +/* + * 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._javaloader.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** +* Test for <code>com.sun.star.comp.stoc.Java2</code> service <p> +* Files which are used : +* <ul> +* <li> <code>MyPersistObjectImpl.jar</code> : jar which will be loaded in +* <code>XImplementationLoader</code> interface test. </li> +* <ul> +* Multithread testing compliant. +* @see com.sun.star.loader.XImplementationLoader +* @see com.sun.star.lang.XServiceInfo +* @see ifc.loader._XImplementationLoader +* @see ifc.lang._XServiceInfo +*/ +public class JavaComponentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.comp.stoc.Java2</code> + * service. <p> + * The following object relations created : + * <ul> + * <li> <code>'ImplementationLoader'</code> : service which is + * responsible for loading jar implementations. </li> + * <li> <code>'ImplementationUrl'</code> : jar file location. </li> + * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance( + "com.sun.star.comp.stoc.JavaComponentLoader" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for JavaComponentLoader object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding object relation for XImplementationLoader ifc test + tEnv.addObjRelation("ImplementationLoader", + "com.sun.star.loader.JavaComponentLoader") ; + + String implURL = utils.getFullTestURL("qadevlibs/MyPersistObjectImpl.jar"); + tEnv.addObjRelation("ImplementationUrl", implURL) ; + log.println("looking for shared lib: " + implURL); + tEnv.addObjRelation("ImplementationName", + "com.sun.star.cmp.MyPersistObject") ; + + return tEnv; + } // finish method createTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_javavm/uno/JavaVirtualMachine.java b/qadevOOo/tests/java/mod/_javavm/uno/JavaVirtualMachine.java new file mode 100644 index 000000000..b45447636 --- /dev/null +++ b/qadevOOo/tests/java/mod/_javavm/uno/JavaVirtualMachine.java @@ -0,0 +1,61 @@ +/* + * 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._javavm.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.java.JavaVirtualMachine</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::java::XJavaThreadRegister_11</code></li> +* <li> <code>com::sun::star::java::XJavaVM</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.java.XJavaThreadRegister_11 +* @see com.sun.star.java.XJavaVM +* @see com.sun.star.java.XJavaVirtualMachine +* @see ifc.java._XJavaThreadRegister_11 +* @see ifc.java._XJavaVM +*/ +public class JavaVirtualMachine extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.java.JavaVirtualMachine</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.java.JavaVirtualMachine"); + + return new TestEnvironment(xInt); + } +} diff --git a/qadevOOo/tests/java/mod/_javavm/uno/package.html b/qadevOOo/tests/java/mod/_javavm/uno/package.html new file mode 100644 index 000000000..a54ca6e09 --- /dev/null +++ b/qadevOOo/tests/java/mod/_javavm/uno/package.html @@ -0,0 +1,6 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<HTML> +<BODY> +<P>Contains all test cases for the module 'jen'.</P> +</BODY> +</HTML>
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_jdbc/JDBCDriver.java b/qadevOOo/tests/java/mod/_jdbc/JDBCDriver.java new file mode 100644 index 000000000..e0e6b5913 --- /dev/null +++ b/qadevOOo/tests/java/mod/_jdbc/JDBCDriver.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._jdbc; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DBTools; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + + +/** +* Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> +* Test allows to run object tests in several threads concurrently. +* @see com.sun.star.sdbc.Driver +* @see com.sun.star.sdbc.XDriver +* @see ifc.sdbc._XDriver +*/ +public class JDBCDriver extends TestCase { + /** + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the database to which to connect. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>flat.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments. + * The values for list are obtained from the parameter + * <code>jdbc.user</code> and <code>jdbc.password</code>.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.sdbc.JDBCDriver"); + + log.println("creating a new environment for JDBCDriver object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String jdbcURL = (String) Param.get("jdbc.url"); + if (jdbcURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "jdbc:" + jdbcURL); + + String user = (String) Param.get("jdbc.user"); + String password = (String) Param.get("jdbc.password"); + if (user == null || password == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.user' or 'jdbc.password' from ini-file")); + } + PropertyValue[] info = new PropertyValue[4]; + info[0] = new PropertyValue(); + info[0].Name = "JavaDriverClass"; + info[0].Value = DBTools.TST_JDBC_DRIVER; + info[1] = new PropertyValue(); + info[1].Name = "user"; + info[1].Value = user; + info[2] = new PropertyValue(); + info[2].Name = "password"; + info[2].Value = password; + info[3] = new PropertyValue(); + info[3].Name = "isPasswordRequired"; + info[3].Value = Boolean.TRUE; + + tEnv.addObjRelation("XDriver.INFO", info); + + String flatUrl = (String) Param.get("flat.url"); + if (flatUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'flat.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "sdbc:flat:" + flatUrl); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_jen/JavaVirtualMachine.java b/qadevOOo/tests/java/mod/_jen/JavaVirtualMachine.java new file mode 100644 index 000000000..2a27fda8c --- /dev/null +++ b/qadevOOo/tests/java/mod/_jen/JavaVirtualMachine.java @@ -0,0 +1,63 @@ +/* + * 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._jen; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.java.JavaVirtualMachine</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::java::XJavaThreadRegister_11</code></li> +* <li> <code>com::sun::star::java::XJavaVM</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.java.XJavaThreadRegister_11 +* @see com.sun.star.java.XJavaVM +* @see com.sun.star.java.XJavaVirtualMachine +* @see ifc.java._XJavaThreadRegister_11 +* @see ifc.java._XJavaVM +*/ +public class JavaVirtualMachine extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.java.JavaVirtualMachine</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.java.JavaVirtualMachine"); + + return new TestEnvironment(xInt); + } +} diff --git a/qadevOOo/tests/java/mod/_jen/package.html b/qadevOOo/tests/java/mod/_jen/package.html new file mode 100644 index 000000000..639ba6ade --- /dev/null +++ b/qadevOOo/tests/java/mod/_jen/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 'jen'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_lng/DicList.java b/qadevOOo/tests/java/mod/_lng/DicList.java new file mode 100644 index 000000000..a787d79bc --- /dev/null +++ b/qadevOOo/tests/java/mod/_lng/DicList.java @@ -0,0 +1,97 @@ +/* + * 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._lng; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.Locale; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.linguistic2.XDictionary; +import com.sun.star.linguistic2.XDictionaryList; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.lingu2.DicList</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::linguistic2::XSearchableDictionaryList</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::linguistic2::XDictionaryList</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.linguistic2.XSearchableDictionaryList + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.linguistic2.XDictionaryList + * @see ifc.linguistic2._XSearchableDictionaryList + * @see ifc.lang._XComponent + * @see ifc.lang._XServiceInfo + * @see ifc.linguistic2._XDictionaryList + */ +public class DicList extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.lingu2.DicList</code>. Then two dictionaries + * are created (positive and negative) and added to the list, one + * entry is added to each of dictionaries and they both are activated. + * The dictionary list is returned as a component for testing. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance("com.sun.star.lingu2.DicList"); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //creating a user defined dictionary for XSearchableDictionaryList + XDictionaryList xDicList = UnoRuntime.queryInterface( + XDictionaryList.class, oObj); + xDicList.removeDictionary(xDicList.getDictionaryByName("MyDictionary")); + XDictionary xDic = xDicList.createDictionary("NegativDic",new Locale( + "en","US","WIN"),com.sun.star.linguistic2.DictionaryType.NEGATIVE,""); + XDictionary xDic2 = xDicList.createDictionary("PositivDic",new Locale( + "en","US","WIN"),com.sun.star.linguistic2.DictionaryType.POSITIVE,""); + xDic2.add("Positive",false,""); + xDic.add("Negative",true,""); + xDicList.addDictionary(xDic); + xDicList.addDictionary(xDic2); + xDic.setActive(true); + xDic2.setActive(true); + + return tEnv; + } + +} // finish class DicList + diff --git a/qadevOOo/tests/java/mod/_lng/LinguProps.java b/qadevOOo/tests/java/mod/_lng/LinguProps.java new file mode 100644 index 000000000..f5097cba4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_lng/LinguProps.java @@ -0,0 +1,82 @@ +/* + * 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._lng; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.linguistic2.LinguProperties</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::beans::XFastPropertySet</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::linguistic2::LinguProperties</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.beans.XFastPropertySet + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.linguistic2.LinguProperties + * @see ifc.lang._XComponent + * @see ifc.lang._XServiceInfo + * @see ifc.beans._XFastPropertySet + * @see ifc.beans._XPropertySet + * @see ifc.linguistic2._LinguProperties + */ +public class LinguProps extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.linguistic2.LinguProperties</code>. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance + ("com.sun.star.linguistic2.LinguProperties"); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + +} // finish class LinguProps + diff --git a/qadevOOo/tests/java/mod/_lng/LngSvcMgr.java b/qadevOOo/tests/java/mod/_lng/LngSvcMgr.java new file mode 100644 index 000000000..ff234d823 --- /dev/null +++ b/qadevOOo/tests/java/mod/_lng/LngSvcMgr.java @@ -0,0 +1,76 @@ +/* + * 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._lng; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.linguistic2.LinguServiceManager</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::linguistic2::XLinguServiceManager</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XComponent + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.linguistic2.XLinguServiceManager + * @see ifc.lang._XComponent + * @see ifc.lang._XServiceInfo + * @see ifc.linguistic2._XLinguServiceManager + */ +public class LngSvcMgr extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.linguistic2.LinguServiceManager</code>. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance + ("com.sun.star.linguistic2.LinguServiceManager"); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + +} // finish class LngSvcMgr + diff --git a/qadevOOo/tests/java/mod/_lnn/Hyphenator.java b/qadevOOo/tests/java/mod/_lnn/Hyphenator.java new file mode 100644 index 000000000..40577a211 --- /dev/null +++ b/qadevOOo/tests/java/mod/_lnn/Hyphenator.java @@ -0,0 +1,94 @@ +/* + * 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._lnn; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.linguistic2.Hyphenator</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::linguistic2::XHyphenator</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::linguistic2::XSupportedLocales</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::lang::XServiceDisplayName</code></li> + * <li> <code>com::sun::star::linguistic2::XLinguServiceEventBroadcaster</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.linguistic2.XHyphenator + * @see com.sun.star.lang.XComponent + * @see com.sun.star.linguistic2.XSupportedLocales + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.lang.XServiceDisplayName + * @see com.sun.star.linguistic2.XLinguServiceEventBroadcaster + * @see ifc.lang._XInitialization + * @see ifc.linguistic2._XHyphenator + * @see ifc.lang._XComponent + * @see ifc.linguistic2._XSupportedLocales + * @see ifc.lang._XServiceInfo + * @see ifc.lang._XServiceDisplayName + * @see ifc.linguistic2._XLinguServiceEventBroadcaster + */ +public class Hyphenator extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.linguistic2.Hyphenator</code>. + * Then a property for using new German rules for hyphenation + * is set. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance + ("com.sun.star.linguistic2.Hyphenator"); + Object LP = xMSF.createInstance + ("com.sun.star.linguistic2.LinguProperties"); + XPropertySet LProps = UnoRuntime.queryInterface(XPropertySet.class,LP); + LProps.setPropertyValue("IsGermanPreReform",Boolean.TRUE); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + +} // finish class Hyphenator + diff --git a/qadevOOo/tests/java/mod/_lnn/SpellChecker.java b/qadevOOo/tests/java/mod/_lnn/SpellChecker.java new file mode 100644 index 000000000..2c16edb8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_lnn/SpellChecker.java @@ -0,0 +1,92 @@ +/* + * 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._lnn; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.linguistic2.XLinguServiceManager; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.linguistic2.SpellChecker</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::linguistic2::XSupportedLocales</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::linguistic2::XSpellChecker</code></li> + * <li> <code>com::sun::star::lang::XServiceDisplayName</code></li> + * <li> <code>com::sun::star::linguistic2::XLinguServiceEventBroadcaster</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.lang.XComponent + * @see com.sun.star.linguistic2.XSupportedLocales + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.linguistic2.XSpellChecker + * @see com.sun.star.lang.XServiceDisplayName + * @see com.sun.star.linguistic2.XLinguServiceEventBroadcaster + * @see ifc.lang._XInitialization + * @see ifc.lang._XComponent + * @see ifc.linguistic2._XSupportedLocales + * @see ifc.lang._XServiceInfo + * @see ifc.linguistic2._XSpellChecker + * @see ifc.lang._XServiceDisplayName + * @see ifc.linguistic2._XLinguServiceEventBroadcaster + */ +public class SpellChecker extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.linguistic2.SpellChecker</code>. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance + ("com.sun.star.lingu2.SpellChecker"); + Object LinguServiceManager = xMSF.createInstance + ("com.sun.star.linguistic2.LinguServiceManager"); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + XLinguServiceManager xLinguServiceManager = UnoRuntime.queryInterface(XLinguServiceManager.class, LinguServiceManager); + tEnv.addObjRelation("AlternativeChecker",xLinguServiceManager.getSpellChecker()); + + return tEnv; + } + +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_lnn/Thesaurus.java b/qadevOOo/tests/java/mod/_lnn/Thesaurus.java new file mode 100644 index 000000000..c41d2f169 --- /dev/null +++ b/qadevOOo/tests/java/mod/_lnn/Thesaurus.java @@ -0,0 +1,82 @@ +/* + * 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._lnn; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.linguistic2.Thesaurus</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::linguistic2::XSupportedLocales</code></li> + * <li> <code>com::sun::star::linguistic2::XThesaurus</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::lang::XServiceDisplayName</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.lang.XComponent + * @see com.sun.star.linguistic2.XSupportedLocales + * @see com.sun.star.linguistic2.XThesaurus + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.lang.XServiceDisplayName + * @see ifc.lang._XInitialization + * @see ifc.lang._XComponent + * @see ifc.linguistic2._XSupportedLocales + * @see ifc.linguistic2._XThesaurus + * @see ifc.lang._XServiceInfo + * @see ifc.lang._XServiceDisplayName + */ +public class Thesaurus extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.linguistic2.Thesaurus</code>. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface oObj = (XInterface)xMSF.createInstance + ("com.sun.star.linguistic2.Thesaurus"); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_mcnttype/MimeContentTypeFactory.java b/qadevOOo/tests/java/mod/_mcnttype/MimeContentTypeFactory.java new file mode 100644 index 000000000..771f3e9e2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_mcnttype/MimeContentTypeFactory.java @@ -0,0 +1,71 @@ +/* + * 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._mcnttype; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.mcnttype.MimeContentTypeFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::datatransfer::XMimeContentTypeFactory</code></li> +* <li> <code>com::sun::star::lang::XServiceInfo</code></li> +* <li> <code>com::sun::star::lang::XTypeProvider</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.datatransfer.XMimeContentTypeFactory +* @see com.sun.star.lang.XServiceInfo +* @see com.sun.star.lang.XTypeProvider +* @see com.sun.star.mcnttype.MimeContentTypeFactory +* @see ifc.datatransfer._XMimeContentTypeFactory +* @see ifc.lang._XServiceInfo +* @see ifc.lang._XTypeProvider +*/ +public class MimeContentTypeFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.datatransfer.MimeContentTypeFactory</code>. <p> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.datatransfer.MimeContentTypeFactory" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_namingservice/NamingService.java b/qadevOOo/tests/java/mod/_namingservice/NamingService.java new file mode 100644 index 000000000..5e2d70550 --- /dev/null +++ b/qadevOOo/tests/java/mod/_namingservice/NamingService.java @@ -0,0 +1,88 @@ +/* + * 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._namingservice; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.uno.NamingService</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::uno::XNamingService</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.uno.XNamingService +* @see com.sun.star.uno.NamingService +* @see ifc.uno._XNamingService +*/ +public class NamingService extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.uno.NamingService</code>. + * Object relations created : + * <ul> + * <li> <code>'XNamingService.RegisterObject'</code> for + * {@link ifc.uno._XNamingService} : an object + * which can be registered. Here it is an instance + * of <code>com.sun.star.lang.ServiceManager</code> + * service.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.uno.NamingService" ); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // objRelation for XNamingService as object to be registered + tEnv.addObjRelation("XNamingService.RegisterObject", + Param.getMSF().createInstance + ("com.sun.star.lang.ServiceManager")) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_namingservice/package.html b/qadevOOo/tests/java/mod/_namingservice/package.html new file mode 100644 index 000000000..3ac1e50ad --- /dev/null +++ b/qadevOOo/tests/java/mod/_namingservice/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 'namingservice'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_namingservice/uno/NamingService.java b/qadevOOo/tests/java/mod/_namingservice/uno/NamingService.java new file mode 100644 index 000000000..3c33d8272 --- /dev/null +++ b/qadevOOo/tests/java/mod/_namingservice/uno/NamingService.java @@ -0,0 +1,85 @@ +/* + * 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._namingservice.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.uno.NamingService</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::uno::XNamingService</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.uno.XNamingService +* @see com.sun.star.uno.NamingService +* @see ifc.uno._XNamingService +*/ +public class NamingService extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.uno.NamingService</code>. + * Object relations created : + * <ul> + * <li> <code>'XNamingService.RegisterObject'</code> for + * {@link ifc.uno._XNamingService} : an object + * which can be registered. Here it is an instance + * of <code>com.sun.star.lang.ServiceManager</code> + * service.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null; + XMultiServiceFactory xMSF = null; + + try { + xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.uno.NamingService" ); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // objRelation for XNamingService as object to be registered + tEnv.addObjRelation("XNamingService.RegisterObject", + xMSF.createInstance + ("com.sun.star.lang.ServiceManager")) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_nestedreg/uno/NestedRegistry.java b/qadevOOo/tests/java/mod/_nestedreg/uno/NestedRegistry.java new file mode 100644 index 000000000..b546d56d4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_nestedreg/uno/NestedRegistry.java @@ -0,0 +1,197 @@ +/* + * 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._nestedreg.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.XInterface; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.RegistryTools; +import util.utils; + +/** +* Test for object which is represented by service +* <code>com.sun.star.registry.NestedRegistry</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::registry::XSimpleRegistry</code></li> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> XSimpleRegistry.rdb </b> : Registry file created before. </li> +* <li><b> XSimpleRegistry_open#.rdb </b> : Temporary registry file as copy of +* <b> XSimpleRegistry.rdb </b> in the SOffice temp directory. +* ('#' - is an ordinary number) </li> +* <li><b> XSimpleRegistry_merge#.rdb </b> : Temporary registry file as copy of +* <b> XSimpleRegistry.rdb </b> in the SOffice temp directory. +* ('#' - is an ordinary number) </li> +* </ul> <p> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.registry.XSimpleRegistry +* @see com.sun.star.lang.XInitialization +* @see ifc.registry._XSimpleRegistry +* @see ifc.lang._XInitialization +*/ +public class NestedRegistry extends TestCase { + + protected static int uniq = 0 ; + XSimpleRegistry reg1; + XSimpleRegistry reg2; + + @Override + public synchronized void disposeTestEnvironment( TestEnvironment tEnv, + TestParameters tParam ) { + try { + reg1.destroy(); + reg2.destroy(); + } + catch (com.sun.star.registry.InvalidRegistryException e) { + System.out.println("caught exception: " + e); + } + } + + /** + * Creates a temporary copy of file, which is deleted when VM exits. + * @param src Source file path. + * @param dst Destination file path. + * @throws java.io.IOException If any problems occur during copying. + */ + protected void copyFile(String src, String dst) + throws java.io.IOException { + File srcF = new File(src) ; + File dstF = new File(dst) ; + + if (dstF.exists()) { + boolean bDeleteOk = dstF.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + + boolean bCreateOk = dstF.createNewFile() ; + if (!bCreateOk) { + System.out.println("create failed"); + } + + dstF.deleteOnExit() ; + + FileInputStream fIn = new FileInputStream(srcF) ; + FileOutputStream fOut = new FileOutputStream(dstF) ; + + byte[] buf = new byte[1024] ; + int bytesRead = 0 ; + while ((bytesRead = fIn.read(buf)) > 0) { + fOut.write(buf, 0, bytesRead) ; + } + + fIn.close() ; + fOut.close() ; + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two temporary copies of registry file created before, opens + * them, and creates service <code>com.sun.star.comp.stoc.NestedRegistry</code> + * with these two registries. <p> + * Object relations created : + * <ul> + * <li> <code>'NR'</code> for {@link ifc.registry._XSimpleRegistry} : + * Just informs interface test that <code>NestedRegistry</code> + * service is tested. If this relation exists, then some methods + * are not supported. The relation is a <code>String</code> with + * object name.</li> + * <li> <code>'XSimpleRegistry.open'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * <li> <code>'XSimpleRegistry.destroy'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * <li> <code>'XSimpleRegistry.merge'</code> for + * {@link ifc.registry._XSimpleRegistry} + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null; + + final String tmpDir = utils.getOfficeTempDirSys( + Param.getMSF()) ; + final String openF = tmpDir + "XSimpleRegistry_open" + uniq + ".rdb" ; + final String destroyF = tmpDir + + "XSimpleRegistry_destroy" + uniq + ".rdb" ; + final String mergeF = tmpDir + "XSimpleRegistry_merge" + uniq + ".rdb" ; + uniq++ ; + + log.println("creating copies of the registry for XSimpleRegistry"); + String source = utils.getFullTestDocName("XSimpleRegistry.rdb"); + copyFile(source, openF) ; + copyFile(source, mergeF) ; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + reg1 = RegistryTools. + createRegistryService(xMSF) ; + reg1.open(mergeF, false, true) ; + reg2 = RegistryTools. + createRegistryService(xMSF) ; + reg2.open(openF, false, true) ; + XSimpleRegistry[] arg = new XSimpleRegistry[2]; + arg[0]=reg1; + arg[1]=reg2; + oInterface = xMSF.createInstanceWithArguments + ( "com.sun.star.comp.stoc.NestedRegistry", arg ); + } + catch( Exception e ) { + log.println("Introspection Service not available" ); + } + oObj = (XInterface) oInterface; + + + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("NR","NestedRegistry"); + + tEnv.addObjRelation("XSimpleRegistry.open", openF) ; + tEnv.addObjRelation("XSimpleRegistry.merge", mergeF) ; + tEnv.addObjRelation("XSimpleRegistry.destroy", destroyF) ; + + return tEnv; + } // finish method getTestEnvironment + + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + + } + +} // finish class NestedRegistry + diff --git a/qadevOOo/tests/java/mod/_nestedreg/uno/package.html b/qadevOOo/tests/java/mod/_nestedreg/uno/package.html new file mode 100644 index 000000000..bee4740a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_nestedreg/uno/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 'defreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_odbc/ODBCDriver.java b/qadevOOo/tests/java/mod/_odbc/ODBCDriver.java new file mode 100644 index 000000000..03a2108e1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_odbc/ODBCDriver.java @@ -0,0 +1,85 @@ +/* + * 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._odbc; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.XInterface; + +/** + * Here <code>com.sun.star.sdbc.Driver</code> service is tested.<p> + * Test allows to run object tests in several threads concurrently. + * @see com.sun.star.sdbc.Driver + * @see com.sun.star.sdbc.XDriver + * @see ifc.sdbc._XDriver + */ +public class ODBCDriver extends TestCase { + /** + * Creates an instance of the service + * <code>com.sun.star.sdbc.Driver</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'XDriver.URL'</code> for {@link ifc.sdbc._XDriver}: + * is the URL of the database to which to connect. + * The URL is obtained from the parameter <code>odbc.url</code></li> + * <li> <code>'XDriver.UNSUITABLE_URL'</code> for {@link ifc.sdbc._XDriver}: + * the wrong kind of URL to connect using given driver. + * The URL is obtained from the parameter <code>jdbc.url</code></li> + * <li> <code>'XDriver.INFO'</code> for {@link ifc.sdbc._XDriver}: + * a list of arbitrary string tag/value pairs as connection arguments. + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface)Param.getMSF().createInstance( + "com.sun.star.comp.sdbc.ODBCDriver"); + + log.println("creating a new environment for ODBCDriver object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding relation for sdbc.XDriver + String odbcURL = (String) Param.get("odbc.url"); + if (odbcURL == null) { + throw new StatusException(Status.failed( + "Couldn't get 'odbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.URL", "sdbc:odbc:" + odbcURL); + + PropertyValue[] info = new PropertyValue[0]; + tEnv.addObjRelation("XDriver.INFO", info); + + String jdbcUrl = (String) Param.get("jdbc.url"); + if (jdbcUrl == null) { + throw new StatusException(Status.failed( + "Couldn't get 'jdbc.url' from ini-file")); + } + tEnv.addObjRelation("XDriver.UNSUITABLE_URL", "jdbc:" + jdbcUrl); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_pcr/ObjectInspector.java b/qadevOOo/tests/java/mod/_pcr/ObjectInspector.java new file mode 100644 index 000000000..d226e6bb3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_pcr/ObjectInspector.java @@ -0,0 +1,191 @@ +/* + * 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._pcr; + +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XFrames; +import com.sun.star.frame.XFramesSupplier; +import com.sun.star.inspection.XObjectInspector; +import com.sun.star.inspection.XObjectInspectorModel; +import com.sun.star.lang.XInitialization; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.CloseVetoException; +import com.sun.star.util.XCloseable; +import helper.PropertyHandlerImpl; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import util.DesktopTools; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.reflection.ObjectInspector</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::inspection::XObjectInspector</code></li> + * <li> <code>com::sun::star::frame::XController</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.inspection.XObjectInspector + * @see com.sun.star.frame.XController + */ +public class ObjectInspector extends TestCase { + + /** + * module variable which holds the Desktop + * @see com.sun.star.frame.Desktop + */ + protected static XDesktop xDesktop = null; + + /** + * assign to the module variable <CODE>xDesktop</CODE> the desktop + * @param Param the test parameters + * @param log the log writer + * @see lib.TestParameters + * @see share.LogWriter + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("create a desktop..."); + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.inspection.ObjectInspector</code> and adds it to + * a floating frame.<br> + * To test <CODE>com.sun.star.inspection.XObjectInspector.inspect()</CODE> + * an own implementation of + * <CODE>com.sun.star.inspection.XPropertyHandler</CODE> was used. + * @param tParam the tests parameter + * @param log the logger + * @return the test environment + * @see util.DesktopTools + * @see helper.PropertyHandlerImpl + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + this.cleanup(tParam, log); + + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface oInspector = (XInterface) xMSF.createInstance("com.sun.star.inspection.ObjectInspector"); + + XObjectInspector xInspector = UnoRuntime.queryInterface(XObjectInspector.class, oInspector); + + log.println("ImplementationName '" + utils.getImplName(xInspector) + "'"); + + XInterface oInspectorModel = (XInterface) xMSF.createInstance("com.sun.star.inspection.ObjectInspectorModel"); + + XObjectInspectorModel xInspectorModel = UnoRuntime.queryInterface(XObjectInspectorModel.class, oInspectorModel); + + XInterface oInspectorModelToSet = (XInterface) xMSF.createInstance("com.sun.star.inspection.ObjectInspectorModel"); + + XObjectInspectorModel xInspectorModelToSet = UnoRuntime.queryInterface(XObjectInspectorModel.class, oInspectorModelToSet); + + + log.println("create a floating frame..."); + + XWindowPeer xWindowPeer = DesktopTools.createFloatingWindow(xMSF); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer); + + XInterface oFrame = (XInterface) xMSF.createInstance("com.sun.star.frame.Frame"); + + XFrame xFrame = UnoRuntime.queryInterface(XFrame.class, oFrame); + + xFrame.setName("ObjectInspector"); + xFrame.initialize(xWindow); + + XFramesSupplier xFramesSup = UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop); + + XFrames xFrames = xFramesSup.getFrames(); + xFrames.append(xFrame); + + + log.println("attach ObjectInspector to floating frame..."); + + XInitialization xOII = UnoRuntime.queryInterface(XInitialization.class, xInspectorModel); + + xOII.initialize(new Object[0]); + + xInspector.setInspectorModel(xInspectorModel); + + // for debug purposes the following lines could commented out. But in + // this case the com.sun.star.frame.XController would be failed! + //xInspector.attachFrame(xFrame); + //xWindow.setVisible(true); + + Object[] oInspect = new Object[1]; + oInspect[0] = new PropertyHandlerImpl(); + + TestEnvironment tEnv = new TestEnvironment(xInspector); + + // com.sun.star.frame.XController + tEnv.addObjRelation("Frame",xFrame); + + tEnv.addObjRelation("XObjectInspector.toInspect", oInspect); + + tEnv.addObjRelation("XObjectInspector.InspectorModelToSet", xInspectorModelToSet); + + return tEnv; + } + + /** + * Closes the ObjectOnspector using <CODE>XCloseable</CODE> + * @see com.sun.star.util.XCloseable + * @param Param the test parameter + * @param log the logger + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog if one exists ... "); + + XFrame existentInspector = null; + + XFrame xFrame = UnoRuntime.queryInterface(XFrame.class, xDesktop); + + existentInspector = xFrame.findFrame( "ObjectInspector", 255 ); + + if ( existentInspector != null ){ + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, existentInspector); + try{ + closer.close(true); + } catch (CloseVetoException e){ + log.println("Could not close inspector: " + e.toString()); + } + } + } +} diff --git a/qadevOOo/tests/java/mod/_pcr/ObjectInspectorModel.java b/qadevOOo/tests/java/mod/_pcr/ObjectInspectorModel.java new file mode 100644 index 000000000..a87d0d740 --- /dev/null +++ b/qadevOOo/tests/java/mod/_pcr/ObjectInspectorModel.java @@ -0,0 +1,147 @@ +/* + * 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._pcr; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XFrame; +import com.sun.star.inspection.XObjectInspectorModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.util.CloseVetoException; +import com.sun.star.util.XCloseable; +import helper.PropertyHandlerFactroy; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import util.DesktopTools; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.reflection.ObjectInspectorModel</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::inspection::XObjectInspectorModel</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.inspection.XObjectInspectorModel + */ +public class ObjectInspectorModel extends TestCase { + + /** + * module variable which holds the Desktop + * @see com.sun.star.frame.Desktop + */ + protected static XDesktop xDesktop = null; + + /** + * assign to the module variable <CODE>xDesktop</CODE> the desktop + * @param Param the test parameters + * @param log the log writer + * @see lib.TestParameters + * @see share.LogWriter + * @see com.sun.star.frame.Desktop + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("create a desktop..."); + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.inspection.ObjectInspectorModel</code> with a <code>DefaultContext</code> and + * <code>PropertyHandlerFactroy[]</code> as parameter + * + * @param tParam the tests parameter + * @param log the logger + * @return the test environment + * @see util.DesktopTools + * @see helper.PropertyHandlerImpl + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + this.cleanup(tParam, log); + + XMultiServiceFactory xMSF = tParam.getMSF(); + + XPropertySet xMSFProp = UnoRuntime.queryInterface(XPropertySet.class, xMSF); + XComponentContext xDefaultContext = null; + // Get the default context from the office server. + Object oDefaultContext = xMSFProp.getPropertyValue("DefaultContext"); + + // Query for the interface XComponentContext. + xDefaultContext = UnoRuntime.queryInterface( + XComponentContext.class, oDefaultContext); + + Object[] oHandlerFactories = new Object[1]; + oHandlerFactories[0] = new PropertyHandlerFactroy(); + + int minHelpTextLines = 200; + int maxHelpTextLines = 400; + + XObjectInspectorModel oInspectorModel = com.sun.star.inspection.ObjectInspectorModel. + createWithHandlerFactoriesAndHelpSection(xDefaultContext, oHandlerFactories, + minHelpTextLines, maxHelpTextLines); + + log.println("ImplementationName '" + utils.getImplName(oInspectorModel) + "'"); + + TestEnvironment tEnv = new TestEnvironment(oInspectorModel); + + // com.sun.star.inspection.XObjectInspectorModel + tEnv.addObjRelation("minHelpTextLines", Integer.valueOf(minHelpTextLines)); + tEnv.addObjRelation("maxHelpTextLines", Integer.valueOf(maxHelpTextLines)); + + return tEnv; + } + + /** + * Closes the ObjectOnspector using <CODE>XCloseable</CODE> + * @see com.sun.star.util.XCloseable + * @param Param the test parameter + * @param log the logger + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog if one exists ... "); + + XFrame existentInspector = null; + + XFrame xFrame = UnoRuntime.queryInterface(XFrame.class, xDesktop); + + existentInspector = xFrame.findFrame( "ObjectInspector", 255 ); + + if ( existentInspector != null ){ + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, existentInspector); + try{ + closer.close(true); + } catch (CloseVetoException e){ + log.println("Could not close inspector: " + e.toString()); + } + } + } +} diff --git a/qadevOOo/tests/java/mod/_proxyfac/ProxyFactory.java b/qadevOOo/tests/java/mod/_proxyfac/ProxyFactory.java new file mode 100644 index 000000000..c04679c90 --- /dev/null +++ b/qadevOOo/tests/java/mod/_proxyfac/ProxyFactory.java @@ -0,0 +1,63 @@ +/* + * 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._proxyfac; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.ProxyFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::reflection::XProxyFactory</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.reflection.XProxyFactory +* @see com.sun.star.reflection.ProxyFactory +* @see ifc.reflection._XProxyFactory +*/ +public class ProxyFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.reflection.ProxyFactory</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.reflection.ProxyFactory"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_proxyfac/package.html b/qadevOOo/tests/java/mod/_proxyfac/package.html new file mode 100644 index 000000000..c563073c0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_proxyfac/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 'proxyfac'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_proxyfac/uno/ProxyFactory.java b/qadevOOo/tests/java/mod/_proxyfac/uno/ProxyFactory.java new file mode 100644 index 000000000..f9fdb4e9a --- /dev/null +++ b/qadevOOo/tests/java/mod/_proxyfac/uno/ProxyFactory.java @@ -0,0 +1,61 @@ +/* + * 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._proxyfac.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.ProxyFactory</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::reflection::XProxyFactory</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.reflection.XProxyFactory +* @see com.sun.star.reflection.ProxyFactory +* @see ifc.reflection._XProxyFactory +*/ +public class ProxyFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.reflection.ProxyFactory</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.reflection.ProxyFactory"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_rdbtdp/RegistryTypeDescriptionProvider.java b/qadevOOo/tests/java/mod/_rdbtdp/RegistryTypeDescriptionProvider.java new file mode 100644 index 000000000..3c1e5a7cb --- /dev/null +++ b/qadevOOo/tests/java/mod/_rdbtdp/RegistryTypeDescriptionProvider.java @@ -0,0 +1,115 @@ +/* + * 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._rdbtdp; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +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.XComponentContext; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.TypeDescriptionProvider</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XHierarchicalNameAccess</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.container.XHierarchicalNameAccess +* @see com.sun.star.lang.XComponent +* @see com.sun.star.reflection.TypeDescriptionProvider +* @see ifc.container._XHierarchicalNameAccess +* @see ifc.lang._XComponent +*/ +public class RegistryTypeDescriptionProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.reflection.TypeDescriptionProvider</code>. + * Object relations created : + * <ul> + * <li> <code>'ElementName'</code> for + * {@link ifc.container._XHierarchicalNameAccess} : + * name of the existing element. Here it type name for + * <code>com.sun.star.uno.XInterface</code> interface.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, xMSF); + // get context + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, + xProp.getPropertyValue("DefaultContext")); + // get the type description manager + Object o = xContext.getValueByName("/singletons/" + + "com.sun.star.reflection.theTypeDescriptionManager"); + // the manager contains all providers + XEnumerationAccess aProviderAccess = UnoRuntime.queryInterface(XEnumerationAccess.class, o); + // collect enumeration + XEnumeration xProviderEnum; + if (aProviderAccess.hasElements()) + xProviderEnum = aProviderAccess.createEnumeration(); + else + throw new lib.StatusException(Status.failed( + "No TypeDescriptionProvider given")); + // take the first registry type description provider + oInterface = xProviderEnum.nextElement(); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oInterface); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XHierarchicalNameAccess + tEnv.addObjRelation("ElementName", "com.sun.star.uno.XInterface") ; + tEnv.addObjRelation("SearchString", "com.sun.star.loader"); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_rdbtdp/package.html b/qadevOOo/tests/java/mod/_rdbtdp/package.html new file mode 100644 index 000000000..19cdd22c6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_rdbtdp/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 'rdbtdp'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_regtypeprov/uno/RegistryTypeDescriptionProvider.java b/qadevOOo/tests/java/mod/_regtypeprov/uno/RegistryTypeDescriptionProvider.java new file mode 100644 index 000000000..553578d00 --- /dev/null +++ b/qadevOOo/tests/java/mod/_regtypeprov/uno/RegistryTypeDescriptionProvider.java @@ -0,0 +1,110 @@ +/* + * 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._regtypeprov.uno; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import java.io.PrintWriter; +import lib.Status; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.reflection.TypeDescriptionProvider</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XHierarchicalNameAccess</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.container.XHierarchicalNameAccess +* @see com.sun.star.lang.XComponent +* @see com.sun.star.reflection.TypeDescriptionProvider +* @see ifc.container._XHierarchicalNameAccess +* @see ifc.lang._XComponent +*/ +public class RegistryTypeDescriptionProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.reflection.TypeDescriptionProvider</code>. + * Object relations created : + * <ul> + * <li> <code>'ElementName'</code> for + * {@link ifc.container._XHierarchicalNameAccess} : + * name of the existing element. Here it type name for + * <code>com.sun.star.uno.XInterface</code> interface.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, xMSF); + // get context + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, + xProp.getPropertyValue("DefaultContext")); + // get the type description manager + Object o = xContext.getValueByName("/singletons/" + + "com.sun.star.reflection.theTypeDescriptionManager"); + // the manager contains all providers + XEnumerationAccess aProviderAccess = UnoRuntime.queryInterface(XEnumerationAccess.class, o); + // collect enumeration + XEnumeration xProviderEnum; + if (aProviderAccess.hasElements()) + xProviderEnum = aProviderAccess.createEnumeration(); + else + throw new lib.StatusException(Status.failed( + "No TypeDescriptionProvider given")); + // take the first registry type description provider + oInterface = xProviderEnum.nextElement(); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oInterface); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XHierarchicalNameAccess + tEnv.addObjRelation("ElementName", "com.sun.star.uno.XInterface") ; + tEnv.addObjRelation("SearchString", "com.sun.star.loader"); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_remotebridge/package.html b/qadevOOo/tests/java/mod/_remotebridge/package.html new file mode 100644 index 000000000..0663f0cb2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_remotebridge/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 'remotebridge'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_remotebridge/uno/various.java b/qadevOOo/tests/java/mod/_remotebridge/uno/various.java new file mode 100644 index 000000000..b9bc78696 --- /dev/null +++ b/qadevOOo/tests/java/mod/_remotebridge/uno/various.java @@ -0,0 +1,266 @@ +/* + * 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._remotebridge.uno; + +import com.sun.star.bridge.XBridgeFactory; +import com.sun.star.bridge.XInstanceProvider; +import com.sun.star.connection.XAcceptor; +import com.sun.star.connection.XConnection; +import com.sun.star.connection.XConnector; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.bridge.Bridge</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::bridge::XBridge</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.lang.XComponent +* @see com.sun.star.bridge.XBridge +* @see com.sun.star.bridge.Bridge +* @see ifc.lang._XInitialization +* @see ifc.lang._XComponent +* @see ifc.bridge._XBridge +*/ +public class various extends TestCase { + + /** + * String for establishing a connection + */ + protected String connectString = null ; + + /** + * Choose the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 50000; + private static final int curPort = 50000; + + private XAcceptor xAcctr; + private XConnector xCntr; + private XBridgeFactory xBrdgFctr; + private AcceptorThread accThread; + + public XInterface bridge = null; + + /** + * Implementation of interface XInstanceProvider + * + * @see com.sun.star.bridge.XInstanceProvider + */ + private static class MyInstanceProvider implements XInstanceProvider { + /** + * a MultiServiceFactory for creating instances + * + * @see com.sun.star.lang.MultiServiceFactory + */ + private final XMultiServiceFactory xMSF; + + /** + * Construct object with a MultiServiceFactory + * + * @see com.sun.star.lang.MultiServiceFactory + */ + private MyInstanceProvider(XMultiServiceFactory xMSF) { + this.xMSF = xMSF; + } + + /** + * get an instance by name + */ + public Object getInstance(String aInstanceName) + throws com.sun.star.container.NoSuchElementException + { + System.out.println("######## Try to get "+aInstanceName); + try { + return xMSF.createInstance(aInstanceName); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Unexpected exception", e); + } + } + } + + /** + * Calls <code>accept()</code> method in a separate thread. + * Then stores exception thrown by call if it occurred, or + * return value. + */ + private class AcceptorThread extends Thread { + private final XAcceptor acc; + private final XInstanceProvider xInstProv; + private final XBridgeFactory xBrdgFctr; + /** + * If method call returns some value it stores in this field. + */ + private XConnection acceptedCall = null ; + + /** + * Creates object which can call <code>accept</code> method + * of the Acceptor object specified. + */ + private AcceptorThread(XAcceptor acc, XInstanceProvider xInstProv, + XBridgeFactory xBrdgFctr) { + this.acc = acc ; + this.xInstProv = xInstProv; + this.xBrdgFctr = xBrdgFctr; + } + + /** + * Call <code>accept()</code> method and establish a bridge with an + * instance provider + */ + @Override + public void run() { + try { + acceptedCall = acc.accept(connectString) ; + xBrdgFctr.createBridge("MyBridge", "urp", + acceptedCall, xInstProv); + } catch (com.sun.star.connection.ConnectionSetupException e) { + } catch (com.sun.star.connection.AlreadyAcceptingException e) { + } catch (com.sun.star.bridge.BridgeExistsException e) { + } + } + } + + private final boolean[] bridgeDisposed = new boolean[1] ; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.bridge.Bridge</code>. + * Object relations created : + * <ul> + * <li> <code>'XInitialization.args'</code> for + * {@link ifc.lang._XInitialization} and + * {@link ifc.bridge._XBridge} : contains arguments + * for <code>initialize()</code> method test.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.Bridge"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + // creating arguments for XInitialization + // first, creating a connection + // connection string + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + + // select the port + log.println("Choose Port nr: " + curPort); + + connectString = "socket,host=" + + cncstr.substring(idx, cncstr.indexOf(",", idx)) + + ",port=" + curPort; + + // create acceptor + XInterface oAcctr = (XInterface)xMSF.createInstance( + "com.sun.star.connection.Acceptor") ; + + xAcctr = UnoRuntime.queryInterface( + XAcceptor.class, oAcctr); + // create connector + XInterface oCntr = (XInterface)xMSF.createInstance( + "com.sun.star.connection.Connector") ; + xCntr = UnoRuntime.queryInterface( + XConnector.class, oCntr); + + // create bridge factory + XInterface oBrdg = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.BridgeFactory") ; + xBrdgFctr = UnoRuntime.queryInterface(XBridgeFactory.class, oBrdg); + + // create own implementation of XInstanceProvider + XInstanceProvider xInstProv = new MyInstanceProvider(xMSF); + // create waiting acceptor thread + accThread = new AcceptorThread(xAcctr, xInstProv, xBrdgFctr); + accThread.start(); + // let the thread sleep + util.utils.pause(500); + + // establish the connection + XConnection xConnection = xCntr.connect(connectString); + + String protocol = "urp"; + String bridgeName = protocol + ":" + connectString; + + tEnv.addObjRelation("XInitialization.args", new Object[] { + bridgeName, protocol, xConnection, null}); + + bridge = tEnv.getTestObject(); + + return tEnv; + } + + /** + * Stop the acceptor thread and dispose the bridge + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + + System.out.println("++++++++ cleanup"); + xAcctr.stopAccepting(); + if (accThread.isAlive()) { + accThread.interrupt(); + } + XComponent xComp = UnoRuntime.queryInterface( + XComponent.class, xAcctr); + if (xComp != null) + xComp.dispose(); + xComp = UnoRuntime.queryInterface( + XComponent.class, xCntr); + if (xComp != null) + xComp.dispose(); + xComp = UnoRuntime.queryInterface( + XComponent.class, xBrdgFctr); + if (xComp != null) + xComp.dispose(); + + xComp = UnoRuntime.queryInterface( + XComponent.class, bridge); + if (xComp != null) { + System.out.println("######## Dispose bridge"); + bridgeDisposed[0] = true; + xComp.dispose(); + // wait for dispose + util.utils.pause(5000); + } + } +} diff --git a/qadevOOo/tests/java/mod/_remotebridge/various.java b/qadevOOo/tests/java/mod/_remotebridge/various.java new file mode 100644 index 000000000..6e11c46ba --- /dev/null +++ b/qadevOOo/tests/java/mod/_remotebridge/various.java @@ -0,0 +1,213 @@ +/* + * 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._remotebridge; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.bridge.XBridgeFactory; +import com.sun.star.connection.XAcceptor; +import com.sun.star.connection.XConnection; +import com.sun.star.connection.XConnector; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.bridge.Bridge</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XInitialization</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::bridge::XBridge</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.lang.XInitialization +* @see com.sun.star.lang.XComponent +* @see com.sun.star.bridge.XBridge +* @see com.sun.star.bridge.Bridge +* @see ifc.lang._XInitialization +* @see ifc.lang._XComponent +* @see ifc.bridge._XBridge +*/ +public class various extends TestCase { + + /** + * String for establishing a connection + */ + protected String connectString = null ; + + /** + * Choose the first port after <code>basePort</code> + * which is free. + */ + protected static final int basePort = 50000; + private static final int curPort = 50000; + + private XAcceptor xAcctr; + private XConnector xCntr; + private XBridgeFactory xBrdgFctr; + private AcceptorThread accThread; + + public XInterface bridge = null; + + /** + * Calls <code>accept()</code> method in a separate thread. + * Then stores exception thrown by call if it occurred, or + * return value. + */ + private class AcceptorThread extends Thread { + private final XAcceptor acc; + + /** + * Creates object which can call <code>accept</code> method + * of the Acceptor object specified. + */ + private AcceptorThread(XAcceptor acc) { + this.acc = acc ; + } + + /** + * Call <code>accept()</code> method and establish a bridge with an + * instance provider + */ + @Override + public void run() { + try { + acc.accept(connectString) ; + } catch (com.sun.star.connection.ConnectionSetupException e) { + } catch (com.sun.star.connection.AlreadyAcceptingException e) { + } + } + } + + private final boolean[] bridgeDisposed = new boolean[1] ; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.bridge.Bridge</code>. + * Object relations created : + * <ul> + * <li> <code>'XInitialization.args'</code> for + * {@link ifc.lang._XInitialization} and + * {@link ifc.bridge._XBridge} : contains arguments + * for <code>initialize()</code> method test.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.Bridge"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + // creating arguments for XInitialization + // first, creating a connection + // connection string + String cncstr = (String) tParam.get("CONNECTION_STRING") ; + int idx = cncstr.indexOf("host=") + 5 ; + + // select the port + log.println("Choose Port nr: " + curPort); + + connectString = "socket,host=" + + cncstr.substring(idx, cncstr.indexOf(",", idx)) + + ",port=" + curPort; + + // create acceptor + XInterface oAcctr = (XInterface)xMSF.createInstance( + "com.sun.star.connection.Acceptor") ; + + xAcctr = UnoRuntime.queryInterface( + XAcceptor.class, oAcctr); + // create connector + XInterface oCntr = (XInterface)xMSF.createInstance( + "com.sun.star.connection.Connector") ; + xCntr = UnoRuntime.queryInterface( + XConnector.class, oCntr); + + // create bridge factory + XInterface oBrdg = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.BridgeFactory") ; + xBrdgFctr = UnoRuntime.queryInterface(XBridgeFactory.class, oBrdg); + + // create waiting acceptor thread + accThread = new AcceptorThread(xAcctr); + accThread.start(); + // let the thread sleep + util.utils.pause(500); + + // establish the connection + XConnection xConnection = xCntr.connect(connectString); + + String protocol = "urp"; + String bridgeName = protocol + ":" + connectString; + + tEnv.addObjRelation("XInitialization.args", new Object[] { + bridgeName, protocol, xConnection, null}); + + bridge = tEnv.getTestObject(); + + return tEnv; + } + + /** + * Stop the acceptor thread and dispose the bridge + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + + System.out.println("++++++++ cleanup"); + xAcctr.stopAccepting(); + if (accThread.isAlive()) { + accThread.interrupt(); + } + XComponent xComp = UnoRuntime.queryInterface( + XComponent.class, xAcctr); + if (xComp != null) + xComp.dispose(); + xComp = UnoRuntime.queryInterface( + XComponent.class, xCntr); + if (xComp != null) + xComp.dispose(); + xComp = UnoRuntime.queryInterface( + XComponent.class, xBrdgFctr); + if (xComp != null) + xComp.dispose(); + + xComp = UnoRuntime.queryInterface( + XComponent.class, bridge); + if (xComp != null) { + System.out.println("######## Dispose bridge"); + bridgeDisposed[0] = true; + xComp.dispose(); + // wait for dispose + util.utils.pause(5000); + } + } +} diff --git a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_HeaderFooter.java b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_HeaderFooter.java new file mode 100644 index 000000000..ed9e5da9a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_HeaderFooter.java @@ -0,0 +1,202 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +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.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + + +public class AccessibleEditableTextPara_HeaderFooter extends TestCase { + protected static XComponent xCalcDoc = null; + protected static XMultiServiceFactory msf = null; + protected static XAccessibleAction action = null; + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XAccessibleContext oObj = null; + Object toolkit = msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + util.utils.waitForEventIdle(Param.getMSF()); + + DiagThread psDiag = new DiagThread(xCalcDoc, msf); + psDiag.start(); + + util.utils.waitForEventIdle(Param.getMSF()); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + util.utils.waitForEventIdle(Param.getMSF()); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XAccessibleContext ok_button = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Cancel"); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH); + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + oObj.getAccessibleName()); + log.println("ParentDescription " + + oObj.getAccessibleParent().getAccessibleContext() + .getAccessibleDescription()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + action = UnoRuntime.queryInterface( + XAccessibleAction.class, ok_button); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + XAccessibleEditableText eText = UnoRuntime.queryInterface( + XAccessibleEditableText.class, + oObj); + + eText.setText("LEFT"); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("Destroy", "AccessibleEditableTextPara_PreviewCell"); + + final XAccessibleEditableText editText = eText; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + editText.setText("LEFT_EVENT"); + } + }); + + return tEnv; + } + + /** + * Closes the dialog using accessible button 'OK' found in + * <code>createTestEnvironment()</code>. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" disposing xCalcDoc "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xCalcDoc); + } + + /** + * Opens new writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + msf = Param.getMSF(); + + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xCalcDoc = UnoRuntime.queryInterface(XComponent.class, + SOF.createCalcDoc( + null)); + } + + + /** + * Thread for opening modal dialog 'Print Settings'. + */ + private class DiagThread extends Thread { + private XComponent xCalcDoc = null; + private XMultiServiceFactory msf = null; + + private DiagThread(XComponent xCalcDoc, XMultiServiceFactory msf) { + this.xCalcDoc = xCalcDoc; + this.msf = msf; + } + + @Override + public void run() { + XModel aModel = UnoRuntime.queryInterface(XModel.class, + xCalcDoc); + + XController xController = aModel.getCurrentController(); + + //Opening HeaderFooterDialog + try { + String aSlotID = ".uno:EditHeaderAndFooter"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + xController); + XURLTransformer xParser = UnoRuntime.queryInterface( + XURLTransformer.class, + msf.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 open dialog"); + } + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java new file mode 100644 index 000000000..b8ecfbfc2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/AccessibleEditableTextPara_PreviewCell.java @@ -0,0 +1,161 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + + +public class AccessibleEditableTextPara_PreviewCell extends TestCase { + XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Obtains the accessible object for a one of cell in preview mode. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XCell xCell = null; + + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet") ; + xCell = oSheet.getCellByPosition(0, 0); + + xCell.setFormula("Value"); + + XModel xModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + + XController xController = xModel.getCurrentController(); + + //switch to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF().createInstance("com.sun.star.util.URLTransformer")); + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + XAccessibleContext oObj = null; + for (int i = 0;; ++i) { + Thread.sleep(500); + try { + XAccessible xRoot = AccessibilityTools.getAccessibleObject( + AccessibilityTools.getCurrentWindow( + xModel)); + if (xRoot != null) { + AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE_CELL, true); + xRoot = AccessibilityTools.SearchedAccessible; + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.PARAGRAPH); + if (oObj != null) { + break; + } + } + } + } catch (DisposedException e) { + log.println("Ignoring DisposedException"); + } + if (i == 20) { // give up after 10 sec + throw new RuntimeException( + "Couldn't get AccessibleRoot.HEADER object"); + } + log.println("No TABLE_CELL/PARAGRAPH found yet, retrying"); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + oObj.getAccessibleName()); + log.println("Parent " + utils.getImplName(oObj.getAccessibleParent())); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EditOnly", "AccessibleEditableTextPara_PreviewCell"); + tEnv.addObjRelation("Destroy", "AccessibleEditableTextPara_PreviewCell"); + + final XCell cell_to_change = xCell; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + cell_to_change.setFormula("NewString"); + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleCell.java new file mode 100644 index 000000000..1ec596a09 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleCell.java @@ -0,0 +1,175 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.table.XColumnRowRange; +import com.sun.star.table.XTableColumns; +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 accessible component of + * a cell in the spreadsheet. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleTable</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleTable + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleTable + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessibleCell extends TestCase { + + private XSpreadsheetDocument xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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 { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println("creating a spreadsheetdocument"); + xSpreadsheetDoc = SOF.createCalcDoc(null); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.TABLE_CELL, "B1"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + // relation for XAccessibleEventBroadcaster + XCell xCell = null; + final String text = "XAccessibleText"; + try { + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + xCell = oSheet.getCellByPosition(1, 0) ; + xCell.setFormula(text); + XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, oSheet); + XTableColumns oColumns = oColumnRowRange.getColumns(); + XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, oColumns); + XPropertySet column = UnoRuntime.queryInterface( + XPropertySet.class,oIndexAccess.getByIndex(1)); + column.setPropertyValue("OptimalWidth", Boolean.TRUE); + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception creating relation :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception creating relation :"); + e.printStackTrace(log); + } catch(com.sun.star.beans.UnknownPropertyException e) { + log.println("Exception creating relation :"); + e.printStackTrace(log); + } catch(com.sun.star.beans.PropertyVetoException e) { + log.println("Exception creating relation :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception creating relation :"); + e.printStackTrace(log); + } + + tEnv.addObjRelation("EditOnly", + "This method is only supported if the Cell is in edit mode"); + + final XCell fCell = xCell ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + fCell.setFormula("firing event"); + fCell.setFormula(text); + } + }); + + tEnv.addObjRelation("XAccessibleText.Text", text); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc) ; + util.DesktopTools.closeDoc(oComp); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvCell.java new file mode 100644 index 000000000..3e4be0a8f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvCell.java @@ -0,0 +1,145 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ScAccessibleCsvCell extends TestCase { + + static XAccessibleAction accAction = 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 tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = (XInterface) tParam.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class,oObj); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.PUSH_BUTTON, "Cancel"); + + accAction = UnoRuntime.queryInterface(XAccessibleAction.class, oObj); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.TABLE, true); + + XAccessibleContext cont = UnoRuntime.queryInterface(XAccessibleContext.class, oObj); + + String name = ""; + try { + XAccessible acc = cont.getAccessibleChild(3); + name = acc.getAccessibleContext().getAccessibleName(); + log.println("Child: "+ name); + log.println("ImplementationName " + utils.getImplName(acc)); + oObj = acc; + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) {} + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this dialog"); + + tEnv.addObjRelation("XAccessibleText.Text", name); + + return tEnv; + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " closing Dialog " ); + try { + accAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException iae) { + log.println("Couldn't close dialog"); + } + } + + /** + * 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("opening dialog"); + + PropertyValue[] args = new PropertyValue[1]; + try { + args[0] = new PropertyValue(); + args[0].Name = "InteractionHandler"; + args[0].Value = Param.getMSF().createInstance( + "com.sun.star.comp.uui.UUIInteractionHandler"); + } catch(com.sun.star.uno.Exception e) { + } + + String url= utils.getFullTestURL("10test.csv"); + log.println("loading "+url); + SOF.loadDocument(url,args); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvGrid.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvGrid.java new file mode 100644 index 000000000..0e7aefc2b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvGrid.java @@ -0,0 +1,129 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ScAccessibleCsvGrid extends TestCase { + + static XAccessibleAction accAction = 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) throws Exception { + + XInterface oObj = (XInterface) Param.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class,oObj); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.PUSH_BUTTON, "Cancel"); + + accAction = UnoRuntime.queryInterface(XAccessibleAction.class, oObj); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.TABLE, true); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " closing Dialog " ); + try { + accAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException iae) { + log.println("Couldn't close dialog"); + } + } + + /** + * 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("opening dialog"); + + PropertyValue[] args = new PropertyValue[1]; + try { + args[0] = new PropertyValue(); + args[0].Name = "InteractionHandler"; + args[0].Value = Param.getMSF().createInstance( + "com.sun.star.comp.uui.UUIInteractionHandler"); + } catch(com.sun.star.uno.Exception e) { + } + + String url= utils.getFullTestURL("10test.csv"); + log.println("loading "+url); + SOF.loadDocument(url,args); + } + +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvRuler.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvRuler.java new file mode 100644 index 000000000..d3cd92464 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleCsvRuler.java @@ -0,0 +1,166 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ScAccessibleCsvRuler extends TestCase { + + static XAccessibleAction accAction = 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) throws Exception { + XMultiServiceFactory msf = Param.getMSF(); + + XInterface oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, + "Cancel"); + + accAction = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + XAccessibleContext acc = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.RADIO_BUTTON); + + log.println("Click on: " + acc.getAccessibleName()); + + XAccessibleAction accAction2 = UnoRuntime.queryInterface( + XAccessibleAction.class, acc); + + try { + accAction2.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException iae) { + } + + + AccessibilityTools.printAccessibleTree(log, xRoot); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT, + "Ruler", true); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this dialog"); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + int lastone = 100; + + for (int i = 0; i < 1000; i++) { + try { + text.getCharacterBounds(i); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + lastone = i - 1; + + break; + } + } + + tEnv.addObjRelation("LimitedBounds", Integer.valueOf(lastone)); + tEnv.addObjRelation("PreviousUsed",new int[]{11,22,33,44,55,66,77,88,99}); + + return tEnv; + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + } + + /** + * 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("opening dialog"); + + PropertyValue[] args = new PropertyValue[1]; + try { + args[0] = new PropertyValue(); + args[0].Name = "InteractionHandler"; + args[0].Value = Param.getMSF().createInstance( + "com.sun.star.comp.uui.UUIInteractionHandler"); + } catch(com.sun.star.uno.Exception e) { + } + + String url= utils.getFullTestURL("10test.csv"); + log.println("loading "+url); + SOF.loadDocument(url,args); + } + +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java new file mode 100644 index 000000000..348e8a6bc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocument.java @@ -0,0 +1,143 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by accessible component of + * a spreadsheet document. + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleSelection + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessibleDocument extends TestCase { + + static XComponent xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Obtains accessible object for the spreadsheet document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + // get the drawpage of drawing here + log.println( "getting Drawpages" ); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT, ""); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XWindow xDocWin = xWindow; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle rect = xDocWin.getPosSize(); + xDocWin.setPosSize(rect.X,rect.Y,rect.Height,rect.Width-10,com.sun.star.awt.PosSize.POSSIZE); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + util.DesktopTools.closeDoc(xSpreadsheetDoc); + } + + /** + * Called while the <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 spreadsheetdocument"); + String url = utils.getFullTestURL("calcshapes.sxc"); + log.println("loading document "+url); + xSpreadsheetDoc = SOF.loadDocument(url); + util.utils.waitForEventIdle(Param.getMSF()); + } + +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleDocumentPagePreview.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocumentPagePreview.java new file mode 100644 index 000000000..6474f8d84 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleDocumentPagePreview.java @@ -0,0 +1,198 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +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.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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.URL; +import com.sun.star.util.XURLTransformer; + +/** + * Test for object which is represented by accessible component of + * a spreadsheet page in 'Page Preview' mode. + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessibleDocumentPagePreview extends TestCase { + + private XSpreadsheetDocument xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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; + + // inserting some content to have non-empty page preview + XCell xCell = null; + try { + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = null; + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(1)); + xCell = oSheet.getCellByPosition(0, 0) ; + xCell.setFormula("ScAccessibleDocumentPagePreview - Page 2"); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(2)); + xCell = oSheet.getCellByPosition(0, 0) ; + xCell.setFormula("ScAccessibleDocumentPagePreview - Page 3"); + + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + xCell = oSheet.getCellByPosition(0, 0) ; + xCell.setFormula("ScAccessibleDocumentPagePreview"); + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception creating document page preview :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception creating document page preview :"); + e.printStackTrace(log); + } + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XController xController = aModel.getCurrentController(); + + // switching to 'Page Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + 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 = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + util.utils.shortWait(); + + XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.DOCUMENT, ""); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XDesktop desk = util.DesktopTools.createDesktop(Param.getMSF()); + final XWindow win = desk.getCurrentFrame().getComponentWindow(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle rec = win.getPosSize(); + win.setPosSize(rec.X,rec.Y,rec.Height-10,rec.Width, com.sun.star.awt.PosSize.POSSIZE); + win.setPosSize(rec.X,rec.Y,rec.Height,rec.Width,com.sun.star.awt.PosSize.POSSIZE ); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc) ; + util.DesktopTools.closeDoc(oComp); + } + + /** + * 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 spreadsheetdocument"); + String url = utils.getFullTestURL("calcshapes.sxc"); + log.println("loading document "+url); + xSpreadsheetDoc = UnoRuntime.queryInterface( + XSpreadsheetDocument.class,SOF.loadDocument(url)); + util.utils.waitForEventIdle(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeader.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeader.java new file mode 100644 index 000000000..74670742c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeader.java @@ -0,0 +1,238 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.DisposedException; +import com.sun.star.sheet.XHeaderFooterContent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.table.XCell; +import com.sun.star.text.XText; +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.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.util.XURLTransformer; + +/** + * Test for object which is represented by accessible component of + * a printed header in 'Page Preview' mode. + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessiblePageHeader extends TestCase { + + private XSpreadsheetDocument xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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 { + + // inserting some content to have non-empty page preview + XCell xCell = null; + try { + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + xCell = oSheet.getCellByPosition(0, 0) ; + xCell.setFormula("ScAccessiblePageHeader"); + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception creating page header :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception creating page header :"); + e.printStackTrace(log); + } + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XController xController = aModel.getCurrentController(); + + // switching to 'Page Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + 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 = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + XInterface oObj = null; + for (int i = 0;; ++i) { + Thread.sleep(500); + try { + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.HEADER, ""); + if (oObj != null) { + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + break; + } + } + } catch (DisposedException e) { + log.println("Ignoring DisposedException"); + } + if (i == 20) { // give up after 10 sec + throw new RuntimeException( + "Couldn't get AccessibleRoot.HEADER object"); + } + log.println("No HEADER found yet, retrying"); + } + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, + xSpreadsheetDoc ); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + XStyle StdStyle = null; + + XNameAccess PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class), + StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class), PageStyles.getByName("Default")); + + //get the property-set + final XPropertySet PropSet = UnoRuntime.queryInterface(XPropertySet.class, StdStyle); + + XHeaderFooterContent RPHC = null; + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + RPHC = (XHeaderFooterContent) AnyConverter.toObject( + new Type(XHeaderFooterContent.class), + PropSet.getPropertyValue("RightPageHeaderContent")); + + final XHeaderFooterContent RPHC2 = RPHC; + + final XText center = RPHC2.getCenterText(); + final XText left = RPHC2.getLeftText(); + final XText right = RPHC2.getRightText(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + center.setString("CENTER"); + left.setString("LEFT"); + right.setString("RIGHT"); + try { + PropSet.setPropertyValue("RightPageHeaderContent",RPHC2); + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.lang.WrappedTargetException e) {} + } + }); + + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + try { + XCloseable oComp = UnoRuntime.queryInterface (XCloseable.class, xSpreadsheetDoc) ; + oComp.close(true); + } catch(com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document: "+e.getMessage()); + } + } + + /** + * 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 spreadsheetdocument"); + xSpreadsheetDoc = SOF.createCalcDoc(null); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeaderArea.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeaderArea.java new file mode 100644 index 000000000..87f1c5a74 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePageHeaderArea.java @@ -0,0 +1,200 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleStateSet; +import com.sun.star.awt.XWindow; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.util.XURLTransformer; + +/** + * Test for object which is represented by accessible component of + * a printed header in 'Page Preview' mode. + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + */ +public class ScAccessiblePageHeaderArea extends TestCase { + + private XSpreadsheetDocument xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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; + + // inserting some content to have non-empty page preview + XCell xCell = null; + try { + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + xCell = oSheet.getCellByPosition(0, 0) ; + xCell.setFormula("ScAccessiblePageHeaderArea"); + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception creating page header area :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception creating page header area :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception creating page header area :"); + e.printStackTrace(log); + } + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XController xController = aModel.getCurrentController(); + + // switching to 'Page Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + 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 = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = AccessibilityTools.getCurrentContainerWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.HEADER, "").getAccessibleChild(0); + XAccessibleContext cont = UnoRuntime.queryInterface(XAccessibleContext.class, oObj); + XAccessibleStateSet StateSet = cont.getAccessibleStateSet(); + if (StateSet.contains((short)27)) { + log.println("Object is transient"); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XAccessibleContext zoomIn = + AccessibilityTools.getAccessibleObjectForRole(xRoot,AccessibleRole.PUSH_BUTTON, "Zoom In"); + + final XAccessibleAction pressZoom = UnoRuntime.queryInterface(XAccessibleAction.class, zoomIn); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + pressZoom.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ibe) { + System.out.println("caught exception: " + ibe); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes calc document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + try { + XCloseable oComp = UnoRuntime.queryInterface (XCloseable.class, xSpreadsheetDoc) ; + oComp.close(true); + }catch(com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document: "+e.getMessage()); + } + } + + /** + * 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 spreadsheetdocument"); + xSpreadsheetDoc = SOF.createCalcDoc(null); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java new file mode 100644 index 000000000..d645c407a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewCell.java @@ -0,0 +1,173 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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.URL; +import com.sun.star.util.XURLTransformer; + +/** + * Object implements the following interfaces: + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleValue</code> + * </li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleTable + */ +public class ScAccessiblePreviewCell extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Obtains the accessible object for a one of cell in preview mode. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XCell xCell = null; + + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet") ; + xCell = oSheet.getCellByPosition(0, 0); + + xCell.setFormula("Value"); + + XModel xModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + + XController xController = xModel.getCurrentController(); + + //switch to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF().createInstance("com.sun.star.util.URLTransformer")); + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + XInterface oObj = null; + for (int i = 0;; ++i) { + Thread.sleep(500); + try { + XAccessible xRoot = AccessibilityTools.getAccessibleObject( + AccessibilityTools.getCurrentWindow( + xModel)); + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE_CELL, true); + if (oObj != null) { + break; + } + } + } catch (DisposedException e) { + log.println("Ignoring DisposedException"); + } + if (i == 20) { // give up after 10 sec + throw new RuntimeException( + "Couldn't get AccessibleRole.TABLE_CELL object"); + } + log.println("No TABLE_CELL found yet, retrying"); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + System.out.println("Fire Event"); + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java new file mode 100644 index 000000000..911b65aec --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewHeaderCell.java @@ -0,0 +1,232 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.table.XCell; +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.URL; +import com.sun.star.util.XCloseable; +import com.sun.star.util.XURLTransformer; + + +/** + * Object implements the following interfaces: + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleValue</code> + * </li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleTable + */ +public class ScAccessiblePreviewHeaderCell extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + if (xSheetDoc != null) { + try { + XCloseable oComp = UnoRuntime.queryInterface( + XCloseable.class, xSheetDoc); + oComp.close(true); + xSheetDoc = null; + } catch (com.sun.star.util.CloseVetoException e) { + e.printStackTrace(log); + } catch (com.sun.star.lang.DisposedException e) { + log.println("document already disposed"); + xSheetDoc = null; + } + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Sets a value of the cell 'A1'. Sets the property 'PrintHeaders' + * of the style 'Default' of the family 'PageStyles' to true. + * Switch the document to preview mode and then obtains the + * accessible object for the header cell. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + if (xSheetDoc != null) { + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println("creating a Spreadsheet document"); + xSheetDoc = SOF.createCalcDoc(null); + + XModel xModel = UnoRuntime.queryInterface(XModel.class, + xSheetDoc); + + XController xController = xModel.getCurrentController(); + + //setting value of cell A1 + XCell xCell = null; + + log.println("Getting spreadsheet"); + + XSpreadsheets oSheets = xSheetDoc.getSheets(); + XIndexAccess oIndexSheets = UnoRuntime.queryInterface( + XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet"); + xCell = oSheet.getCellByPosition(0, 0); + + xCell.setFormula("Value"); + + //setting property 'PrintHeaders' of the style 'Default' + XStyleFamiliesSupplier xSFS = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, + xSheetDoc); + XNameAccess xNA = xSFS.getStyleFamilies(); + XPropertySet xPropSet = null; + + Object oPageStyles = xNA.getByName("PageStyles"); + xNA = UnoRuntime.queryInterface(XNameAccess.class, + oPageStyles); + + Object oDefStyle = xNA.getByName("Default"); + xPropSet = UnoRuntime.queryInterface( + XPropertySet.class, oDefStyle); + + xPropSet.setPropertyValue("PrintHeaders", Boolean.TRUE); + + //switching to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + xController); + XURLTransformer xParser = UnoRuntime.queryInterface( + XURLTransformer.class, + Param.getMSF() + .createInstance("com.sun.star.util.URLTransformer")); + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + + if (xDispatcher != null) { + xDispatcher.dispatch(aURL, null); + } + + XInterface oObj = null; + for (int i = 0;; ++i) { + Thread.sleep(500); + try { + XAccessible xRoot = AccessibilityTools.getAccessibleObject( + AccessibilityTools.getCurrentWindow( + xModel)); + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE, "A"); + if (oObj == null) { + log.println("Version with a fixed #103863#?"); + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE_CELL, true); + } + if (oObj != null) { + break; + } + } + } catch (DisposedException e) { + log.println("Ignoring DisposedException"); + } + if (i == 20) { // give up after 10 sec + throw new RuntimeException( + "Couldn't get AccessibleRole.TABLE/TABLE_CELL object"); + } + log.println("No TABLE/TABLE_CELL found yet, retrying"); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java new file mode 100644 index 000000000..fece4f3d1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessiblePreviewTable.java @@ -0,0 +1,191 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.DisposedException; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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.URL; +import com.sun.star.util.XURLTransformer; + +/** + * Object implements the following interfaces: + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleTable</code> + * </li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleTable + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleTable + */ +public class ScAccessiblePreviewTable extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Obtains the accessible object for a table in preview mode. + */ + @Override + protected TestEnvironment createTestEnvironment(final TestParameters Param, + final PrintWriter log) throws Exception { + + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet") ; + XCell xCell = oSheet.getCellByPosition(0, 0); + xCell.setFormula("Value"); + + XModel xModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + + XController xController = xModel.getCurrentController(); + + //switch to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + XURLTransformer xParser = UnoRuntime.queryInterface(XURLTransformer.class, + Param.getMSF().createInstance("com.sun.star.util.URLTransformer")); + URL[] aParseURL = new URL[1]; + aParseURL[0] = new URL(); + aParseURL[0].Complete = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + XAccessible xRoot; + XInterface oObj; + for (int i = 0;; ++i) { + Thread.sleep(500); + try { + xRoot = AccessibilityTools.getAccessibleObject( + AccessibilityTools.getCurrentContainerWindow( + xModel)); + if (xRoot != null) { + oObj = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TABLE); + if (oObj != null) { + break; + } + } + } catch (DisposedException e) { + log.println("Ignoring DisposedException"); + } + if (i == 20) { // give up after 10 sec + throw new RuntimeException( + "Couldn't get AccessibleRole.TABLE/PUSH_BUTTON object"); + } + log.println("No TABLE/PUSH_BUTTON found yet, retrying"); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XAccessibleContext zoomIn = + AccessibilityTools.getAccessibleObjectForRole(xRoot,AccessibleRole.PUSH_BUTTON, "Zoom In"); + + log.println("Getting \"" + zoomIn.getAccessibleName() + "\" which is a \"" + UnoRuntime.queryInterface(com.sun.star.lang.XServiceInfo.class, zoomIn).getImplementationName() + "\""); + + final XAccessibleAction pressZoom = UnoRuntime.queryInterface(XAccessibleAction.class, zoomIn); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + pressZoom.doAccessibleAction(0); + // the action is not triggered on the preview table + // but some toolbar button - this will indirectly + // trigger a table event but only from VCL main loop + utils.waitForEventIdle(Param.getMSF()); + // sadly it turns out that idle is not enough... + Thread.sleep(500); + } catch (com.sun.star.lang.IndexOutOfBoundsException ibe) { + log.println("ScAccessiblePreviewTable: IndexOutOfBoundsException from pressZoom.doAccessibleAction(0)"); + } catch (InterruptedException ex) {} + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAccessibleSpreadsheet.java b/qadevOOo/tests/java/mod/_sc/ScAccessibleSpreadsheet.java new file mode 100644 index 000000000..dd177b7e3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAccessibleSpreadsheet.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._sc; + +import java.io.PrintWriter; + +import lib.StatusException; +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.container.XIndexAccess; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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 accessible object of spreadsheet document.<p> + * Object implements the following interfaces: + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code> + * </li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleTable</code> + * </li> + * </ul> + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleTable + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleTable + */ +public class ScAccessibleSpreadsheet extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Obtains the accessible object for the spreadsheet. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + + XModel xModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(xModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE ); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // relation for XAccessibleEventBroadcaster + XCell xCell = null; + final String text = "Text for testing of the interface XAccessibleText"; + try { + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + xCell = oSheet.getCellByPosition(5, 5) ; + xCell.setFormula(text); + } catch(com.sun.star.lang.WrappedTargetException e) { + log.println("Exception creating accessible text :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception creating accessible text :"); + e.printStackTrace(log); + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception creating accessible text :"); + e.printStackTrace(log); + } + + final XCell fCell = xCell ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + fCell.setFormula("firing event"); + fCell.setFormula(text); + } + }); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sc/ScAnnotationShapeObj.java b/qadevOOo/tests/java/mod/_sc/ScAnnotationShapeObj.java new file mode 100644 index 000000000..21cae1a41 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAnnotationShapeObj.java @@ -0,0 +1,185 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSheetAnnotation; +import com.sun.star.sheet.XSheetAnnotationAnchor; +import com.sun.star.sheet.XSheetAnnotationShapeSupplier; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XSimpleText; +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 lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; +import util.utils; + +import java.io.PrintWriter; +import util.DefaultDsc; +import util.InstCreator; + + +/** +* Test for object which represents some text annotation +* anchored to some cell in spreadsheet (implement +* <code>com.sun.star.sheet.CellAnnotation</code>).<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::text::XSimpleText</code></li> +* <li> <code>com::sun::star::text::XTextRange</code></li> +* <li> <code>com::sun::star::sheet::XSheetAnnotation</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.sheet.CellAnnotation +* @see com.sun.star.text.XSimpleText +* @see com.sun.star.text.XTextRange +* @see com.sun.star.sheet.XSheetAnnotation +* @see ifc.text._XSimpleText +* @see ifc.text._XTextRange +* @see ifc.sheet._XSheetAnnotation +*/ +public class ScAnnotationShapeObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates a spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = + SOfficeFactory.getFactory(tParam + .getMSF()); + + log.println("creating a Spreadsheet document"); + log.println("Loading: "+utils.getFullTestURL( + "ScAnnotationShapeObj.sxc")); + xSheetDoc = + UnoRuntime.queryInterface(XSpreadsheetDocument.class, + SOF.loadDocument(utils.getFullTestURL( + "ScAnnotationShapeObj.sxc"))); + } + + /** + * Disposes a spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = + UnoRuntime.queryInterface(XComponent.class, + xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document, + * and takes one them. Then a single cell is retrieved, and + * using its <code>com.sun.star.sheet.XSheetAnnotationAnchor</code> + * interface an annotation is got. + * Object relations created : + * <ul> + * <li> <code>'CELLPOS'</code> for + * {@link ifc.sheet._XSheetAnnotation} (of <code> + * com.sun.star.table.CellAddress</code> type) which + * contains the annotation cell address.</li> + * </ul> + */ + @Override + public 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"); + + CellAddress cellPos = new CellAddress((short) 0, 1, 2); + + log.println("Getting test object "); + + XSpreadsheetDocument xArea = + UnoRuntime.queryInterface(XSpreadsheetDocument.class, + xSheetDoc); + XSpreadsheets oSheets = xArea.getSheets(); + + XIndexAccess XAccess = + UnoRuntime.queryInterface(XIndexAccess.class, + oSheets); + XCell oCell = null; + + XSpreadsheet oSheet = + (XSpreadsheet) AnyConverter.toObject(new Type( + XSpreadsheet.class), + XAccess.getByIndex(cellPos.Sheet)); + XCellRange oCRange = + UnoRuntime.queryInterface(XCellRange.class, + oSheet); + oCell = + oCRange.getCellByPosition(cellPos.Column, cellPos.Row); + + XSheetAnnotationAnchor oAnnoA = + UnoRuntime.queryInterface(XSheetAnnotationAnchor.class, + oCell); + XSheetAnnotation oAnno = oAnnoA.getAnnotation(); + + XSimpleText xAnnoText = + UnoRuntime.queryInterface(XSimpleText.class, + oAnno); + xAnnoText.setString("ScAnnotationShapeObj"); + + XSheetAnnotationShapeSupplier xSheetAnnotationShapeSupplier = + UnoRuntime.queryInterface(XSheetAnnotationShapeSupplier.class, + oAnno); + + oObj = xSheetAnnotationShapeSupplier.getAnnotationShape(); + + log.println("ImplementationName: " + + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //adding ObjRelation for RotationDescriptor + tEnv.addObjRelation("NoShear", Boolean.TRUE); + + //adding ObjRelation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.DateTime"); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( + "XTEXTINFO", new InstCreator( xSheetDoc, tDsc ) ); + + return tEnv; + } +} + // finish class ScAnnotationShapeObj diff --git a/qadevOOo/tests/java/mod/_sc/ScAnnotationTextCursor.java b/qadevOOo/tests/java/mod/_sc/ScAnnotationTextCursor.java new file mode 100644 index 000000000..caa2e2a91 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAnnotationTextCursor.java @@ -0,0 +1,124 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSheetAnnotation; +import com.sun.star.sheet.XSheetAnnotationAnchor; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XSimpleText; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.document.XDocumentInsertable + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XParagraphCursor + * @see com.sun.star.text.XSentenceCursor + * @see com.sun.star.text.XTextCursor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XWordCursor + * @see com.sun.star.util.XSortable + * + */ +public class ScAnnotationTextCursor extends TestCase { + + private XSpreadsheetDocument xSheetDoc = null; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc) ; + util.DesktopTools.closeDoc(oComp); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public 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" ); + + CellAddress cellPos = new CellAddress((short)0, 1, 2); + + log.println("Getting test object ") ; + + XSpreadsheetDocument xArea = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); + + XSpreadsheets oSheets = xArea.getSheets(); + + XIndexAccess XAccess = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + + XSpreadsheet oSheet = (XSpreadsheet)XAccess.getByIndex(cellPos.Sheet); + + XCellRange oCRange = UnoRuntime.queryInterface(XCellRange.class, oSheet); + + XCell oCell = oCRange.getCellByPosition(cellPos.Column, cellPos.Row); + + XSheetAnnotationAnchor oAnnoA = UnoRuntime.queryInterface(XSheetAnnotationAnchor.class, oCell); + + XSheetAnnotation oAnno = oAnnoA.getAnnotation(); + XSimpleText aText = UnoRuntime.queryInterface(XSimpleText.class,oAnno); + aText.setString("A nice little Test"); + oObj = aText.createTextCursor(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Other parameters required for interface tests + + return tEnv; + } + +} // finish class ScAnnotationTextCursor + diff --git a/qadevOOo/tests/java/mod/_sc/ScAutoFormatFieldObj.java b/qadevOOo/tests/java/mod/_sc/ScAutoFormatFieldObj.java new file mode 100644 index 000000000..a97d3bbb4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScAutoFormatFieldObj.java @@ -0,0 +1,97 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import com.sun.star.container.XIndexAccess; +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.sheet.TableAutoFormatField</code>. +* In StarCalc application there is a collection of autoformats +* for tables (you can select a predefined format for a +* table or create your own). Each autoformat has a number +* of fields with definitions of font parameters, number +* formats etc. for different parts of a table (column and +* row names, footers, data). This object represents the +* field of the same kind. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sheet::TableAutoFormatField</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.sheet.TableAutoFormatField +* @see com.sun.star.beans.XPropertySet +* @see ifc.sheet._TableAutoFormatField +* @see ifc.beans._XPropertySet +*/ +public class ScAutoFormatFieldObj extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Using SOffice ServiceManager an instance of + * <code>com.sun.star.sheet.TableAutoFormatField</code> service + * is created. From this collection one Format is retrieved + * and then from this format one of its compound fields is + * retrieved. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) throws StatusException { + + XInterface oObj = null; + + try { + + log.println ("create Object ...") ; + // creation of testobject here + XInterface formats = (XInterface)Param.getMSF().createInstance + ("com.sun.star.sheet.TableAutoFormats"); + XIndexAccess formatsIndex = UnoRuntime.queryInterface + (XIndexAccess.class, formats); + XInterface format = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),formatsIndex.getByIndex(0)); + XIndexAccess formatIndex = UnoRuntime.queryInterface + (XIndexAccess.class, format); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),formatIndex.getByIndex(0)); + + } catch (com.sun.star.uno.Exception e) { + log.println ("Exception occurred while creating test Object.") ; + e.printStackTrace(log) ; + } + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + return tEnv; + } + +} // finish class ScAutoFormatFieldObj + diff --git a/qadevOOo/tests/java/mod/_sc/ScCellCursorObj.java b/qadevOOo/tests/java/mod/_sc/ScCellCursorObj.java new file mode 100644 index 000000000..fe155bba8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScCellCursorObj.java @@ -0,0 +1,294 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.ValueComparer; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSheetCellRange; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +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 ifc.sheet._XCellRangesQuery; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.SheetCellCursor</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::sheet::XUsedAreaCursor</code></li> +* <li> <code>com::sun::star::table::CellProperties</code></li> +* <li> <code>com::sun::star::table::XCellRange</code></li> +* <li> <code>com::sun::star::sheet::XCellRangeAddressable</code></li> +* <li> <code>com::sun::star::table::XCellCursor</code></li> +* <li> <code>com::sun::star::sheet::XSheetCellCursor</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::sheet::XSheetOperation</code></li> +* <li> <code>com::sun::star::sheet::XArrayFormulaRange</code></li> +* <li> <code>com::sun::star::sheet::XSheetCellRange</code></li> +* <li> <code>com::sun::star::sheet::SheetCellRange</code></li> +* <li> <code>com::sun::star::chart::XChartData</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::util::XMergeable</code></li> +* <li> <code>com::sun::star::table::XColumnRowRange</code></li> +* </ul> +* @see com.sun.star.sheet.SheetCellCursor +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.sheet.XUsedAreaCursor +* @see com.sun.star.table.CellProperties +* @see com.sun.star.table.XCellRange +* @see com.sun.star.sheet.XCellRangeAddressable +* @see com.sun.star.table.XCellCursor +* @see com.sun.star.sheet.XSheetCellCursor +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.sheet.XSheetOperation +* @see com.sun.star.sheet.XArrayFormulaRange +* @see com.sun.star.sheet.XSheetCellRange +* @see com.sun.star.sheet.SheetCellRange +* @see com.sun.star.chart.XChartData +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.util.XMergeable +* @see com.sun.star.table.XColumnRowRange +* @see ifc.style._ParagraphProperties +* @see ifc.sheet._XUsedAreaCursor +* @see ifc.table._CellProperties +* @see ifc.table._XCellRange +* @see ifc.sheet._XCellRangeAddressable +* @see ifc.table._XCellCursor +* @see ifc.sheet._XSheetCellCursor +* @see ifc.style._CharacterProperties +* @see ifc.sheet._XSheetOperation +* @see ifc.sheet._XArrayFormulaRange +* @see ifc.sheet._XSheetCellRange +* @see ifc.sheet._SheetCellRange +* @see ifc.chart._XChartData +* @see ifc.beans._XPropertySet +* @see ifc.util._XMergeable +* @see ifc.table._XColumnRowRange +*/ +public class ScCellCursorObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a Spreadsheet document"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSheetDoc); + + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document, + * and takes one of them, retrieves some cell range and creates cursor range + * that is instance of the service + * <code>com.sun.star.sheet.SheetCellCursor</code>, + * fills some cells in the cell range. + * Object relations created : + * <ul> + * <li> <code>'SHEET'</code> for + * {@link ifc.table._XCellCursor}, + * {@link ifc.sheet._XArrayFormulaRange} (the spreadsheet that was + * retrieved from collection)</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + TestEnvironment tEnv = null; + XSpreadsheet oSheet = null; + XCellRange testRange = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("Creating a test environment"); + + XSpreadsheets oSpreadsheets = UnoRuntime.queryInterface( + XSpreadsheetDocument.class, + xSheetDoc).getSheets(); + + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oSpreadsheets.getByName( + oSpreadsheets.getElementNames()[0])); + + testRange = oSheet.getCellRangeByName("$A$1:$D$4"); + + XSheetCellRange testSheetRange = UnoRuntime.queryInterface( + XSheetCellRange.class, + testRange); + oObj = oSheet.createCursorByRange(testSheetRange); + oSheet.getCellByPosition(1, 1).setValue(1); + oSheet.getCellByPosition(4, 5).setValue(1); + oSheet.getCellByPosition(3, 2).setFormula("xTextDoc"); + oSheet.getCellByPosition(3, 3).setFormula("xTextDoc"); + + log.println("Test object successfully created."); + + tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("CRDESC", + "Column and RowDescriptions can't be changed for this Object"); + + tEnv.addObjRelation("SHEET", oSheet); + // add expected results for the XCellRangesQuery interface test + String[]expectedResults = new String[7]; + expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.B1"; + expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = "Sheet1.B2"; + expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = "Sheet1.A1 ... Sheet1.B1 ... Sheet1.B3 ... Sheet1.C1 ... Sheet1.D1"; + expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = "Sheet1.D4"; + expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.A2;Sheet1.C2"; + expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.A2"; + tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", expectedResults); + + tEnv.addObjRelation("NewData", + new Object[][] + { + { "", "", "", "" }, + { "", "2", "3", "4" }, + { "", "2", "3", "4" }, + { "", "2", "3", "4" } + }); + + XPropertySet PropSet = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + tEnv.addObjRelation("PropSet", PropSet); + + //Adding relation for util.XSortable + final PrintWriter finalLog = log; + final XCellRange oTable = testRange; + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + try { + oTable.getCellByPosition(0, 0).setValue(4); + oTable.getCellByPosition(0, 1).setFormula("b"); + oTable.getCellByPosition(0, 2).setValue(3); + oTable.getCellByPosition(0, 3).setValue(23); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + boolean res = false; + String[] value = new String[4]; + + for (int i = 0; i < 4; i++) { + try { + XCell cell = oTable.getCellByPosition(0, i); + value[i] = cell.getFormula(); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + if (isSortNumbering) { + if (isSortAscending) { + out.println("Sorting ascending"); + + String[] rightVal = { "3", "4", "23", "b" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } else { + if (isSortAscending) { + String[] rightVal = { "3", "4", "23", "b" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } + + if (res) { + out.println("Sorted correctly"); + } else { + out.println("Sorted incorrectly"); + } + + return res; + } + }); + + return tEnv; + } +} // finish class ScCellCursorObj diff --git a/qadevOOo/tests/java/mod/_sc/ScCellObj.java b/qadevOOo/tests/java/mod/_sc/ScCellObj.java new file mode 100644 index 000000000..1c5e02d37 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScCellObj.java @@ -0,0 +1,183 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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 ifc.sheet._XCellRangesQuery; + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.SheetCell</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::table::CellProperties</code></li> +* <li> <code>com::sun::star::text::XSimpleText</code></li> +* <li> <code>com::sun::star::table::XCell</code></li> +* <li> <code>com::sun::star::text::XTextRange</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::document::XActionLockable</code></li> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::text::XText</code></li> +* <li> <code>com::sun::star::sheet::XCellAddressable</code></li> +* </ul> +* @see com.sun.star.sheet.SheetCell +* @see com.sun.star.table.CellProperties +* @see com.sun.star.text.XSimpleText +* @see com.sun.star.table.XCell +* @see com.sun.star.text.XTextRange +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.document.XActionLockable +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.text.XText +* @see com.sun.star.sheet.XCellAddressable +* @see ifc.table._CellProperties +* @see ifc.text._XSimpleText +* @see ifc.table._XCell +* @see ifc.text._XTextRange +* @see ifc.beans._XPropertySet +* @see ifc.style._CharacterProperties +* @see ifc.document._XActionLockable +* @see ifc.style._ParagraphProperties +* @see ifc.text._XText +* @see ifc.sheet._XCellAddressable +*/ +public class ScCellObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "Creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document, + * and takes one of them. Retrieves some cell from the spreadsheet + * that is instance of the service <code>com.sun.star.sheet.SheetCell</code>. + * Object relations created : + * <ul> + * <li> <code>'XTEXTINFO',</code> for + * {@link ifc.text._XText} </li> + * </ul> + * @see com.sun.star.sheet.SheetCell + */ + @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" ); + + XSpreadsheet oSheet = null; + XCell cell = null; + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet") ; + oObj = oSheet.getCellByPosition(2, 3) ; + cell = UnoRuntime.queryInterface(XCell.class, oObj); + + log.println( "creating a new environment for ScCellObj object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Object relations for interface tests + DefaultDsc tDsc = new DefaultDsc( + "com.sun.star.text.XTextContent", "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xSheetDoc, tDsc ) ); + // add the sheet + tEnv.addObjRelation("SHEET", oSheet); + // add expected results for the XCellRangesQuery interface test + String[]expectedResults = new String[7]; + + expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.C4"; + expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = "Sheet1.C4"; + expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = ""; + expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.C4"; + expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.C4"; + tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", expectedResults); + tEnv.addObjRelation("XCellRangesQuery.CREATEENTRIES", Boolean.TRUE); + + // make entries in this cell at the interface test + tEnv.addObjRelation("XTextFieldsSupplier.MAKEENTRY", Boolean.TRUE); + tEnv.addObjRelation("MAKEENTRYINCELL", cell); + + // for XSearchable and XReplaceable interface test + tEnv.addObjRelation("XSearchable.MAKEENTRYINCELL", cell); + tEnv.addObjRelation("EXCLUDEFINDNEXT", Boolean.TRUE); + + // for XFormulaQuery interface test + tEnv.addObjRelation("EXPECTEDDEPENDENTVALUES", new int[]{2,2,3,3}); + tEnv.addObjRelation("EXPECTEDPRECEDENTVALUES", new int[]{0,3,0,0}); + tEnv.addObjRelation("RANGEINDICES", new int[]{0,0}); + + // XTextFieldsSupplier + tEnv.addObjRelation("SPREADSHEET", xSheetDoc); + + XPropertySet PropSet = UnoRuntime.queryInterface(XPropertySet.class, oObj); + tEnv.addObjRelation("PropSet",PropSet); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ScCellObj + diff --git a/qadevOOo/tests/java/mod/_sc/ScCellRangeObj.java b/qadevOOo/tests/java/mod/_sc/ScCellRangeObj.java new file mode 100644 index 000000000..c37e04015 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScCellRangeObj.java @@ -0,0 +1,279 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.ValueComparer; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +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 ifc.sheet._XCellRangesQuery; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.SheetCellRange</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::table::CellProperties</code></li> +* <li> <code>com::sun::star::util::XMergeable</code></li> +* <li> <code>com::sun::star::sheet::XCellRangeAddressable</code></li> +* <li> <code>com::sun::star::sheet::XArrayFormulaRange</code></li> +* <li> <code>com::sun::star::chart::XChartData</code></li> +* <li> <code>com::sun::star::table::XColumnRowRange</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::sheet::XSheetOperation</code></li> +* <li> <code>com::sun::star::table::XCellRange</code></li> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::sheet::SheetCellRange</code></li> +* </ul> +* @see com.sun.star.sheet.SheetCellRange +* @see com.sun.star.table.CellProperties +* @see com.sun.star.util.XMergeable +* @see com.sun.star.sheet.XCellRangeAddressable +* @see com.sun.star.sheet.XArrayFormulaRange +* @see com.sun.star.chart.XChartData +* @see com.sun.star.table.XColumnRowRange +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.sheet.XSheetOperation +* @see com.sun.star.table.XCellRange +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.sheet.SheetCellRange +* @see ifc.table._CellProperties +* @see ifc.util._XMergeable +* @see ifc.sheet._XCellRangeAddressable +* @see ifc.sheet._XArrayFormulaRange +* @see ifc.chart._XChartData +* @see ifc.table._XColumnRowRange +* @see ifc.beans._XPropertySet +* @see ifc.style._CharacterProperties +* @see ifc.sheet._XSheetOperation +* @see ifc.table._XCellRange +* @see ifc.style._ParagraphProperties +* @see ifc.sheet._SheetCellRange +*/ +public class ScCellRangeObj extends TestCase { + XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a Spreadsheet document"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document, + * and takes one of them. Retrieves some cell range from the spreadsheet. + * The retrieved cell range is instance of the service + * <code>com.sun.star.sheet.SheetCellRange</code>. + * Object relations created : + * <ul> + * <li> <code>'SHEET'</code> for + * {@link ifc.sheet._XArrayFormulaRange} (the spreadsheet which the cell + * range was retrieved from)</li> + * </ul> + * @see com.sun.star.sheet.XSpreadsheet + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XCellRange testRange; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("Creating a test environment"); + + XSpreadsheets oSpreadsheets = UnoRuntime.queryInterface( + XSpreadsheetDocument.class, + xSheetDoc).getSheets(); + XNameAccess oNames = UnoRuntime.queryInterface( + XNameAccess.class, oSpreadsheets); + + XSpreadsheet oSheet = null; + + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oNames.getByName(oNames.getElementNames()[0])); + + oObj = oSheet.getCellRangeByPosition(0, 0, 3, 4); + testRange = UnoRuntime.queryInterface( + XCellRange.class, oObj); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("SHEET", oSheet); + // add expected results for the XCellRangesQuery interface test + String[]expectedResults = new String[7]; + expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.B1:C1;Sheet1.B3"; + expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = "Sheet1.B2:B3"; + expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = "Sheet1.A1 ... Sheet1.B1 ... Sheet1.B5 ... Sheet1.C3 ... Sheet1.D1"; + expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = "Sheet1.C2"; + expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = "Sheet1.D4"; + expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.A2:A4;Sheet1.C2:D4"; + expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.A2"; + tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", expectedResults); + tEnv.addObjRelation("XCellRangesQuery.CREATEENTRIES", Boolean.TRUE); + + XPropertySet PropSet = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + tEnv.addObjRelation("PropSet", PropSet); + + // XSearchable: Add a cell to make a searchable entry + try { + tEnv.addObjRelation("XSearchable.MAKEENTRYINCELL", new XCell[] { + testRange.getCellByPosition(0,0), testRange.getCellByPosition(0,1)}); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e){ + e.printStackTrace(log); + log.println("Cannot make required object relation 'XSearchable.MAKEENTRYINCELL'."); + } + + // XCellRangeData +/* Object[][] newData = new Object[5][4]; + for (int i=0; i<newData.length; i++) { + for (int j=0; j<newData[i].length; j++) { + newData[i][j] = new Double(i*10+j); + } + } + tEnv.addObjRelation("NewData", newData); */ + + //Adding relation for util.XSortable + final PrintWriter finalLog = log; + final XCellRange oTable = testRange; + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + try { + oTable.getCellByPosition(0, 0).setValue(4); + oTable.getCellByPosition(0, 1).setFormula("b"); + oTable.getCellByPosition(0, 2).setValue(3); + oTable.getCellByPosition(0, 3).setValue(23); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + boolean res = false; + String[] value = new String[4]; + + for (int i = 0; i < 4; i++) { + try { + XCell cell = oTable.getCellByPosition(0, i); + value[i] = cell.getFormula(); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + if (isSortNumbering) { + if (isSortAscending) { + out.println("Sorting ascending"); + + String[] rightVal = { "3", "4", "23", "b" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } else { + if (isSortAscending) { + String[] rightVal = { "3", "4", "23", "b" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } + + if (res) { + out.println("Sorted correctly"); + } else { + out.println("Sorted incorrectly"); + } + + return res; + } + }); + + return tEnv; + } +} // finish class ScCellRangeObj diff --git a/qadevOOo/tests/java/mod/_sc/ScCellRangesObj.java b/qadevOOo/tests/java/mod/_sc/ScCellRangesObj.java new file mode 100644 index 000000000..1dfbcfc1e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScCellRangesObj.java @@ -0,0 +1,224 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +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 ifc.sheet._XCellRangesQuery; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.SheetCellRanges</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::table::CellProperties</code></li> +* <li> <code>com::sun::star::container::XNameReplace</code></li> +* <li> <code>com::sun::star::container::XNameContainer</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::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::sheet::XSheetCellRangeContainer</code></li> +* <li> <code>com::sun::star::sheet::XSheetOperation</code></li> +* <li> <code>com::sun::star::sheet::XSheetCellRanges</code></li> +* <li> <code>com::sun::star::container::XNameAccess</code></li> +* </ul> +* @see com.sun.star.sheet.SheetCellRanges +* @see com.sun.star.table.CellProperties +* @see com.sun.star.container.XNameReplace +* @see com.sun.star.container.XNameContainer +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XIndexAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.sheet.XSheetCellRangeContainer +* @see com.sun.star.sheet.XSheetOperation +* @see com.sun.star.sheet.XSheetCellRanges +* @see com.sun.star.container.XNameAccess +* @see ifc.table._CellProperties +* @see ifc.container._XNameReplace +* @see ifc.container._XNameContainer +* @see ifc.beans._XPropertySet +* @see ifc.container._XIndexAccess +* @see ifc.container._XElementAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.sheet._XSheetCellRangeContainer +* @see ifc.sheet._XSheetOperation +* @see ifc.sheet._XSheetCellRanges +* @see ifc.container._XNameAccess +*/ +public class ScCellRangesObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a sheetdocument" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = + UnoRuntime.queryInterface (XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.sheet.SheetCellRanges</code> and fills some cells. + * Object relations created : + * <ul> + * <li> <code>'INSTANCE1', ..., 'INSTANCEN'</code> for + * {@link ifc.container._XNameReplace}, + * {@link ifc.container._XNameContainer} (type of + * <code>XCellRange</code>)</li> + * <li> <code>'THRCNT'</code> for + * {@link ifc.container._XNameReplace}(the number of the running threads + * that was retrieved from the method parameter <code>Param</code>)</li> + * <li> <code>'NameReplaceIndex'</code> for + * {@link ifc.container._XNameReplace} </li> + * </ul> + * @see com.sun.star.table.XCellRange + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oRange = 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() ); + + log.println("Getting test object "); + + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc); + + oObj = (XInterface) + SOF.createInstance(oComp, "com.sun.star.sheet.SheetCellRanges"); + + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndSheets = UnoRuntime.queryInterface (XIndexAccess.class, oSheets); + XSpreadsheet oSheet = null; + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), oIndSheets.getByIndex(0)); + XNameContainer oRanges = UnoRuntime.queryInterface(XNameContainer.class, oObj); + + oRange = oSheet.getCellRangeByName("C1:D4"); + oRanges.insertByName("Range1", oRange); + oRange = oSheet.getCellRangeByName("E2:F5"); + oRanges.insertByName("Range2", oRange); + oRange = oSheet.getCellRangeByName("G2:H3"); + oRanges.insertByName("Range3", oRange); + oRange = oSheet.getCellRangeByName("I7:J8"); + oRanges.insertByName("Range4", oRange); + + log.println("filling some cells"); + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 5; j++) { + oSheet.getCellByPosition(i, j).setFormula("a"); + } + } + for (int i = 0; i < 10; i++) { + for (int j = 5; j < 10; j++) { + oSheet.getCellByPosition(i, j).setValue(i + j); + } + } + + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // NameReplaceIndex : _XNameReplace + log.println( "adding NameReplaceIndex as mod relation to environment" ); + tEnv.addObjRelation("NameReplaceIndex", "0"); + + // INSTANCEn : _XNameContainer; _XNameReplace + log.println( "adding INSTANCEn as mod relation to environment" ); + + int THRCNT = 1; + if ((String)Param.get("THRCNT") != null) { + THRCNT= Integer.parseInt((String)Param.get("THRCNT")); + } + int a = 0; + int b = 0; + for (int n = 1; n < (THRCNT + 1) ; n++) { + a = n * 2; + b = a + 1; + oRange = oSheet.getCellRangeByName("A" + a + ":B" + b); + log.println( + "adding INSTANCE" + n + " as mod relation to environment" ); + + tEnv.addObjRelation("INSTANCE" + n, oRange); + } + + XPropertySet PropSet = UnoRuntime.queryInterface(XPropertySet.class, oObj); + tEnv.addObjRelation("PropSet",PropSet); + tEnv.addObjRelation("SHEET", oSheet); + // add expected results for the XCellRangesQuery interface test + String[]expectedResults = new String[7]; + expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.I7:J8"; + expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = ""; + expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = "Sheet1.D4"; + expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.I7:J8"; + expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.C2:D4"; // first range, first line invisible + tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", expectedResults); + + // for XSearchable and XReplaceable interface test + tEnv.addObjRelation("SEARCHSTRING", "15"); + + // for XFormulaQuery interface test + tEnv.addObjRelation("EXPECTEDDEPENDENTVALUES", new int[]{4,5,1,4}); + tEnv.addObjRelation("EXPECTEDPRECEDENTVALUES", new int[]{4,5,1,4}); + return tEnv ; + } + +} // finish class ScCellRangesObj + diff --git a/qadevOOo/tests/java/mod/_sc/ScCellTextCursor.java b/qadevOOo/tests/java/mod/_sc/ScCellTextCursor.java new file mode 100644 index 000000000..882f25702 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScCellTextCursor.java @@ -0,0 +1,162 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.text.XText; +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.text.TextCursor</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::text::XTextCursor</code></li> +* <li> <code>com::sun::star::text::XWordCursor</code></li> +* <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> +* <li> <code>com::sun::star::text::XTextRange</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::text::XSentenceCursor</code></li> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::text::XParagraphCursor</code></li> +* <li> <code>com::sun::star::document::XDocumentInsertable</code></li> +* <li> <code>com::sun::star::util::XSortable</code></li> +* <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> +* </ul> +* @see com.sun.star.text.TextCursor +* @see com.sun.star.text.XTextCursor +* @see com.sun.star.text.XWordCursor +* @see com.sun.star.style.CharacterPropertiesComplex +* @see com.sun.star.text.XTextRange +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XContentEnumerationAccess +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.text.XSentenceCursor +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.text.XParagraphCursor +* @see com.sun.star.document.XDocumentInsertable +* @see com.sun.star.util.XSortable +* @see com.sun.star.style.CharacterPropertiesAsian +* @see ifc.text._XTextCursor +* @see ifc.text._XWordCursor +* @see ifc.style._CharacterPropertiesComplex +* @see ifc.text._XTextRange +* @see ifc.beans._XPropertySet +* @see ifc.container._XContentEnumerationAccess +* @see ifc.beans._XPropertyState +* @see ifc.style._CharacterProperties +* @see ifc.text._XSentenceCursor +* @see ifc.style._ParagraphProperties +* @see ifc.text._XParagraphCursor +* @see ifc.document._XDocumentInsertable +* @see ifc.util._XSortable +* @see ifc.style._CharacterPropertiesAsian +*/ +public class ScCellTextCursor extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ; + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document + * and takes one of them. Retrieves the cell from the spreadsheet + * and creates text cursor of the cell using the interface + * <code>XText</code>. This text cursor is the instance of + * the service <code>com.sun.star.text.TextCursor</code>. + * Object relations created : + * <ul> + * <li> <code>'XTEXT'</code> for + * {@link ifc.text._XTextRange} (type of + * <code>XEnumerationAccess</code> that was retrieved from the + * collection of visible cells)</li> + * </ul> + * @see com.sun.star.text.XText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XCell aCell = 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 + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet") ; + aCell = oSheet.getCellByPosition(1,1) ; + + XText aText = UnoRuntime.queryInterface(XText.class, aCell); + aText.setString("ScCellTextCursor"); + oObj = aText.createTextCursor(); + + log.println( "creating a new environment for ScCellTextCursor object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Object relations for interface tests + tEnv.addObjRelation("XTEXT", aText); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ScCellTextCursor + diff --git a/qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj.java b/qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj.java new file mode 100644 index 000000000..47f43fd1d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScDataPilotItemObj.java @@ -0,0 +1,328 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.DataPilotFieldOrientation; +import com.sun.star.sheet.XDataPilotDescriptor; +import com.sun.star.sheet.XDataPilotField; +import com.sun.star.sheet.XDataPilotTables; +import com.sun.star.sheet.XDataPilotTablesSupplier; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +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 java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.DataPilotField</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::sheet::DataPilotField</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.sheet.DataPilotField +* @see com.sun.star.container.XNamed +* @see com.sun.star.sheet.DataPilotField +* @see com.sun.star.beans.XPropertySet +* @see ifc.container._XNamed +* @see ifc.sheet._DataPilotField +* @see ifc.beans._XPropertySet +*/ +public class ScDataPilotItemObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * A field is filled some values. This integer determines the size of the + * field in x and y direction. + */ + private static final int mMaxFieldIndex = 6; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a Spreadsheet document"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document + * and takes one of them. Fills some table in the spreadsheet. + * Obtains the collection of data pilot tables using the interface + * <code>XDataPilotTablesSupplier</code>. Creates a data pilot descriptor + * for the filled table and inserts new data pilot table with this descriptor + * to the collection. Obtains the collection of all the data pilot fields + * using the interface <code>XDataPilotDescriptor</code>. Retrieves from + * the collection the data pilot field with index 0. This data pilot field + * is the instance of the service <code>com.sun.star.sheet.DataPilotField</code>. + * @see com.sun.star.sheet.DataPilotField + * @see com.sun.star.sheet.XDataPilotTablesSupplier + * @see com.sun.star.sheet.XDataPilotDescriptor + */ + @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"); + + // the cell range + CellRangeAddress sCellRangeAddress = new CellRangeAddress(); + sCellRangeAddress.Sheet = 0; + sCellRangeAddress.StartColumn = 1; + sCellRangeAddress.StartRow = 0; + sCellRangeAddress.EndColumn = mMaxFieldIndex - 1; + sCellRangeAddress.EndRow = mMaxFieldIndex - 1; + + // position of the data pilot table + CellAddress sCellAddress = new CellAddress(); + sCellAddress.Sheet = 0; + sCellAddress.Column = 7; + sCellAddress.Row = 8; + + log.println("Getting a sheet"); + + XSpreadsheets xSpreadsheets = xSheetDoc.getSheets(); + XSpreadsheet oSheet = null; + XSpreadsheet oSheet2 = null; + XIndexAccess oIndexAccess = UnoRuntime.queryInterface( + XIndexAccess.class, xSpreadsheets); + // Make sure there are at least two sheets + xSpreadsheets.insertNewByName("Some Sheet", (short)0); + + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oIndexAccess.getByIndex(0)); + oSheet2 = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oIndexAccess.getByIndex(1)); + + log.println("Filling a table"); + + for (int i = 1; i < mMaxFieldIndex; i++) { + oSheet.getCellByPosition(i, 0).setFormula("Col" + i); + oSheet.getCellByPosition(0, i).setFormula("Row" + i); + oSheet2.getCellByPosition(i, 0).setFormula("Col" + i); + oSheet2.getCellByPosition(0, i).setFormula("Row" + i); + } + + for (int i = 1; i < mMaxFieldIndex; i++) + for (int j = 1; j < mMaxFieldIndex; j++) { + oSheet.getCellByPosition(i, j).setValue(i * (j + 1)); + oSheet2.getCellByPosition(i, j).setValue(i * (j + 2)); + } + + oSheet.getCellByPosition(1, 5); + + int x = sCellAddress.Column; + int y = sCellAddress.Row + 3; + + + oSheet.getCellByPosition(x, y); + + + // create the test objects + log.println("Getting test objects"); + + XDataPilotTablesSupplier DPTS = UnoRuntime.queryInterface( + XDataPilotTablesSupplier.class, + oSheet); + XDataPilotTables DPT = DPTS.getDataPilotTables(); + XDataPilotDescriptor DPDsc = DPT.createDataPilotDescriptor(); + DPDsc.setSourceRange(sCellRangeAddress); + + XPropertySet fieldPropSet = null; + + Object oDataPilotField = DPDsc.getDataPilotFields().getByIndex(0); + fieldPropSet = UnoRuntime.queryInterface( + XPropertySet.class, oDataPilotField); + + fieldPropSet.setPropertyValue("Function", + com.sun.star.sheet.GeneralFunction.SUM); + fieldPropSet.setPropertyValue("Orientation", + com.sun.star.sheet.DataPilotFieldOrientation.DATA); + + log.println("Insert the DataPilotTable"); + + if (DPT.hasByName("DataPilotTable")) { + DPT.removeByName("DataPilotTable"); + } + + XIndexAccess IA = DPDsc.getDataPilotFields(); + getSRange(IA); + + DPT.insertNewByName("DataPilotTable", sCellAddress, DPDsc); + + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), IA.getByIndex(0)); + + log.println("Creating object - " + + ((oObj == null) ? "FAILED" : "OK")); + + XDataPilotField xDataPilotField = UnoRuntime.queryInterface( + XDataPilotField.class, oObj); + + XIndexAccess xIA = xDataPilotField.getItems(); + + oObj = UnoRuntime.queryInterface(XInterface.class, + xIA.getByIndex(0)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("Implementationname: " + util.utils.getImplName(oObj)); + + // Other parameters required for interface tests + tEnv.addObjRelation("NoSetName", "ScDataPilotItemObj"); + return tEnv; + } + + private void getSRange(XIndexAccess IA) { + int fieldsAmount = IA.getCount() + 1; + + int i = -1; + int cnt = 0; + + while ((++i) < fieldsAmount) { + Object field; + + try { + field = IA.getByIndex(i); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + + return; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + + return; + } + + XNamed named = UnoRuntime.queryInterface(XNamed.class, + field); + String name = named.getName(); + + log.println("**Field : '" + name + "' ... "); + + if (!name.equals("Data")) { + + XPropertySet props = UnoRuntime.queryInterface( + XPropertySet.class, field); + + try { + switch (cnt % 5) { + case 0: + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.COLUMN); + log.println(" Column"); + + break; + + case 1: + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.ROW); + log.println(" Row"); + + break; + + case 2: + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.DATA); + log.println(" Data"); + + break; + + case 3: + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.HIDDEN); + log.println(" Hidden"); + + break; + + case 4: + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.PAGE); + log.println(" Page"); + + break; + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + + return; + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + + return; + } catch (com.sun.star.beans.PropertyVetoException e) { + e.printStackTrace(log); + + return; + } catch (com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace(log); + + return; + } + + if ((++cnt) > 4) { + break; + } + } else { + return; + } + } + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj.java b/qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj.java new file mode 100644 index 000000000..65630bd00 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScDatabaseRangeObj.java @@ -0,0 +1,200 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XCellRangeReferrer; +import com.sun.star.sheet.XDatabaseRanges; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCellRange; +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.XImportable; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.DatabaseRange</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::sheet::DatabaseRange</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::sheet::XDatabaseRange</code></li> +* <li> <code>com::sun::star::sheet::XCellRangeReferrer</code></li> +* </ul> +* @see com.sun.star.sheet.DatabaseRange +* @see com.sun.star.container.XNamed +* @see com.sun.star.sheet.DatabaseRange +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.sheet.XDatabaseRange +* @see com.sun.star.sheet.XCellRangeReferrer +* @see ifc.container._XNamed +* @see ifc.sheet._DatabaseRange +* @see ifc.beans._XPropertySet +* @see ifc.sheet._XDatabaseRange +* @see ifc.sheet._XCellRangeReferrer +*/ +public class ScDatabaseRangeObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a Spreadsheet document"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of database ranges in the document. + * If the database range with name <code>'dbRange'</code> exists + * in the collection then removes it from the collection. + * Creates new database range and adds it to the collection with the name + * <code>'dbRange'</code>.The database range that was added to the collection + * is the instance of the service <code>com.sun.star.sheet.DatabaseRange</code>. + * Object relations created : + * <ul> + * <li> <code>'DATAAREA'</code> for + * {@link ifc.sheet._XCellRangeReferrer}(of type + * <code>CellRangeAddress</code>)</li> + * <li> <code>'XCELLRANGE'</code> (of type <code>XCellRange</code>): + * cell range of the spreadsheet with database range</li> + * </ul> + * @see com.sun.star.sheet.DatabaseRange + * @see com.sun.star.table.CellRangeAddress + */ + @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"); + + log.println("Getting test object "); + + XPropertySet docProps = UnoRuntime.queryInterface( + XPropertySet.class, xSheetDoc); + + XSpreadsheets sheets = xSheetDoc.getSheets(); + String[] names = sheets.getElementNames(); + XDatabaseRanges dbRanges = null; + XImportable xImp = null; + + Object sheet = sheets.getByName(names[0]); + xImp = UnoRuntime.queryInterface(XImportable.class, + sheet); + dbRanges = (XDatabaseRanges) AnyConverter.toObject( + new Type(XDatabaseRanges.class), + docProps.getPropertyValue("DatabaseRanges")); + _doImport(xImp); + + String dbName = "dbRange"; + + if (dbRanges.hasByName(dbName)) { + dbRanges.removeByName(dbName); + } + + + CellRangeAddress aRange = null; + + XNameAccess dbrNA = UnoRuntime.queryInterface( + XNameAccess.class, dbRanges); + // we need to add it + dbRanges.addNewByName(dbName,new CellRangeAddress((short)0, 0, 0, 0, 5)); + + UnoRuntime.queryInterface(XNamed.class, + dbrNA.getByName( + dbName)); + + XCellRangeReferrer aReferrer = UnoRuntime.queryInterface( + XCellRangeReferrer.class, + dbrNA.getByName(dbName)); + XCellRangeAddressable aRangeA = UnoRuntime.queryInterface( + XCellRangeAddressable.class, + aReferrer.getReferredCells()); + aRange = aRangeA.getRangeAddress(); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), + dbrNA.getByName(dbName)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + // Other parameters required for interface tests + tEnv.addObjRelation("DATAAREA", aRange); + + XCellRange xCellRange = UnoRuntime.queryInterface( + XCellRange.class, sheets.getByName(names[0])); + + tEnv.addObjRelation("XCELLRANGE", xCellRange); + + return tEnv; + } + + public void _doImport(XImportable imp) { + PropertyValue[] descriptor = imp.createImportDescriptor(false); + + log.print("Setting the ImportDescriptor (Bibliograpy, SQL, select Identifier from biblio) -- "); + descriptor[0].Value = "Bibliography"; + descriptor[1].Value = com.sun.star.sheet.DataImportMode.SQL; + descriptor[2].Value = "select Identifier from biblio"; + log.println("done"); + + log.print("Importing data (Bibliograpy, Table, biblio) -- "); + imp.doImport(descriptor); + log.println("done"); + } +} diff --git a/qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration.java b/qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration.java new file mode 100644 index 000000000..1add5a952 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScDocumentConfiguration.java @@ -0,0 +1,71 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.DesktopTools; +import util.SOfficeFactory; + + +public class ScDocumentConfiguration extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a sheetdocument"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + DesktopTools.closeDoc(xSheetDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory docMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xSheetDoc); + Object oObj = docMSF.createInstance("com.sun.star.sheet.DocumentSettings"); + + log.println("Implementationname: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment((XInterface) oObj); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor.java b/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor.java new file mode 100644 index 000000000..f91682023 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextCursor.java @@ -0,0 +1,174 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XHeaderFooterContent; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +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.text.TextCursor</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::text::XTextCursor</code></li> +* <li> <code>com::sun::star::text::XWordCursor</code></li> +* <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> +* <li> <code>com::sun::star::text::XTextRange</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> +* <li> <code>com::sun::star::beans::XPropertyState</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::text::XSentenceCursor</code></li> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::text::XParagraphCursor</code></li> +* <li> <code>com::sun::star::document::XDocumentInsertable</code></li> +* <li> <code>com::sun::star::util::XSortable</code></li> +* <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> +* </ul> +* @see com.sun.star.text.TextCursor +* @see com.sun.star.text.XTextCursor +* @see com.sun.star.text.XWordCursor +* @see com.sun.star.style.CharacterPropertiesComplex +* @see com.sun.star.text.XTextRange +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.container.XContentEnumerationAccess +* @see com.sun.star.beans.XPropertyState +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.text.XSentenceCursor +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.text.XParagraphCursor +* @see com.sun.star.document.XDocumentInsertable +* @see com.sun.star.util.XSortable +* @see com.sun.star.style.CharacterPropertiesAsian +* @see ifc.text._XTextCursor +* @see ifc.text._XWordCursor +* @see ifc.style._CharacterPropertiesComplex +* @see ifc.text._XTextRange +* @see ifc.beans._XPropertySet +* @see ifc.container._XContentEnumerationAccess +* @see ifc.beans._XPropertyState +* @see ifc.style._CharacterProperties +* @see ifc.text._XSentenceCursor +* @see ifc.style._ParagraphProperties +* @see ifc.text._XParagraphCursor +* @see ifc.document._XDocumentInsertable +* @see ifc.util._XSortable +* @see ifc.style._CharacterPropertiesAsian +*/ +public class ScHeaderFooterTextCursor extends TestCase { + private XSpreadsheetDocument xSpreadsheetDoc; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSpreadsheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc) ; + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of style families available in the document + * using the interface <code>XStyleFamiliesSupplier</code>. + * Obtains default style from the style family <code>'PageStyles'</code>. + * Retrieves value of the property <code>'RightPageHeaderContent'</code>. + * Sets some string for the text which is printed in the center part of the + * header or footer using the interface <code>XHeaderFooterContent</code> + * and sets new value of the property <code>'RightPageHeaderContent'</code>. + * Creates text cursor for the text which is printed in the center part of + * the header or footer. This text cursor is the instance of the service + * <code>com.sun.star.text.TextCursor</code>. + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XPropertySet PropSet; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, + xSpreadsheetDoc ); + + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Default")); + + //get the property-set + PropSet = UnoRuntime.queryInterface(XPropertySet.class, StdStyle); + + XHeaderFooterContent RPHC = null; + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + RPHC = (XHeaderFooterContent) AnyConverter.toObject( + new Type(XHeaderFooterContent.class), + PropSet.getPropertyValue("RightPageHeaderContent")); + + XText center = RPHC.getCenterText(); + center.setString("CENTER"); + + PropSet.setPropertyValue("RightPageHeaderContent",RPHC); + + // create testobject here + oObj = center.createTextCursor(); + TestEnvironment tEnv = new TestEnvironment(oObj); + + // add relation for XTextRange + tEnv.addObjRelation("XTEXT", + UnoRuntime.queryInterface(XText.class,center)); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class ScHeaderFooterTextCursor diff --git a/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj.java b/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj.java new file mode 100644 index 000000000..990d6183a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScHeaderFooterTextObj.java @@ -0,0 +1,219 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XHeaderFooterContent; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +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.text.Text</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::text::XTextRangeMover</code></li> +* <li> <code>com::sun::star::text::XSimpleText</code></li> +* <li> <code>com::sun::star::text::XTextRange</code></li> +* <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> +* <li> <code>com::sun::star::text::XTextRangeCompare</code></li> +* <li> <code>com::sun::star::container::XElementAccess</code></li> +* <li> <code>com::sun::star::container::XEnumerationAccess</code></li> +* <li> <code>com::sun::star::text::XText</code></li> +* </ul> +* @see com.sun.star.text.Text +* @see com.sun.star.text.XTextRangeMover +* @see com.sun.star.text.XSimpleText +* @see com.sun.star.text.XTextRange +* @see com.sun.star.text.XRelativeTextContentInsert +* @see com.sun.star.text.XTextRangeCompare +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.container.XEnumerationAccess +* @see com.sun.star.text.XText +* @see ifc.text._XTextRangeMover +* @see ifc.text._XSimpleText +* @see ifc.text._XTextRange +* @see ifc.text._XRelativeTextContentInsert +* @see ifc.text._XTextRangeCompare +* @see ifc.container._XElementAccess +* @see ifc.container._XEnumerationAccess +* @see ifc.text._XText +*/ +public class ScHeaderFooterTextObj extends TestCase { + + private XSpreadsheetDocument xSpreadsheetDoc; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSpreadsheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSpreadsheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of style families available in the document + * using the interface <code>XStyleFamiliesSupplier</code>. + * Obtains default style from the style family <code>'PageStyles'</code>. + * Retrieves value of the property <code>'RightPageHeaderContent'</code>. + * Creates text cursor for the text which is printed in the center part of + * the header or footer using the interface <code>XHeaderFooterContent</code>. + * Insert some lines using the created cursor and sets new value of the + * property <code>'RightPageHeaderContent'</code>. The value of the property + * <code>'RightPageHeaderContent'</code> is the instance of the service + * <code>com.sun.star.text.Text</code>. + * Object relations created : + * <ul> + * <li> <code>'RangeForMove'</code> for + * {@link ifc.text._XTextRangeMover} (the range to be moved)</li> + * <li> <code>'XTextRange'</code> for + * {@link ifc.text._XTextRangeMover} (the range that includes moving + * range)</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}(the instance creator + * which can create instances of some text content service)</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert}(the instance creator + * which can create instances of <code>com.sun.star.text.Paragraph</code> + * service)</li> + * </ul> + * @see com.sun.star.text.Text + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XPropertySet PropSet; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, + xSpreadsheetDoc ); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Default")); + + //get the property-set + PropSet = UnoRuntime.queryInterface(XPropertySet.class, StdStyle); + + XHeaderFooterContent RPHC = null; + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + RPHC = (XHeaderFooterContent) AnyConverter.toObject( + new Type(XHeaderFooterContent.class), + PropSet.getPropertyValue("RightPageHeaderContent")); + + XText center = RPHC.getCenterText(); + + XTextRange text_to_move = null; + + log.println( "inserting some lines" ); + XTextCursor oCursor = center.createTextCursor(); + center.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + center.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + center.insertString(oCursor,"Paragraph 1", false); + center.insertString(oCursor,": ScHeaderFooterTextObj", false); + center.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + center.insertString(oCursor, "THE QUICK BROWN FOX JUMPS OVER THE" + + " LAZY DOG: ScHeaderFooterTextObj", false ); + center.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + center.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + oCursor.setString("TextForMove"); + text_to_move = oCursor; + + XTextCursor oCursor1 = center.createTextCursorByRange(center.getEnd()); + center.insertString(oCursor1,"Paragraph 2", false); + center.insertString(oCursor1,": ScHeaderFooterTextObj", false); + center.insertControlCharacter( + oCursor1, ControlCharacter.PARAGRAPH_BREAK, false ); + center.insertString( oCursor1, "THE QUICK BROWN FOX JUMPS OVER THE" + + " LAZY DOG: ScHeaderFooterTextObj", false); + center.insertControlCharacter( + oCursor1, ControlCharacter.PARAGRAPH_BREAK, false ); + center.insertControlCharacter( + oCursor1, ControlCharacter.LINE_BREAK, false ); + + PropSet.setPropertyValue("RightPageHeaderContent", RPHC); + + // create testobject here + oObj = center; + TestEnvironment tEnv = new TestEnvironment(oObj); + + DefaultDsc tDsc = new DefaultDsc( + "com.sun.star.text.XTextContent","com.sun.star.text.TextField.Time"); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( + "XTEXTINFO", new InstCreator( xSpreadsheetDoc, tDsc ) ); + + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator(xSpreadsheetDoc, pDsc) ); + + log.println("adding TextRange for XTextRangeMover" ); + tEnv.addObjRelation("RangeForMove", text_to_move); + tEnv.addObjRelation("XTextRange", RPHC.getCenterText()); + + return tEnv; + + } // finish method getTestEnvironment +} // finish class ScHeaderFooterTextObj diff --git a/qadevOOo/tests/java/mod/_sc/ScModelObj.java b/qadevOOo/tests/java/mod/_sc/ScModelObj.java new file mode 100644 index 000000000..e4a89b971 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScModelObj.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._sc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +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.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.SOfficeFactory; +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.SpreadsheetDocument</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::sheet::XSpreadsheetDocument</code></li> +* <li> <code>com::sun::star::sheet::SpreadsheetDocumentSettings</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::frame::XModel</code></li> +* <li> <code>com::sun::star::sheet::SpreadsheetDocument</code></li> +* <li> <code>com::sun::star::util::XNumberFormatsSupplier</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.sheet.SpreadsheetDocument +* @see com.sun.star.sheet.XSpreadsheetDocument +* @see com.sun.star.sheet.SpreadsheetDocumentSettings +* @see com.sun.star.lang.XComponent +* @see com.sun.star.frame.XModel +* @see com.sun.star.sheet.SpreadsheetDocument +* @see com.sun.star.util.XNumberFormatsSupplier +* @see com.sun.star.beans.XPropertySet +* @see ifc.sheet._XSpreadsheetDocument +* @see ifc.sheet._SpreadsheetDocumentSettings +* @see ifc.lang._XComponent +* @see ifc.frame._XModel +* @see ifc.sheet._SpreadsheetDocument +* @see ifc.util._XNumberFormatsSupplier +* @see ifc.beans._XPropertySet +*/ +public class ScModelObj extends TestCase { + private XSpreadsheetDocument xSpreadsheetDoc; + private XSpreadsheetDocument xSecondsheetDoc; + + /** + * Disposes Spreadsheet documents. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSpreadsheetDoc); + util.DesktopTools.closeDoc(oComp); + + oComp = UnoRuntime.queryInterface(XComponent.class, + xSecondsheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Disposes the spreadsheet documents if they were created already. + * Creates two spreadsheet documents. Retrieves the current controller for + * each of them. Obtains the collection of spreadsheets, takes one of them + * and takes some cell from the spreadsheet. The created documents are the instances + * of the service <code>com.sun.star.sheet.SpreadsheetDocument</code>. + * Object relations created : + * <ul> + * <li> <code>'SELSUPP'</code> for + * {@link ifc.frame._XModel}( the interface + * <code>XSelectionSupplier</code> that was queried from the current + * controller of the spreadsheet)</li> + * <li> <code>'TOSELECT'</code> for + * {@link ifc.frame._XModel}( the cell that was retrieved from the + * spreadsheet)</li> + * <li> <code>'CONT2'</code> for + * {@link ifc.frame._XModel}( the current controller of the second + * spreadsheet)</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + // creation of the 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()); + + if (xSpreadsheetDoc != null) { + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSpreadsheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + if (xSecondsheetDoc != null) { + XComponent oComp = UnoRuntime.queryInterface( + XComponent.class, xSecondsheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + log.println("creating two spreadsheet documents"); + xSpreadsheetDoc = SOF.createCalcDoc(null); + xSecondsheetDoc = SOF.createCalcDoc(null); + + XModel model1 = UnoRuntime.queryInterface(XModel.class, + xSpreadsheetDoc); + XModel model2 = UnoRuntime.queryInterface(XModel.class, + xSecondsheetDoc); + XInterface oObj = model1; + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController cont1 = model1.getCurrentController(); + XController cont2 = model2.getCurrentController(); + cont1.getFrame().setName("cont1"); + cont2.getFrame().setName("cont2"); + + XSelectionSupplier sel = UnoRuntime.queryInterface( + XSelectionSupplier.class, cont1); + + XCell toSel = null; + XCell[] xCalculatableCells = null; + log.println("Getting spreadsheet"); + + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets(); + XIndexAccess oIndexSheets = UnoRuntime.queryInterface( + XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oIndexSheets.getByIndex(0)); + + log.println("Getting a cell from sheet"); + toSel = oSheet.getCellByPosition(2, 3); + // create a simple formula for XCalculatable + oSheet.getCellByPosition(4, 5).setValue(15); + oSheet.getCellByPosition(5, 5).setValue(10); + oSheet.getCellByPosition(6, 5).setFormula("= E6 * F6"); + xCalculatableCells = new XCell[]{ + oSheet.getCellByPosition(4, 5), + oSheet.getCellByPosition(5, 5), + oSheet.getCellByPosition(6, 5) + }; + + // Make sure there are at least two sheets: + oSheets.insertNewByName("Some Sheet", (short) 1); + + log.println("Adding SelectionSupplier and Shape to select for XModel"); + tEnv.addObjRelation("SELSUPP", sel); + tEnv.addObjRelation("TOSELECT", toSel); + + log.println("Adding cells for XCalculatable"); + tEnv.addObjRelation("XCalculatable.Cells", xCalculatableCells); + log.println("adding Controller as ObjRelation for XModel"); + tEnv.addObjRelation("CONT2", cont2); + + // 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(oObj, fileName); + tEnv.addObjRelation("XPrintJobBroadcaster.XPrintJobListener", listener); + + return tEnv; + } + +} // finish class ScModelObj diff --git a/qadevOOo/tests/java/mod/_sc/ScShapeObj.java b/qadevOOo/tests/java/mod/_sc/ScShapeObj.java new file mode 100644 index 000000000..335f2f848 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScShapeObj.java @@ -0,0 +1,101 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ScShapeObj extends TestCase { + + static XComponent xSheetDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a sheetdoc" ); + xSheetDoc = UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null)); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.drawing.EllipseShape</code> as tested component + * and adds it to the document. + * Object relations created : + * <ul> + * <li> <code>'Style1', 'Style2'</code> for + * {@link ifc.drawing._Shape} : + * two values of 'Style' property. The first is taken + * from the shape tested, the second from another + * shape added to the draw page. </li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : + * creator which can create instances of + * <code>com.sun.star.text.TextField.URL</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = 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( tParam.getMSF()); + oShape = SOF.createShape(xSheetDoc,5000, 3500, 7500, 5000,"Rectangle"); + DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add(oShape); + oObj = oShape ; + + for (int i=0; i < 10; i++) { + DrawTools.getShapes(DrawTools.getDrawPage(xSheetDoc,0)).add( + SOF.createShape(xSheetDoc, + 5000, 3500, 7510 + 10 * i, 5010 + 10 * i, "Rectangle")); + } + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oShape ); + + log.println("Implementation name: "+util.utils.getImplName(oObj)); + tEnv.addObjRelation("DOCUMENT",xSheetDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ScShapeObj diff --git a/qadevOOo/tests/java/mod/_sc/ScSheetLinkObj.java b/qadevOOo/tests/java/mod/_sc/ScSheetLinkObj.java new file mode 100644 index 000000000..5e30fa9e5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScSheetLinkObj.java @@ -0,0 +1,143 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XSheetLinkable; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +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.sheet.SheetLink</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::util::XRefreshable</code></li> +* <li> <code>com::sun::star::sheet::SheetLink</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> ScSheetLinksObj.sdc </b> : for creating link </li> +* </ul> <p> +* @see com.sun.star.sheet.SheetLink +* @see com.sun.star.container.XNamed +* @see com.sun.star.util.XRefreshable +* @see com.sun.star.sheet.SheetLink +* @see com.sun.star.beans.XPropertySet +* @see ifc.container._XNamed +* @see ifc.util._XRefreshable +* @see ifc.sheet._SheetLink +* @see ifc.beans._XPropertySet +*/ +public class ScSheetLinkObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document + * and takes one of them. Links the sheet to another sheet in another + * document using the interface <code>XSheetLinkable</code>. Obtains the + * value of the property <code>'SheetLinks'</code> that is the collection of + * sheet links. Retrieves from the collection one of the sheet link that + * is the instance of the service <code>com.sun.star.sheet.SheetLink</code>. + * @see com.sun.star.sheet.SheetLink + * @see com.sun.star.sheet.XSheetLinkable + */ + @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" ); + XSpreadsheet oSheet = null; + + log.println("Getting test object ") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + XSheetLinkable SL = UnoRuntime.queryInterface(XSheetLinkable.class, oSheet); + + // creating link. Doesn't matter that it refers to unexistent object. + // this is for proper work of XAccess tests. + String sURL = utils.getFullTestDocName("ScSheetLinksObj.ods"); + SL.link(sURL, "Sheet1", "", "", com.sun.star.sheet.SheetLinkMode.VALUE); + + // Getting links. + XPropertySet docProps = UnoRuntime.queryInterface(XPropertySet.class, xSheetDoc); + Object oLinks = docProps.getPropertyValue("SheetLinks"); + + XNameAccess links = UnoRuntime.queryInterface(XNameAccess.class, oLinks); + + String[] names = links.getElementNames(); + + oObj = (XInterface)AnyConverter.toObject( + new Type(XInterface.class),links.getByName(names[0])); + + log.println("Creating object - " + + ((oObj == null) ? "FAILED" : "OK")); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sc/ScStyleObj.java b/qadevOOo/tests/java/mod/_sc/ScStyleObj.java new file mode 100644 index 000000000..8705c6d7d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScStyleObj.java @@ -0,0 +1,193 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.table.XCell; +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.style.Style</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::style::Style</code></li> +* <li> <code>com::sun::star::style::XStyle</code></li> +* </ul> +* @see com.sun.star.style.Style +* @see com.sun.star.container.XNamed +* @see com.sun.star.style.Style +* @see com.sun.star.style.XStyle +* @see ifc.container._XNamed +* @see ifc.style._Style +* @see ifc.style._XStyle +*/ +public class ScStyleObj extends TestCase { + private XSpreadsheetDocument xSpreadsheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a Spreadsheet document" ); + xSpreadsheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc); + util.DesktopTools.closeDoc(oComp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the collection of style families from the document + * using the interface <code>XStyleFamiliesSupplier</code>. + * Obtains style family with index 0 from the collection and obtains + * style with index 0 from this style family. Creates the instance of the + * service <code>com.sun.star.style.CellStyle</code>. Inserts the created + * style to the obtained style family. Retrieves a collection of spreadsheets + * from the document and takes one of them. Gets a cell from the spreadsheet + * and sets the value of property <code>'CellStyle'</code> to the created + * style. The created style is the instance of the service + * <code>com.sun.star.style.Style</code> also. + * Object relations created : + * <ul> + * <li> <code>'PoolStyle'</code> for + * {@link ifc.style._XStyle}(the style with index 0 that was obtained + * from the collection)</li> + * </ul> + * @see com.sun.star.style.CellStyle + * @see com.sun.star.style.Style + * @see com.sun.star.style.XStyleFamiliesSupplier + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + + // creation of the testobject here + // first we write what we are intend to do to log file + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oStyleFamiliesSupplier = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, xSpreadsheetDoc); + XNameAccess oStyleFamilies = oStyleFamiliesSupplier.getStyleFamilies(); + XIndexAccess oStyleFamiliesIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, oStyleFamilies); + XNameAccess oStyleFamilyNameAccess = null; + XStyle oStyle = null; + oStyleFamilyNameAccess = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class), + oStyleFamiliesIndexAccess.getByIndex(0)); + + XIndexAccess oStyleFamilyIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, + oStyleFamilyNameAccess); + oStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oStyleFamilyIndexAccess.getByIndex(0)); + + log.println("Creating a user-defined style"); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, xSpreadsheetDoc); + + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.CellStyle"); + XStyle oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + XNameContainer oStyleFamilyNameContainer = UnoRuntime. + queryInterface(XNameContainer.class, oStyleFamilyNameAccess); + + if (oStyleFamilyNameContainer.hasByName("My Style")) { + oStyleFamilyNameContainer.removeByName("My Style"); + } + + oStyleFamilyNameContainer.insertByName("My Style", oMyStyle); + + + //using the style + log.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSpreadsheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + + XCell aCell = null; + XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + log.println("Getting a cell from sheet") ; + aCell = oSheet.getCellByPosition(2,3) ; + + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, aCell); + + xProp.setPropertyValue("CellStyle", oMyStyle.getName()); + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment(oMyStyle); + + tEnv.addObjRelation("PoolStyle", oStyle); + + tEnv.addObjRelation("PropertyNames", getPropertyNames + (UnoRuntime.queryInterface + (XPropertySet.class, oMyStyle))); + + return tEnv; + } + + public String[] getPropertyNames(XPropertySet props) { + Property[] the_props = props.getPropertySetInfo().getProperties(); + ArrayList<String> names = new ArrayList<String>() ; + + for (int i=0;i<the_props.length;i++) { + boolean isWritable = + ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable) { + names.add(the_props[i].Name); + } + } + return names.toArray(new String[names.size()]) ; + } +} // finish class ScStyleObj diff --git a/qadevOOo/tests/java/mod/_sc/ScTabViewObj.java b/qadevOOo/tests/java/mod/_sc/ScTabViewObj.java new file mode 100644 index 000000000..a00b2724d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScTabViewObj.java @@ -0,0 +1,233 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import com.sun.star.container.NoSuchElementException; +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.drawing.XShape; +import com.sun.star.form.XForm; +import com.sun.star.lang.WrappedTargetException; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.ValueComparer; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +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.sheet.SpreadsheetView</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::sheet::XViewSplitable</code></li> + * <li> <code>com::sun::star::sheet::XViewFreezable</code></li> + * <li> <code>com::sun::star::sheet::SpreadsheetViewSettings</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::sheet::XSpreadsheetView</code></li> + * <li> <code>com::sun::star::view::XSelectionSupplier</code></li> + * </ul> + * @see com.sun.star.sheet.XViewSplitable + * @see com.sun.star.sheet.XViewFreezable + * @see com.sun.star.sheet.SpreadsheetViewSettings + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.sheet.XSpreadsheetView + * @see com.sun.star.view.XSelectionSupplier + * @see ifc.sheet._XViewSplitable + * @see ifc.sheet._XViewFreezable + * @see ifc.sheet._SpreadsheetViewSettings + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.sheet._XSpreadsheetView + * @see ifc.view._XSelectionSupplier + */ +public class ScTabViewObj extends TestCase { + private XSpreadsheetDocument xSpreadsheetDoc; + private XSpreadsheetDocument xSpreadsheetDoc2; + + /** + * Creates Spreadsheet document. + */ + @Override + public void initialize( TestParameters Param, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println("creating two spreadsheet documents"); + xSpreadsheetDoc = SOF.createCalcDoc(null); + util.utils.waitForEventIdle(Param.getMSF()); + xSpreadsheetDoc2 = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xSheetDoc " ); + XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc) ; + util.DesktopTools.closeDoc(oComp); + XComponent oComp2 = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc2) ; + util.DesktopTools.closeDoc(oComp2); + } + + /* + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the current controller of the spreadsheet document using the + * interface <code>XModel</code>. The controller is the instance of the + * service <code>com.sun.star.sheet.SpreadsheetView</code>. Retrieves + * a collection of spreadsheets from the document and takes one of them. + * Fills two cells in the spreadsheet. + * Object relations created : + * <ul> + * <li> <code>'Sheet'</code> for + * {@link ifc.sheet._XSpreadsheetView}(the retrieved spreadsheet)</li> + * </ul> + * @see com.sun.star.frame.XModel + * @see com.sun.star.sheet.SpreadsheetView + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XDrawPage oDrawPage = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XModel aSecondModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc2); + + XInterface oObj = aModel.getCurrentController(); + + log.println("getting sheets"); + XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets(); + + log.println("getting a sheet"); + XSpreadsheet oSheet = null; + XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), oIndexAccess.getByIndex(1)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XDispatchProvider.URL", ".uno:Copy") ; + + log.println("adding 'Sheet' as ObjRelation"); + tEnv.addObjRelation("Sheet", oSheet); + tEnv.addObjRelation("Frame",aModel.getCurrentController().getFrame()); + tEnv.addObjRelation("SecondModel",aSecondModel); + tEnv.addObjRelation("FirstModel",aModel); + + //Relation for XControlAccess + tEnv.addObjRelation("DOCUMENT", UnoRuntime.queryInterface(XComponent.class,xSpreadsheetDoc)); + tEnv.addObjRelation("XControlAccess.isSheet", Boolean.TRUE); + //Relations for XSelectionSupplier + XCell cell_1 = null; + XCell cell_2 = null; + Object cellRange = null; + cellRange = oSheet.getCellRangeByPosition(0, 0, 3, 3); + cell_1 = oSheet.getCellByPosition(5,5); + cell_2 = oSheet.getCellByPosition(7,7); + cell_2.setValue(17.5); + cell_1.setValue(5.5); + + Object[] selections = {oSheet, cellRange, cell_1, cell_2}; + tEnv.addObjRelation("Selections", selections); + + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XCellRangeAddressable adr1 = UnoRuntime.queryInterface(XCellRangeAddressable.class, o1); + XCellRangeAddressable adr2 = UnoRuntime.queryInterface(XCellRangeAddressable.class, o2); + if (adr1 == null || adr2 == null) return -1; + CellRangeAddress range1 = adr1.getRangeAddress(); + CellRangeAddress range2 = adr2.getRangeAddress(); + return ValueComparer.equalValue(range1, range2) ? 0 : 1 ; + }}); + + tEnv.addObjRelation("XUserInputInterception.XModel", aModel); + + // XForm for com.sun.star.view.XFormLayerAccess + + XForm myForm = null; + String kindOfControl="CommandButton"; + XShape aShape = null; + log.println("adding control shape '" + kindOfControl + "'"); + XComponent oComp = UnoRuntime.queryInterface(XComponent.class, xSpreadsheetDoc) ; + + aShape = FormTools.createControlShape(oComp, 3000, 4500, 15000, 10000, kindOfControl); + + log.println("adding relation for com.sun.star.view.XFormLayerAccess: XForm"); + try { + log.println( "getting Drawpages" ); + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface(XDrawPagesSupplier.class,xSpreadsheetDoc); + XDrawPages oDP = oDPS.getDrawPages(); + oDP.insertNewByIndex(1); + oDP.insertNewByIndex(2); + oDrawPage = (XDrawPage) AnyConverter.toObject( + new Type(XDrawPage.class),oDP.getByIndex(0)); + if (oDrawPage == null) + log.println("ERROR: could not get DrawPage: null"); + + oDrawPage.add(aShape); + log.println("getting XForm"); + XNameContainer xForm = FormTools.getForms(oDrawPage); + try { + myForm = (XForm) AnyConverter.toObject(new Type(XForm.class),xForm.getByName("Standard")); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not XForm 'Standard': " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not XForm 'Standard': " + ex.toString()); + } catch (NoSuchElementException ex) { + log.println("ERROR: could not XForm 'Standard': " + ex.toString()); + } + if (myForm == null) + log.println("ERROR: could not get XForm: null"); + tEnv.addObjRelation("XFormLayerAccess.XForm", myForm); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } + return tEnv; + } + +} // finish class ScTabViewObj diff --git a/qadevOOo/tests/java/mod/_sc/ScTableSheetObj.java b/qadevOOo/tests/java/mod/_sc/ScTableSheetObj.java new file mode 100644 index 000000000..436901258 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/ScTableSheetObj.java @@ -0,0 +1,384 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package mod._sc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.XScenariosSupplier; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +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.XCloseable; + +import ifc.sheet._XCellRangesQuery; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; +import util.ValueComparer; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.sheet.Spreadsheet</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::style::ParagraphProperties</code></li> +* <li> <code>com::sun::star::table::XTableChartsSupplier</code></li> +* <li> <code>com::sun::star::sheet::XSpreadsheet</code></li> +* <li> <code>com::sun::star::table::CellProperties</code></li> +* <li> <code>com::sun::star::sheet::XSheetAnnotationsSupplier</code></li> +* <li> <code>com::sun::star::table::XCellRange</code></li> +* <li> <code>com::sun::star::sheet::XCellRangeAddressable</code></li> +* <li> <code>com::sun::star::sheet::XDataPilotTablesSupplier</code></li> +* <li> <code>com::sun::star::sheet::Spreadsheet</code></li> +* <li> <code>com::sun::star::sheet::XCellRangeMovement</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::sheet::XSheetOperation</code></li> +* <li> <code>com::sun::star::sheet::XScenariosSupplier</code></li> +* <li> <code>com::sun::star::sheet::XSheetPageBreak</code></li> +* <li> <code>com::sun::star::sheet::XArrayFormulaRange</code></li> +* <li> <code>com::sun::star::sheet::XSheetCellRange</code></li> +* <li> <code>com::sun::star::container::XNamed</code></li> +* <li> <code>com::sun::star::sheet::SheetCellRange</code></li> +* <li> <code>com::sun::star::chart::XChartData</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::util::XMergeable</code></li> +* <li> <code>com::sun::star::table::XColumnRowRange</code></li> +* </ul> +* @see com.sun.star.style.ParagraphProperties +* @see com.sun.star.table.XTableChartsSupplier +* @see com.sun.star.sheet.XSpreadsheet +* @see com.sun.star.table.CellProperties +* @see com.sun.star.sheet.XSheetAnnotationsSupplier +* @see com.sun.star.table.XCellRange +* @see com.sun.star.sheet.XCellRangeAddressable +* @see com.sun.star.sheet.XDataPilotTablesSupplier +* @see com.sun.star.sheet.Spreadsheet +* @see com.sun.star.sheet.XCellRangeMovement +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.sheet.XSheetOperation +* @see com.sun.star.sheet.XScenariosSupplier +* @see com.sun.star.sheet.XSheetPageBreak +* @see com.sun.star.sheet.XArrayFormulaRange +* @see com.sun.star.sheet.XSheetCellRange +* @see com.sun.star.container.XNamed +* @see com.sun.star.sheet.SheetCellRange +* @see com.sun.star.chart.XChartData +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.util.XMergeable +* @see com.sun.star.table.XColumnRowRange +* @see ifc.style._ParagraphProperties +* @see ifc.table._XTableChartsSupplier +* @see ifc.sheet._XSpreadsheet +* @see ifc.table._CellProperties +* @see ifc.sheet._XSheetAnnotationsSupplier +* @see ifc.table._XCellRange +* @see ifc.sheet._XCellRangeAddressable +* @see ifc.sheet._XDataPilotTablesSupplier +* @see ifc.sheet._Spreadsheet +* @see ifc.sheet._XCellRangeMovement +* @see ifc.style._CharacterProperties +* @see ifc.sheet._XSheetOperation +* @see ifc.sheet._XScenariosSupplier +* @see ifc.sheet._XSheetPageBreak +* @see ifc.sheet._XArrayFormulaRange +* @see ifc.sheet._XSheetCellRange +* @see ifc.container._XNamed +* @see ifc.sheet._SheetCellRange +* @see ifc.chart._XChartData +* @see ifc.beans._XPropertySet +* @see ifc.util._XMergeable +* @see ifc.table._XColumnRowRange +*/ +public class ScTableSheetObj extends TestCase { + private XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a sheetdocument"); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + + try { + XCloseable oCloser = UnoRuntime.queryInterface( + XCloseable.class, xSheetDoc); + oCloser.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Document already disposed"); + } catch (NullPointerException e) { + log.println("Couldn't get XCloseable"); + } + + util.utils.pause(500); + + log.println("... Done"); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from the document and takes one of + * them. Fills some cell in the spreadsheet. The retrieved spreadsheet is the + * instance of the service <code>com.sun.star.sheet.Spreadsheet</code>. + * Object relations created : + * <ul> + * <li> <code>'noArray'</code> for + * {@link ifc.sheet._XArrayFormulaRange}(to avoid the test of + * the interface <code>XArrayFormulaRange</code>)</li> + * </ul> + * @see com.sun.star.sheet.XArrayFormulaRange + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + log.println("getting sheets"); + + XSpreadsheets xSpreadsheets = xSheetDoc.getSheets(); + + log.println("getting a sheet"); + + XSpreadsheet oSheet = null; + XIndexAccess oIndexAccess = UnoRuntime.queryInterface( + XIndexAccess.class, xSpreadsheets); + + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class), + oIndexAccess.getByIndex(0)); + + log.println("filling some cells"); + + oSheet.getCellByPosition(5, 5).setValue(15); + oSheet.getCellByPosition(1, 4).setValue(10); + oSheet.getCellByPosition(2, 0).setValue(-5.15); + oSheet.getCellByPosition(8, 8).setFormula("= B5 + C1"); + // fill cells for XSheetOtline::autooutline + oSheet.getCellByPosition(6, 6).setValue(3); + oSheet.getCellByPosition(7, 6).setValue(3); + oSheet.getCellByPosition(8, 6).setFormula("= SUM(G7:H7)"); + oSheet.getCellByPosition(9, 6).setFormula("= G7*I7"); + + oObj = UnoRuntime.queryInterface(XInterface.class, oSheet); + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + // set the address ranges of the cells (see values set above): for e.g. XSheetOutline test + tEnv.addObjRelation("CellRangeAddress", + new CellRangeAddress((short)0, 6, 6, 8, 8)); + tEnv.addObjRelation("CellRangeSubAddress", + new CellRangeAddress((short)0, 6, 6, 7, 8)); + // pick a cell with a formula for XSheetAuditing, a dependent cell and a precedent cell + tEnv.addObjRelation("XSheetAuditing.CellAddress", new CellAddress((short)0, 8, 6)); + tEnv.addObjRelation("XSheetAuditing.PrecedentCellAddress", new CellAddress((short)0, 7, 6)); + tEnv.addObjRelation("XSheetAuditing.DependentCellAddress", new CellAddress((short)0, 9, 6)); + + // add an existing sheet for linking + tEnv.addObjRelation("XSheetLinkable.LinkSheet", "ScSheetLinksObj.ods"); + + //adding Scenario and with that a ScenarioSheet-Relation for Scenario and XScenarioEnhanced + XScenariosSupplier scene = UnoRuntime.queryInterface( + XScenariosSupplier.class, + tEnv.getTestObject()); + scene.getScenarios() + .addNewByName("Scenario", + new CellRangeAddress[] { + new CellRangeAddress((short) 0, 0, 0, 10, 10) + }, "Comment"); + + XSpreadsheet sSheet = null; + + try { + sSheet = UnoRuntime.queryInterface( + XSpreadsheet.class, + xSpreadsheets.getByName("Scenario")); + } catch (com.sun.star.container.NoSuchElementException e) { + log.println("Couldn't get Scenario"); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Couldn't get Scenario"); + } + + tEnv.addObjRelation("ScenarioSheet", sSheet); + + log.println("adding ObjRelation 'noArray' to avoid the test" + + " 'XArrayFormulaRange'"); + tEnv.addObjRelation("noArray", "ScTableSheetObj"); + + XPropertySet PropSet = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + tEnv.addObjRelation("PropSet", PropSet); + tEnv.addObjRelation("SHEET", oSheet); + + // add expected results for the XCellRangesQuery interface test + String[] expectedResults = new String[7]; + expectedResults[_XCellRangesQuery.QUERYCOLUMNDIFFERENCES] = "Sheet1.B5;Sheet1.C1"; + expectedResults[_XCellRangesQuery.QUERYCONTENTCELLS] = "Sheet1.B5;Sheet1.C1;Sheet1.F6"; + expectedResults[_XCellRangesQuery.QUERYEMPTYCELLS] = "Sheet1.A1 ... Sheet1.B1 ... Sheet1.B6 ... Sheet1.C2 ... Sheet1.D1 ... Sheet1.F1 ... Sheet1.F7 ... Sheet1.G1"; + expectedResults[_XCellRangesQuery.QUERYFORMULACELLS] = "Sheet1.I7:J7;Sheet1.I9"; + expectedResults[_XCellRangesQuery.QUERYINTERSECTION] = "Sheet1.D4"; + expectedResults[_XCellRangesQuery.QUERYROWDIFFERENCES] = "Sheet1.A5;Sheet1.C1"; + expectedResults[_XCellRangesQuery.QUERYVISIBLECELLS] = "Sheet1.A2"; + tEnv.addObjRelation("XCellRangesQuery.EXPECTEDRESULTS", + expectedResults); + + // for XFormulaQuery interface test + try { + tEnv.addObjRelation("MAKEENTRYINCELL", + oSheet.getCellByPosition(15, 15)); + tEnv.addObjRelation("RANGEINDICES", new int[] { 0, 0 }); + tEnv.addObjRelation("EXPECTEDDEPENDENTVALUES", + new int[] { 0, 255, 0, 65535 }); + tEnv.addObjRelation("EXPECTEDPRECEDENTVALUES", + new int[] { 0, 255, 0, 65535 }); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println( + "Cannot add the necessary object relation for XFormulaQuery test."); + } + + // XSearchable interface test + try { + tEnv.addObjRelation("XSearchable.MAKEENTRYINCELL", + new XCell[] { + oSheet.getCellByPosition(15, 15), + oSheet.getCellByPosition(15, 16) + }); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + log.println( + "Cannot make required object relation 'XSearchable.MAKEENTRYINCELL'."); + } + + //Adding relation for util.XSortable + final PrintWriter finalLog = log; + final XCellRange oTable = oSheet; + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + try { + oTable.getCellByPosition(0, 0).setValue(4); + oTable.getCellByPosition(0, 1).setFormula("b"); + oTable.getCellByPosition(0, 2).setValue(3); + oTable.getCellByPosition(0, 3).setValue(23); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + boolean res = false; + String[] value = new String[4]; + + for (int i = 0; i < 4; i++) { + try { + XCell cell = oTable.getCellByPosition(0, i); + value[i] = cell.getFormula(); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + out.println("Exception while checking sort"); + } + } + + if (isSortNumbering) { + if (isSortAscending) { + out.println("Sorting ascending"); + + String[] rightVal = { "3", "4", "23", "b" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + String[] vals = { value[0], value[1], value[2], value[3] }; + res = ValueComparer.equalValue(vals, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } else { + if (isSortAscending) { + String[] rightVal = { "3", "4", "23", "b" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected 3, 4, 23, b"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } else { + String[] rightVal = { "b", "23", "4", "3" }; + res = ValueComparer.equalValue(value, rightVal); + out.println("Expected b, 23, 4, 3"); + out.println("getting: " + value[0] + ", " + + value[1] + ", " + value[2] + ", " + + value[3]); + } + } + + if (res) { + out.println("Sorted correctly"); + } else { + out.println("Sorted incorrectly"); + } + + return res; + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sc/XMLContentExporter.java b/qadevOOo/tests/java/mod/_sc/XMLContentExporter.java new file mode 100644 index 000000000..098866ff0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLContentExporter.java @@ -0,0 +1,190 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.XCell; +import com.sun.star.uno.Any; +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.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + + static XComponent xSheetDoc; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a calc document" ); + xSheetDoc = SOF.openDoc("scalc","_blank"); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xCalcDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The calc document is set as a source document for exporter + * created. A cell in the sheet is set to some value. This made + * for checking if this value is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String CELL_TEXT = "XMLContentExporter"; + + ContentFilterChecker Filter = new ContentFilterChecker(log); + + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Calc.XMLContentExporter", + new Object[] {arg} ); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xSheetDoc); + + // Setting some string to a cell + XSpreadsheetDocument xSpreadsheetDoc = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); + XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets(); + XIndexAccess xSheetsIndexArray = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); + XSpreadsheet xSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),xSheetsIndexArray.getByIndex(0)); + XCell xCell = xSheet.getCellByPosition(0, 0); + xCell.setFormula(CELL_TEXT); + + log.println("fill sheet 1 with content..."); + util.CalcTools.fillCalcSheetWithContent(xSheetDoc, 1, 1, 1, 5, 5); + + // adding tags which must be contained in XML output + Filter.addTag("office:document-content"); + Filter.addTagEnclosed("office:body", "office:document-content"); + Filter.addTagEnclosed("office:script", "office:document-content"); + Filter.addTagEnclosed("table:table", "office:body"); + Filter.addTagEnclosed("table:table-column", "table:table"); + Filter.addTagEnclosed("table:table-row", "table:table"); + Filter.addTagEnclosed("table:table-cell", "table:table-row"); + Filter.addTagEnclosed("text:p", "table:table-cell"); + Filter.addCharactersEnclosed(CELL_TEXT, "text:p"); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"scalc: StarOffice XML (Calc)"})); + tEnv.addObjRelation("SourceDocument",xSheetDoc); + tEnv.addObjRelation("XFilter.Checker", Filter); + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class ContentFilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private ContentFilterChecker(PrintWriter log) { + super(log) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLContentImporter.java b/qadevOOo/tests/java/mod/_sc/XMLContentImporter.java new file mode 100644 index 000000000..5f3d65547 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLContentImporter.java @@ -0,0 +1,180 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XImporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + private XSpreadsheetDocument xSheetDoc; + static XComponent comp ; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc( null ); + comp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc) ; + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + util.DesktopTools.closeDoc(comp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLContentImporter</code><p> + * + * The calc document is set as a target document for importer. + * Imported XML-data contains only content tags including table + * with test table name. + * After import table name getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Calc.XMLContentImporter") ; + XImporter imp = UnoRuntime.queryInterface + (XImporter.class, oInt) ; + imp.setTargetDocument(comp); + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relations + tEnv.addObjRelation("TargetDocument", comp) ; + + final String impValue = "XMLContentImporter_test" ; + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-content", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "office:class", "CDATA", "spreadsheet" + }, + {"start", "office:body"}, + {"start", "table:table", + "table:name", "CDATA", impValue}, + {"end", "table:table"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + //save to log content before import + final PrintWriter fLog = log; + final XSpreadsheets xSheets = xSheetDoc.getSheets(); + + log.println("Sheets before importing :") ; + String[] names = xSheets.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]) ; + } + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + fLog.println("Sheet names :") ; + String[] snames = xSheets.getElementNames() ; + for (int i = 0; i < snames.length; i++) { + fLog.println(" " + snames[i]) ; + } + return xSheets.hasByName(impValue) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLExporter.java b/qadevOOo/tests/java/mod/_sc/XMLExporter.java new file mode 100644 index 000000000..c9edb37ab --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLExporter.java @@ -0,0 +1,199 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.uno.Any; +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.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + static XComponent xSheetDoc; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a calc document" ); + xSheetDoc = SOF.openDoc("scalc","_blank"); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xCalcDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The calc document is set as a source document for exporter + * created. Checking whether tags for table corresponding to some sheet + * is exported.<p> + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker Filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + final String SHEET_NAME = "XMLExporter_SheetTestName"; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Calc.XMLExporter", new Object[] {arg} ); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xSheetDoc); + + //set name of sheet + XSpreadsheetDocument xSpreadsheetDoc = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); + XSpreadsheets xSpreadsheets = xSpreadsheetDoc.getSheets(); + XIndexAccess xSheetsIndexArray = UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets); + XSpreadsheet xSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),xSheetsIndexArray.getByIndex(0)); + XNamed xSheetNamed = UnoRuntime.queryInterface(XNamed.class, xSheet); + xSheetNamed.setName(SHEET_NAME); + + log.println("fill sheet with content..."); + util.CalcTools.fillCalcSheetWithContent(xSheet, 3, 3, 50, 50); + + // adding tags which must be contained in XML output + Filter.addTag( new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:script"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:styles"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("table:table"), + new XMLTools.Tag("office:body") ); + Filter.addTag( + new XMLTools.Tag("table:table", "table:name", SHEET_NAME) ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"scalc: StarOffice XML (Calc)"})); + tEnv.addObjRelation("SourceDocument",xSheetDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLImporter.java b/qadevOOo/tests/java/mod/_sc/XMLImporter.java new file mode 100644 index 000000000..ff5e94063 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLImporter.java @@ -0,0 +1,176 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XImporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + + static XComponent xSheetDoc; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + XSpreadsheetDocument xSpreadsheetDoc = SOF.createCalcDoc( null ); + xSheetDoc = UnoRuntime.queryInterface + (XComponent.class, xSpreadsheetDoc); + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLImporter</code><p> + * + * The calc document is set as a target document for importer. + * Imported tags contain new value for table name. + * After import table name getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance("com.sun.star.comp.Calc.XMLImporter") ; + XImporter imp = UnoRuntime.queryInterface + (XImporter.class, oInt) ; + imp.setTargetDocument(xSheetDoc); + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xSheetDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "office:class", "CDATA", "spreadsheet" + }, + {"start", "office:body"}, + {"start", "table:table", + "table:name", "CDATA", impValue}, + {"end", "table:table"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter fLog = log ; + XSpreadsheetDocument xSpreadsheetDoc = UnoRuntime.queryInterface(XSpreadsheetDocument.class, xSheetDoc); + final XSpreadsheets sheets = xSpreadsheetDoc.getSheets() ; + log.println("Sheets before importing :") ; + String[] names = sheets.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]) ; + } + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + fLog.println("Sheet names :") ; + String[] snames = sheets.getElementNames() ; + for (int i = 0; i < snames.length; i++) { + fLog.println(" " + snames[i]) ; + } + + return sheets.hasByName(impValue) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java new file mode 100644 index 000000000..0f49662c1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java @@ -0,0 +1,181 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + + static XComponent xSheetDoc; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a calc document" ); + xSheetDoc = SOF.openDoc("scalc","_blank"); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xCalcDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The calc document is set as a source document for exporter + * created. A meta property 'Title' is set to some value. This made + * for checking if this value is successfully exported within + * the document meta information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + // Checking tags existence and changed property value + filter.addTag(new XMLTools.Tag ("office:document-meta")); + filter.addTag(new XMLTools.Tag ("office:meta")); + filter.addCharactersEnclosed("TestDocument", + new XMLTools.Tag ("dc:title")); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Calc.XMLMetaExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xSheetDoc); + + // Obtaining and changing property values + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xSheetDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle("TestDocument"); + + log.println("fill sheet 1 with content..."); + util.CalcTools.fillCalcSheetWithContent(xSheetDoc,1, 3, 3, 50, 50); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"scalc: StarOffice XML (Calc)"})); + tEnv.addObjRelation("SourceDocument",xSheetDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java new file mode 100644 index 000000000..b7e26d0bb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java @@ -0,0 +1,171 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XImporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + private XSpreadsheetDocument xSheetDoc; + static XComponent comp ; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc( null ); + comp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc) ; + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + util.DesktopTools.closeDoc(comp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLMetaImporter</code><p> + * + * The calc document is set as a target document for importer. + * Imported XML-data contains only meta tags including title tag + * with test title name. + * After import title name getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impTitle = "XMLMetaImporter" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Calc.XMLMetaImporter") ; + XImporter imp = UnoRuntime.queryInterface + (XImporter.class, oInt) ; + imp.setTargetDocument(comp) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:meta", "CDATA", "http://openoffice.org/2000/meta", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"}, + {"start", "office:meta"} , + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xSheetDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_sc/XMLSettingsExporter.java new file mode 100644 index 000000000..9386a233d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLSettingsExporter.java @@ -0,0 +1,182 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + + static XComponent xSheetDoc; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a calc document" ); + xSheetDoc = SOF.openDoc("scalc","_blank"); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xCalcDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The calc document is set as a source document for exporter + * created. Sets settings' property 'ShowGrid' to 'false', then checks + * it in the exported xml document.<p> + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + SettingsFilterChecker filter = new SettingsFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), filter); + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Calc.XMLSettingsExporter", + new Object[] {arg} ); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xSheetDoc); + + //set some settings + XModel xSheetModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + XController xController = xSheetModel.getCurrentController(); + XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + xPropSet.setPropertyValue("ShowGrid", "false"); + + util.CalcTools.fillCalcSheetWithContent(xSheetDoc, 0, 3, 3, 50, 50); + + //Create and prepare filter + // adding tags which must be contained in XML output + filter.addTag(new XMLTools.Tag("office:document-settings") ); + filter.addTagEnclosed( + new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document-settings") ); + filter.addCharactersEnclosed( + "false", + new XMLTools.Tag("config:config-item", "config:name", "ShowGrid") ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"scalc: StarOffice XML (Calc)"})); + tEnv.addObjRelation("SourceDocument",xSheetDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class SettingsFilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private SettingsFilterChecker(PrintWriter log) { + super(log, false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_sc/XMLSettingsImporter.java new file mode 100644 index 000000000..fc83d3e3b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLSettingsImporter.java @@ -0,0 +1,199 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XImporter; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + private XSpreadsheetDocument xSheetDoc; + static XComponent comp ; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc( null ); + comp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc) ; + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + util.DesktopTools.closeDoc(comp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLSettingsImporter</code><p> + * + * The calc document is set as a target document for importer. + * Imported XML-data contains only settings tags including tag + * with new number of iteration steps. + * After import 'IterationCount' property getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + final XPropertySet xPropSet ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Calc.XMLSettingsImporter") ; + XImporter imp = UnoRuntime.queryInterface + (XImporter.class, oInt) ; + imp.setTargetDocument(comp) ; + + XModel xSheetModel = UnoRuntime.queryInterface(XModel.class, xSheetDoc); + XController xController = xSheetModel.getCurrentController(); + xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config"}, + {"start", "office:settings"}, + {"start", "config:config-item-set", + "config:name", "CDATA", "view-settings"}, + {"start", "config:config-item-map-indexed", + "config:name", "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start", "config:config-item", + "config:name", "CDATA", "ShowGrid", + "config:type", "CDATA", "boolean"}, + {"chars", "false"}, + {"end", "config:config-item"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomType", + "config:type", "CDATA", "short"}, + {"chars", "0"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomValue", + "config:type", "CDATA", "int"}, + {"chars", "124"}, + {"end", "config:config-item"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "config:config-item-set"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Object gVal = xPropSet.getPropertyValue("ShowGrid") ; + logF.println("ShowGrid = " + gVal ) ; + return "false".equals(gVal) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_sc/XMLStylesExporter.java new file mode 100644 index 000000000..36b1bc7e7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLStylesExporter.java @@ -0,0 +1,185 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.Any; +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.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + static XComponent xSheetDoc; + protected int counter = 0; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a calc document" ); + xSheetDoc = SOF.openDoc("scalc","_blank"); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xCalcDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The calc document is set as a source document for exporter + * created. New style 'NewStyle' added to style family "Cell Styles". + * This made for checking if this style is successfully exported within + * the document styles information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + String newName = "NewStyle" + counter++; + // Adding tags for checking existence of head tag and property value + filter.addTag(new XMLTools.Tag("office:document-styles")); + filter.addTag(new XMLTools.Tag("style:style","style:name", newName)); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Calc.XMLStylesExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xSheetDoc); + + // Obtaining and changing property values + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface( + XStyleFamiliesSupplier.class, xSheetDoc); + XNameAccess StyleFamilies = styleSup.getStyleFamilies(); + String[] styleFamiliesNames = StyleFamilies.getElementNames(); + XNameContainer StyleFamilyName = (XNameContainer) + AnyConverter.toObject(new Type(XNameContainer.class), + StyleFamilies.getByName(styleFamiliesNames[0])); + Object SC = SOF.createInstance( + xSheetDoc, "com.sun.star.style.CellStyle"); + XStyle StyleCell = UnoRuntime.queryInterface(XStyle.class,SC); + StyleFamilyName.insertByName(newName, StyleCell); + + log.println("fill sheet 1 with content..."); + util.CalcTools.fillCalcSheetWithContent(xSheetDoc, 0, 3, 3, 50, 100); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"scalc: StarOffice XML (Calc)"})); + tEnv.addObjRelation("SourceDocument",xSheetDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_sc/XMLStylesImporter.java new file mode 100644 index 000000000..49cb036de --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/XMLStylesImporter.java @@ -0,0 +1,196 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._sc; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.document.XImporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + private XSpreadsheetDocument xSheetDoc; + static XComponent comp ; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a Spreadsheet document" ); + xSheetDoc = SOF.createCalcDoc( null ); + comp = UnoRuntime.queryInterface + (XComponent.class, xSheetDoc) ; + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + util.DesktopTools.closeDoc(comp); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLStylesImporter</code><p> + * + * The calc document is set as a target document for importer. + * Imported XML-data contains only style tags including tag + * with new style name. + * After import style names getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Calc.XMLStylesImporter") ; + XImporter imp = UnoRuntime.queryInterface + (XImporter.class, oInt) ; + imp.setTargetDocument(comp) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + final String impStyleName = "XMLStylesImporter" ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:fo", "CDATA", "http://www.w3.org/1999/XSL/Format", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table"}, + {"start", "office:styles"}, + {"start", "style:style", + "style:name", "CDATA", impStyleName, + "style:family", "CDATA", "table-cell", + "style:parent-style-name", "CDATA", "Default"}, + { "start", "style:properties", + "fo:width", "CDATA", "12cm", + "fo:background-color", "CDATA", "light-grey"}, + {"end", "style:properties"}, + {"end", "style:style"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XNameAccess styles = null ; + try { + XStyleFamiliesSupplier sup = UnoRuntime.queryInterface + (XStyleFamiliesSupplier.class, xSheetDoc); + XNameAccess oStyleFamilies = sup.getStyleFamilies(); + Object family = oStyleFamilies.getByName("CellStyles") ; + styles = UnoRuntime.queryInterface + (XNameAccess.class, family) ; + log.println("Styles before:") ; + String[] names = styles.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]) ; + } + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + } + final XNameAccess stylesF = styles ; + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + logF.println("Styles after:") ; + String[] names = stylesF.getElementNames() ; + for (int i = 0; i < names.length; i++) { + logF.println(" " + names[i]) ; + } + return stylesF.hasByName(impStyleName) ; + } + }) ; + + return tEnv ; + } +} + diff --git a/qadevOOo/tests/java/mod/_sc/package.html b/qadevOOo/tests/java/mod/_sc/package.html new file mode 100644 index 000000000..198d6b17d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sc/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 'sc'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_sch/AccArea.java b/qadevOOo/tests/java/mod/_sch/AccArea.java new file mode 100644 index 000000000..19cf04550 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccArea.java @@ -0,0 +1,101 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccArea extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccArea"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccAxis.java b/qadevOOo/tests/java/mod/_sch/AccAxis.java new file mode 100644 index 000000000..8b3eb65c4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccAxis.java @@ -0,0 +1,99 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccAxis extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccAxis"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccDataPoint.java b/qadevOOo/tests/java/mod/_sch/AccDataPoint.java new file mode 100644 index 000000000..b5ce67dfc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccDataPoint.java @@ -0,0 +1,100 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccDataPoint extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccDataPoint"); + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccDataSeries.java b/qadevOOo/tests/java/mod/_sch/AccDataSeries.java new file mode 100644 index 000000000..007ef7d58 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccDataSeries.java @@ -0,0 +1,100 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccDataSeries extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccDataSeries"); + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccDiagram.java b/qadevOOo/tests/java/mod/_sch/AccDiagram.java new file mode 100644 index 000000000..55593914c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccDiagram.java @@ -0,0 +1,100 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccDiagram extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccDiagram"); + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccFloor.java b/qadevOOo/tests/java/mod/_sch/AccFloor.java new file mode 100644 index 000000000..3d5426fab --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccFloor.java @@ -0,0 +1,106 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccFloor extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + log.println("Change Diagram to 3D"); + XPropertySet ChartProps = UnoRuntime.queryInterface( XPropertySet.class, xChartDoc.getDiagram() ); + ChartProps.setPropertyValue("Dim3D", Boolean.TRUE); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccFloor"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccGrid.java b/qadevOOo/tests/java/mod/_sch/AccGrid.java new file mode 100644 index 000000000..c0d6e6c20 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccGrid.java @@ -0,0 +1,101 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccGrid extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccGrid"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccLegend.java b/qadevOOo/tests/java/mod/_sch/AccLegend.java new file mode 100644 index 000000000..5cda48c80 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccLegend.java @@ -0,0 +1,99 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccLegend extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccLegend"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccLegendEntry.java b/qadevOOo/tests/java/mod/_sch/AccLegendEntry.java new file mode 100644 index 000000000..28635af5c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccLegendEntry.java @@ -0,0 +1,99 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccLegendEntry extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccLegendEntry"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccTitle.java b/qadevOOo/tests/java/mod/_sch/AccTitle.java new file mode 100644 index 000000000..27486a00e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccTitle.java @@ -0,0 +1,99 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccTitle extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccTitle"); + + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccWall.java b/qadevOOo/tests/java/mod/_sch/AccWall.java new file mode 100644 index 000000000..fe3f0388e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccWall.java @@ -0,0 +1,105 @@ +/* + * 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._sch; + +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.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccWall extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + if (xChartDoc != null) cleanup(Param, log); + log.println( "creating a chart document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + log.println("Change Diagram to 3D"); + XPropertySet ChartProps = UnoRuntime.queryInterface( XPropertySet.class, xChartDoc.getDiagram() ); + ChartProps.setPropertyValue("Dim3D", Boolean.TRUE); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext cont = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.SHAPE, "", "AccWall"); + + oObj = cont; + + log.println("ImplementationName " + utils.getImplName(oObj)); + log.println("AccessibleName " + cont.getAccessibleName()); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acc = UnoRuntime.queryInterface( + XAccessibleComponent.class,oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acc.grabFocus(); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + +} diff --git a/qadevOOo/tests/java/mod/_sch/AccessibleDocumentView.java b/qadevOOo/tests/java/mod/_sch/AccessibleDocumentView.java new file mode 100644 index 000000000..f2217435e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/AccessibleDocumentView.java @@ -0,0 +1,112 @@ +/* + * 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._sch; + +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.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XWindow; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleDocumentView extends TestCase { + + XChartDocument xChartDoc = null; + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); + + if (oObj == null) { + log.println("DocumentView hasn't the role 'Document'"); + log.println("trying the role 'Shape'"); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XWindow xDocWin = xWindow; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle rect = xDocWin.getPosSize(); + xDocWin.setPosSize(100,100,100,100,PosSize.POSSIZE); + xDocWin.setPosSize(rect.X,rect.Y,rect.Width,rect.Height, + PosSize.POSSIZE); + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a chart document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } +} diff --git a/qadevOOo/tests/java/mod/_sch/ChXChartAxis.java b/qadevOOo/tests/java/mod/_sch/ChXChartAxis.java new file mode 100644 index 000000000..844d1ce9c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXChartAxis.java @@ -0,0 +1,113 @@ +/* + * 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._sch; + +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.chart.XAxisYSupplier; +import com.sun.star.chart.XChartDocument; +import com.sun.star.drawing.XShape; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartAxis</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::chart::ChartAxis</code></li> +* </ul> +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.chart.ChartAxis +* @see ifc.drawing._LineProperties +* @see ifc.style._CharacterProperties +* @see ifc.beans._XPropertySet +* @see ifc.chart._ChartAxis +*/ +public class ChXChartAxis extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the diagram of the chart document. Then obtains the properties + * of the y-axis of the diagram using the interface + * <code>XAxisYSupplier</code>. The obatined property is the instance + * of the service <code>com.sun.star.chart.ChartAxis</code>. + * @see com.sun.star.chart.XAxisYSupplier + * @see com.sun.star.chart.ChartAxis + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XPropertySet oObj = null; + XShape oDiagram = null; + + // create testobject here + // get the Diagram + log.println( "getting Diagram" ); + oDiagram = xChartDoc.getDiagram(); + + // get the Axis + log.println( "getting ChartAxis" ); + XAxisYSupplier oAxisSup = UnoRuntime.queryInterface(XAxisYSupplier.class,oDiagram); + oObj = oAxisSup.getYAxis(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + + + +} // finish class ChXChartAxis + diff --git a/qadevOOo/tests/java/mod/_sch/ChXChartData.java b/qadevOOo/tests/java/mod/_sch/ChXChartData.java new file mode 100644 index 000000000..ffe925925 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXChartData.java @@ -0,0 +1,88 @@ +/* + * 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._sch; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartData; +import com.sun.star.chart.XChartDocument; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartData</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::chart::XChartData</code></li> +* </ul> +* @see com.sun.star.chart.ChartData +* @see com.sun.star.chart.XChartData +* @see ifc.chart._XChartData +*/ +public class ChXChartData extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the data source of the chart. This data source is the instance + * of the service <code>com.sun.star.chart.ChartData</code>. + * @see com.sun.star.chart.ChartData + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + // get the Data + log.println( "getting Data" ); + XChartData oObj = xChartDoc.getData(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ChXChartData + diff --git a/qadevOOo/tests/java/mod/_sch/ChXChartDataArray.java b/qadevOOo/tests/java/mod/_sch/ChXChartDataArray.java new file mode 100644 index 000000000..fca97a6ab --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXChartDataArray.java @@ -0,0 +1,91 @@ +/* + * 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._sch; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartData; +import com.sun.star.chart.XChartDocument; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartDataArray</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::chart::XChartData</code></li> +* <li> <code>com::sun::star::chart::XChartDataArray</code></li> +* </ul> +* @see com.sun.star.chart.ChartDataArray +* @see com.sun.star.chart.XChartData +* @see com.sun.star.chart.XChartDataArray +* @see ifc.chart._XChartData +* @see ifc.chart._XChartDataArray +*/ +public class ChXChartDataArray extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the data source of the chart. This data source is the instance + * of the service <code>com.sun.star.chart.ChartDataArray</code>. + * <code>com.sun.star.chart.ChartDataArray</code>. + * @see com.sun.star.chart.ChartDataArray + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + // get the Data + log.println( "getting Data" ); + XChartData oObj = xChartDoc.getData(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ChXChartDataArray + diff --git a/qadevOOo/tests/java/mod/_sch/ChXChartDocument.java b/qadevOOo/tests/java/mod/_sch/ChXChartDocument.java new file mode 100644 index 000000000..91388fd92 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXChartDocument.java @@ -0,0 +1,156 @@ +/* + * 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._sch; + +import com.sun.star.chart.XChartData; +import com.sun.star.chart.XChartDocument; +import com.sun.star.frame.XController; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartDocument</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::frame::XModel</code></li> +* <li> <code>com::sun::star::chart::XChartDocument</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::chart::ChartTableAddressSupplier</code></li> +* <li> <code>com::sun::star::chart::ChartDocument</code></li> +* </ul> +* @see com.sun.star.lang.XComponent +* @see com.sun.star.frame.XModel +* @see com.sun.star.chart.XChartDocument +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.chart.ChartTableAddressSupplier +* @see com.sun.star.chart.ChartDocument +* @see ifc.lang._XComponent +* @see ifc.frame._XModel +* @see ifc.chart._XChartDocument +* @see ifc.beans._XPropertySet +* @see ifc.chart._ChartTableAddressSupplier +* @see ifc.chart._ChartDocument +*/ +public class ChXChartDocument extends TestCase { + XChartDocument xChartDoc = null; + XChartDocument doc2 = null; + + /** + * Disposes Chart documents. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + if( doc2!=null ) { + log.println( " closing xChartDoc2" ); + util.DesktopTools.closeDoc(doc2); + doc2 = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates two chart documents and retrieves current controllers from them + * using the interface <code>XChartDocument</code>. The created documents + * is the instances of the service <code>com.sun.star.chart.ChartDocument</code>. + * Obtains the data source of the second created chart and creates + * a pie diagram. + * Object relations created : + * <ul> + * <li> <code>'SELSUPP'</code> for + * {@link ifc.frame._XModel}(the controller of the first created chart + * document)</li> + * <li> <code>'TOSELECT'</code> for + * {@link ifc.frame._XModel}(the shape of the main title of + * the first created chart document)</li> + * <li> <code>'CONT2'</code> for + * {@link ifc.frame._XModel}(the second created chart document)</li> + * <li> <code>'DIAGRAM'</code> for + * {@link ifc.chart._XChartDocument}(the created pie diagram)</li> + * <li> <code>'CHARTDATA'</code> for + * {@link ifc.chart._XChartDocument}(the data source of the second + * created chart)</li> + * </ul> + * @see com.sun.star.chart.XChartData + * @see com.sun.star.chart.ChartDocument + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a chartdocument"); + xChartDoc = SOF.createChartDoc(); + log.println("Waiting before opening second document"); + doc2 = SOF.createChartDoc(); + + + // get the chartdocument + log.println("getting ChartDocument"); + + XInterface oObj = xChartDoc; + + XController cont1 = xChartDoc.getCurrentController(); + XController cont2 = doc2.getCurrentController(); + + cont1.getFrame().setName("cont1"); + cont2.getFrame().setName("cont2"); + + XSelectionSupplier sel = UnoRuntime.queryInterface( + XSelectionSupplier.class, cont1); + + log.println("creating a new environment for chartdocument object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("Adding SelectionSupplier and Shape to select for XModel"); + tEnv.addObjRelation("SELSUPP", sel); + tEnv.addObjRelation("TOSELECT", xChartDoc.getTitle()); + + log.println("adding Controller as ObjRelation for XModel"); + tEnv.addObjRelation("CONT2", cont2); + + log.println("adding another Diagram as mod relation to environment"); + tEnv.addObjRelation("DIAGRAM", + SOF.createDiagram(xChartDoc, "PieDiagram")); + + log.println("adding another ChartData as mod relation to environment"); + + XChartData ChartData = doc2.getData(); + tEnv.addObjRelation("CHARTDATA", ChartData); + + return tEnv; + } // finish method getTestEnvironment +} // finish class ChXChartDocument diff --git a/qadevOOo/tests/java/mod/_sch/ChXChartView.java b/qadevOOo/tests/java/mod/_sch/ChXChartView.java new file mode 100644 index 000000000..89873574d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXChartView.java @@ -0,0 +1,127 @@ +/* + * 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._sch; + +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.drawing.XShapeDescriptor; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.view.OfficeDocumentView</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li> +* <li> <code>com::sun::star::view::XControlAccess</code></li> +* <li> <code>com::sun::star::view::XSelectionSupplier</code></li> +* </ul> +* @see com.sun.star.view.OfficeDocumentView +* @see com.sun.star.view.XViewSettingsSupplier +* @see com.sun.star.view.XControlAccess +* @see com.sun.star.view.XSelectionSupplier +* @see ifc.view._XViewSettingsSupplier +* @see ifc.view._XControlAccess +* @see ifc.view._XSelectionSupplier +*/ +public class ChXChartView extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the current controller of the chart document using + * the interface <code>XModel</code>.The retrieved controller is the instance + * of the service <code>com.sun.star.view.OfficeDocumentView</code>. + * Obtains the main title and the legend of the chart document. + * Object relations created : + * <ul> + * + * </ul> + * @see com.sun.star.frame.XModel + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XController oObj = null; + XModel oModel = null; + + // get the ChartView + log.println( "getting ChartView" ); + oModel = UnoRuntime.queryInterface(XModel.class, xChartDoc); + oObj = oModel.getCurrentController(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("Selections", new Object[] + {xChartDoc.getArea(), xChartDoc.getDiagram(), xChartDoc.getTitle(), + xChartDoc.getLegend()} ); + + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XShapeDescriptor descr1 = UnoRuntime.queryInterface(XShapeDescriptor.class, o1); + XShapeDescriptor descr2 = UnoRuntime.queryInterface(XShapeDescriptor.class, o2); + if (descr1 == null || descr2 == null) { + return -1; + } + if (descr1.getShapeType().equals(descr2.getShapeType())) { + return 0; + } + return 1; + } + } ); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class ChXChartView + diff --git a/qadevOOo/tests/java/mod/_sch/ChXDataPoint.java b/qadevOOo/tests/java/mod/_sch/ChXDataPoint.java new file mode 100644 index 000000000..abad0f6ca --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXDataPoint.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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.chart.XDiagram; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartDataPointProperties</code>. <p> +* Object implements the following interfaces +* <ul> +* <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li> +* <li> <code>com::sun::star::drawing::FillProperties</code></li> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TransparencyChart.sxs </b> : to load predefined chart +* document where two 'automatic' transparency styles exists : +* 'Transparency 1' and 'Transparency 2'.</li> +* </ul> <p> +* @see com.sun.star.chart.ChartDataPointProperties +* @see com.sun.star.drawing.FillProperties +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.chart.Chart3DBarProperties +* @see ifc.chart._ChartDataPointProperties +* @see ifc.drawing._FillProperties +* @see ifc.drawing._LineProperties +* @see ifc.style._CharacterProperties +* @see ifc.beans._XPropertySet +* @see ifc.chart._Chart3DBarProperties +*/ +public class ChXDataPoint extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + XComponent xComp = SOF.loadDocument( + utils.getFullTestURL("TransparencyChart.sxs")); + xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the diagram of the chart document. Obtains the properties of + * the specified data point. The obtained properties is the instance of + * the service <code>com.sun.star.chart.ChartDataPointProperties</code>. + * Creates a XY-diagram and bar-diagram also. + * Object relations created : + * <ul> + * <li> <code>'LINE'</code> for + * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li> + * <li> <code>'CHARTDOC'</code> for + * {@link ifc.chart._ChartDataPointProperties}, + * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li> + * <li> <code>'BAR'</code> for + * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XPropertySet oObj = null; + XDiagram oDiagram = null; + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + // get the DataRowPoint_Point + log.println( "getting ChXDataRowPoint_Point" ); + oDiagram = xChartDoc.getDiagram(); + oObj = oDiagram.getDataPointProperties(1,1); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + Object line = SOF.createDiagram(xChartDoc,"XYDiagram"); + tEnv.addObjRelation("LINE",line); + + Object bar = SOF.createDiagram(xChartDoc,"BarDiagram"); + tEnv.addObjRelation("BAR",bar); + + log.println( "adding ChartDocument as mod relation to environment" ); + tEnv.addObjRelation("CHARTDOC", xChartDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ChXDataPoint + diff --git a/qadevOOo/tests/java/mod/_sch/ChXDataRow.java b/qadevOOo/tests/java/mod/_sch/ChXDataRow.java new file mode 100644 index 000000000..e723aa716 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXDataRow.java @@ -0,0 +1,147 @@ +/* + * 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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.chart.XDiagram; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartDataRowProperties</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::FillProperties</code></li> +* <li> <code>com::sun::star::chart::ChartStatistics</code></li> +* <li> <code>com::sun::star::chart::ChartDataRowProperties</code></li> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::chart::ChartDataPointProperties</code></li> +* <li> <code>com::sun::star::chart::Chart3DBarProperties</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TransparencyChart.sxs </b> : to load predefined chart +* document where two 'automatic' transparency styles exists : +* 'Transparency 1' and 'Transparency 2'.</li> +* </ul> <p> +* @see com.sun.star.drawing.FillProperties +* @see com.sun.star.chart.ChartStatistics +* @see com.sun.star.chart.ChartDataRowProperties +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.chart.ChartDataPointProperties +* @see com.sun.star.chart.Chart3DBarProperties +* @see com.sun.star.style.CharacterProperties +* @see ifc.drawing._FillProperties +* @see ifc.chart._ChartStatistics +* @see ifc.chart._ChartDataRowProperties +* @see ifc.drawing._LineProperties +* @see ifc.beans._XPropertySet +* @see ifc.chart._ChartDataPointProperties +* @see ifc.chart._Chart3DBarProperties +* @see ifc.style._CharacterProperties +*/ +public class ChXDataRow extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + XComponent xComp = SOF.loadDocument( + utils.getFullTestURL("TransparencyChart.sxs")); + xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp); + } + + /** + * Disposes Chart document. + */ + @Override + protected synchronized void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the diagram of the chart document. Obtains the properties of + * the specified data row. The obtained properties is the instance of + * the service <code>com.sun.star.chart.ChartDataRowProperties</code>. + * Creates a XY-diagram and bar-diagram also. + * Object relations created : + * <ul> + * <li> <code>'LINE'</code> for + * {@link ifc.chart._ChartDataPointProperties}(the created XY-diagram)</li> + * <li> <code>'CHARTDOC'</code> for + * {@link ifc.chart._ChartDataPointProperties}, + * {@link ifc.chart._Chart3DBarProperties}(the chart document)</li> + * <li> <code>'BAR'</code> for + * {@link ifc.chart._Chart3DBarProperties}(the created bar-diagram)</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XPropertySet oObj = null; + XDiagram oDiagram = null; + // get the ChXDataRowPoint_Row + log.println( "getting ChXDataRowPoint_Row" ); + oDiagram = xChartDoc.getDiagram(); + oObj = oDiagram.getDataRowProperties(1); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + Object line = SOF.createDiagram(xChartDoc,"XYDiagram"); + tEnv.addObjRelation("LINE",line); + + Object bar = SOF.createDiagram(xChartDoc,"BarDiagram"); + tEnv.addObjRelation("BAR",bar); + + log.println( "adding ChartDocument as mod relation to environment" ); + tEnv.addObjRelation("CHARTDOC", xChartDoc); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class ChXDataRow + diff --git a/qadevOOo/tests/java/mod/_sch/ChXDiagram.java b/qadevOOo/tests/java/mod/_sch/ChXDiagram.java new file mode 100644 index 000000000..c9433e6b9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChXDiagram.java @@ -0,0 +1,367 @@ +/* + * 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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.awt.Rectangle; +import com.sun.star.chart.XChartDataArray; +import com.sun.star.chart.XChartDocument; +import com.sun.star.chart.XDiagram; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.document.XEmbeddedObjectSupplier; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XTableChart; +import com.sun.star.table.XTableCharts; +import com.sun.star.table.XTableChartsSupplier; +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 the following services: +* <ul> +* <li> <code>com.sun.star.chart.Dim3DDiagram</code> </li> +* <li> <code>com.sun.star.chart.StockDiagram</code> </li> +* <li> <code>com.sun.star.chart.LineDiagram</code> </li> +* <li> <code>com.sun.star.chart.BarDiagram</code> </li> +* <li> <code>com.sun.star.chart.StackableDiagram</code> </li> +* </ul> +* <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::chart::XDiagram</code></li> +* <li> <code>com::sun::star::chart::ChartAxisXSupplier</code></li> +* <li> <code>com::sun::star::chart::Dim3DDiagram</code></li> +* <li> <code>com::sun::star::chart::StockDiagram</code></li> +* <li> <code>com::sun::star::chart::ChartAxisZSupplier</code></li> +* <li> <code>com::sun::star::chart::XTwoAxisXSupplier</code></li> +* <li> <code>com::sun::star::chart::LineDiagram</code></li> +* <li> <code>com::sun::star::chart::BarDiagram</code></li> +* <li> <code>com::sun::star::chart::XAxisYSupplier</code></li> +* <li> <code>com::sun::star::chart::Diagram</code></li> +* <li> <code>com::sun::star::chart::X3DDisplay</code></li> +* <li> <code>com::sun::star::chart::ChartTwoAxisYSupplier</code></li> +* <li> <code>com::sun::star::chart::StackableDiagram</code></li> +* <li> <code>com::sun::star::chart::ChartAxisYSupplier</code></li> +* <li> <code>com::sun::star::chart::XAxisXSupplier</code></li> +* <li> <code>com::sun::star::chart::ChartTwoAxisXSupplier</code></li> +* <li> <code>com::sun::star::drawing::XShape</code></li> +* <li> <code>com::sun::star::chart::XTwoAxisYSupplier</code></li> +* <li> <code>com::sun::star::chart::ChartStatistics</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> +* <li> <code>com::sun::star::chart::XAxisZSupplier</code></li> +* <li> <code>com::sun::star::chart::XStatisticDisplay</code></li> +* </ul> +* @see com.sun.star.chart.XDiagram +* @see com.sun.star.chart.ChartAxisXSupplier +* @see com.sun.star.chart.Dim3DDiagram +* @see com.sun.star.chart.StockDiagram +* @see com.sun.star.chart.ChartAxisZSupplier +* @see com.sun.star.chart.XTwoAxisXSupplier +* @see com.sun.star.chart.LineDiagram +* @see com.sun.star.chart.BarDiagram +* @see com.sun.star.chart.XAxisYSupplier +* @see com.sun.star.chart.Diagram +* @see com.sun.star.chart.X3DDisplay +* @see com.sun.star.chart.ChartTwoAxisYSupplier +* @see com.sun.star.chart.StackableDiagram +* @see com.sun.star.chart.ChartAxisYSupplier +* @see com.sun.star.chart.XAxisXSupplier +* @see com.sun.star.chart.ChartTwoAxisXSupplier +* @see com.sun.star.drawing.XShape +* @see com.sun.star.chart.XTwoAxisYSupplier +* @see com.sun.star.chart.ChartStatistics +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.drawing.XShapeDescriptor +* @see com.sun.star.chart.XAxisZSupplier +* @see com.sun.star.chart.XStatisticDisplay +* @see ifc.chart._XDiagram +* @see ifc.chart._ChartAxisXSupplier +* @see ifc.chart._Dim3DDiagram +* @see ifc.chart._StockDiagram +* @see ifc.chart._ChartAxisZSupplier +* @see ifc.chart._XTwoAxisXSupplier +* @see ifc.chart._LineDiagram +* @see ifc.chart._BarDiagram +* @see ifc.chart._XAxisYSupplier +* @see ifc.chart._Diagram +* @see ifc.chart._X3DDisplay +* @see ifc.chart._ChartTwoAxisYSupplier +* @see ifc.chart._StackableDiagram +* @see ifc.chart._ChartAxisYSupplier +* @see ifc.chart._XAxisXSupplier +* @see ifc.chart._ChartTwoAxisXSupplier +* @see ifc.drawing._XShape +* @see ifc.chart._XTwoAxisYSupplier +* @see ifc.chart._ChartStatistics +* @see ifc.beans._XPropertySet +* @see ifc.drawing._XShapeDescriptor +* @see ifc.chart._XAxisZSupplier +* @see ifc.chart._XStatisticDisplay +*/ +public class ChXDiagram extends TestCase { + XSpreadsheetDocument xSheetDoc = null; + + /** + * Creates Spreadsheet document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a sheetdocument" ); + xSheetDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes Spreadsheet document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " closing xSheetDoc " ); + util.DesktopTools.closeDoc(xSheetDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves a collection of spreadsheets from a document + * and takes one of them. Inserts some values into the cells of the same cell + * range address. Adds and retrieves the chart that using the data from + * the cells of this cell range address. Obtains the chart document which is + * embedded into the retrieved chart using the interface + * <code>XEmbeddedObjectSupplier</code>. Retrieves the diagram from + * the obtained chart document. The retrieved diagram is the instance of + * the service <code>com.sun.star.chart.Diagram</code>. + * Obtains the data source of the chart from the chart document. + * Creates a stock-diagram, a bar-diagram, a XY-diagram and line-diagram + * that are the instances of the following services: + * <ul> + * <li> <code>com.sun.star.chart.StockDiagram</code> </li> + * <li> <code>com.sun.star.chart.BarDiagram</code> </li> + * <li> <code>com.sun.star.chart.LineDiagram</code> </li> + * <li> <code>com.sun.star.chart.StackableDiagram</code> </li> + * </ul>. + * Object relations created : + * <ul> + * <li> <code>'CHARTDOC'</code> for + * {@link ifc.chart._Dim3DDiagram}, {@link ifc.chart._StockDiagram}, + * {@link ifc.chart._ChartAxisZSupplier}, {@link ifc.chart._LineDiagram}, + * {@link ifc.chart._BarDiagram}, {@link ifc.chart._Diagram}, + * {@link ifc.chart._ChartTwoAxisYSupplier}, + * {@link ifc.chart._StackableDiagram}, {@link ifc.chart._Diagram}, + * {@link ifc.chart._ChartAxisYSupplier}, + * {@link ifc.chart._ChartTwoAxisXSupplier}, + * {@link ifc.chart._ChartStatistics} (the obtained chart document)</li> + * <li> <code>'ROWAMOUNT', 'COLAMOUNT'</code> for + * {@link ifc.chart._XDiagram}(the number of chart columns and + * the number of chart rows) </li> + * <li> <code>'STOCK'</code> for + * {@link ifc.chart._StockDiagram}(the created stock-diagram) </li> + * <li> <code>'BAR'</code> for + * {@link ifc.chart._BarDiagram}, {@link ifc.chart._ChartAxisZSupplier}, + * {@link ifc.chart._ChartTwoAxisXSupplier}, + * {@link ifc.chart._ChartTwoAxisYSupplier}(the created bar-diagram)</li> + * <li> <code>'LINE'</code> for + * {@link ifc.chart._LineDiagram}(the created XY-diagram) </li> + * <li> <code>'STACK'</code> for + * {@link ifc.chart._StackableDiagram}(the created Line-diagram) </li> + * </ul> + * @see com.sun.star.document.XEmbeddedObjectSupplier + * @see com.sun.star.chart.Diagram + * @see com.sun.star.chart.StockDiagram + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XSpreadsheet oSheet=null; + XChartDocument xChartDoc=null; + XDiagram oObj = null; + + System.out.println("Getting spreadsheet") ; + XSpreadsheets oSheets = xSheetDoc.getSheets() ; + XIndexAccess oIndexSheets = UnoRuntime.queryInterface(XIndexAccess.class, oSheets); + oSheet = (XSpreadsheet) AnyConverter.toObject( + new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0)); + + log.println("Creating the Header") ; + + insertIntoCell(1,0,"JAN",oSheet,""); + insertIntoCell(2,0,"FEB",oSheet,""); + insertIntoCell(3,0,"MAR",oSheet,""); + insertIntoCell(4,0,"APR",oSheet,""); + insertIntoCell(5,0,"MAI",oSheet,""); + insertIntoCell(6,0,"JUN",oSheet,""); + insertIntoCell(7,0,"JUL",oSheet,""); + insertIntoCell(8,0,"AUG",oSheet,""); + insertIntoCell(9,0,"SEP",oSheet,""); + insertIntoCell(10,0,"OCT",oSheet,""); + insertIntoCell(11,0,"NOV",oSheet,""); + insertIntoCell(12,0,"DEC",oSheet,""); + insertIntoCell(13,0,"SUM",oSheet,""); + + log.println("Fill the lines"); + + insertIntoCell(0,1,"Smith",oSheet,""); + insertIntoCell(1,1,"42",oSheet,"V"); + insertIntoCell(2,1,"58.9",oSheet,"V"); + insertIntoCell(3,1,"-66.5",oSheet,"V"); + insertIntoCell(4,1,"43.4",oSheet,"V"); + insertIntoCell(5,1,"44.5",oSheet,"V"); + insertIntoCell(6,1,"45.3",oSheet,"V"); + insertIntoCell(7,1,"-67.3",oSheet,"V"); + insertIntoCell(8,1,"30.5",oSheet,"V"); + insertIntoCell(9,1,"23.2",oSheet,"V"); + insertIntoCell(10,1,"-97.3",oSheet,"V"); + insertIntoCell(11,1,"22.4",oSheet,"V"); + insertIntoCell(12,1,"23.5",oSheet,"V"); + insertIntoCell(13,1,"=SUM(B2:M2)",oSheet,""); + + insertIntoCell(0,2,"Jones",oSheet,""); + insertIntoCell(1,2,"21",oSheet,"V"); + insertIntoCell(2,2,"40.9",oSheet,"V"); + insertIntoCell(3,2,"-57.5",oSheet,"V"); + insertIntoCell(4,2,"-23.4",oSheet,"V"); + insertIntoCell(5,2,"34.5",oSheet,"V"); + insertIntoCell(6,2,"59.3",oSheet,"V"); + insertIntoCell(7,2,"27.3",oSheet,"V"); + insertIntoCell(8,2,"-38.5",oSheet,"V"); + insertIntoCell(9,2,"43.2",oSheet,"V"); + insertIntoCell(10,2,"57.3",oSheet,"V"); + insertIntoCell(11,2,"25.4",oSheet,"V"); + insertIntoCell(12,2,"28.5",oSheet,"V"); + insertIntoCell(13,2,"=SUM(B3:M3)",oSheet,""); + + insertIntoCell(0,3,"Brown",oSheet,""); + insertIntoCell(1,3,"31.45",oSheet,"V"); + insertIntoCell(2,3,"-20.9",oSheet,"V"); + insertIntoCell(3,3,"-117.5",oSheet,"V"); + insertIntoCell(4,3,"23.4",oSheet,"V"); + insertIntoCell(5,3,"-114.5",oSheet,"V"); + insertIntoCell(6,3,"115.3",oSheet,"V"); + insertIntoCell(7,3,"-171.3",oSheet,"V"); + insertIntoCell(8,3,"89.5",oSheet,"V"); + insertIntoCell(9,3,"41.2",oSheet,"V"); + insertIntoCell(10,3,"71.3",oSheet,"V"); + insertIntoCell(11,3,"25.4",oSheet,"V"); + insertIntoCell(12,3,"38.5",oSheet,"V"); + insertIntoCell(13,3,"=SUM(A4:L4)",oSheet,""); + + // insert a chart + Rectangle oRect = new Rectangle(500, 3000, 25000, 11000); + + XCellRange oRange = UnoRuntime.queryInterface(XCellRange.class, oSheet); + XCellRange myRange = oRange.getCellRangeByName("A1:N4"); + XCellRangeAddressable oRangeAddr = UnoRuntime.queryInterface(XCellRangeAddressable.class, myRange); + CellRangeAddress myAddr = oRangeAddr.getRangeAddress(); + + CellRangeAddress[] oAddr = new CellRangeAddress[1]; + oAddr[0] = myAddr; + XTableChartsSupplier oSupp = UnoRuntime.queryInterface(XTableChartsSupplier.class, oSheet); + + log.println("Insert Chart"); + XTableCharts oCharts = oSupp.getCharts(); + + + if (!oCharts.hasByName("ChXDiagram")) { + oCharts.addNewByName("ChXDiagram", oRect, oAddr, true, true); + } + + // get the TableChart + XTableChart oChart = (XTableChart) AnyConverter.toObject( + new Type(XTableChart.class),UnoRuntime.queryInterface( + XNameAccess.class, oCharts).getByName("ChXDiagram")); + + XEmbeddedObjectSupplier oEOS = UnoRuntime.queryInterface(XEmbeddedObjectSupplier.class, oChart); + XInterface oInt = oEOS.getEmbeddedObject(); + xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,oInt); + oObj = xChartDoc.getDiagram(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding ChartDocument as mod relation to environment" ); + tEnv.addObjRelation("CHARTDOC", xChartDoc); + + XChartDataArray da = UnoRuntime.queryInterface(XChartDataArray.class, xChartDoc.getData()); + int cols = da.getColumnDescriptions().length; + int rows = da.getRowDescriptions().length; + + tEnv.addObjRelation("ROWAMOUNT", Integer.valueOf(rows)); + tEnv.addObjRelation("COLAMOUNT", Integer.valueOf(cols)); + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + Object stock = SOF.createDiagram(xChartDoc,"StockDiagram"); + tEnv.addObjRelation("STOCK",stock); + + Object bar = SOF.createDiagram(xChartDoc,"BarDiagram"); + tEnv.addObjRelation("BAR",bar); + + Object line = SOF.createDiagram(xChartDoc,"XYDiagram"); + tEnv.addObjRelation("LINE",line); + + Object stack = SOF.createDiagram(xChartDoc,"LineDiagram"); + tEnv.addObjRelation("STACK",stack); + + return tEnv; + } // finish method getTestEnvironment + + /** + * Inserts a value or a formula in the cell of the spreadsheet. + * @param CellX is the column index of the cell + * @param CellY is the row index of the cell + * @param theValue string representation of the value + * @param TT1 specify the spreadsheet, the interface + * <code>com.sun.star.sheet.XSpreadsheet</code> + * @param flag if it's equal to <code>'V'</code> then the method inserts + * a double-value in the cell else it inserts a formula in the cell + */ + public static void insertIntoCell( + int CellX, int CellY, String theValue, XSpreadsheet TT1, String flag) + throws com.sun.star.lang.IndexOutOfBoundsException { + + XCell oCell = TT1.getCellByPosition(CellX, CellY); + + if (flag.equals("V")) { + oCell.setValue(Float.parseFloat(theValue)); + } + else { + oCell.setFormula(theValue); + } + + } // end of insertIntoCell + + +} // finish class ChXDiagram + diff --git a/qadevOOo/tests/java/mod/_sch/ChartArea.java b/qadevOOo/tests/java/mod/_sch/ChartArea.java new file mode 100644 index 000000000..c81a7cea2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChartArea.java @@ -0,0 +1,106 @@ +/* + * 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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartArea</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::FillProperties</code></li> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TransparencyChart.sxs </b> : to load predefined chart +* document where two 'automatic' transparency styles exists : +* 'Transparency 1' and 'Transparency 2'.</li> +* </ul> <p> +* @see com.sun.star.chart.ChartArea +* @see com.sun.star.drawing.FillProperties +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.beans.XPropertySet +* @see ifc.drawing._FillProperties +* @see ifc.drawing._LineProperties +* @see ifc.beans._XPropertySet +*/ +public class ChartArea extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + XComponent xComp = SOF.loadDocument( + utils.getFullTestURL("TransparencyChart.sxs")); + xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieved the instance of the service <code>com.sun.star.chart.ChartArea</code> + * using the interface <code>XChartDocument</code>. + * @see com.sun.star.chart.XChartDocument + * @see com.sun.star.chart.ChartArea + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + // get the Area + log.println( "getting Area" ); + XPropertySet oObj = xChartDoc.getArea(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class ChartArea + diff --git a/qadevOOo/tests/java/mod/_sch/ChartGrid.java b/qadevOOo/tests/java/mod/_sch/ChartGrid.java new file mode 100644 index 000000000..79b3aa3f0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChartGrid.java @@ -0,0 +1,105 @@ +/* + * 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._sch; + +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.chart.XAxisXSupplier; +import com.sun.star.chart.XChartDocument; +import com.sun.star.drawing.XShape; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartGrid</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.chart.ChartGrid +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.beans.XPropertySet +* @see ifc.drawing._LineProperties +* @see ifc.beans._XPropertySet +*/ +public class ChartGrid extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the diagram of the chart document. Then obtains + * the properties of the main grid of the x-axis of the diagram + * using the interface <code>XAxisXSupplier</code>. This properties is + * the instance of the service <code>com.sun.star.chart.ChartGrid</code>. + * @see com.sun.star.chart.XAxisXSupplier + * @see com.sun.star.chart.ChartGrid + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XPropertySet oObj = null; + XShape oDiagram = null; + + // get the Diagram + log.println( "getting Diagram" ); + oDiagram = xChartDoc.getDiagram(); + + // get the Grid + log.println( "getting ChartGrid" ); + XAxisXSupplier oAxisSup = UnoRuntime.queryInterface(XAxisXSupplier.class,oDiagram); + oObj = oAxisSup.getXMainGrid(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class ChartGrid + diff --git a/qadevOOo/tests/java/mod/_sch/ChartLegend.java b/qadevOOo/tests/java/mod/_sch/ChartLegend.java new file mode 100644 index 000000000..c8cfaa477 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChartLegend.java @@ -0,0 +1,126 @@ +/* + * 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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartLegend</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::FillProperties</code></li> +* <li> <code>com::sun::star::drawing::XShape</code></li> +* <li> <code>com::sun::star::drawing::Shape</code></li> +* <li> <code>com::sun::star::chart::ChartLegend</code></li> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::style::CharacterProperties</code></li> +* <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> TransparencyChart.sxs </b> : to load predefined chart +* document where two 'automatic' transparency styles exists : +* 'Transparency 1' and 'Transparency 2'.</li> +* </ul> <p> +* @see com.sun.star.drawing.FillProperties +* @see com.sun.star.drawing.XShape +* @see com.sun.star.drawing.Shape +* @see com.sun.star.chart.ChartLegend +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.drawing.XShapeDescriptor +* @see com.sun.star.lang.XComponent +* @see ifc.drawing._FillProperties +* @see ifc.drawing._XShape +* @see ifc.drawing._Shape +* @see ifc.chart._ChartLegend +* @see ifc.drawing._LineProperties +* @see ifc.beans._XPropertySet +* @see ifc.style._CharacterProperties +* @see ifc.drawing._XShapeDescriptor +* @see ifc.lang._XComponent +*/ +public class ChartLegend extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + XComponent xComp = SOF.loadDocument( + utils.getFullTestURL("TransparencyChart.sxs")); + xChartDoc = UnoRuntime.queryInterface(XChartDocument.class,xComp); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the diagram of the chart document. The retrieved + * diagram is the instance of the service + * <code>com.sun.star.chart.ChartLegend</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XShape oObj = null; + + // get the Legend + log.println( "getting Legend" ); + oObj = xChartDoc.getLegend(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("NoSetSize", "sch.ChartLegend"); + return tEnv; + } // finish method getTestEnvironment + + +} // finish class ChartLegend + diff --git a/qadevOOo/tests/java/mod/_sch/ChartLine.java b/qadevOOo/tests/java/mod/_sch/ChartLine.java new file mode 100644 index 000000000..69c0a510a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChartLine.java @@ -0,0 +1,112 @@ +/* + * 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._sch; + +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.chart.XChartDocument; +import com.sun.star.chart.XDiagram; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartLine</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::drawing::LineProperties</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* </ul> +* @see com.sun.star.drawing.LineProperties +* @see com.sun.star.beans.XPropertySet +* @see ifc.drawing._LineProperties +* @see ifc.beans._XPropertySet +*/ +public class ChartLine extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates a bar diagram and sets the created diagram for the chart document. + * Retrieves the property <code>'DataMeanValueProperties'</code> of + * the specified data row. The retrieved property is the instance of + * the service <code>com.sun.star.chart.ChartLine</code>. + * @see com.sun.star.chart.ChartLine + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XPropertySet oObj = null; + XDiagram oDiagram = null; + SOfficeFactory SOF = null; + + //get LineDiagram + SOF = SOfficeFactory.getFactory( Param.getMSF()); + oDiagram = SOF.createDiagram(xChartDoc, "LineDiagram"); + + log.println( "getting Line-Diagram" ); + xChartDoc.setDiagram(oDiagram); + + // get the Line + log.println( "getting Line" ); + XPropertySet RowProps = oDiagram.getDataRowProperties(1); + RowProps.setPropertyValue("MeanValue", Boolean.TRUE); + oObj = (XPropertySet) AnyConverter.toObject( + new Type(XPropertySet.class), + RowProps.getPropertyValue("DataMeanValueProperties")); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class ChartLine + diff --git a/qadevOOo/tests/java/mod/_sch/ChartTitle.java b/qadevOOo/tests/java/mod/_sch/ChartTitle.java new file mode 100644 index 000000000..1a4aaccfb --- /dev/null +++ b/qadevOOo/tests/java/mod/_sch/ChartTitle.java @@ -0,0 +1,105 @@ +/* + * 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._sch; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.drawing.XShape; + +/** +* Test for object which is represented by service +* <code>com.sun.star.chart.ChartTitle</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::chart::ChartTitle</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::style::CharacterProperties</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.chart.ChartTitle +* @see com.sun.star.drawing.XShape +* @see com.sun.star.drawing.XShapeDescriptor +* @see com.sun.star.style.CharacterProperties +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.drawing.Shape +* @see ifc.lang._XComponent +* @see ifc.chart._ChartTitle +* @see ifc.drawing._XShape +* @see ifc.drawing._XShapeDescriptor +* @see ifc.style._CharacterProperties +* @see ifc.beans._XPropertySet +* @see ifc.drawing._Shape +*/ +public class ChartTitle extends TestCase { + XChartDocument xChartDoc = null; + + /** + * Creates Chart document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Disposes Chart document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Retrieves the shape of the main title of the chart document. + * The retrieved shape is the instance of the service + * <code>com.sun.star.chart.ChartTitle</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + // get the Title + log.println( "getting Title" ); + XShape oObj = xChartDoc.getTitle(); + + log.println( "creating a new environment for chartdocument object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("NoSetSize","sch.ChartTitle"); + return tEnv; + } // finish method getTestEnvironment + +} // finish class ChXChartObject_Title + 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> diff --git a/qadevOOo/tests/java/mod/_servicemgr/uno/OServiceManager.java b/qadevOOo/tests/java/mod/_servicemgr/uno/OServiceManager.java new file mode 100644 index 000000000..3e904d74a --- /dev/null +++ b/qadevOOo/tests/java/mod/_servicemgr/uno/OServiceManager.java @@ -0,0 +1,158 @@ +/* + * 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._servicemgr.uno; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XSet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.stoc.OServiceManager</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li> + * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> + * <li> <code>com::sun::star::container::XSet</code></li> + * <li> <code>com::sun::star::lang::XMultiComponentFactory</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XMultiServiceFactory + * @see com.sun.star.container.XContentEnumerationAccess + * @see com.sun.star.container.XSet + * @see com.sun.star.lang.XMultiComponentFactory + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.lang.XComponent + * @see ifc.lang._XMultiServiceFactory + * @see ifc.container._XContentEnumerationAccess + * @see ifc.container._XSet + * @see ifc.lang._XMultiComponentFactory + * @see ifc.lang._XServiceInfo + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.lang._XComponent + */ +public class OServiceManager extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.stoc.OServiceManager</code>. + * Object relations created : + * <ul> + * <li> <code>'NewElement'</code> for + * {@link ifc.container._XSet} : + * element to be inserted into manager. Here + * a new <code>ServiceManager</code> implementation is + * create using + * <code>tools.SOConnect.createSimpleServiceManager()</code> + * and one of services contained in it is taken.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.OServiceManager" ); + } catch( com.sun.star.uno.Exception e ) { + log.println("ServiceManager service not available" ); + } + + // adding a service to the manager + Object newElement = null ; + XMultiServiceFactory srvMan = null; + XComponentContext xContext = null; + + try { + + srvMan = com.sun.star.comp.helper.Bootstrap.createSimpleServiceManager(); + + } catch ( java.lang.Exception ex) { + log.println("Error creating SimpleServiceManager :"); + ex.printStackTrace(log); + } + + XSet set = UnoRuntime.queryInterface + (XSet.class, oInterface) ; + XSet set1 = UnoRuntime.queryInterface + (XSet.class, srvMan) ; + XEnumeration oEnum = set1.createEnumeration(); + Object srv = oEnum.nextElement(); + + set.insert(srv) ; + + newElement = oEnum.nextElement(); + + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, oInterface); + if (xProp != null) { + xContext = (XComponentContext) AnyConverter.toObject( + new Type(XComponentContext.class), + xProp.getPropertyValue("DefaultContext")); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XSet interface + tEnv.addObjRelation("NewElement", newElement) ; + + // adding relation for XPropertySet + tEnv.addObjRelation("PTT",new String[]{"DefaultContext","none","none"}); + + //adding relation for XMultiComponentFactory + if (xContext != null) { + tEnv.addObjRelation("DC", xContext); + } + return tEnv; + } // finish method getTestEnvironment + +} // finish class OServiceManager + diff --git a/qadevOOo/tests/java/mod/_servicemgr/uno/package.html b/qadevOOo/tests/java/mod/_servicemgr/uno/package.html new file mode 100644 index 000000000..bef49b8c5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_servicemgr/uno/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 'smgr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_sfx/AppDispatchProvider.java b/qadevOOo/tests/java/mod/_sfx/AppDispatchProvider.java new file mode 100644 index 000000000..3592c387e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sfx/AppDispatchProvider.java @@ -0,0 +1,84 @@ +/* + * 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._sfx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.dbg; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::frame::XDispatchProvider</code></li> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.frame.XDispatchProvider + * @see com.sun.star.lang.XInitialization + * @see ifc.frame._XDispatchProvider + * @see ifc.lang._XInitialization + */ +public class AppDispatchProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FrameLoader.URL"'</code> for + * {@link ifc.frame._XFrameLoader} </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null ; + + //now get the OButtonControl + oInterface = Param.getMSF().createInstance + ("com.sun.star.comp.sfx2.AppDispatchProvider") ; + + oObj = (XInterface) oInterface ; + System.out.println("ImplName: "+utils.getImplName(oObj)); + dbg.printInterfaces(oObj); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for :XDispatchProvider + tEnv.addObjRelation("XDispatchProvider.URL", ".uno:BibliographyComponent") ; + + tEnv.addObjRelation("XInitialization.args", new Object[] { null }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_sfx/DocumentTemplates.java b/qadevOOo/tests/java/mod/_sfx/DocumentTemplates.java new file mode 100644 index 000000000..835e5c643 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sfx/DocumentTemplates.java @@ -0,0 +1,85 @@ +/* + * 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._sfx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.frame.XStorable; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.frame.DocumentTemplates</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::frame::XDocumentTemplates</code></li> + * </ul> <p> + * + */ +public class DocumentTemplates extends TestCase { + + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + String aURL=util.utils.getFullTestURL("report2.stw"); + xTextDoc = util.WriterTools.loadTextDoc(tParam.getMSF(),aURL); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + xTextDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.frame.DocumentTemplates</code>. + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface oObj = null; + XStorable store = null; + + oObj = (XInterface)xMSF.createInstance + ("com.sun.star.frame.DocumentTemplates"); + store = UnoRuntime.queryInterface + (XStorable.class,xTextDoc); + + String Iname = util.utils.getImplName(oObj); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(oObj); + tEnv.addObjRelation("Store",store); + return tEnv; + } + +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_sfx/FrameLoader.java b/qadevOOo/tests/java/mod/_sfx/FrameLoader.java new file mode 100644 index 000000000..7822d9208 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sfx/FrameLoader.java @@ -0,0 +1,79 @@ +/* + * 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._sfx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.dbg; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.comp.office.FrameLoader</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::frame::XFrameLoader</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.frame.FrameLoader +* @see com.sun.star.frame.XSynchronousFrameLoader +*/ +public class FrameLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.office.FrameLoader</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FrameLoader.URL"'</code> for + * {@link ifc.frame._XFrameLoader} </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null ; + + //now get the OButtonControl + oInterface = Param.getMSF().createInstance + ("com.sun.star.comp.office.FrameLoader") ; + + oObj = (XInterface) oInterface ; + System.out.println("ImplName: "+utils.getImplName(oObj)); + dbg.printInterfaces(oObj); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XFrameLoader + tEnv.addObjRelation("FrameLoader.URL","private:factory/swriter"); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_sfx/SfxMacroLoader.java b/qadevOOo/tests/java/mod/_sfx/SfxMacroLoader.java new file mode 100644 index 000000000..9d2fbb4d9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sfx/SfxMacroLoader.java @@ -0,0 +1,85 @@ +/* + * 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._sfx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.dbg; +import util.utils; + +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::frame::XDispatchProvider</code></li> + * <li> <code>com::sun::star::lang::XInitialization</code></li> + * </ul> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.frame.XDispatchProvider + * @see com.sun.star.lang.XInitialization + * @see ifc.frame._XDispatchProvider + * @see ifc.lang._XInitialization + */ +public class SfxMacroLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.sfx2.SfxMacroLoader</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FrameLoader.URL"'</code> for + * {@link ifc.frame._XFrameLoader} </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + Object oInterface = null ; + + //now get the OButtonControl + oInterface = Param.getMSF().createInstance + ("com.sun.star.comp.sfx2.SfxMacroLoader"); + + oObj = (XInterface) oInterface ; + System.out.println("ImplName: "+utils.getImplName(oObj)); + dbg.printInterfaces(oObj); + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XFrameLoader + tEnv.addObjRelation("XDispatchProvider.URL", + "macro:tools.UCB.CreateFolder(\"" + + utils.getOfficeTemp(Param.getMSF()) + "/SfxMacroLoader\")") ; + + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_shlibloader/uno/DLLComponentLoader.java b/qadevOOo/tests/java/mod/_shlibloader/uno/DLLComponentLoader.java new file mode 100644 index 000000000..18e7a2d9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_shlibloader/uno/DLLComponentLoader.java @@ -0,0 +1,101 @@ +/* + * 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._shlibloader.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** +* Test for <code>com.sun.star.comp.stoc.DLLComponentLoader</code> service <p> +* Files which are used : +* <ul> +* <li> <code>XImpReg.dll</code> : DLL which will be loaded in +* <code>XImplementationLoader</code> interface test. </li> +* <ul> +* Multithread testing compliant. +* @see com.sun.star.loader.XImplementationLoader +* @see com.sun.star.lang.XServiceInfo +* @see ifc.loader._XImplementationLoader +* @see ifc.lang._XServiceInfo +*/ +public class DLLComponentLoader extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.comp.stoc.DLLComponentLoader</code> + * service. <p> + * The following object relations created : + * <ul> + * <li> <code>'ImplementationLoader'</code> : service which is + * responsible for loading DLL implementations. </li> + * <li> <code>'ImplementationUrl'</code> : DLL file location. </li> + * <li> <code>'ImplementationName'</code> : Name of the implementation.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws com.sun.star.uno.Exception { + XInterface oObj = null; + Object oInterface = null; + XMultiServiceFactory xMSF = null; + + try { + xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.DLLComponentLoader" ); + } + catch( Exception e ) { + log.println("DLLComponentLoader Service not available" ); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for DLLComponentLoader object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding object relation for XImplementationLoader ifc test + tEnv.addObjRelation("ImplementationLoader", + "com.sun.star.loader.SharedLibrary") ; + String os = (String) Param.get("OS"); + if (os == null || os.equals("")) + throw new StatusException( + "Couldn't determine operating system for naming convention.", + new NullPointerException()); + String name = "javaloader.uno"; + if (!os.equals("wntmsci")) + name = name + ".so"; + else + name += ".dll"; + String implURL = utils.getOfficeURL(xMSF)+"/"+name; + tEnv.addObjRelation("ImplementationUrl", implURL) ; + log.println("looking for shared lib: " + implURL); + tEnv.addObjRelation("ImplementationName", + "com.sun.star.comp.stoc.JavaComponentLoader") ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class DLLComponentLoader + diff --git a/qadevOOo/tests/java/mod/_shlibloader/uno/package.html b/qadevOOo/tests/java/mod/_shlibloader/uno/package.html new file mode 100644 index 000000000..1bc7bf117 --- /dev/null +++ b/qadevOOo/tests/java/mod/_shlibloader/uno/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 'cpld'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_simplereg/uno/SimpleRegistry.java b/qadevOOo/tests/java/mod/_simplereg/uno/SimpleRegistry.java new file mode 100644 index 000000000..99146f159 --- /dev/null +++ b/qadevOOo/tests/java/mod/_simplereg/uno/SimpleRegistry.java @@ -0,0 +1,166 @@ +/* + * 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._simplereg.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.registry.SimpleRegistry</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::registry::XSimpleRegistry</code></li> + * </ul> <p> + * The following files used by this test : + * <ul> + * <li><b> XSimpleRegistry.rdb </b> : a registry file with + * some key set. </li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.registry.XSimpleRegistry + * @see ifc.registry._XSimpleRegistry + */ +public class SimpleRegistry extends TestCase { + + /** + * Creates a temporary copy of file, which is deleted when VM exits. + * @param src Source file path. + * @param dst Destination file path. + * @param log The log writer. + * @throws java.io.IOException If any problems occur during copying. + */ + protected void copyFile(String src, String dst, PrintWriter log) + throws java.io.IOException { + File srcF = new File(src) ; + File dstF = new File(dst) ; + System.out.println("H1"); + + if (dstF.exists()) { + boolean bDeleteOk = dstF.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + + System.out.println("H2"); + + boolean bCreateOk = dstF.createNewFile(); + if (!bCreateOk) { + System.out.println("create failed"); + } + + dstF.deleteOnExit() ; + System.out.println("H3"); + + FileInputStream fIn = new FileInputStream(srcF) ; + System.out.println("H4"); + + FileOutputStream fOut = new FileOutputStream(dstF) ; + + byte[] buf = new byte[1024] ; + int bytesRead = 0 ; + while ((bytesRead = fIn.read(buf)) > 0) { + fOut.write(buf, 0, bytesRead) ; + } + + fIn.close() ; + fOut.close() ; + } + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.registry.SimpleRegistry</code>. Then + * makes three copies of a predefined registry file with different + * names in a temporary SOffice directory and passes their URLs as + * relations. <p> + * + * Object relations created : + * <ul> + * <li> <code>'XSimpleRegistry.open'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * <li> <code>'XSimpleRegistry.merge'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * <li> <code>'XSimpleRegistry.destroy'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + final String tmpDir = utils.getOfficeTempDirSys( + Param.getMSF()) ; + final String openF = "XSimpleRegistry_open.rdb" ; + final String destroyF = "XSimpleRegistry_destroy.rdb" ; + final String mergeF = "XSimpleRegistry_merge.rdb" ; + + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.registry.SimpleRegistry" ); + } catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + if (oInterface == null) + log.println("Service wasn't created") ; + + oObj = (XInterface) oInterface; + + log.println("creating copies of the registry for XSimpleRegistry"); + try { + String source = utils.getFullTestDocName("XSimpleRegistry.rdb"); + copyFile(source, tmpDir + openF, log); + copyFile(source, tmpDir + destroyF, log); + copyFile(source, tmpDir + mergeF, log); + } catch (java.io.IOException e) { + log.println("Exception occurred while copying files"); + e.printStackTrace(log); + } + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XSimpleRegistry.open", tmpDir + openF); + tEnv.addObjRelation("XSimpleRegistry.destroy", tmpDir + destroyF); + tEnv.addObjRelation("XSimpleRegistry.merge", tmpDir + mergeF); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SimpleRegistry + diff --git a/qadevOOo/tests/java/mod/_simplereg/uno/package.html b/qadevOOo/tests/java/mod/_simplereg/uno/package.html new file mode 100644 index 000000000..b70d93793 --- /dev/null +++ b/qadevOOo/tests/java/mod/_simplereg/uno/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 'simreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_simreg/SimpleRegistry.java b/qadevOOo/tests/java/mod/_simreg/SimpleRegistry.java new file mode 100644 index 000000000..8c513d7b5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_simreg/SimpleRegistry.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._simreg; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.registry.SimpleRegistry</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::registry::XSimpleRegistry</code></li> + * </ul> <p> + * The following files used by this test : + * <ul> + * <li><b> XSimpleRegistry.rdb </b> : a registry file with + * some key set. </li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.registry.XSimpleRegistry + * @see ifc.registry._XSimpleRegistry + */ +public class SimpleRegistry extends TestCase { + + /** + * Creates a temporary copy of file, which is deleted when VM exits. + * @param src Source file path. + * @param dst Destination file path. + * @param log The log writer. + * @throws java.io.IOException If any problems occur during copying. + */ + protected void copyFile(String src, String dst, PrintWriter log) + throws java.io.IOException { + File srcF = new File(src) ; + File dstF = new File(dst) ; + log.println("H1"); + + if (dstF.exists()) { + boolean bDeleteOk = dstF.delete(); + if (!bDeleteOk) { + System.out.println("delete failed"); + } + } + + System.out.println("H2"); + + boolean bCreateOk = dstF.createNewFile(); + if (!bCreateOk) { + System.out.println("create failed"); + } + + dstF.deleteOnExit() ; + log.println("H3"); + + FileInputStream fIn = new FileInputStream(srcF) ; + System.out.println("H4"); + + FileOutputStream fOut = new FileOutputStream(dstF) ; + + byte[] buf = new byte[1024] ; + int bytesRead = 0 ; + while ((bytesRead = fIn.read(buf)) > 0) { + fOut.write(buf, 0, bytesRead) ; + } + + fIn.close() ; + fOut.close() ; + } + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.registry.SimpleRegistry</code>. Then + * makes three copies of a predefined registry file with different + * names in a temporary SOffice directory and passes their URLs as + * relations. <p> + * + * Object relations created : + * <ul> + * <li> <code>'XSimpleRegistry.open'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * <li> <code>'XSimpleRegistry.merge'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * <li> <code>'XSimpleRegistry.destroy'</code> for + * {@link ifc.registry._XSimpleRegistry} : + * URL of 'XSimpleRegistry.rbd' file copy in the + * temp directory. </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + XInterface oObj = null; + Object oInterface = null; + final String tmpDir = utils.getOfficeTempDirSys(Param.getMSF()) ; + final String openF = "XSimpleRegistry_open.rdb" ; + final String destroyF = "XSimpleRegistry_destroy.rdb" ; + final String mergeF = "XSimpleRegistry_merge.rdb" ; + + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.registry.SimpleRegistry" ); + } catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + if (oInterface == null) + log.println("Service wasn't created") ; + + oObj = (XInterface) oInterface; + + log.println("creating copies of the registry for XSimpleRegistry"); + try { + String source = utils.getFullTestDocName("XSimpleRegistry.rdb"); + copyFile(source, tmpDir + openF, log); + copyFile(source, tmpDir + destroyF, log); + copyFile(source, tmpDir + mergeF, log); + } catch (java.io.IOException e) { + log.println("Exception occurred while copying files"); + e.printStackTrace(log); + } + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("XSimpleRegistry.open", tmpDir + openF); + tEnv.addObjRelation("XSimpleRegistry.destroy", tmpDir + destroyF); + tEnv.addObjRelation("XSimpleRegistry.merge", tmpDir + mergeF); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SimpleRegistry + diff --git a/qadevOOo/tests/java/mod/_simreg/package.html b/qadevOOo/tests/java/mod/_simreg/package.html new file mode 100644 index 000000000..b70d93793 --- /dev/null +++ b/qadevOOo/tests/java/mod/_simreg/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 'simreg'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_sm/SmEditAccessible.java b/qadevOOo/tests/java/mod/_sm/SmEditAccessible.java new file mode 100644 index 000000000..b32e7f4da --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/SmEditAccessible.java @@ -0,0 +1,129 @@ +/* + * 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._sm; + +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.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessible</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + */ +public class SmEditAccessible extends TestCase { + XComponent xMathDoc; + + /** + * Creates a <code>StarMath</code> document and obtains an accessibility + * component with the role <code>AccessibleRole.TEXT_FRAME</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(final TestParameters Param, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + + // setting a formula in document + final String expFormula = "sum hat a"; + final XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc); + xPS.setPropertyValue("Formula", expFormula); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xMathDoc); + + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.TEXT_FRAME, "", "WeldEditAccessible"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("Destroy", Boolean.TRUE); + + final XAccessibleContext con = UnoRuntime.queryInterface(XAccessibleContext.class, oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + System.out.println("Children "+con.getAccessibleChildCount()); + xPS.setPropertyValue("Formula", "sum hat x \n int a \n sum b"); + util.utils.waitForEventIdle(Param.getMSF()); + System.out.println("Children "+con.getAccessibleChildCount()); + xPS.setPropertyValue("Formula", expFormula); + util.utils.waitForEventIdle(Param.getMSF()); + } catch(com.sun.star.lang.WrappedTargetException e) { + } catch(com.sun.star.lang.IllegalArgumentException e) { + } catch(com.sun.star.beans.PropertyVetoException e) { + } catch(com.sun.star.beans.UnknownPropertyException e) { + } + } + }); + + return tEnv; + } + + /** + * Disposes the document created in <code>createTestEnvironment</code> + * method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } +} // finish class SmModel diff --git a/qadevOOo/tests/java/mod/_sm/SmGraphicAccessible.java b/qadevOOo/tests/java/mod/_sm/SmGraphicAccessible.java new file mode 100644 index 000000000..1d02f98bc --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/SmGraphicAccessible.java @@ -0,0 +1,132 @@ +/* + * 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._sm; + +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.accessibility.XAccessibleComponent; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessible</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessible + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessible + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + */ +public class SmGraphicAccessible extends TestCase { + XComponent xMathDoc; + + /** + * Creates a <code>StarMath</code> document and obtains an accessibility + * component with the role <code>AccessibleRole.PANEL</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(final TestParameters Param, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + + // setting a formula in document + final String expFormula = "sum a cdot b"; + final XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc); + xPS.setPropertyValue("Formula", expFormula); + + XInterface oObj = null; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xMathDoc); + + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole + (xRoot, AccessibleRole.DOCUMENT, "Formula"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + final XAccessibleComponent xAC = UnoRuntime.queryInterface(XAccessibleComponent.class, oObj); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this dialog"); + + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + xAC.grabFocus(); + xPS.setPropertyValue("Formula", "sum hat x"); + util.utils.waitForEventIdle(Param.getMSF()); + xPS.setPropertyValue("Formula", expFormula); + util.utils.waitForEventIdle(Param.getMSF()); + } catch(com.sun.star.lang.WrappedTargetException e) { + } catch(com.sun.star.lang.IllegalArgumentException e) { + } catch(com.sun.star.beans.PropertyVetoException e) { + } catch(com.sun.star.beans.UnknownPropertyException e) { + } + }}); + + return tEnv; + } + + /** + * Disposes the document created in <code>createTestEnvironment</code> + * method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } +} // finish class SmModel diff --git a/qadevOOo/tests/java/mod/_sm/SmModel.java b/qadevOOo/tests/java/mod/_sm/SmModel.java new file mode 100644 index 000000000..44cf134e5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/SmModel.java @@ -0,0 +1,80 @@ +/* + * 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._sm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XComponent; + +/** + * Test for object which is represented by + * <code>'StarMath'</code> document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::formula::FormulaProperties</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.formula.FormulaProperties + * @see ifc.formula._FormulaProperties + */ +public class SmModel extends TestCase { + XComponent xMathDoc; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates a <code>StarMath</code> document and passes it as + * tested component. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + + String Iname = util.utils.getImplName(xMathDoc); + log.println("Implementation Name: "+Iname); + TestEnvironment tEnv = new TestEnvironment(xMathDoc); + return tEnv; + } + + /** + * Disposes the document created in <code>createTestEnvironment</code> + * method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + +} // finish class SmModel + diff --git a/qadevOOo/tests/java/mod/_sm/XMLExporter.java b/qadevOOo/tests/java/mod/_sm/XMLExporter.java new file mode 100644 index 000000000..f13275f00 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLExporter.java @@ -0,0 +1,185 @@ +/* + * 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._sm; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XComponent xMathDoc; + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a math document" ); + xMathDoc = SOF.createMathDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The math document is set as a source document for exporter + * created. A new formula inserted into document. This made + * for checking if this formula is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String expFormula = "a - b" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), filter); + + try { + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Math.XMLExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xMathDoc); + + // setting a formula in document + XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc) ; + xPS.setPropertyValue("Formula", expFormula) ; + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + throw new StatusException("Can't create component.", e) ; + } + + // checking tags required + filter.addTag(new XMLTools.Tag("math:math")) ; + filter.addTagEnclosed(new XMLTools.Tag("math:annotation"), + new XMLTools.Tag("math:semantics")) ; + filter.addCharactersEnclosed(expFormula, + new XMLTools.Tag("math:annotation")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"smath: StarOffice XML (Math)"})); + tEnv.addObjRelation("SourceDocument",xMathDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } + +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_sm/XMLImporter.java b/qadevOOo/tests/java/mod/_sm/XMLImporter.java new file mode 100644 index 000000000..6b42f254e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLImporter.java @@ -0,0 +1,153 @@ +/* + * 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._sm; + +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.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XComponent xMathDoc; + + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLImporter</code><p> + * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag which specifies a formula + * in the document. + * After import the formula getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = null; + final String impFormula = "a - b" ; + + oObj = (XInterface)xMSF.createInstance( + "com.sun.star.comp.Math.XMLImporter"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("TargetDocument",xMathDoc); + + String[][] xml = new String[][] { + {"start", "math:math", + "xmlns:math", "CDATA", "http://www.w3.org/1998/Math/MathML"}, + {"start", "math:semantics"}, + {"start", "math:annotation", + "math:encoding", "CDATA", "StarMath 5.0"}, + {"chars", impFormula}, + {"end", "math:annotation"}, + {"end", "math:semantics"}, + {"end", "math:math"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + final XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc) ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String gFormula = (String) xPS.getPropertyValue + ("Formula") ; + logF.println("Formula returned = '" + gFormula + "'") ; + return impFormula.equals(gFormula) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } +} + diff --git a/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java new file mode 100644 index 000000000..e2e29911b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java @@ -0,0 +1,181 @@ +/* + * 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._sm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + XComponent xMathDoc; + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a math document" ); + xMathDoc = SOF.createMathDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The math document is set as a source document for exporter + * created. A new user info field inserted into document. This made + * for checking if this info field is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String expName = "XMLMetaExporterName" ; + final String expValue = "XMLMetaExporterValue" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Math.XMLMetaExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xMathDoc); + + // setting a new name and value for user info field + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xMathDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + XPropertyContainer xProps = xDocProps.getUserDefinedProperties(); + xProps.addProperty(expName, (short)0, expValue); + + // checking tags required + filter.addTag(new XMLTools.Tag("office:document-meta")) ; + filter.addCharactersEnclosed(expValue, + new XMLTools.Tag("meta:user-defined", "meta:name", expName)) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"smath: StarOffice XML (Math)"})); + tEnv.addObjRelation("SourceDocument",xMathDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java new file mode 100644 index 000000000..72ba25ccd --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java @@ -0,0 +1,187 @@ +/* + * 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._sm; + +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.beans.XPropertySetInfo; +import com.sun.star.beans.Property; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + XComponent xMathDoc; + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLMetaImporter</code><p> + * + * The math document is set as a target document for importer. + * Imported XML-data contains the tag which specifies new user info + * field and a title of document. + * After import user fields info and the title of target document + * is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = null; + final String impName = "XMLMetaImporter" ; + final String impValue = "XMLMetaImporter_Value" ; + final String impTitle = "XMLMetaImporter Title" ; + + oObj = (XInterface)xMSF.createInstance( + "com.sun.star.comp.Math.XMLMetaImporter"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("TargetDocument",xMathDoc); + + String[][] xml = new String[][] { + {"start", "office:document-meta", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:meta", "CDATA", "http://openoffice.org/2000/meta", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/" + }, + {"start", "office:meta"}, + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"start", "meta:user-defined", + "meta:name", "CDATA", impName}, + {"chars", impValue}, + {"end", "meta:user-defined"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + XDocumentPropertiesSupplier xPropSup = + UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xMathDoc); + final XDocumentProperties xDocProps = + xPropSup.getDocumentProperties(); + + XPropertySet xUDProps = UnoRuntime.queryInterface( + XPropertySet.class, + xDocProps.getUserDefinedProperties()); + XPropertySetInfo xInfo = + xUDProps.getPropertySetInfo(); + Property[] props = xInfo.getProperties(); + boolean result = false; + for (int i = 0; i < props.length; i++) { + String gName = props[i].Name; + String gValue = (String) + xUDProps.getPropertyValue(gName); + logF.println("Field '" + gName + "' = '" + + gValue + "'") ; + if (impName.equals(gName) && impValue.equals(gValue)) + result = true ; + } + String gTitle = xDocProps.getTitle(); + logF.println("Title returned : '" + gTitle + "'"); + result &= impTitle.equals(gTitle) ; + + return result ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } +} + diff --git a/qadevOOo/tests/java/mod/_sm/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_sm/XMLSettingsExporter.java new file mode 100644 index 000000000..f52ef2b2a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLSettingsExporter.java @@ -0,0 +1,180 @@ +/* + * 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._sm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + XComponent xMathDoc; + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a math document" ); + xMathDoc = SOF.createMathDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The math document is set as a source document for exporter + * created. A new value for TopMargin property is set for document. + * This made + * for checking if this property is successfully exported within + * the document settings. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final short expMargin = 67 ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Math.XMLSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xMathDoc); + + // setting a formula in document + XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc) ; + + xPS.setPropertyValue("TopMargin", Short.valueOf(expMargin)) ; + + // checking tags required + + filter.addTag(new XMLTools.Tag("office:document-settings")) ; + filter.addCharactersEnclosed(String.valueOf(expMargin), + new XMLTools.Tag("config:config-item", "config:name", "TopMargin")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"smath: StarOffice XML (Math)"})); + tEnv.addObjRelation("SourceDocument",xMathDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } + +} // finish class TestCase + diff --git a/qadevOOo/tests/java/mod/_sm/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_sm/XMLSettingsImporter.java new file mode 100644 index 000000000..484cd2b6d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sm/XMLSettingsImporter.java @@ -0,0 +1,162 @@ +/* + * 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._sm; + +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.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Math.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + XComponent xMathDoc; + + /** + * New math document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + xMathDoc = SOF.openDoc("smath","_blank"); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xMathDoc " ); + xMathDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Math.XMLSettingsImporter</code><p> + * + * The math document is set as a target document for importer. + * Imported XML-data contains the tag which specifies new + * 'TopMargin' property value. + * After import 'TopMargin' property value of target document + * is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) + throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = null; + final short impMargin = 67 ; + + oObj = (XInterface)xMSF.createInstance( + "com.sun.star.comp.Math.XMLSettingsImporter"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("TargetDocument",xMathDoc); + + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + "office:version", "CDATA", "1.0" + }, + {"start", "office:settings"}, + {"start", "config:config-item-set", + "config:name", "CDATA", "configuration-settings"}, + + {"start", "config:config-item", + "config:name", "CDATA", "TopMargin", + "config:type", "CDATA", "short"}, + {"chars", String.valueOf(impMargin)}, + {"end", "config:config-item"}, + {"end", "config:config-item-set"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + final XPropertySet xPS = UnoRuntime.queryInterface + (XPropertySet.class, xMathDoc) ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Short gMargin = (Short) xPS.getPropertyValue + ("TopMargin") ; + logF.println("Margin returned: " + gMargin); + return impMargin == gMargin.shortValue() ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } +} + diff --git a/qadevOOo/tests/java/mod/_smgr/OServiceManager.java b/qadevOOo/tests/java/mod/_smgr/OServiceManager.java new file mode 100644 index 000000000..797246b2c --- /dev/null +++ b/qadevOOo/tests/java/mod/_smgr/OServiceManager.java @@ -0,0 +1,157 @@ +/* + * 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._smgr; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XSet; +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.XComponentContext; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.stoc.OServiceManager</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li> + * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> + * <li> <code>com::sun::star::container::XSet</code></li> + * <li> <code>com::sun::star::lang::XMultiComponentFactory</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.lang.XMultiServiceFactory + * @see com.sun.star.container.XContentEnumerationAccess + * @see com.sun.star.container.XSet + * @see com.sun.star.lang.XMultiComponentFactory + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.lang.XComponent + * @see ifc.lang._XMultiServiceFactory + * @see ifc.container._XContentEnumerationAccess + * @see ifc.container._XSet + * @see ifc.lang._XMultiComponentFactory + * @see ifc.lang._XServiceInfo + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.lang._XComponent + */ +public class OServiceManager extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.stoc.OServiceManager</code>. + * Object relations created : + * <ul> + * <li> <code>'NewElement'</code> for + * {@link ifc.container._XSet} : + * element to be inserted into manager. Here + * a new <code>ServiceManager</code> implementation is + * create using + * <code>tools.SOConnect.createSimpleServiceManager()</code> + * and one of services contained in it is taken.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.stoc.OServiceManager" ); + } catch( com.sun.star.uno.Exception e ) { + log.println("ServiceManager service not available" ); + } + + // adding a service to the manager + Object newElement = null ; + XMultiServiceFactory srvMan = null; + XComponentContext xContext = null; + + try { + + srvMan = com.sun.star.comp.helper.Bootstrap.createSimpleServiceManager(); + + } catch ( java.lang.Exception ex) { + log.println("Error creating SimpleServiceManager :"); + ex.printStackTrace(log); + } + + XSet set = UnoRuntime.queryInterface + (XSet.class, oInterface) ; + XSet set1 = UnoRuntime.queryInterface + (XSet.class, srvMan) ; + XEnumeration oEnum = set1.createEnumeration(); + Object srv = oEnum.nextElement(); + + set.insert(srv) ; + + newElement = oEnum.nextElement(); + + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, oInterface); + if (xProp != null) { + xContext = (XComponentContext) AnyConverter.toObject( + new Type(XComponentContext.class), + xProp.getPropertyValue("DefaultContext")); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XSet interface + tEnv.addObjRelation("NewElement", newElement) ; + + // adding relation for XPropertySet + tEnv.addObjRelation("PTT",new String[]{"DefaultContext","none","none"}); + + //adding relation for XMultiComponentFactory + if (xContext != null) { + tEnv.addObjRelation("DC", xContext); + } + return tEnv; + } // finish method getTestEnvironment + +} // finish class OServiceManager + diff --git a/qadevOOo/tests/java/mod/_smgr/package.html b/qadevOOo/tests/java/mod/_smgr/package.html new file mode 100644 index 000000000..bef49b8c5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_smgr/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 'smgr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_smplmail/SimpleSystemMail.java b/qadevOOo/tests/java/mod/_smplmail/SimpleSystemMail.java new file mode 100644 index 000000000..6e0d1037a --- /dev/null +++ b/qadevOOo/tests/java/mod/_smplmail/SimpleSystemMail.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._smplmail; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.system.SimpleSystemMail</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::system::XSimpleMailClientSupplier</code></li> + * <li> <code>com::sun::star::lang::XServiceInfo</code></li> + * <li> <code>com::sun::star::lang::XTypeProvider</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.system.XSimpleMailClientSupplier + * @see com.sun.star.lang.XServiceInfo + * @see com.sun.star.lang.XTypeProvider + * @see ifc.system._XSimpleMailClientSupplier + * @see ifc.lang._XServiceInfo + * @see ifc.lang._XTypeProvider + */ +public class SimpleSystemMail extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * In case if OS is Win or not specified tries to create an instance + * of the service <code>com.sun.star.system.SimpleSystemMail</code>. <p> + * + * Object relations created : + * <ul> + * <li> <code>'SystemMailExist'</code> for + * {@link ifc.system._XSimpleMailClientSupplier} : + * the value depends on tested platform and + * <code>test.system.mail.isExist</code> INI + * parameter.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + boolean isWinOS = false ; + boolean isSystemMailExist = false ; + + // if 'OS' parameter is not defined then by default + // Win platform is used. If really not the error will occurs. + isWinOS = Param.get("OS") == null || + "wntmsci".equals(Param.get("OS")) ; + isSystemMailExist = "true".equalsIgnoreCase + ((String) Param.get("test.system.mail.isExist")) ; + + XMultiServiceFactory xMSF = Param.getMSF(); + if (isWinOS) { + log.println("The OS is Win : trying to create service"); + oInterface = xMSF.createInstance + ( "com.sun.star.system.SimpleSystemMail" ); + } else { + log.println("The OS is NOT Win, SKIPPING this component"); + log.println("Creating Dummy object ..."); + oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" ); + } + + oObj = (XInterface) oInterface; + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("SystemMailExist", Boolean.valueOf(isSystemMailExist)); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SimpleSystemMail + diff --git a/qadevOOo/tests/java/mod/_srtrs/SortedDynamicResultSetFactory.java b/qadevOOo/tests/java/mod/_srtrs/SortedDynamicResultSetFactory.java new file mode 100644 index 000000000..7449c4907 --- /dev/null +++ b/qadevOOo/tests/java/mod/_srtrs/SortedDynamicResultSetFactory.java @@ -0,0 +1,75 @@ +/* + * 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._srtrs; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.ucb.SortedDynamicResultSetFactory</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::ucb::XSortedDynamicResultSetFactory</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.ucb.XSortedDynamicResultSetFactory + * @see ifc.ucb._XSortedDynamicResultSetFactory + */ +public class SortedDynamicResultSetFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.SortedDynamicResultSetFactory</code>. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = tParam.getMSF(); + oInterface = xMSF.createInstance( + "com.sun.star.ucb.SortedDynamicResultSetFactory"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } +} + diff --git a/qadevOOo/tests/java/mod/_stm/DataInputStream.java b/qadevOOo/tests/java/mod/_stm/DataInputStream.java new file mode 100644 index 000000000..ee55f57fa --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/DataInputStream.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._stm; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XDataOutputStream; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.DataInputStream</code>. +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XDataInputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.DataInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XDataInputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XInputStream +* @see ifc.io._XDataInputStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +*/ +public class DataInputStream extends TestCase { + + /** + * Creates a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.io.DataInputStream</code> object, + * connects it to <code>com.sun.star.io.DataOutputStream</code> + * through <code>com.sun.star.io.Pipe</code>. All of possible data + * types are written into <code>DataOutputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XDataInputStream} + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable}(another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance("com.sun.star.io.DataInputStream"); + + XInterface oObj = (XInterface) oInterface; + + // creating and connecting DataOutputStream to the + // DataInputStream created through the Pipe + XActiveDataSink xDataSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj); + + XInterface oPipe = (XInterface) + xMSF.createInstance("com.sun.star.io.Pipe"); + + XInputStream xPipeInput = UnoRuntime.queryInterface(XInputStream.class, oPipe); + XOutputStream xPipeOutput = UnoRuntime.queryInterface(XOutputStream.class, oPipe); + + XInterface oDataOutput = (XInterface) + xMSF.createInstance("com.sun.star.io.DataOutputStream"); + + XDataOutputStream xDataOutput = UnoRuntime.queryInterface(XDataOutputStream.class, oDataOutput) ; + XActiveDataSource xDataSource = UnoRuntime.queryInterface(XActiveDataSource.class, oDataOutput) ; + + xDataSource.setOutputStream(xPipeOutput) ; + xDataSink.setInputStream(xPipeInput) ; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>(); + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + // creating a connectable object for XConnectable interface + XInterface xConnect = (XInterface)xMSF.createInstance( + "com.sun.star.io.DataInputStream") ; + + // creating an input stream to set in XActiveDataSink + XInterface oDataInput = (XInterface) xMSF.createInstance( + "com.sun.star.io.Pipe" ); + + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding sequence of data that must be read + // by XDataInputStream interface methods + tEnv.addObjRelation("StreamData", data) ; + // add a writer + tEnv.addObjRelation("StreamWriter", xDataOutput); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + // add an inputStream + tEnv.addObjRelation("InputStream", oDataInput); + tEnv.addObjRelation("ByteData", byteData); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/DataOutputStream.java b/qadevOOo/tests/java/mod/_stm/DataOutputStream.java new file mode 100644 index 000000000..ead4fc671 --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/DataOutputStream.java @@ -0,0 +1,164 @@ +/* + * 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._stm; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.DataOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XDataOutputStream</code></li> +* </ul> +* @see com.sun.star.io.DataOutputStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XDataOutputStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XDataOutputStream +*/ +public class DataOutputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.io.DataOutputStream</code> + * and an instance of the service <code>com.sun.star.io.Pipe</code>. + * Plugs the created pipe as output stream for the created DataOutputStream. + * @see com.sun.star.io.DataOutputStream + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + XInterface oPipe = null; + XMultiServiceFactory xMSF = null ; + + xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ("com.sun.star.io.DataOutputStream"); + oPipe = (XInterface)xMSF.createInstance("com.sun.star.io.Pipe"); + + oObj = (XInterface) oInterface; + + final XOutputStream xPipeOutput = UnoRuntime.queryInterface(XOutputStream.class, oPipe); + + XActiveDataSource xDataSource = UnoRuntime.queryInterface(XActiveDataSource.class, oObj); + + xDataSource.setOutputStream(xPipeOutput); + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", oPipe); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + final XInputStream xPipeInput = UnoRuntime.queryInterface(XInputStream.class, oPipe); + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + xPipeOutput.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.DataInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(xPipeInput); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_stm/MarkableInputStream.java b/qadevOOo/tests/java/mod/_stm/MarkableInputStream.java new file mode 100644 index 000000000..a86369867 --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/MarkableInputStream.java @@ -0,0 +1,129 @@ +/* + * 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._stm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.MarkableInputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.MarkableInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XInputStream +* @see ifc.io._XMarkableStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +*/ +public class MarkableInputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. + * Plugs the created pipe as output stream for the created + * <code>MarkableOutputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. Writes some data to the + * <code>MarkableOutputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable}(another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + + Object aPipe = null; + Object mostream = null; + Object mistream = null; + Object xConnect = null; + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance("com.sun.star.io.MarkableOutputStream"); + xConnect = xMSF.createInstance("com.sun.star.io.DataInputStream"); + + // Creating construction : + // MarkableOutputStream -> Pipe -> MarkableInputStream + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class, aPipe); + XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class, aPipe); + + xdSmo.setOutputStream(PipeOut); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + + xmSi.setInputStream(PipeIn) ; + + XInterface oObj = (XInterface) mistream; + + byte[] byteData = new byte[] {1,2,3,4,5,6}; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // add a writer + tEnv.addObjRelation("StreamWriter", mostream); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + // add an inputStream + tEnv.addObjRelation("InputStream", mistream); + tEnv.addObjRelation("ByteData", byteData); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/MarkableOutputStream.java b/qadevOOo/tests/java/mod/_stm/MarkableOutputStream.java new file mode 100644 index 000000000..6765ba721 --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/MarkableOutputStream.java @@ -0,0 +1,188 @@ +/* + * 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._stm; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.MarkableOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* </ul> +* @see com.sun.star.io.MarkableOutputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XConnectable +* @see ifc.io._XMarkableStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XConnectable +*/ +public class MarkableOutputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. + * Plugs the created pipe as output stream for the created + * <code>MarkableOutputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XOutputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataOutputStream}(the data that should be + * written into the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + Object aPipe = null; + Object mostream = null; + Object mistream = null; + XInterface aConnect; + + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + aConnect = (XInterface)xMSF.createInstance + ("com.sun.star.io.DataOutputStream"); + + // Creating construction : + // MarkableOutputStream -> Pipe -> MarkableInputStream + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + final XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class,aPipe); + final XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class,aPipe); + + xdSmo.setOutputStream(PipeOut); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + + xmSi.setInputStream(PipeIn) ; + + oObj = (XInterface) mostream; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", aPipe); + tEnv.addObjRelation("Connectable", aConnect); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + PipeOut.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.MarkableInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(PipeIn); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/ObjectInputStream.java b/qadevOOo/tests/java/mod/_stm/ObjectInputStream.java new file mode 100644 index 000000000..e40f2a12e --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/ObjectInputStream.java @@ -0,0 +1,250 @@ +/* + * 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._stm; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XObjectInputStream; +import com.sun.star.io.XObjectOutputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.io.XPersistObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XImplementationRegistration; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.ObjectInputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XDataInputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* <li> <code>com::sun::star::io::XObjectInputStream</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> MyPersistObjectImpl.jar </b> : the implementation of the persist +* object</li> +* </ul> <p> +* @see com.sun.star.io.ObjectInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XDataInputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see com.sun.star.io.XObjectInputStream +* @see ifc.io._XInputStream +* @see ifc.io._XMarkableStream +* @see ifc.io._XDataInputStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +* @see ifc.io._XObjectInputStream +*/ +public class ObjectInputStream extends TestCase { + + /** + * Register the implementation of service + * <code>com.sun.star.cmp.PersistObject</code> if not yet registered. + * @see com.sun.star.cmp.PersistObject + */ + @Override + public void initialize(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + Object oPersObj = null; + // test first if object is already registered + try { + oPersObj = xMSF.createInstance("com.sun.star.cmp.PersistObject"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Could not create instance of PersistObject"); + e.printStackTrace(log); + log.println("Going on with test..."); + } + if ( oPersObj == null ) { + // object is not available: it has to be registered + String url = util.utils.getFullTestURL + ("qadevlibs/MyPersistObjectImpl.jar"); + XImplementationRegistration xir; + Object o = xMSF.createInstance( + "com.sun.star.registry.ImplementationRegistration"); + xir = UnoRuntime.queryInterface( + XImplementationRegistration.class, o); + + XSimpleRegistry xReg = null; + System.out.println("Register library: " + url); + xir.registerImplementation( + "com.sun.star.loader.Java2", url, xReg); + System.out.println("...done"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services + * <code>com.sun.star.io.ObjectInputStream</code>, + * <code>com.sun.star.io.ObjectOutputStream</code>, + * <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. Plugs the created + * markable output stream as output stream for the created + * <code>ObjectOutputStream</code>. Plugs the created pipe as output stream + * for the created <code>MarkableOutputStream</code>. Plugs the created + * markable input stream as input stream for the created + * <code>ObjectInputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. Creates an instance + * of the service <code>com.sun.star.cmp.PersistObject</code> and writes + * the created object to the object output stream. + * Object relations created : + * <ul> + * <li> <code>'PersistObject'</code> for + * {@link ifc.io._XObjectInputStream}(the created instance of the + * persist object ) </li> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XDataInputStream} + * {@link ifc.io._XObjectInputStream} + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + * @see com.sun.star.io.ObjectInputStream + * @see com.sun.star.io.ObjectOutputStream + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + * @see com.sun.star.cmp.PersistObject + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + System.out.println("create TestEnvironment started."); + XMultiServiceFactory xMSF = Param.getMSF(); + Object ostream = null; + Object aPipe = null; + Object mostream = null; + Object mistream = null; + Object istream = null; + Object xConnect = null; + istream = xMSF.createInstance + ("com.sun.star.io.ObjectInputStream"); + ostream = xMSF.createInstance + ("com.sun.star.io.ObjectOutputStream"); + aPipe = xMSF.createInstance + ("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + xConnect = xMSF.createInstance + ("com.sun.star.io.DataInputStream") ; + + // Creating construction : + // ObjectOutputStream -> MarkableOutputStream -> Pipe -> + // -> MarkableInputStream -> ObjectInputStream + XActiveDataSource xdSo = UnoRuntime.queryInterface(XActiveDataSource.class, ostream); + + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream moStream = UnoRuntime.queryInterface(XOutputStream.class, mostream); + + XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class, aPipe); + XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class, aPipe); + + xdSo.setOutputStream(moStream); + xdSmo.setOutputStream(PipeOut); + + XObjectInputStream iStream = UnoRuntime.queryInterface(XObjectInputStream.class, istream); + XObjectOutputStream oStream = null; + oStream = UnoRuntime.queryInterface(XObjectOutputStream.class, ostream); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + XInputStream xmIstream = UnoRuntime.queryInterface(XInputStream.class, mistream); + + XActiveDataSink xdSi = UnoRuntime.queryInterface + (XActiveDataSink.class, istream); + xdSi.setInputStream(xmIstream); + xmSi.setInputStream(PipeIn); + + // creating Persist object which has to be written + XPersistObject xPersObj = null; + Object oPersObj = xMSF.createInstance + ("com.sun.star.cmp.PersistObject"); + xPersObj = UnoRuntime.queryInterface(XPersistObject.class, oPersObj); + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + + System.out.println("create environment"); + XInterface oObj = iStream; + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding persistent object + tEnv.addObjRelation("PersistObject", xPersObj); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + tEnv.addObjRelation("StreamWriter", oStream); + // for XActiveDataSink + tEnv.addObjRelation("InputStream", aPipe); + // adding sequence of data that must be read + // by XDataInputStream interface methods + tEnv.addObjRelation("StreamData", data) ; + // and by XInputStream interface methods + tEnv.addObjRelation("ByteData", byteData) ; + + System.out.println("create TestEnvironment finished."); + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/ObjectOutputStream.java b/qadevOOo/tests/java/mod/_stm/ObjectOutputStream.java new file mode 100644 index 000000000..37f091b9f --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/ObjectOutputStream.java @@ -0,0 +1,272 @@ +/* + * 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._stm; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XObjectInputStream; +import com.sun.star.io.XObjectOutputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.io.XPersistObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XImplementationRegistration; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.ObjectOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XDataOutputStream</code></li> +* <li> <code>com::sun::star::io::XObjectOutputStream</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> MyPersistObjectImpl.jar </b> : the implementation of the persist +* object</li> +* </ul> <p> +* @see com.sun.star.io.ObjectOutputStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XDataOutputStream +* @see com.sun.star.io.XObjectOutputStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XConnectable +* @see ifc.io._XDataOutputStream +* @see ifc.io._XObjectOutputStream +*/ +public class ObjectOutputStream extends TestCase { + + /** + * Register the implementation of service + * <code>com.sun.star.cmp.PersistObject</code> if not yet registered. + * @see com.sun.star.cmp.PersistObject + */ + @Override + public void initialize(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + Object oPersObj = null; + // test first if object is already registered + try { + oPersObj = xMSF.createInstance("com.sun.star.cmp.PersistObject"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Could not create instance of PersistObject"); + e.printStackTrace(log); + log.println("Going on with test..."); + } + if ( oPersObj == null ) { + // object is not available: it has to be registered + String url = util.utils.getFullTestURL + ("qadevlibs/MyPersistObjectImpl.jar"); + XImplementationRegistration xir; + Object o = xMSF.createInstance( + "com.sun.star.registry.ImplementationRegistration"); + xir = UnoRuntime.queryInterface( + XImplementationRegistration.class, o); + + XSimpleRegistry xReg = null; + System.out.println("Register library: " + url); + xir.registerImplementation( + "com.sun.star.loader.Java2", url, xReg); + System.out.println("...done"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services + * <code>com.sun.star.io.ObjectOutputStream</code>, + * <code>com.sun.star.io.Pipe</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. Plugs the created + * markable output stream as output stream for the created + * <code>ObjectOutputStream</code>. Plugs the created pipe as output stream + * for the created <code>MarkableOutputStream</code>. Creates an instance + * of the service <code>com.sun.star.cmp.PersistObject</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataOutputStream}(the data that should + * be written into the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XOutputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'PersistObject'</code> for + * {@link ifc.io._XObjectOutputStream}(the created instance of the + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XObjectInputStream}(the created instance of the + * persist object ) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.ObjectInputStream + * @see com.sun.star.io.ObjectOutputStream + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + * @see com.sun.star.cmp.PersistObject + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + + XObjectOutputStream oStream = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + Object ostream = null, istream = null; + Object aPipe = null; + Object mostream = null; + XInterface aConnect = null; + Object minstream = null; + + ostream = xMSF.createInstance + ( "com.sun.star.io.ObjectOutputStream" ); + istream = xMSF.createInstance + ("com.sun.star.io.ObjectInputStream"); + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + aConnect = (XInterface)xMSF.createInstance + ("com.sun.star.io.DataInputStream"); + minstream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + + // creating the pipe where object has to be written to + XActiveDataSource xdSo = UnoRuntime.queryInterface(XActiveDataSource.class, ostream); + + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream moStream = UnoRuntime.queryInterface(XOutputStream.class, mostream); + + XActiveDataSink markIn = UnoRuntime.queryInterface(XActiveDataSink.class, minstream); + XActiveDataSink inStream = UnoRuntime.queryInterface(XActiveDataSink.class, istream); + XInputStream markInStream = UnoRuntime.queryInterface(XInputStream.class, minstream); + + final XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class,aPipe); + final XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class,aPipe); + + markIn.setInputStream(PipeIn); + inStream.setInputStream(markInStream); + XObjectInputStream objInputStream = UnoRuntime.queryInterface(XObjectInputStream.class, istream); + xdSo.setOutputStream(moStream); + xdSmo.setOutputStream(PipeOut); + + oStream = UnoRuntime.queryInterface(XObjectOutputStream.class, ostream); + + // creating Persistent object which has to be written + XPersistObject xPersObj = null ; + Object oPersObj = xMSF.createInstance + ("com.sun.star.cmp.PersistObject"); + xPersObj = UnoRuntime.queryInterface(XPersistObject.class, oPersObj); + + oObj = oStream; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("PersistObject", xPersObj); + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", aPipe); + tEnv.addObjRelation("Connectable", aConnect); + + tEnv.addObjRelation("InputStream", objInputStream); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + PipeOut.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.ObjectInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(PipeIn); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/Pipe.java b/qadevOOo/tests/java/mod/_stm/Pipe.java new file mode 100644 index 000000000..facd2cafe --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/Pipe.java @@ -0,0 +1,99 @@ +/* + * 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._stm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.XInputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.Pipe</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* </ul> +* @see com.sun.star.io.Pipe +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XOutputStream +* @see ifc.io._XInputStream +* @see ifc.io._XOutputStream +*/ +public class Pipe extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service <code>com.sun.star.io.Pipe</code>. + * Writes some information to the created pipe. + * Object relations created : + * <ul> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.Pipe + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" ); + + oObj = (XInterface) oInterface; + + // writing some information to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //add relation for io.XOutputStream + final XInputStream iStream = UnoRuntime.queryInterface(XInputStream.class, oObj); + + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("StreamWriter", oObj); + + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + public void resetStreams() { + } + + public XInputStream getInStream() { + return iStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_stm/Pump.java b/qadevOOo/tests/java/mod/_stm/Pump.java new file mode 100644 index 000000000..d53d6ea1e --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/Pump.java @@ -0,0 +1,174 @@ +/* + * 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._stm; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.io.NotConnectedException; +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.Pump</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XActiveDataControl</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.Pump +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XActiveDataControl +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XActiveDataSource +* @see ifc.io._XActiveDataControl +* @see ifc.io._XActiveDataSink +*/ +public class Pump extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service <code>com.sun.star.io.Pump</code>. + * Settings up input and output streams for the created pump. + * Object relations created : + * <ul> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSource}(an input stream to set) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource}(an output stream to set) </li> + * </ul> + * @see com.sun.star.io.Pump + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + + Object oInterface = null; + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oPipe; + + // creating an instance of stm.Pump + oInterface = xMSF.createInstance( "com.sun.star.io.Pump" ); + oPipe = (XInterface) xMSF.createInstance( "com.sun.star.io.Pipe" ); + + + XInterface oObj = (XInterface) oInterface; + + // setting up input and output streams for pump + XActiveDataSink xSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj); + XActiveDataSource xSource = UnoRuntime.queryInterface(XActiveDataSource.class, oObj); + + XInputStream xInput = new MyInput(); + XOutputStream xOutput = new MyOutput(); + + xSink.setInputStream(xInput); + xSource.setOutputStream(xOutput); + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // add object relations for ActiveDataSource and XActiveDataSink + tEnv.addObjRelation("InputStream", oPipe); + tEnv.addObjRelation("OutputStream", oPipe); + + return tEnv; + } // finish method getTestEnvironment + + /** + * XInputStream implementation to use with the test. It returns bytes of + * which a simple string consists. + */ + private static class MyInput implements XInputStream { + String str = "Pump tesing string" ; + + public int readBytes(byte[][] bytes, int len) + throws NotConnectedException{ + + if (str == null) + throw new NotConnectedException("Input stream was closed"); + + int actual = 0 ; + if (len <= str.length()) { + String resStr = str.substring(0, len-1) ; + bytes[0] = resStr.getBytes() ; + actual = len ; + str = str.substring(len) ; + } else { + bytes[0] = str.getBytes() ; + actual = str.length() ; + } + + return actual; + } + + public int readSomeBytes(byte[][] bytes, int len) + throws NotConnectedException{ + return readBytes(bytes, len); + } + + public void skipBytes(int len) throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + if (len >= str.length()) + str = "" ; + else + str = str.substring(len) ; + } + + public void closeInput() throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + str = null ; + } + + public int available() throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + return str.length(); + } + } + + /** + * Dummy XOutputStream implementation to use with the test. Does nothing. + */ + private static class MyOutput implements XOutputStream { + public void writeBytes(byte[] bytes) { + } + + public void flush() { + } + + public void closeOutput() { + } + } +} + diff --git a/qadevOOo/tests/java/mod/_stm/package.html b/qadevOOo/tests/java/mod/_stm/package.html new file mode 100644 index 000000000..aa2793cf2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_stm/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 'stm'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_streams/uno/DataInputStream.java b/qadevOOo/tests/java/mod/_streams/uno/DataInputStream.java new file mode 100644 index 000000000..a1c4a49d9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/DataInputStream.java @@ -0,0 +1,151 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XDataOutputStream; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.DataInputStream</code>. +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XDataInputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.DataInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XDataInputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XInputStream +* @see ifc.io._XDataInputStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +*/ +public class DataInputStream extends TestCase { + + /** + * Creates a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.io.DataInputStream</code> object, + * connects it to <code>com.sun.star.io.DataOutputStream</code> + * through <code>com.sun.star.io.Pipe</code>. All of possible data + * types are written into <code>DataOutputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XDataInputStream} + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable}(another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance("com.sun.star.io.DataInputStream"); + + XInterface oObj = (XInterface) oInterface; + + // creating and connecting DataOutputStream to the + // DataInputStream created through the Pipe + XActiveDataSink xDataSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj); + + XInterface oPipe = (XInterface) + xMSF.createInstance("com.sun.star.io.Pipe"); + + XInputStream xPipeInput = UnoRuntime.queryInterface(XInputStream.class, oPipe); + XOutputStream xPipeOutput = UnoRuntime.queryInterface(XOutputStream.class, oPipe); + + XInterface oDataOutput = (XInterface) + xMSF.createInstance("com.sun.star.io.DataOutputStream"); + + XDataOutputStream xDataOutput = UnoRuntime.queryInterface(XDataOutputStream.class, oDataOutput) ; + XActiveDataSource xDataSource = UnoRuntime.queryInterface(XActiveDataSource.class, oDataOutput) ; + + xDataSource.setOutputStream(xPipeOutput) ; + xDataSink.setInputStream(xPipeInput) ; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + // creating a connectable object for XConnectable interface + XInterface xConnect = (XInterface)xMSF.createInstance( + "com.sun.star.io.DataInputStream") ; + + // creating an input stream to set in XActiveDataSink + XInterface oDataInput = (XInterface) xMSF.createInstance( + "com.sun.star.io.Pipe" ); + + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding sequence of data that must be read + // by XDataInputStream interface methods + tEnv.addObjRelation("StreamData", data) ; + // add a writer + tEnv.addObjRelation("StreamWriter", xDataOutput); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + // add an inputStream + tEnv.addObjRelation("InputStream", oDataInput); + tEnv.addObjRelation("ByteData", byteData); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/DataOutputStream.java b/qadevOOo/tests/java/mod/_streams/uno/DataOutputStream.java new file mode 100644 index 000000000..fad95930a --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/DataOutputStream.java @@ -0,0 +1,163 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.DataOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XDataOutputStream</code></li> +* </ul> +* @see com.sun.star.io.DataOutputStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XDataOutputStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XDataOutputStream +*/ +public class DataOutputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.io.DataOutputStream</code> + * and an instance of the service <code>com.sun.star.io.Pipe</code>. + * Plugs the created pipe as output stream for the created DataOutputStream. + * @see com.sun.star.io.DataOutputStream + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + XInterface oPipe = null; + XMultiServiceFactory xMSF = null ; + + xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ("com.sun.star.io.DataOutputStream"); + oPipe = (XInterface)xMSF.createInstance("com.sun.star.io.Pipe"); + + oObj = (XInterface) oInterface; + + final XOutputStream xPipeOutput = UnoRuntime.queryInterface(XOutputStream.class, oPipe); + + XActiveDataSource xDataSource = UnoRuntime.queryInterface(XActiveDataSource.class, oObj); + + xDataSource.setOutputStream(xPipeOutput); + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", oPipe); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + final XInputStream xPipeInput = UnoRuntime.queryInterface(XInputStream.class, oPipe); + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + xPipeOutput.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.DataInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(xPipeInput); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/MarkableInputStream.java b/qadevOOo/tests/java/mod/_streams/uno/MarkableInputStream.java new file mode 100644 index 000000000..30f0202a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/MarkableInputStream.java @@ -0,0 +1,128 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.MarkableInputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.MarkableInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XInputStream +* @see ifc.io._XMarkableStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +*/ +public class MarkableInputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. + * Plugs the created pipe as output stream for the created + * <code>MarkableOutputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. Writes some data to the + * <code>MarkableOutputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable}(another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + + Object aPipe = null; + Object mostream = null; + Object mistream = null; + Object xConnect = null; + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance("com.sun.star.io.MarkableOutputStream"); + xConnect = xMSF.createInstance("com.sun.star.io.DataInputStream"); + + // Creating construction : + // MarkableOutputStream -> Pipe -> MarkableInputStream + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class, aPipe); + XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class, aPipe); + + xdSmo.setOutputStream(PipeOut); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + + xmSi.setInputStream(PipeIn) ; + + XInterface oObj = (XInterface) mistream; + + byte[] byteData = new byte[] {1,2,3,4,5,6}; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // add a writer + tEnv.addObjRelation("StreamWriter", mostream); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + // add an inputStream + tEnv.addObjRelation("InputStream", mistream); + tEnv.addObjRelation("ByteData", byteData); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/MarkableOutputStream.java b/qadevOOo/tests/java/mod/_streams/uno/MarkableOutputStream.java new file mode 100644 index 000000000..f08b20f17 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/MarkableOutputStream.java @@ -0,0 +1,187 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.MarkableOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* </ul> +* @see com.sun.star.io.MarkableOutputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XConnectable +* @see ifc.io._XMarkableStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XConnectable +*/ +public class MarkableOutputStream extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. + * Plugs the created pipe as output stream for the created + * <code>MarkableOutputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. + * Object relations created : + * <ul> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XOutputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataOutputStream}(the data that should be + * written into the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + Object aPipe = null; + Object mostream = null; + Object mistream = null; + XInterface aConnect; + + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + aConnect = (XInterface)xMSF.createInstance + ("com.sun.star.io.DataOutputStream"); + + // Creating construction : + // MarkableOutputStream -> Pipe -> MarkableInputStream + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + final XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class,aPipe); + final XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class,aPipe); + + xdSmo.setOutputStream(PipeOut); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + + xmSi.setInputStream(PipeIn) ; + + oObj = (XInterface) mostream; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", aPipe); + tEnv.addObjRelation("Connectable", aConnect); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + PipeOut.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.MarkableInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(PipeIn); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/ObjectInputStream.java b/qadevOOo/tests/java/mod/_streams/uno/ObjectInputStream.java new file mode 100644 index 000000000..6be959ed9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/ObjectInputStream.java @@ -0,0 +1,256 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XObjectInputStream; +import com.sun.star.io.XObjectOutputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.io.XPersistObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XImplementationRegistration; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.ObjectInputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XMarkableStream</code></li> +* <li> <code>com::sun::star::io::XDataInputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* <li> <code>com::sun::star::io::XObjectInputStream</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> MyPersistObjectImpl.jar </b> : the implementation of the persist +* object</li> +* </ul> <p> +* @see com.sun.star.io.ObjectInputStream +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XMarkableStream +* @see com.sun.star.io.XDataInputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XActiveDataSink +* @see com.sun.star.io.XObjectInputStream +* @see ifc.io._XInputStream +* @see ifc.io._XMarkableStream +* @see ifc.io._XDataInputStream +* @see ifc.io._XConnectable +* @see ifc.io._XActiveDataSink +* @see ifc.io._XObjectInputStream +*/ +public class ObjectInputStream extends TestCase { + + /** + * Register the implementation of service + * <code>com.sun.star.cmp.PersistObject</code> if not yet registered. + * @see com.sun.star.cmp.PersistObject + */ + @Override + public void initialize(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + Object oPersObj = null; + // test first if object is already registered + try { + oPersObj = xMSF.createInstance("com.sun.star.cmp.PersistObject"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Could not create instance of PersistObject"); + e.printStackTrace(log); + log.println("Going on with test..."); + } + if ( oPersObj == null ) { + // object is not available: it has to be registered + String url = util.utils.getFullTestURL + ("qadevlibs/MyPersistObjectImpl.jar"); + XImplementationRegistration xir; + Object o = xMSF.createInstance( + "com.sun.star.registry.ImplementationRegistration"); + xir = UnoRuntime.queryInterface( + XImplementationRegistration.class, o); + + XSimpleRegistry xReg = null; + System.out.println("Register library: " + url); + xir.registerImplementation( + "com.sun.star.loader.Java2", url, xReg); + System.out.println("...done"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services + * <code>com.sun.star.io.ObjectInputStream</code>, + * <code>com.sun.star.io.ObjectOutputStream</code>, + * <code>com.sun.star.io.Pipe</code>, + * <code>com.sun.star.io.MarkableInputStream</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. Plugs the created + * markable output stream as output stream for the created + * <code>ObjectOutputStream</code>. Plugs the created pipe as output stream + * for the created <code>MarkableOutputStream</code>. Plugs the created + * markable input stream as input stream for the created + * <code>ObjectInputStream</code>. Plugs the created pipe as input stream + * for the created <code>MarkableInputStream</code>. Creates an instance + * of the service <code>com.sun.star.cmp.PersistObject</code> and writes + * the created object to the object output stream. + * Object relations created : + * <ul> + * <li> <code>'PersistObject'</code> for + * {@link ifc.io._XObjectInputStream}(the created instance of the + * persist object ) </li> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XInputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'StreamWriter'</code> for + * {@link ifc.io._XDataInputStream} + * {@link ifc.io._XObjectInputStream} + * {@link ifc.io._XInputStream}(a stream to write data to) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSink}(an input stream to set and get) </li> + * </ul> + * @see com.sun.star.io.ObjectInputStream + * @see com.sun.star.io.ObjectOutputStream + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + * @see com.sun.star.cmp.PersistObject + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + System.out.println("create TestEnvironment started."); + XMultiServiceFactory xMSF = Param.getMSF(); + Object ostream = null; + Object aPipe = null; + Object mostream = null; + Object mistream = null; + Object istream = null; + Object xConnect = null; + istream = xMSF.createInstance + ("com.sun.star.io.ObjectInputStream"); + ostream = xMSF.createInstance + ("com.sun.star.io.ObjectOutputStream"); + aPipe = xMSF.createInstance + ("com.sun.star.io.Pipe"); + mistream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + xConnect = xMSF.createInstance + ("com.sun.star.io.DataInputStream") ; + // Creating construction : + // ObjectOutputStream -> MarkableOutputStream -> Pipe -> + // -> MarkableInputStream -> ObjectInputStream + XActiveDataSource xdSo = UnoRuntime.queryInterface(XActiveDataSource.class, ostream); + + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream moStream = UnoRuntime.queryInterface(XOutputStream.class, mostream); + + XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class, aPipe); + XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class, aPipe); + + xdSo.setOutputStream(moStream); + xdSmo.setOutputStream(PipeOut); + + XObjectInputStream iStream = UnoRuntime.queryInterface(XObjectInputStream.class, istream); + XObjectOutputStream oStream = null; + oStream = UnoRuntime.queryInterface(XObjectOutputStream.class, ostream); + + XActiveDataSink xmSi = UnoRuntime.queryInterface(XActiveDataSink.class, mistream); + XInputStream xmIstream = UnoRuntime.queryInterface(XInputStream.class, mistream); + + XActiveDataSink xdSi = UnoRuntime.queryInterface + (XActiveDataSink.class, istream); + xdSi.setInputStream(xmIstream); + xmSi.setInputStream(PipeIn); + + // creating Persist object which has to be written + XPersistObject xPersObj = null; + try { + Object oPersObj = xMSF.createInstance + ("com.sun.star.cmp.PersistObject"); + xPersObj = UnoRuntime.queryInterface(XPersistObject.class, oPersObj); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Can't write persist object.", e); + } + + + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + + System.out.println("create environment"); + XInterface oObj = iStream; + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding persistent object + tEnv.addObjRelation("PersistObject", xPersObj); + // add a connectable + tEnv.addObjRelation("Connectable", xConnect); + tEnv.addObjRelation("StreamWriter", oStream); + // for XActiveDataSink + tEnv.addObjRelation("InputStream", aPipe); + // adding sequence of data that must be read + // by XDataInputStream interface methods + tEnv.addObjRelation("StreamData", data) ; + // and by XInputStream interface methods + tEnv.addObjRelation("ByteData", byteData) ; + + System.out.println("create TestEnvironment finished."); + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/ObjectOutputStream.java b/qadevOOo/tests/java/mod/_streams/uno/ObjectOutputStream.java new file mode 100644 index 000000000..98ffcbcb3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/ObjectOutputStream.java @@ -0,0 +1,271 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XObjectInputStream; +import com.sun.star.io.XObjectOutputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.io.XPersistObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.registry.XImplementationRegistration; +import com.sun.star.registry.XSimpleRegistry; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; +import java.util.ArrayList; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.ObjectOutputStream</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* <li> <code>com::sun::star::io::XConnectable</code></li> +* <li> <code>com::sun::star::io::XDataOutputStream</code></li> +* <li> <code>com::sun::star::io::XObjectOutputStream</code></li> +* </ul> +* The following files used by this test : +* <ul> +* <li><b> MyPersistObjectImpl.jar </b> : the implementation of the persist +* object</li> +* </ul> <p> +* @see com.sun.star.io.ObjectOutputStream +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XOutputStream +* @see com.sun.star.io.XConnectable +* @see com.sun.star.io.XDataOutputStream +* @see com.sun.star.io.XObjectOutputStream +* @see ifc.io._XActiveDataSource +* @see ifc.io._XOutputStream +* @see ifc.io._XConnectable +* @see ifc.io._XDataOutputStream +* @see ifc.io._XObjectOutputStream +*/ +public class ObjectOutputStream extends TestCase { + + /** + * Register the implementation of service + * <code>com.sun.star.cmp.PersistObject</code> if not yet registered. + * @see com.sun.star.cmp.PersistObject + */ + @Override + public void initialize(TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + Object oPersObj = null; + // test first if object is already registered + try { + oPersObj = xMSF.createInstance("com.sun.star.cmp.PersistObject"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Could not create instance of PersistObject"); + e.printStackTrace(log); + log.println("Going on with test..."); + } + if ( oPersObj == null ) { + // object is not available: it has to be registered + String url = util.utils.getFullTestURL + ("qadevlibs/MyPersistObjectImpl.jar"); + XImplementationRegistration xir; + Object o = xMSF.createInstance( + "com.sun.star.registry.ImplementationRegistration"); + xir = UnoRuntime.queryInterface( + XImplementationRegistration.class, o); + + XSimpleRegistry xReg = null; + System.out.println("Register library: " + url); + xir.registerImplementation( + "com.sun.star.loader.Java2", url, xReg); + System.out.println("...done"); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of services + * <code>com.sun.star.io.ObjectOutputStream</code>, + * <code>com.sun.star.io.Pipe</code> and + * <code>com.sun.star.io.MarkableOutputStream</code>. Plugs the created + * markable output stream as output stream for the created + * <code>ObjectOutputStream</code>. Plugs the created pipe as output stream + * for the created <code>MarkableOutputStream</code>. Creates an instance + * of the service <code>com.sun.star.cmp.PersistObject</code>. + * Object relations created : + * <ul> + * <li> <code>'StreamData'</code> for + * {@link ifc.io._XDataOutputStream}(the data that should + * be written into the stream) </li> + * <li> <code>'ByteData'</code> for + * {@link ifc.io._XOutputStream}(the data that should be written into + * the stream) </li> + * <li> <code>'Connectable'</code> for + * {@link ifc.io._XConnectable} + * (another object that can be connected) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource} + * (an input stream to set and get) </li> + * <li> <code>'PersistObject'</code> for + * {@link ifc.io._XObjectOutputStream}(the created instance of the + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XObjectInputStream}(the created instance of the + * persist object ) </li> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.ObjectInputStream + * @see com.sun.star.io.ObjectOutputStream + * @see com.sun.star.io.Pipe + * @see com.sun.star.io.MarkableInputStream + * @see com.sun.star.io.MarkableOutputStream + * @see com.sun.star.cmp.PersistObject + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + + XObjectOutputStream oStream = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + Object ostream = null, istream = null; + Object aPipe = null; + Object mostream = null; + XInterface aConnect = null; + Object minstream = null; + + ostream = xMSF.createInstance + ( "com.sun.star.io.ObjectOutputStream" ); + istream = xMSF.createInstance + ("com.sun.star.io.ObjectInputStream"); + aPipe = xMSF.createInstance("com.sun.star.io.Pipe"); + mostream = xMSF.createInstance + ("com.sun.star.io.MarkableOutputStream"); + aConnect = (XInterface)xMSF.createInstance + ("com.sun.star.io.DataInputStream"); + minstream = xMSF.createInstance + ("com.sun.star.io.MarkableInputStream"); + + // creating the pipe where object has to be written to + XActiveDataSource xdSo = UnoRuntime.queryInterface(XActiveDataSource.class, ostream); + + XActiveDataSource xdSmo = UnoRuntime.queryInterface(XActiveDataSource.class, mostream); + + XOutputStream moStream = UnoRuntime.queryInterface(XOutputStream.class, mostream); + + XActiveDataSink markIn = UnoRuntime.queryInterface(XActiveDataSink.class, minstream); + XActiveDataSink inStream = UnoRuntime.queryInterface(XActiveDataSink.class, istream); + XInputStream markInStream = UnoRuntime.queryInterface(XInputStream.class, minstream); + + final XOutputStream PipeOut = UnoRuntime.queryInterface(XOutputStream.class,aPipe); + final XInputStream PipeIn = UnoRuntime.queryInterface(XInputStream.class,aPipe); + + markIn.setInputStream(PipeIn); + inStream.setInputStream(markInStream); + XObjectInputStream objInputStream = UnoRuntime.queryInterface(XObjectInputStream.class, istream); + xdSo.setOutputStream(moStream); + xdSmo.setOutputStream(PipeOut); + + oStream = UnoRuntime.queryInterface(XObjectOutputStream.class, ostream); + + // creating Persistent object which has to be written + XPersistObject xPersObj = null ; + Object oPersObj = xMSF.createInstance + ("com.sun.star.cmp.PersistObject"); + xPersObj = UnoRuntime.queryInterface(XPersistObject.class, oPersObj); + + oObj = oStream; + + // all data types for writing to an XDataInputStream + ArrayList<Object> data = new ArrayList<Object>() ; + data.add(Boolean.TRUE) ; + data.add(Byte.valueOf((byte)123)) ; + data.add(new Character((char)1234)) ; + data.add(Short.valueOf((short)1234)) ; + data.add(Integer.valueOf(123456)) ; + data.add(new Float(1.234)) ; + data.add(new Double(1.23456)) ; + data.add("DataInputStream") ; + // information for writing to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("PersistObject", xPersObj); + tEnv.addObjRelation("StreamData", data); + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("OutputStream", aPipe); + tEnv.addObjRelation("Connectable", aConnect); + + tEnv.addObjRelation("InputStream", objInputStream); + + //add relation for io.XOutputStream + final XMultiServiceFactory msf = xMSF; + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + XInputStream xInStream = null; + public void resetStreams() { + if (xInStream != null) { + try { + xInStream.closeInput(); + xInStream = null; + } catch(com.sun.star.io.IOException e) { + } + } else { + try { + PipeOut.closeOutput(); + } catch(com.sun.star.io.IOException e) { + } + } + } + + public XInputStream getInStream() { + resetStreams(); + try { + Object oInStream = msf.createInstance( + "com.sun.star.io.ObjectInputStream"); + xInStream = UnoRuntime.queryInterface + (XInputStream.class, oInStream); + } catch(com.sun.star.uno.Exception e) { + return null; + } + + XActiveDataSink xDataSink = UnoRuntime.queryInterface( + XActiveDataSink.class, xInStream); + xDataSink.setInputStream(PipeIn); + + return xInStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/Pipe.java b/qadevOOo/tests/java/mod/_streams/uno/Pipe.java new file mode 100644 index 000000000..96c4891a1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/Pipe.java @@ -0,0 +1,98 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.XInputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.Pipe</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XInputStream</code></li> +* <li> <code>com::sun::star::io::XOutputStream</code></li> +* </ul> +* @see com.sun.star.io.Pipe +* @see com.sun.star.io.XInputStream +* @see com.sun.star.io.XOutputStream +* @see ifc.io._XInputStream +* @see ifc.io._XOutputStream +*/ +public class Pipe extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service <code>com.sun.star.io.Pipe</code>. + * Writes some information to the created pipe. + * Object relations created : + * <ul> + * <li> <code>'XOutputStream.StreamChecker'</code> for + * {@link ifc.io._XOutputStream}( implementation of the interface + * ifc.io._XOutputStream.StreamChecker ) </li> + * </ul> + * @see com.sun.star.io.Pipe + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" ); + + oObj = (XInterface) oInterface; + + // writing some information to the pipe + byte[] byteData = new byte[] { + 1, 2, 3, 4, 5, 6, 7, 8 } ; + + log.println( "creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //add relation for io.XOutputStream + final XInputStream iStream = UnoRuntime.queryInterface(XInputStream.class, oObj); + + tEnv.addObjRelation("ByteData", byteData); + tEnv.addObjRelation("StreamWriter", oObj); + + tEnv.addObjRelation("XOutputStream.StreamChecker", + new ifc.io._XOutputStream.StreamChecker() { + public void resetStreams() { + } + + public XInputStream getInStream() { + return iStream; + } + }); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/Pump.java b/qadevOOo/tests/java/mod/_streams/uno/Pump.java new file mode 100644 index 000000000..85669fbcc --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/Pump.java @@ -0,0 +1,172 @@ +/* + * 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._streams.uno; + +import com.sun.star.io.NotConnectedException; +import com.sun.star.io.XActiveDataSink; +import com.sun.star.io.XActiveDataSource; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Test for object which is represented by service +* <code>com.sun.star.io.Pump</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::io::XActiveDataSource</code></li> +* <li> <code>com::sun::star::io::XActiveDataControl</code></li> +* <li> <code>com::sun::star::io::XActiveDataSink</code></li> +* </ul> +* @see com.sun.star.io.Pump +* @see com.sun.star.io.XActiveDataSource +* @see com.sun.star.io.XActiveDataControl +* @see com.sun.star.io.XActiveDataSink +* @see ifc.io._XActiveDataSource +* @see ifc.io._XActiveDataControl +* @see ifc.io._XActiveDataSink +*/ +public class Pump extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service <code>com.sun.star.io.Pump</code>. + * Settings up input and output streams for the created pump. + * Object relations created : + * <ul> + * <li> <code>'InputStream'</code> for + * {@link ifc.io._XActiveDataSource}(an input stream to set) </li> + * <li> <code>'OutputStream'</code> for + * {@link ifc.io._XActiveDataSource}(an output stream to set) </li> + * </ul> + * @see com.sun.star.io.Pump + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + Object oInterface = null; + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oPipe; + + // creating an instance of stm.Pump + oInterface = xMSF.createInstance( "com.sun.star.io.Pump" ); + oPipe = (XInterface) xMSF.createInstance( "com.sun.star.io.Pipe" ); + + XInterface oObj = (XInterface) oInterface; + + // setting up input and output streams for pump + XActiveDataSink xSink = UnoRuntime.queryInterface(XActiveDataSink.class, oObj); + XActiveDataSource xSource = UnoRuntime.queryInterface(XActiveDataSource.class, oObj); + + XInputStream xInput = new MyInput(); + XOutputStream xOutput = new MyOutput(); + + xSink.setInputStream(xInput); + xSource.setOutputStream(xOutput); + + log.println("creating a new environment for object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // add object relations for ActiveDataSource and XActiveDataSink + tEnv.addObjRelation("InputStream", oPipe); + tEnv.addObjRelation("OutputStream", oPipe); + + return tEnv; + } // finish method getTestEnvironment + + /** + * XInputStream implementation to use with the test. It returns bytes of + * which a simple string consists. + */ + private static class MyInput implements XInputStream { + String str = "Pump tesing string" ; + + public int readBytes(byte[][] bytes, int len) + throws NotConnectedException{ + + if (str == null) + throw new NotConnectedException("Input stream was closed"); + + int actual = 0 ; + if (len <= str.length()) { + String resStr = str.substring(0, len-1) ; + bytes[0] = resStr.getBytes() ; + actual = len ; + str = str.substring(len) ; + } else { + bytes[0] = str.getBytes() ; + actual = str.length() ; + } + + return actual; + } + + public int readSomeBytes(byte[][] bytes, int len) + throws NotConnectedException{ + return readBytes(bytes, len); + } + + public void skipBytes(int len) throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + if (len >= str.length()) + str = "" ; + else + str = str.substring(len) ; + } + + public void closeInput() throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + str = null ; + } + + public int available() throws NotConnectedException { + if (str == null) + throw new NotConnectedException("Stream was closed.") ; + + return str.length(); + } + } + + /** + * Dummy XOutputStream implementation to use with the test. Does nothing. + */ + private static class MyOutput implements XOutputStream { + public void writeBytes(byte[] bytes) { + } + + public void flush() { + } + + public void closeOutput() { + } + } +} + diff --git a/qadevOOo/tests/java/mod/_streams/uno/package.html b/qadevOOo/tests/java/mod/_streams/uno/package.html new file mode 100644 index 000000000..aa2793cf2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_streams/uno/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 'stm'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBox.java b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBox.java new file mode 100644 index 000000000..2bba0293e --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBox.java @@ -0,0 +1,172 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.view.XSelectionSupplier; + +public class AccessibleBrowseBox extends TestCase { + + static XDesktop xDesktop; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * 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 tParam test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + log.println("creating a test environment"); + + if (xTextDoc != null) { + xTextDoc.dispose(); // get a soffice factory object + } + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + + XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class, + secondController); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = null; + + final XSelectionSupplier xSelect = UnoRuntime.queryInterface( + XSelectionSupplier.class, the_frame2.getController()); + + PropertyValue[] params = new PropertyValue[]{new PropertyValue(), new PropertyValue(), new PropertyValue()}; + params[0].Name = "DataSourceName"; + params[0].Value = "Bibliography"; + params[1].Name = "CommandType"; + params[1].Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[2].Name = "Command"; + params[2].Value = "biblio"; + + final PropertyValue[] fParams = params; + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "", "AccessibleBrowseBox"); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + + public void fireEvent() { + try { + xSelect.select(fParams); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(); + } + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderBar.java b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderBar.java new file mode 100644 index 000000000..a19e61076 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderBar.java @@ -0,0 +1,222 @@ +/* + * 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._svtools; + +import com.sun.star.view.XSelectionSupplier; + +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.awt.Point; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleBrowseBoxHeaderBar extends TestCase { + static XDesktop xDesktop; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the DataSource browser. + * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code> + * and gets active top window. Then obtains an accessible object with + * the role <code>AccessibleRole.TABLE</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + + // an XSelectionSupplier at the controller -> call with params + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + PropertyValue[] params = new PropertyValue[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XController xCont = the_frame2.getController(); + + XSelectionSupplier xSelect = UnoRuntime.queryInterface( + XSelectionSupplier.class, xCont); + + xSelect.select(params); + + XInterface oObj = null; + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XAccessibleComponent accComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + final Point point = accComp.getLocationOnScreen(); + + util.utils.waitForEventIdle(tParam.getMSF()); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Robot rob = new Robot(); + rob.mouseMove(point.X + 5, point.Y + 5); + rob.mousePress(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + System.out.println("couldn't fire event"); + } + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderCell.java b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderCell.java new file mode 100644 index 000000000..e050458ec --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxHeaderCell.java @@ -0,0 +1,207 @@ +/* + * 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._svtools; + +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.XInitialization; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleBrowseBoxHeaderCell extends TestCase { + + static XDesktop the_Desk; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + the_Desk = UnoRuntime.queryInterface( + XDesktop.class, DesktopTools.createDesktop(Param.getMSF())); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the DataSource browser and loads + * the table. Creates an instance of the service + * <code>com.sun.star.awt.Toolkit</code> and gets active top window. + * Then obtains an accessible object with the role + * <code>AccessibleRole.UNKNOWN</code> and with the name + * <code>"Identifier"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * method <code>fireEvent()</code> is empty because object is transient + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + if (xTextDoc != null) xTextDoc.dispose(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime. + queryInterface(XDispatchProvider.class, secondController); + + XDispatch getting = null; + + log.println( "opening DatasourceBrowser" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = the_Desk.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = null; + + UnoRuntime.queryInterface( + XInitialization.class, the_frame2.getController()); + + PropertyValue[] params = new PropertyValue[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + XController xCont = the_frame2.getController(); + + XSelectionSupplier xSelect = UnoRuntime.queryInterface( + XSelectionSupplier.class, xCont); + + xSelect.select(params); + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.ROW_HEADER); + + log.println("ImplementationName: "+ util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + } + }); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTable.java b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTable.java new file mode 100644 index 000000000..49f42f4c6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTable.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._svtools; + +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleBrowseBoxTable extends TestCase { + static XDesktop the_Desk; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + the_Desk = UnoRuntime.queryInterface(XDesktop.class, + DesktopTools.createDesktop( + Param.getMSF())); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the DataSource browser. + * Creates an instance of the service + * <code>com.sun.star.awt.Toolkit</code> and gets active top window. + * Then obtains an accessible object with the role + * <code>AccessibleRole.TABLE</code> and with the name + * <code>"Table"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * method <code>fireEvent()</code> is empty because object is transient + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = the_Desk.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + XController xCont = the_frame2.getController(); + + the_frame2.setName("DatasourceBrowser"); + + final PropertyValue[] params = new PropertyValue[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + final XSelectionSupplier xSelect = UnoRuntime.queryInterface( + XSelectionSupplier.class, xCont); + + + XInterface oObj = null; + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE, + "Table"); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + xSelect.select(params); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + } + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTableCell.java b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTableCell.java new file mode 100644 index 000000000..0adc36e3b --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleBrowseBoxTableCell.java @@ -0,0 +1,174 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleBrowseBoxTableCell extends TestCase { + + static XDesktop xDesktop; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the DataSource browser and loads + * the table. Creates an instance of the service + * <code>com.sun.star.awt.Toolkit</code> and gets active top window. + * Then obtains an accessible object with the role + * <code>AccessibleRole.TABLE_CELL</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * method <code>fireEvent()</code> is empty because object is transient + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + if (xTextDoc != null) xTextDoc.dispose(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + + XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class,secondController); + + XDispatch getting = null; + + log.println( "opening DatasourceBrowser" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url,"_beamer",12); + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url,noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer",4); + + the_frame2.setName("DatasourceBrowser"); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XInterface oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL); + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + } + }); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrl.java b/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrl.java new file mode 100644 index 000000000..05907d287 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrl.java @@ -0,0 +1,244 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.XModel; +import com.sun.star.text.XTextDocument; +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 that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleSelection</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + */ +public class AccessibleIconChoiceCtrl extends TestCase { + static XDesktop xDesktop; + static XTextDocument xTextDoc; + static XAccessibleAction accCloseButton = null; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Closes the Hyperlink dialog. + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("closing HyperlinkDialog"); + + try { + if (accCloseButton != null) { + accCloseButton.doAccessibleAction(0); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the Hyperlink dialog. + * Creates an instance of the service + * <code>com.sun.star.awt.Toolkit</code> and gets active top window. + * Then obtains an accessible object with the role + * <code>AccessibleRole.TREE</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * method <code>fireEvent()</code> selects accessible children + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) tParam.getMSF() + .createInstance("com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF() + .createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TREE); + + XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Close"); + + accCloseButton = UnoRuntime.queryInterface( + XAccessibleAction.class, closeButton); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected", + Boolean.TRUE); + + String[] expectedStateNames = new String[] { + "com.sun.star.accessibility.AccessibleStateType.ENABLED", + "com.sun.star.accessibility.AccessibleStateType.FOCUSABLE", + "com.sun.star.accessibility.AccessibleStateType.SHOWING", + "com.sun.star.accessibility.AccessibleStateType.VISIBLE", + "com.sun.star.accessibility.AccessibleStateType.MANAGES_DESCENDANTS", + }; + + short[] expectedStates = new short[] { + com.sun.star.accessibility.AccessibleStateType.ENABLED, + com.sun.star.accessibility.AccessibleStateType.FOCUSABLE, + com.sun.star.accessibility.AccessibleStateType.SHOWING, + com.sun.star.accessibility.AccessibleStateType.VISIBLE, + com.sun.star.accessibility.AccessibleStateType.MANAGES_DESCENDANTS, + }; + + tEnv.addObjRelation("expectedStateNames", expectedStateNames); + tEnv.addObjRelation("expectedStates", expectedStates); + + final XAccessibleSelection selection = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + selection.selectAccessibleChild(1); + selection.selectAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + }); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrlEntry.java b/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrlEntry.java new file mode 100644 index 000000000..847ae380b --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleIconChoiceCtrlEntry.java @@ -0,0 +1,217 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.XModel; +import com.sun.star.text.XTextDocument; +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 that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleIconChoiceCtrlEntry extends TestCase { + + static XDesktop xDesktop; + static XTextDocument xTextDoc; + static XAccessibleAction accCloseButton = null; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Closes the Hyperlink dialog. + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("closing HyperlinkDialog"); + + try { + if (accCloseButton != null) { + accCloseButton.doAccessibleAction(0); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the Hyperlink dialog. + * Creates an instance of the service + * <code>com.sun.star.awt.Toolkit</code> and gets active top window. + * Then obtains an accessible object with the role + * <code>AccessibleRole.LABEL</code> and with the name + * <code>"Internet"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * method <code>fireEvent()</code> is empty because object is transient + * </li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: + * the string representation of the item text + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + if (xTextDoc != null) xTextDoc.dispose(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime. + queryInterface(XDispatchProvider.class, secondController); + + XInterface transf = (XInterface)tParam.getMSF().createInstance + ("com.sun.star.util.URLTransformer"); + XURLTransformer urlTransf = UnoRuntime.queryInterface + (XURLTransformer.class, transf); + + XDispatch getting = null; + log.println( "opening HyperlinkDialog" ); + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.LABEL, "Internet"); + + XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, "Close"); + + accCloseButton = UnoRuntime.queryInterface(XAccessibleAction.class, closeButton); + + log.println("ImplementationName: "+ util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + } + }); + + tEnv.addObjRelation("XAccessibleText.Text", "Internet"); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this dialog"); + + tEnv.addObjRelation("LimitedBounds", + "only delivers senseful values for getCharacterBounds(0,length-1)"); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleTabBar.java b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBar.java new file mode 100644 index 000000000..8e694058b --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBar.java @@ -0,0 +1,132 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +public class AccessibleTabBar extends TestCase { + static XComponent xDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xCalcDoc"); + + if (xDoc != null) { + closeDoc(xDoc); + } + } + + /** + * Creates a spreadsheet document. Then obtains an accessible object with + * the role <code>AccessibleRole.PAGETAB</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xDoc != null) { + closeDoc(xDoc); + } + + XMultiServiceFactory msf = tParam.getMSF(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + + log.println("creating a calc document"); + xDoc = UnoRuntime.queryInterface(XComponent.class, + SOF.createCalcDoc( + null)); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = null; + + XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XWindow aWin = xWindow; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + aWin.setPosSize(100,100, 500, 500, PosSize.POSSIZE); + } + }); + + return tEnv; + } + + protected void closeDoc(XComponent xDoc) { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDoc); + + try { + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document " + e.getMessage()); + } catch (NullPointerException e) { + log.println("Couldn't close document " + e.getMessage()); + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPage.java b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPage.java new file mode 100644 index 000000000..e8b4c56e7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPage.java @@ -0,0 +1,156 @@ +/* + * 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._svtools; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.Point; + +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessibleComponent + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleTabBarPage extends TestCase { + + static XComponent xDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("disposing xCalcDoc"); + if (xDoc != null) { + util.DesktopTools.closeDoc(xDoc); + } + } + + /** + * Creates a spreadsheet document. Then obtains an accessible object with + * the role <code>AccessibleRole.PAGETAB</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + if (xDoc != null) xDoc.dispose(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a calc document" ); + xDoc = UnoRuntime.queryInterface(XComponent.class, SOF.createCalcDoc(null));// SOF.createDrawDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, oObj); + + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB, "Sheet1"); + XAccessibleContext acc = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB, "Sheet2"); + XAccessibleComponent accComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + acc); + final Point point = accComp.getLocationOnScreen(); + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("Destroy","yes"); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + Robot rob = new Robot(); + rob.mouseMove(point.X + 25, point.Y + 5); + rob.mousePress(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + System.out.println("couldn't fire event"); + } + } + }); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPageList.java b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPageList.java new file mode 100644 index 000000000..64ca390ff --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleTabBarPageList.java @@ -0,0 +1,172 @@ +/* + * 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._svtools; + +import com.sun.star.drawing.XLayerManager; +import com.sun.star.drawing.XLayerSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessibleComponent + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleTabBarPageList extends TestCase { + static XComponent xDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xDoc"); + + if (xDoc != null) { + closeDoc(); + } + } + + /** + * Creates a spreadsheet document. Then obtains an accessible object with + * the role <code>AccessibleRole.PAGETABLIST</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a draw document"); + xDoc = SOF.createDrawDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF() + .createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PAGE_TAB_LIST); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected", + Boolean.TRUE); + + XLayerSupplier oLS = UnoRuntime.queryInterface(XLayerSupplier.class, xDoc); + XInterface oLM = oLS.getLayerManager(); + final XLayerManager xLM = UnoRuntime.queryInterface(XLayerManager.class, oLM); + + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + xLM.insertNewByIndex(0); + } + }); + + return tEnv; + } + + protected void closeDoc() { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xDoc); + + try { + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document " + e.getMessage()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Couldn't close document " + e.getMessage()); + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBox.java b/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBox.java new file mode 100644 index 000000000..42371dd4e --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBox.java @@ -0,0 +1,211 @@ +/* + * 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._svtools; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.XInitialization; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessibleComponent + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + */ +public class AccessibleTreeListBox extends TestCase { + + static XDesktop xDesktop; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + xTextDoc.dispose(); + } + } + + /** + * Creates a text document. Opens the DataSource browser. + * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code> + * and gets active top window. Then obtains an accessible object with + * the role <code>AccessibleRole.TREE</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * <li> <code>'XAccessibleSelection.multiSelection'</code> + * of type <code>Boolean</code> for + * {@link ifc.accessibility._XAccessibleSelection}: + * indicates that component supports single selection mode.</li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + log.println( "creating a test environment" ); + + if (xTextDoc != null) xTextDoc.dispose(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime. + queryInterface(XDispatchProvider.class, secondController); + + XDispatch getting = null; + + log.println( "opening DatasourceBrowser" ); + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = null; + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TREE); + + log.println("ImplementationName: "+ util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XInitialization xInit = UnoRuntime.queryInterface( + XInitialization.class, the_frame2.getController()); + + Object[] params = new Object[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE); + params[1] = param2; + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "biblio"; + params[2] = param3; + + final Object[] fParams = params; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + xInit.initialize(fParams); + } catch(com.sun.star.uno.Exception e) { + e.printStackTrace(); + } + } + }); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBoxEntry.java b/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBoxEntry.java new file mode 100644 index 000000000..73f776448 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svtools/AccessibleTreeListBoxEntry.java @@ -0,0 +1,262 @@ +/* + * 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._svtools; + +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +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.XInitialization; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XCloseable; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code>::com::sun::star::accessibility::XAccessibleComponent + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleContext + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleAction + * </code></li> + * <li><code>::com::sun::star::accessibility::XAccessibleText + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleTreeListBoxEntry extends TestCase { + static XDesktop xDesktop; + static XTextDocument xTextDoc; + + /** + * Creates the Desktop service (<code>com.sun.star.frame.Desktop</code>). + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + xDesktop = DesktopTools.createDesktop(Param.getMSF()); + } + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document. Opens the DataSource browser. + * Creates an instance of the service <code>com.sun.star.awt.Toolkit</code> + * and gets active top window. Then obtains an accessible object with + * the role <code>AccessibleRole.LABEL</code> and with the name + * <code>"Bibliography"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * </li> + * <li> <code>'XAccessibleSelection.multiSelection'</code> + * of type <code>Boolean</code> for + * {@link ifc.accessibility._XAccessibleSelection}: + * indicates that component supports single selection mode.</li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: + * the text of the component</li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleText + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XDispatch getting = null; + + log.println("opening DatasourceBrowser"); + + URL the_url = new URL(); + the_url.Complete = ".component:DB/DataSourceBrowser"; + getting = aProv.queryDispatch(the_url, "_beamer", 12); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(the_url, noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XFrame the_frame1 = xDesktop.getCurrentFrame(); + + if (the_frame1 == null) { + log.println("Current frame was not found !!!"); + } + + XFrame the_frame2 = the_frame1.findFrame("_beamer", 4); + + the_frame2.setName("DatasourceBrowser"); + + XInterface oObj = null; + + UnoRuntime.queryInterface( + XInitialization.class, + the_frame2.getController()); + + PropertyValue[] params = new PropertyValue[3]; + PropertyValue param1 = new PropertyValue(); + param1.Name = "DataSourceName"; + param1.Value = "Bibliography"; + params[0] = param1; + + PropertyValue param2 = new PropertyValue(); + param2.Name = "CommandType"; + param2.Value = Integer.valueOf(com.sun.star.sdb.CommandType.QUERY); + params[1] = param2; + + PropertyValue param3 = new PropertyValue(); + param3.Name = "Command"; + param3.Value = "select * from biblio"; + params[2] = param3; + + XController xCont = the_frame2.getController(); + + XSelectionSupplier xSelect = UnoRuntime.queryInterface( + XSelectionSupplier.class, xCont); + + xSelect.select(params); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = secondController.getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.LABEL, + "Bibliography"); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + //adding ObjectRelation for XAccessibleText + tEnv.addObjRelation("LimitedBounds", "true"); + + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + } + }); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + tEnv.addObjRelation("XAccessibleText.Text", "Bibliography"); + + return tEnv; + } + + protected void closeDoc() { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + + try { + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("Couldn't close document " + e.getMessage()); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Couldn't close document " + e.getMessage()); + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_svx/AccessibleControlShape.java b/qadevOOo/tests/java/mod/_svx/AccessibleControlShape.java new file mode 100644 index 000000000..8f55793f0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessibleControlShape.java @@ -0,0 +1,108 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.FormTools; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleControlShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createDrawDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) + throws com.sun.star.uno.Exception + { + + XInterface oObj = null; + + log.println( "creating a test environment" ); + + final XShape oShape = FormTools.insertControlShape + (xDrawDoc,3000,4500,15000,1000,"CommandButton"); + + util.utils.waitForEventIdle(tParam.getMSF()); + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SHAPE); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "Button"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = oShape.getSize(); + size.Width += 100; + oShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessibleEditableTextPara.java b/qadevOOo/tests/java/mod/_svx/AccessibleEditableTextPara.java new file mode 100644 index 000000000..f54b1dd49 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessibleEditableTextPara.java @@ -0,0 +1,134 @@ +/* + * 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._svx; + +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.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +public class AccessibleEditableTextPara extends TestCase { + + static XComponent xSpreadsheetDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Obtains accessible object for the spreadsheet document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xSpreadsheetDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + XAccessibleContext InputLine = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME,"Input line"); + try { + oObj = InputLine.getAccessibleChild(0); + XAccessibleEditableText et = UnoRuntime.queryInterface(XAccessibleEditableText.class, oObj); + et.setText("AccessibleEditablePara"); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + + } + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleEditableText edText = UnoRuntime.queryInterface(XAccessibleEditableText.class,oObj) ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + int l = "AccessibleEditablePara".length(); + edText.deleteText(0, l); + edText.setText("Event"); + edText.setText("AccessibleEditablePara"); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("caught exception: " + e); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xSheetDoc " ); + util.DesktopTools.closeDoc(xSpreadsheetDoc); + } + + /** + * Called while the <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 spreadsheetdocument"); + xSpreadsheetDoc = UnoRuntime.queryInterface(XComponent.class,SOF.createCalcDoc(null)); + util.utils.waitForEventIdle(Param.getMSF()); + } + +} diff --git a/qadevOOo/tests/java/mod/_svx/AccessibleGraphicShape.java b/qadevOOo/tests/java/mod/_svx/AccessibleGraphicShape.java new file mode 100644 index 000000000..73031398a --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessibleGraphicShape.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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleGraphicShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createDrawDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + 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( tParam.getMSF()); + final XShape oShape = SOF.createShape(xDrawDoc, + 5000,5000,1500,1000,"GraphicObject"); + + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "GraphicObject"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = oShape.getSize(); + size.Width += 100; + oShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessibleOLEShape.java b/qadevOOo/tests/java/mod/_svx/AccessibleOLEShape.java new file mode 100644 index 000000000..8529515a2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessibleOLEShape.java @@ -0,0 +1,118 @@ +/* + * 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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleOLEShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createDrawDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, 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( tParam.getMSF()); + final XShape oShape = SOF.createShape + (xDrawDoc,5000,5000,1500,1000,"OLE2"); + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XPropertySet shape_props = UnoRuntime.queryInterface(XPropertySet.class,oShape); + + log.println("Inserting a Chart"); + + shape_props. + setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e"); + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "OLEShape"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = oShape.getSize(); + size.Width += 100; + oShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessiblePageShape.java b/qadevOOo/tests/java/mod/_svx/AccessiblePageShape.java new file mode 100644 index 000000000..4e05ebb19 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessiblePageShape.java @@ -0,0 +1,114 @@ +/* + * 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._svx; + +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.beans.XPropertySet; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessiblePageShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createDrawDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + //XShape oShape = null; + XDrawPage oPage = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "PageShape"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + oPage = DrawTools.getDrawPage(xDrawDoc,0); + final XPropertySet PageProps = UnoRuntime.queryInterface(XPropertySet.class, oPage); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + PageProps.setPropertyValue("Height",Integer.valueOf(5000)); + } catch (com.sun.star.beans.UnknownPropertyException upe) { + System.out.println("Don't no the Property Height"); + } catch (com.sun.star.beans.PropertyVetoException pve) { + System.out.println( + "PropertyVetoException Exception while changing Height"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + System.out.println( + "IllegalArgumentException Exception while changing Height"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + System.out.println( + "WrappedTargetException Exception while changing Height"); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessiblePresentationGraphicShape.java b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationGraphicShape.java new file mode 100644 index 000000000..37a3b8a35 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationGraphicShape.java @@ -0,0 +1,122 @@ +/* + * 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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessiblePresentationGraphicShape extends TestCase { + + static XComponent xDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDoc = SOF.createImpressDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDoc); + oShape = UnoRuntime.queryInterface(XShape.class, + docMSF.createInstance + ("com.sun.star.presentation.GraphicObjectShape")); + + DrawTools.getShapes(DrawTools.getDrawPage(xDoc,0)).add(oShape); + + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + oShapeProps.setPropertyValue( + "GraphicURL",util.utils.getFullTestURL("space-metal.jpg")); + oShapeProps.setPropertyValue("IsEmptyPresentationObject", Boolean.FALSE); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "GraphicObject"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + final XShape fShape = oShape ; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = fShape.getSize(); + size.Width += 100; + fShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessiblePresentationOLEShape.java b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationOLEShape.java new file mode 100644 index 000000000..9329506da --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationOLEShape.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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessiblePresentationOLEShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createImpressDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc); + oShape = UnoRuntime.queryInterface(XShape.class, + docMSF.createInstance("com.sun.star.presentation.OLE2Shape")); + + + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + oShapeProps.setPropertyValue("IsEmptyPresentationObject", Boolean.FALSE); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + try { + oShapeProps.setPropertyValue( + "CLSID","12DCAE26-281F-416F-a234-c3086127382e"); + oShapeProps.setPropertyValue("IsEmptyPresentationObject", Boolean.FALSE); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "ImpressOLE"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + final XShape fShape = oShape ; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = fShape.getSize(); + size.Width += 100; + fShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessiblePresentationShape.java b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationShape.java new file mode 100644 index 000000000..8828d8acf --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessiblePresentationShape.java @@ -0,0 +1,122 @@ +/* + * 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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessiblePresentationShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createImpressDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc); + oShape = UnoRuntime.queryInterface(XShape.class, + docMSF.createInstance + ("com.sun.star.presentation.HandoutShape")); + + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XPropertySet shapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape); + + try { + shapeProps.setPropertyValue( + "IsEmptyPresentationObject", Boolean.FALSE); + } catch (Exception e) {} + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "ImpressHandout"); + + log.println("Implementation Name: "+utils.getImplName(oObj)); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + final XShape fShape = oShape ; + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = fShape.getSize(); + size.Width += 100; + fShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/AccessibleShape.java b/qadevOOo/tests/java/mod/_svx/AccessibleShape.java new file mode 100644 index 000000000..2e160bb78 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/AccessibleShape.java @@ -0,0 +1,110 @@ +/* + * 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._svx; + +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.Size; +import com.sun.star.awt.XWindow; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class AccessibleShape extends TestCase { + + static XComponent xDrawDoc; + static XModel aModel; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.createDrawDoc(null); + aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + 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( tParam.getMSF()); + final XShape oShape = SOF.createShape(xDrawDoc, + 3000,4500,15000,1000,"Rectangle"); + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XWindow xWindow = AccessibilityTools.getCurrentWindow (aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.UNKNOWN, "Rectangle"); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + Size size = oShape.getSize(); + size.Width += 100; + oShape.setSize(size); + } catch(com.sun.star.beans.PropertyVetoException e) { + System.out.println("caught exception: " + e); + } + } + }); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/GraphicExporter.java b/qadevOOo/tests/java/mod/_svx/GraphicExporter.java new file mode 100644 index 000000000..b47073de9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/GraphicExporter.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._svx; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.DrawTools; +import util.SOfficeFactory; +import util.XMLTools; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.drawing.GraphicExportFilter</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::document::XFilter</code></li> + * <li> <code>com::sun::star::document::XMimeTypeInfo</code></li> + * <li> <code>com::sun::star::document::XExporter</code></li> + * </ul> <p> + * + * The following files used by this test : + * <ul> + * <li><b> space-metal.jpg </b> : the file used for GraphicObject + * creation. This image must be then exported. </li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XMimeTypeInfo + * @see com.sun.star.document.XExporter + * @see ifc.document._XFilter + * @see ifc.document._XMimeTypeInfo + * @see ifc.document._XExporter + */ +public class GraphicExporter extends TestCase { + static XComponent xDrawDoc; + + /** + * Creates a new draw document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a drawdoc"); + xDrawDoc = DrawTools.createDrawDoc( + tParam.getMSF()); + } + + /** + * Disposes the draw document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.drawing.GraphicExportFilter</code> as + * a tested component. Then a <code>GraphicObjectShape</code> + * instance is added into the document and its image is obtained + * from JPEG file. This shape content is intended to be exported. + * + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} : + * descriptor which contains target file name in + * the temporary directory, file type (JPEG) + * </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} : + * checks if the target file exists. + * In the case if SOffice is started in 'Hide' mode + * ('soapi.test.hidewindows' test parameter is 'true') + * the checker always returns <code>true</code>. + * </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} : + * the <code>GraphicObjectShape</code> component + * with loaded image. + * </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XInterface oObj = null; + XShape oShape = null; + Object go = null; + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + try { + go = tParam.getMSF().createInstance( + "com.sun.star.drawing.GraphicExportFilter"); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // create testobject here + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc, 5000, 5000, 1500, 1000, + "GraphicObject"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc, 0)).add(oShape); + + XPropertySet oShapeProps = UnoRuntime.queryInterface( + XPropertySet.class, oShape); + XComponent xComp = null; + + oShapeProps.setPropertyValue("GraphicURL", + util.utils.getFullTestURL( + "space-metal.jpg")); + xComp = UnoRuntime.queryInterface(XComponent.class, + oShape); + + XExporter xEx = UnoRuntime.queryInterface( + XExporter.class, go); + xEx.setSourceDocument(xComp); + + final URL aURL = new URL(); + aURL.Complete = util.utils.getOfficeTemp( + tParam.getMSF()) + + "picture.jpg"; + + final XSimpleFileAccess fAcc; + + Object oFAcc = tParam.getMSF().createInstance( + "com.sun.star.ucb.SimpleFileAccess"); + fAcc = UnoRuntime.queryInterface( + XSimpleFileAccess.class, oFAcc); + + if (fAcc.exists(aURL.Complete)) { + fAcc.kill(aURL.Complete); + } + + oObj = (XInterface) go; + log.println("ImplName " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + tEnv.addObjRelation("MediaDescriptor", + XMLTools.createMediaDescriptor( + new String[] { + "FilterName", "URL", "MediaType" + }, new Object[] { "JPG", aURL, "image/jpeg" })); + tEnv.addObjRelation("SourceDocument", xComp); + + log.println("adding ObjRelation for XFilter"); + log.println("This Component doesn't really support the cancel method"); + log.println("See #101725"); + tEnv.addObjRelation("NoFilter.cancel()", Boolean.TRUE); + + final String hideMode = (String) tParam.get("soapi.test.hidewindows"); + tEnv.addObjRelation("XFilter.Checker", + new ifc.document._XFilter.FilterChecker() { + public boolean checkFilter() { + try { + if ((hideMode != null) && hideMode.equals("true")) { + return true; + } + + return fAcc.exists(aURL.Complete); + } catch (com.sun.star.uno.Exception e) { + return false; + } + } + }); + + return tEnv; + } // finish method getTestEnvironment +} // finish class GraphicExporter diff --git a/qadevOOo/tests/java/mod/_svx/SvxDrawPage.java b/qadevOOo/tests/java/mod/_svx/SvxDrawPage.java new file mode 100644 index 000000000..a0d07d0c9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxDrawPage.java @@ -0,0 +1,190 @@ +/* + * 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._svx; + +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.lang.XComponent; +import com.sun.star.sheet.XSpreadsheetDocument; +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 java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + + +/** + * 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> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @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 SvxDrawPage extends TestCase { + static XSpreadsheetDocument xDoc = null; + + /** + * Creates a new Draw document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a sheetdocument"); + xDoc = SOF.createCalcDoc(null); + } + + /** + * Disposes the Draw document created before + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xSheetDoc "); + util.DesktopTools.closeDoc(xDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * From the Draw document created a collection of its draw + * pages is obtained. Two new pages are inserted. And one + * page is obtained as a testing component. A shape is added + * to this page. <p> + * + * Object relations created : + * <ul> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeGrouper} : + * the draw page tested. </li> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes} : + * the creator which can create instances of + * <code>com.sun.star.drawing.Line</code> service </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XInterface oObj = null; + XShape oShape = null; + XDrawPages oDP = null; + + XComponent xComp = UnoRuntime.queryInterface( + XComponent.class, xDoc); + + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating a test environment"); + + log.println("getting Drawpages"); + + XDrawPagesSupplier oDPS = UnoRuntime.queryInterface( + XDrawPagesSupplier.class, xDoc); + oDP = oDPS.getDrawPages(); + oDP.insertNewByIndex(1); + oDP.insertNewByIndex(2); + oObj = (XDrawPage) AnyConverter.toObject(new Type(XDrawPage.class), + oDP.getByIndex(0)); + + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + oShape = SOF.createShape(xComp, 5000, 3500, 7500, 5000, + "Rectangle"); + DrawTools.getShapes((XDrawPage) oObj).add(oShape); + + XShape oShape1 = SOF.createShape(xComp, 5000, 5500, 5000, 5000, + "Rectangle"); + DrawTools.getShapes((XDrawPage) oObj).add(oShape1); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //adding a controlButton to have a Form + FormTools.insertControlShape( + UnoRuntime.queryInterface(XComponent.class, xDoc), + 3000, 4500, 15000, 1000, "CommandButton"); + + // relation for XShapes interface + ShapeDsc sDsc = new ShapeDsc(5000, 3500, 7500, 10000, "Line"); + tEnv.addObjRelation("Shape", new InstCreator(xDoc, sDsc)); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + + // adding relation for XShapeGrouper + tEnv.addObjRelation("DrawPage", oObj); + + // adding relation for XMasterPageTarget + + return tEnv; + } // finish method getTestEnvironment +} // finish class SvxDrawPage diff --git a/qadevOOo/tests/java/mod/_svx/SvxGraphCtrlAccessibleContext.java b/qadevOOo/tests/java/mod/_svx/SvxGraphCtrlAccessibleContext.java new file mode 100644 index 000000000..e2b3581d4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxGraphCtrlAccessibleContext.java @@ -0,0 +1,210 @@ +/* + * 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._svx; + +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.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XController; +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; +import com.sun.star.view.XSelectionSupplier; + +public class SvxGraphCtrlAccessibleContext extends TestCase{ + + static XComponent xDrawDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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; + + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XController xController = aModel.getCurrentController(); + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + final XShape oShape = SOF.createShape(xDrawDoc, + 5000,5000,1500,1000,"GraphicObject"); + + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XPropertySet shapeProps = UnoRuntime.queryInterface(XPropertySet.class, oShape); + + String url = util.utils.getFullTestURL("space-metal.jpg"); + + log.println("Inserting Graphic: "+url); + + try { + shapeProps.setPropertyValue("GraphicURL", url); + } catch (com.sun.star.beans.UnknownPropertyException upe) { + log.println("Property GraphicURL is unknown"); + } catch (com.sun.star.beans.PropertyVetoException pve) { + log.println("Property GraphicURL is read only"); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + log.println("Property GraphicURL tried to set to illegal argument"); + } catch (com.sun.star.lang.WrappedTargetException wte) { + log.println("Wrapped Target Exception was thrown while setting Property GraphicURL"); + } + + + //Opening ImageMapDialog + try { + String aSlotID = "slot:10371"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, xController ); + 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 ); + utils.shortWait(); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't change mode"); + } + + + oObj = (XInterface) Param.getMSF().createInstance + ("com.sun.star.awt.Toolkit") ; + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class,oObj); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class,tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + //selecting the inserted shape + final XSelectionSupplier SelSupp = UnoRuntime.queryInterface(XSelectionSupplier.class,xController); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + SelSupp.select(oShape); + } catch (com.sun.star.lang.IllegalArgumentException iae) { + System.out.println("Couldn't select shape"); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + + XController xController = aModel.getCurrentController(); + + //Closing ImageMapDialog + try { + String aSlotID = "slot:10371"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( XDispatchProvider.class, xController ); + 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( " disposing xDrawDoc " ); + 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/_svx/SvxGraphicObject.java b/qadevOOo/tests/java/mod/_svx/SvxGraphicObject.java new file mode 100644 index 000000000..d544d0294 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxGraphicObject.java @@ -0,0 +1,253 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.awt.XBitmap; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +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.GraphicObject</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> + * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::drawing::GraphicObjectShape</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::drawing::TextProperties</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.drawing.ShadowProperties + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.drawing.XShape + * @see com.sun.star.drawing.GraphicObjectShape + * @see com.sun.star.drawing.Shape + * @see com.sun.star.text.XTextRange + * @see com.sun.star.drawing.XGluePointsSupplier + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.drawing.TextProperties + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XText + * @see com.sun.star.lang.XComponent + * @see ifc.drawing._ShadowProperties + * @see ifc.drawing._RotationDescriptor + * @see ifc.text._XSimpleText + * @see ifc.drawing._XShape + * @see ifc.drawing._GraphicObjectShape + * @see ifc.drawing._Shape + * @see ifc.text._XTextRange + * @see ifc.drawing._XGluePointsSupplier + * @see ifc.beans._XPropertySet + * @see ifc.drawing._TextProperties + * @see ifc.style._CharacterProperties + * @see ifc.drawing._XShapeDescriptor + * @see ifc.style._ParagraphProperties + * @see ifc.text._XText + * @see ifc.lang._XComponent + */ +public class SvxGraphicObject extends TestCase { + + static XComponent xDrawDoc; + + /** + * Creates a new Draw document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * Disposes the Draw document created before + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.drawing.GraphicObject</code> as a tested + * component and inserts it to one of draw pages of the document. + * <p> + * + * Object relations created : + * <ul> + * <li> <code>'Style1', 'Style2'</code> for + * {@link ifc.drawing._Shape} : + * two values of 'Style' property. The first is taken + * from the shape tested, the second from another + * shape added to the draw page. </li> + * <li> <code>'Bitmap1', 'Bitmap2'</code> for + * {@link ifc.drawing._GraphicObjectShape} :</li> + * two bitmap objects which are created by setting + * 'GraphicURL' property of component tested and + * getting its 'GraphicObjectFillBitmap' property. + * <li> <code>'IMAP'</code> for + * {@link ifc.drawing._GraphicObjectShape} : + * <code>com.sun.star.image.ImageMapRectangleObject</code> + * service instance. </li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : + * creator which can create instances of + * <code>com.sun.star.text.TextField.URL</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + Object imap=null; + + // 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 + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc,5000,5000,1500,1000,"GraphicObject"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + oObj = oShape; + + TestEnvironment tEnv = new TestEnvironment( oShape ); + + // adding two styles as ObjRelation for Shape + oShape = SOF.createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + tEnv.addObjRelation("Style1",aStyle); + + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + tEnv.addObjRelation("Style2",aStyle); + + + // adding graphic as ObjRelation for GraphicObjectShape + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XBitmap aBitmap = null; + try { + oShapeProps.setPropertyValue( + "GraphicURL",util.utils.getFullTestURL("space-metal.jpg")); + aBitmap = (XBitmap) AnyConverter.toObject( + new Type(XBitmap.class),oShapeProps.getPropertyValue + ("GraphicObjectFillBitmap")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } + + + tEnv.addObjRelation("Bitmap1",aBitmap); + + try { + oShapeProps.setPropertyValue( + "GraphicURL",util.utils.getFullTestURL("crazy-blue.jpg")); + aBitmap = (XBitmap) AnyConverter.toObject( + new Type(XBitmap.class),oShapeProps.getPropertyValue + ("GraphicObjectFillBitmap")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } catch (com.sun.star.beans.PropertyVetoException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } + + tEnv.addObjRelation("Bitmap2",aBitmap); + + try { + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class,xDrawDoc); + imap = oDocMSF.createInstance + ( "com.sun.star.image.ImageMapRectangleObject" ); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + + tEnv.addObjRelation("IMAP",imap); + tEnv.addObjRelation("ImapObject",imap); + + // adding relation for XText interface + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + tEnv.addObjRelation("NoShear",Boolean.TRUE); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SvxGraphicObject diff --git a/qadevOOo/tests/java/mod/_svx/SvxShape.java b/qadevOOo/tests/java/mod/_svx/SvxShape.java new file mode 100644 index 000000000..74a4e209b --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShape.java @@ -0,0 +1,212 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +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::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::drawing::LineProperties</code></li> + * <li> <code>com::sun::star::drawing::FillProperties</code></li> + * <li> <code>com::sun::star::drawing::TextShape</code></li> + * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> + * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::drawing::TextProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * </ul> <p> + * + * The following files used by this test : + * <ul> + * <li><b> SvxShape.sxd </b> : this document is loaded for + * adding a shape tested to it. </li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.drawing.LineProperties + * @see com.sun.star.drawing.FillProperties + * @see com.sun.star.drawing.TextShape + * @see com.sun.star.drawing.ShadowProperties + * @see com.sun.star.drawing.XGluePointsSupplier + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.drawing.XShape + * @see com.sun.star.lang.XComponent + * @see com.sun.star.drawing.TextProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XText + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.drawing.Shape + * @see ifc.style._ParagraphProperties + * @see ifc.drawing._LineProperties + * @see ifc.drawing._FillProperties + * @see ifc.drawing._TextShape + * @see ifc.drawing._ShadowProperties + * @see ifc.drawing._XGluePointsSupplier + * @see ifc.style._CharacterProperties + * @see ifc.drawing._RotationDescriptor + * @see ifc.text._XTextRange + * @see ifc.drawing._XShape + * @see ifc.lang._XComponent + * @see ifc.drawing._TextProperties + * @see ifc.beans._XPropertySet + * @see ifc.text._XText + * @see ifc.drawing._XShapeDescriptor + * @see ifc.text._XSimpleText + * @see ifc.drawing._Shape + */ +public class SvxShape extends TestCase { + + static XComponent xDrawDoc; + + /** + * Loads a Draw document with name 'SvxShape.sxd' from test + * documents directory + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.loadDocument( + utils.getFullTestURL("SvxShape.sxd")); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.drawing.EllipseShape</code> as tested component + * and adds it to the document. + * Object relations created : + * <ul> + * <li> <code>'Style1', 'Style2'</code> for + * {@link ifc.drawing._Shape} : + * two values of 'Style' property. The first is taken + * from the shape tested, the second from another + * shape added to the draw page. </li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : + * creator which can create instances of + * <code>com.sun.star.text.TextField.URL</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = 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( tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc,3000,4500,15000,1000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + oObj = oShape ; + + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oShape ); + + // adding relations for Shape service + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + log.println( "adding two style as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + tEnv.addObjRelation("Style1",aStyle); + + oShapeProps = UnoRuntime.queryInterface + (XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + tEnv.addObjRelation("Style2",aStyle); + + // adding relation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShape diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeCircle.java b/qadevOOo/tests/java/mod/_svx/SvxShapeCircle.java new file mode 100644 index 000000000..63fd2c4eb --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeCircle.java @@ -0,0 +1,214 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +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.EllipseShape</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::drawing::LineProperties</code></li> + * <li> <code>com::sun::star::drawing::EllipseShape</code></li> + * <li> <code>com::sun::star::drawing::FillProperties</code></li> + * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> + * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::drawing::TextProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * </ul> <p> + * The following files used by this test : + * <ul> + * <li><b> SvxShape.sxd </b> : this document is loaded for + * adding a shape tested to it. </li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.drawing.LineProperties + * @see com.sun.star.drawing.EllipseShape + * @see com.sun.star.drawing.FillProperties + * @see com.sun.star.drawing.ShadowProperties + * @see com.sun.star.drawing.XGluePointsSupplier + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.drawing.XShape + * @see com.sun.star.lang.XComponent + * @see com.sun.star.drawing.TextProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XText + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.drawing.Shape + * @see ifc.style._ParagraphProperties + * @see ifc.drawing._LineProperties + * @see ifc.drawing._EllipseShape + * @see ifc.drawing._FillProperties + * @see ifc.drawing._ShadowProperties + * @see ifc.drawing._XGluePointsSupplier + * @see ifc.style._CharacterProperties + * @see ifc.drawing._RotationDescriptor + * @see ifc.text._XTextRange + * @see ifc.drawing._XShape + * @see ifc.lang._XComponent + * @see ifc.drawing._TextProperties + * @see ifc.beans._XPropertySet + * @see ifc.text._XText + * @see ifc.drawing._XShapeDescriptor + * @see ifc.text._XSimpleText + * @see ifc.drawing._Shape + */ +public class SvxShapeCircle extends TestCase { + + static XComponent xDrawDoc; + + /** + * Loads a Draw document with name 'SvxShape.sxd' from test + * documents directory + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a drawdoc" ); + xDrawDoc = SOF.loadDocument( + utils.getFullTestURL("SvxShape.sxd")); + } + + /** + * Disposes the Draw document loaded before. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.drawing.EllipseShape</code> as tested component + * and adds it to the document. Then the FULL type of circle is set. + * + * Object relations created : + * <ul> + * <li> <code>'Style1', 'Style2'</code> for + * {@link ifc.drawing._Shape} : + * two values of 'Style' property. The first is taken + * from the shape tested, the second from another + * shape added to the draw page. </li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : + * creator which can create instances of + * <code>com.sun.star.text.TextField.URL</code> + * service. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShape oShape = 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(tParam.getMSF()) ; + oShape = SOF.createShape(xDrawDoc,5000,5000,3000,3000,"Ellipse"); + + XPropertySet props = UnoRuntime.queryInterface + (XPropertySet.class, oShape) ; + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + props.setPropertyValue("CircleKind", + com.sun.star.drawing.CircleKind.FULL) ; + + oObj = oShape ; + + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (com.sun.star.lang.WrappedTargetException e) { + } catch (com.sun.star.beans.UnknownPropertyException e) { + } catch (com.sun.star.lang.IllegalArgumentException e) { + } + + tEnv.addObjRelation("Style2",aStyle); + + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeCircle diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeCollection.java b/qadevOOo/tests/java/mod/_svx/SvxShapeCollection.java new file mode 100644 index 000000000..5cbad5230 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeCollection.java @@ -0,0 +1,133 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +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; + +public class SvxShapeCollection extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + try { + // adding some shapes for testing. + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + Object col = tParam.getMSF().createInstance + ("com.sun.star.drawing.ShapeCollection"); + XShapes shapes = UnoRuntime.queryInterface + (XShapes.class,col); + + oShape = SOF.createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + shapes.add(oShape); + + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Rectangle"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + shapes.add(oShape); + + oObj = (XInterface) col ; + + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + System.out.println("IName: "+util.utils.getImplName(oObj)); + ShapeDsc sDsc = new ShapeDsc(5000,3500,7500,10000,"Line"); + tEnv.addObjRelation("Shape", new InstCreator(xDrawDoc, sDsc)) ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeCollection + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeConnector.java b/qadevOOo/tests/java/mod/_svx/SvxShapeConnector.java new file mode 100644 index 000000000..7236bcc18 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeConnector.java @@ -0,0 +1,187 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +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; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.document.LinkTarget + * @see com.sun.star.document.XLinkTargetSupplier + * @see com.sun.star.drawing.ConnectorShapeDescriptor + * @see com.sun.star.drawing.LineShapeDescriptor + * @see com.sun.star.drawing.PolyPolygonDescriptor + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.drawing.ShadowDescriptor + * @see com.sun.star.drawing.ShapeDescriptor + * @see com.sun.star.drawing.Text + * @see com.sun.star.drawing.XConnectorShape + * @see com.sun.star.drawing.XShape + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.lang.XComponent + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XText + * @see com.sun.star.text.XTextRange + * + */ +public class SvxShapeConnector extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + try { + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class,xDrawDoc); + Object oInt = oDocMSF.createInstance + ( "com.sun.star.drawing.ConnectorShape" ); + + oShape = UnoRuntime.queryInterface( XShape.class, oInt ); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // create testobject here + oObj = oShape; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc,3000,4500,15000,1000,"Ellipse"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + for (int i=0;i<10;i++) { + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add( + SOF.createShape(xDrawDoc, + 3000,4500,7510+10*i,5010+10*i,"Rectangle")); + } + + log.println( "adding two style as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) {} + + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) {} + + tEnv.addObjRelation("Style2",aStyle); + + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + tEnv.addObjRelation("NoSetSize","SvxShapeConnector"); + // adding relation for XConnectorShape + XShape oShape1 = SOF.createShape(xDrawDoc,1000,2000,1500,1000,"Line"); + XShape oShape2 = SOF.createShape(xDrawDoc,1000,2000,4000,3000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape1); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape2); + tEnv.addObjRelation("XConnectorShape.Shapes", + new XShape[] {oShape1, oShape2}) ; + System.out.println("IName: "+util.utils.getImplName(oObj)); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeConnector + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeControl.java b/qadevOOo/tests/java/mod/_svx/SvxShapeControl.java new file mode 100644 index 000000000..fe07d0578 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeControl.java @@ -0,0 +1,145 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.FormTools; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +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; + +public class SvxShapeControl extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + try { + + oShape = FormTools.insertControlShape( + xDrawDoc,3000,4500,15000,1000,"CommandButton"); + + oObj = oShape ; + + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style2",aStyle); + + log.println( "adding document relation for XControlShape" ); + tEnv.addObjRelation("xDoc", xDrawDoc) ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeControl + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeDimensioning.java b/qadevOOo/tests/java/mod/_svx/SvxShapeDimensioning.java new file mode 100644 index 000000000..7cccfe069 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeDimensioning.java @@ -0,0 +1,155 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +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; + +public class SvxShapeDimensioning extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + try { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc,4000,4000,3000,3000,"Measure"); + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + for (int i=0;i<10;i++) { + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add( + SOF.createShape(xDrawDoc, + 3000,4500,7510+10*i,5010+10*i,"Rectangle")); + } + + oObj = oShape ; + + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style2",aStyle); + + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeDimensioning + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapeGroup.java b/qadevOOo/tests/java/mod/_svx/SvxShapeGroup.java new file mode 100644 index 000000000..d49200a00 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapeGroup.java @@ -0,0 +1,163 @@ +/* + * 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._svx; + +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.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.XShapeGrouper; +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; + +/** + * + * initial description + * + * @see com.sun.star.drawing._XDrawPage + * + */ + +public class SvxShapeGroup extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method initializes the 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); + } + + /** + * in general this method disposes the 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 + */ + @Override + public 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"); + + 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)); + + if (oObj == null) { + System.out.println("**************************"); + System.out.println(" XDrawPage is NULL"); + System.out.println("**************************"); + } + + // put something on the drawpage + log.println("inserting some Shapes"); + oShapes = UnoRuntime.queryInterface(XShapes.class, oObj); + XShape Shape1 = SOF.createShape(xDrawDoc, 3000, 4500, 15000, 1000, + "Ellipse"); + oShapes.add(SOF.createShape(xDrawDoc, 2000, 1500, 1000, 1000, "Line")); + oShapes.add(Shape1); + XShape Shape2 = SOF.createShape(xDrawDoc, 5000, 3500, 7500, 5000, + "Rectangle"); + oShapes.add(Shape2); + + log.println("adding two style as ObjRelation for ShapeDescriptor"); + XPropertySet oShapeProps = UnoRuntime.queryInterface( + XPropertySet.class, Shape1); + XStyle aStyle1 = null; + try { + aStyle1 = (XStyle) AnyConverter.toObject(new Type(XStyle.class), + oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + } + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class, Shape2); + XStyle aStyle2 = null; + try { + aStyle2 = (XStyle) AnyConverter.toObject(new Type(XStyle.class), + oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + } + + // get the XShapeGrouper + log.println("get XShapeGroup"); + XShapeGrouper oSG = UnoRuntime + .queryInterface(XShapeGrouper.class, oObj); + oObj = oSG.group(oShapes); + + 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)); + + tEnv.addObjRelation("Style1", aStyle1); + tEnv.addObjRelation("Style2", aStyle2); + for (int i = 0; i < 6; i++) { + Shape2 = SOF.createShape(xDrawDoc, 5000 + 100 * i, 3500 + 100 * i, + 7500 + 100 * i, 5000 + 100 * i, "Rectangle"); + oShapes.add(Shape2); + } + return tEnv; + } // finish method createTestEnvironment + +} // finish class SvxShapeGroup + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygon.java b/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygon.java new file mode 100644 index 000000000..d5a43870a --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygon.java @@ -0,0 +1,250 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +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.PolyPolygonShape</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::drawing::LineProperties</code></li> + * <li> <code>com::sun::star::drawing::FillProperties</code></li> + * <li> <code>com::sun::star::drawing::PolyPolygonDescriptor</code></li> + * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> + * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::drawing::TextProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * </ul> <p> + * The following files used by this test : + * <ul> + * <li><b> TransparencyChart.sxs </b> : to load predefined chart + * document where two 'automatic' transparency styles exists : + * 'Transparency 1' and 'Transparency 2'.</li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.drawing.LineProperties + * @see com.sun.star.drawing.FillProperties + * @see com.sun.star.drawing.PolyPolygonDescriptor + * @see com.sun.star.drawing.ShadowProperties + * @see com.sun.star.drawing.XGluePointsSupplier + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.drawing.XShape + * @see com.sun.star.lang.XComponent + * @see com.sun.star.drawing.TextProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XText + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.drawing.Shape + * @see ifc.style._ParagraphProperties + * @see ifc.drawing._LineProperties + * @see ifc.drawing._FillProperties + * @see ifc.drawing._PolyPolygonDescriptor + * @see ifc.drawing._ShadowProperties + * @see ifc.drawing._XGluePointsSupplier + * @see ifc.style._CharacterProperties + * @see ifc.drawing._RotationDescriptor + * @see ifc.text._XTextRange + * @see ifc.drawing._XShape + * @see ifc.lang._XComponent + * @see ifc.drawing._TextProperties + * @see ifc.beans._XPropertySet + * @see ifc.text._XText + * @see ifc.drawing._XShapeDescriptor + * @see ifc.text._XSimpleText + * @see ifc.drawing._Shape + */ +public class SvxShapePolyPolygon extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xDrawDoc = SOF.loadDocument( + utils.getFullTestURL("SvxShape.sxd")); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + try { + // adding some shapes for testing. + XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc) ; + XInterface oInst = (XInterface) xMSF.createInstance + ("com.sun.star.drawing.PolyPolygonShape") ; + oShape = UnoRuntime.queryInterface + (XShape.class, oInst) ; + + oShape.setSize(new Size(0,0)) ; + oShape.setPosition(new Point(0,0)) ; + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + Point[] square1 = new Point[] { + new Point(5000, 5000), + new Point(10000, 5000), + new Point(10000, 10000), + new Point(5000, 10000)} ; + + Point[] square2 = new Point[] { + new Point(6500, 6500), + new Point(8500, 6500), + new Point(8500, 8500), + new Point(6500, 8500)} ; + + Point[][] polygon = new Point[][] {square1, square2}; + + UnoRuntime.queryInterface(XPropertySet.class, + oShape).setPropertyValue("PolyPolygon", polygon) ; + + oObj = oShape ; + + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style2",aStyle); + + // adding relation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapeCollection + diff --git a/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygonBezier.java b/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygonBezier.java new file mode 100644 index 000000000..f053a2e0f --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxShapePolyPolygonBezier.java @@ -0,0 +1,264 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.awt.Point; +import com.sun.star.awt.Size; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.PolyPolygonBezierCoords; +import com.sun.star.drawing.PolygonFlags; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +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.ClosedBezierShape</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::drawing::PolyPolygonBezierDescriptor</code></li> + * <li> <code>com::sun::star::drawing::LineProperties</code></li> + * <li> <code>com::sun::star::drawing::FillProperties</code></li> + * <li> <code>com::sun::star::drawing::ShadowProperties</code></li> + * <li> <code>com::sun::star::drawing::XGluePointsSupplier</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::drawing::RotationDescriptor</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::drawing::XShape</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::drawing::TextProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * <li> <code>com::sun::star::drawing::XShapeDescriptor</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::drawing::Shape</code></li> + * </ul> <p> + * + * The following files used by this test : + * <ul> + * <li><b> TransparencyChart.sxs </b> : to load predefined chart + * document where two 'automatic' transparency styles exists : + * 'Transparency 1' and 'Transparency 2'.</li> + * </ul> <p> + * + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.drawing.PolyPolygonBezierDescriptor + * @see com.sun.star.drawing.LineProperties + * @see com.sun.star.drawing.FillProperties + * @see com.sun.star.drawing.ShadowProperties + * @see com.sun.star.drawing.XGluePointsSupplier + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.drawing.RotationDescriptor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.drawing.XShape + * @see com.sun.star.lang.XComponent + * @see com.sun.star.drawing.TextProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XText + * @see com.sun.star.drawing.XShapeDescriptor + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.drawing.Shape + * @see ifc.style._ParagraphProperties + * @see ifc.drawing._PolyPolygonBezierDescriptor + * @see ifc.drawing._LineProperties + * @see ifc.drawing._FillProperties + * @see ifc.drawing._ShadowProperties + * @see ifc.drawing._XGluePointsSupplier + * @see ifc.style._CharacterProperties + * @see ifc.drawing._RotationDescriptor + * @see ifc.text._XTextRange + * @see ifc.drawing._XShape + * @see ifc.lang._XComponent + * @see ifc.drawing._TextProperties + * @see ifc.beans._XPropertySet + * @see ifc.text._XText + * @see ifc.drawing._XShapeDescriptor + * @see ifc.text._XSimpleText + * @see ifc.drawing._Shape + */ +public class SvxShapePolyPolygonBezier extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating a chartdocument" ); + xDrawDoc = SOF.loadDocument( + utils.getFullTestURL("SvxShape.sxd")); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + XShape oShape = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + try { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + XMultiServiceFactory xMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDrawDoc) ; + + XInterface oInst = (XInterface) xMSF.createInstance + ("com.sun.star.drawing.ClosedBezierShape") ; + oShape = UnoRuntime.queryInterface + (XShape.class, oInst) ; + + Point[] points = new Point[2]; + points[0] = new Point(); + points[0].X = 50; + points[0].Y = 50; + points[1] = new Point(); + points[1].X = 5000; + points[1].Y = 5000; + + Point[][] the_points = new Point[1][2]; + the_points[0] = points; + + PolygonFlags[] flags = new PolygonFlags[2]; + flags[0] = PolygonFlags.NORMAL; + flags[1] = PolygonFlags.NORMAL; + + PolygonFlags[][] the_flags = new PolygonFlags[1][2]; + the_flags[0] = flags; + + PolyPolygonBezierCoords coords = new PolyPolygonBezierCoords(); + coords.Coordinates=the_points; + coords.Flags = the_flags; + + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + oShape.setSize(new Size(3000,3000)) ; + oShape.setPosition(new Point(4000,4000)) ; + + oObj = oShape ; + + XPropertySet shapeProps = UnoRuntime.queryInterface + (XPropertySet.class, oObj); + + shapeProps.setPropertyValue("PolyPolygonBezier",coords); + + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Line"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + } + catch (Exception e) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + // test environment creation + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding two styles as ObjRelation for ShapeDescriptor" ); + XPropertySet oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oObj); + XStyle aStyle = null; + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style1",aStyle); + oShapeProps = UnoRuntime.queryInterface(XPropertySet.class,oShape); + try { + aStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oShapeProps.getPropertyValue("Style")); + } catch (Exception e) { + System.out.println("caught exception: " + e); + } + tEnv.addObjRelation("Style2",aStyle); + + // adding relation for XText + util.DefaultDsc tDsc = new util.DefaultDsc + ("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.URL"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxShapePolyPolygonBezier diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoNumberingRules.java b/qadevOOo/tests/java/mod/_svx/SvxUnoNumberingRules.java new file mode 100644 index 000000000..10a076e0b --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoNumberingRules.java @@ -0,0 +1,78 @@ +/* + * 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._svx; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; + + +public class SvxUnoNumberingRules extends TestCase { + static XComponent xDrawDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a drawdoc"); + xDrawDoc = DrawTools.createDrawDoc( + tParam.getMSF()); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory docMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + xDrawDoc); + XInterface oObj = (XInterface) docMSF.createInstance( + "com.sun.star.text.NumberingRules"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("Implementationname: " + util.utils.getImplName(oObj)); + + Object NewRules=null; + + try{ + XIndexAccess xIA = UnoRuntime.queryInterface(XIndexAccess.class, oObj); + NewRules = xIA.getByIndex(2); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't get new Rules for XIndexReplace"); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Couldn't get new Rules for XIndexReplace"); + } + + tEnv.addObjRelation("INSTANCE1",NewRules); + + return tEnv; + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + util.DesktopTools.closeDoc(xDrawDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoText.java b/qadevOOo/tests/java/mod/_svx/SvxUnoText.java new file mode 100644 index 000000000..19fb1ef32 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoText.java @@ -0,0 +1,156 @@ +/* + * 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._svx; + +import com.sun.star.text.XText; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.DrawTools; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class SvxUnoText extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * Object relations created : + * <ul> + * <li> <code>'RangeForMove'</code> for + * {@link ifc.text._XTextRangeMover} (the range to be moved)</li> + * <li> <code>'XTextRange'</code> for + * {@link ifc.text._XTextRangeMover} (the range that includes moving + * range)</li> + * </ul> + * @see TestParameters + * * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + // create testobject here + XTextRange aRange = null; + XShape oShape = null; + + try { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + oShape = SOF.createShape + (xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XSimpleText text = UnoRuntime.queryInterface + (XSimpleText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + cursor.setString("TextForMove"); + aRange = cursor; + XTextCursor cursor1 = text.createTextCursorByRange(text.getEnd()); + text.insertControlCharacter(cursor1, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor1, "Paragraph 2", false); + text.insertControlCharacter(cursor1, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor1, "Paragraph 3", false) ; + text.insertControlCharacter(cursor1, + ControlCharacter.PARAGRAPH_BREAK, false) ; + oObj = text.getText() ; + } catch (Exception e) { + log.println("Can't create test object") ; + e.printStackTrace(log) ; + } + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + // adding relation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.DateTime"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc, tDsc ) ); + + // adding relation for XTextRangeMover + tEnv.addObjRelation("RangeForMove", aRange); + tEnv.addObjRelation("XTextRange", oObj); + + // adding relation for XTextRangeCompare + tEnv.addObjRelation("TEXT", UnoRuntime.queryInterface(XText.class, oShape)) ; + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxUnoText + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextContent.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextContent.java new file mode 100644 index 000000000..3550663a4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextContent.java @@ -0,0 +1,130 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +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 SvxUnoTextContent extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + // create testobject here + + XEnumerationAccess xEA = null ; + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + XShape oShape = SOF.createShape(xDrawDoc, + 5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + XSimpleText text = UnoRuntime.queryInterface + (XSimpleText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 2", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 3", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, text) ; + + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),xEA.createEnumeration().nextElement()); + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextContentEnum.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextContentEnum.java new file mode 100644 index 000000000..b640c95d6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextContentEnum.java @@ -0,0 +1,133 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class SvxUnoTextContentEnum extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + // create testobject here + + XEnumerationAccess xEA = null ; + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + XShape oShape = SOF.createShape + (xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + XSimpleText text = UnoRuntime.queryInterface + (XSimpleText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 2", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 3", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, text) ; + + oObj = xEA.createEnumeration() ; + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XEnumeration test + tEnv.addObjRelation("ENUM", xEA) ; + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextCursor.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextCursor.java new file mode 100644 index 000000000..ec367094a --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextCursor.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._svx; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class SvxUnoTextCursor extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + XInterface oObj = null; + // create testobject here + + try { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + XShape oShape = SOF.createShape + (xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + XText text = UnoRuntime.queryInterface(XText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 2", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 3", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + + oObj = cursor ; + + } catch (Exception e) { + log.println("Can't create test object") ; + e.printStackTrace(log) ; + } + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxUnoTextCursor + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextField.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextField.java new file mode 100644 index 000000000..f9ffe6726 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextField.java @@ -0,0 +1,129 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see ifc._XComponent + * @see ifc._TextContent + * @see ifc._XTextContent + * @see ifc._XTextField + * + */ +public class SvxUnoTextField extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc( tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XShape oShape = 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( tParam.getMSF()); + oShape = SOF.createShape(xDrawDoc,5000,3500,7500,5000,"Rectangle"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); + + XTextCursor the_Cursor = null; + + // create testobject here + XText the_Text = UnoRuntime.queryInterface(XText.class,oShape); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, xDrawDoc ); + the_Cursor = the_Text.createTextCursor(); + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.TextField.DateTime" ); + XTextContent the_Field = UnoRuntime.queryInterface(XTextContent.class,oObj); + + + the_Text.insertTextContent(the_Cursor,the_Field,false); + + log.println( "creating a new environment for FieldMaster object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("RANGE", the_Cursor); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SvxUnoTextField + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextRange.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextRange.java new file mode 100644 index 000000000..313921f29 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextRange.java @@ -0,0 +1,142 @@ +/* + * 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._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +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 SvxUnoTextRange extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + // create testobject here + + XEnumerationAccess xEA = null ; + try { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + XShape oShape = SOF.createShape + (xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + XSimpleText text = UnoRuntime.queryInterface + (XSimpleText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 2", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 3", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, text) ; + + XInterface oTextContent = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),xEA.createEnumeration().nextElement()); + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, oTextContent) ; + + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),xEA.createEnumeration().nextElement()); + + } catch (Exception e) { + log.println("Can't create test object") ; + e.printStackTrace(log) ; + } + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/SvxUnoTextRangeEnumeration.java b/qadevOOo/tests/java/mod/_svx/SvxUnoTextRangeEnumeration.java new file mode 100644 index 000000000..8fe191542 --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/SvxUnoTextRangeEnumeration.java @@ -0,0 +1,143 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package mod._svx; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DrawTools; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.XComponent; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +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 SvxUnoTextRangeEnumeration extends TestCase { + + static XComponent xDrawDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + log.println( "creating a drawdoc" ); + xDrawDoc = DrawTools.createDrawDoc(tParam.getMSF()); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + util.DesktopTools.closeDoc(xDrawDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + // create testobject here + + XEnumerationAccess xEA = null ; + try { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()) ; + XShape oShape = SOF.createShape + (xDrawDoc,5000,3500,7500,5000,"Text"); + DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape) ; + + XSimpleText text = UnoRuntime.queryInterface + (XSimpleText.class, oShape) ; + + XTextCursor cursor = text.createTextCursor() ; + + text.insertString(cursor, "Paragraph 1", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 2", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + text.insertString(cursor, "Paragraph 3", false) ; + text.insertControlCharacter(cursor, + ControlCharacter.PARAGRAPH_BREAK, false) ; + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, text) ; + + XInterface oTextContent = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),xEA.createEnumeration().nextElement()); + + xEA = UnoRuntime.queryInterface + (XEnumerationAccess.class, oTextContent) ; + + oObj = xEA.createEnumeration(); + + } catch (Exception e) { + log.println("Can't create test object") ; + e.printStackTrace(log) ; + } + + // create test environment here + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("ENUM", xEA); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_svx/package.html b/qadevOOo/tests/java/mod/_svx/package.html new file mode 100644 index 000000000..a4961d2bf --- /dev/null +++ b/qadevOOo/tests/java/mod/_svx/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 'svx'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_sw/CharacterStyle.java b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java new file mode 100644 index 000000000..8f7c3b181 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/CharacterStyle.java @@ -0,0 +1,148 @@ +/* + * 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._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.CharacterStyle</code>. <p> + * @see com.sun.star.style.CharacterStyle + */ +public class CharacterStyle extends TestCase { + private XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * At first style families are gotten from a text document using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from this style family using <code>XIndexAccess</code> interface. + * Next, method creates an instance of the service + * <code>com.sun.star.style.CharacterStyle</code> and inserts it to a + * previously obtained style family using <code>XNameContainer</code> + * interface. Finally, method creates a cursor of a major text of text + * document and sets it's property 'CharStyleName' value to the name of + * previously created style's name. + * Object relations created : + * <ul> + * <li> <code>'PoolStyle'</code> for + * {@link ifc.style._XStyle} : style indexed '10' obtained from + * StyleFamily indexed '0' from text document using + * <code>XIndexAccess</code> interface.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFsIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF); + oSFNA = UnoRuntime.queryInterface( + XNameAccess.class,oSFsIA.getByIndex(0)); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(0)); + + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.CharacterStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + xProp.setPropertyValue("CharStyleName", oMyStyle.getName()); + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + + String[] skipPropertiesNamed = {}; + + short exclude = PropertyAttribute.READONLY; + tEnv.addObjRelation("PropertyNames",utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude, skipPropertiesNamed)); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java new file mode 100644 index 000000000..fbcc9e2b0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/ConditionalParagraphStyle.java @@ -0,0 +1,142 @@ +/* + * 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._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.Status; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.ConditionalParagraphStyle</code>. <p> + * @see com.sun.star.style.ConditionalParagraphStyle + */ +public class ConditionalParagraphStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * Create a new instance of the conditional + * paragraph style, and insert it into the document. + * @see com.sun.star.style.ConditionalParagraphStyle + * @param tParam The test parameters + * @param log The log writer. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("ParagraphStyles")); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(1)); + + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.ConditionalParagraphStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + + if (oMyStyle == null) { + log.println("FAILED"); + throw new StatusException(Status.failed("Couldn't create an own style ")); + } + else { + log.println("OK"); + } + + XNameContainer oSFNC = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oCursor); + xProp.setPropertyValue("ParaStyleName", oMyStyle.getName()); + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + short exclude = PropertyAttribute.READONLY; + String[] skipPropertiesNamed = { "ParaBackGraphicURL" }; + + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude, skipPropertiesNamed); + + tEnv.addObjRelation("PropertyNames", names); + tEnv.addObjRelation("SkipProperties", skipPropertiesNamed); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/DocumentSettings.java b/qadevOOo/tests/java/mod/_sw/DocumentSettings.java new file mode 100644 index 000000000..935c84b1e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/DocumentSettings.java @@ -0,0 +1,78 @@ +/* + * 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._sw; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; +import util.WriterTools; + +import java.io.PrintWriter; + + +public class DocumentSettings extends TestCase +{ + XTextDocument xTextDoc = null; + + /** + * Creates text document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) + { + log.println(" opening xTextDoc "); + xTextDoc = + WriterTools.createTextDoc(tParam.getMSF()); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) + { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log + ) + { + SOfficeFactory SOF = + SOfficeFactory.getFactory(tParam.getMSF()); + XInterface oObj = null; + + log.println("creating a test environment"); + + oObj = + (XInterface) SOF.createInstance( + xTextDoc, "com.sun.star.text.DocumentSettings" + ); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sw/PageStyle.java b/qadevOOo/tests/java/mod/_sw/PageStyle.java new file mode 100644 index 000000000..7de28b201 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/PageStyle.java @@ -0,0 +1,141 @@ +/* + * 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._sw; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.PageStyle</code>. <p> + * @see com.sun.star.style.PageStyle + */ +public class PageStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("PageStyles")); // get the page style + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(0)); + log.println("Chosen pool style: "+oStyle.getName()); + + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.PageStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + + XNameContainer oSFNC = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oCursor); + Property[] props = xProp.getPropertySetInfo().getProperties(); + for (int i=0; i<props.length; i++) + System.out.println("# Property: " + props[i].Name + " val: " + props[i].Type.toString() + " attr: " + props[i].Attributes); + xProp.setPropertyValue("PageDescName", oMyStyle.getName()); + +// oMyStyle = oStyle; + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + tEnv.addObjRelation("FollowStyle", "Envelope"); + XPropertySet xStyleProp = UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + + short exclude = PropertyAttribute.READONLY; + + String[] skipPropertiesNamed = { + "BackGraphicURL", "HeaderBackGraphicURL", "FooterBackGraphicURL" + }; + + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude, skipPropertiesNamed); + tEnv.addObjRelation("PropertyNames", names); + tEnv.addObjRelation("SkipProperties", skipPropertiesNamed); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/ParagraphStyle.java b/qadevOOo/tests/java/mod/_sw/ParagraphStyle.java new file mode 100644 index 000000000..b85a83ab3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/ParagraphStyle.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._sw; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.ParagraphStyle</code>. <p> + * @see com.sun.star.style.ParagraphStyle + */ +public class ParagraphStyle extends TestCase { + + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + oSFNA = UnoRuntime.queryInterface( + XNameAccess.class,oSF.getByName("ParagraphStyles")); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oSFNA.getElementNames(); + oStyle = UnoRuntime.queryInterface( + XStyle.class,oSFIA.getByIndex(1)); + + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.ParagraphStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + xProp.setPropertyValue("ParaStyleName", oMyStyle.getName()); + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + short exclude = PropertyAttribute.READONLY; + + String[] skipPropertiesNamed = { "ParaBackGraphicURL" }; + + String[] names = utils.getFilteredPropertyNames(xStyleProp, (short)0, exclude, skipPropertiesNamed); + tEnv.addObjRelation("PropertyNames", names); + + return tEnv; + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.java new file mode 100644 index 000000000..5fb1a4779 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentPageView.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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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 SwAccessibleDocumentPageView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switch the document to Print Preview mode. + * Obtains accessible object for the document page view. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment( + final TestParameters Param, PrintWriter log) throws Exception{ + + XInterface oObj = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + for (int i=0; i<25; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwAccessibleDocumentPageView", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwAccessibleDocumentPageView", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + + XController xController = xTextDoc.getCurrentController(); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + //switch to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + 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 = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + util.utils.waitForEventIdle(Param.getMSF()); + + 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); + + final XText the_text = oText; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + String oldText = the_text.getString(); + the_text.setString("EVENT FIRED"); + util.utils.waitForEventIdle(Param.getMSF()); + the_text.setString(oldText); + } + }); + + return tEnv; + + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * 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 { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc( Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java new file mode 100644 index 000000000..37b59c323 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleDocumentView.java @@ -0,0 +1,168 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleValue; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test of accessible object for the text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleDocumentView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. The method is called from + * <code>getTestEnvironment()</code>. Obtains accessible object for + * text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + for (int i=0; i<5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + 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); + + getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR); + final XAccessibleValue xAccVal = UnoRuntime.queryInterface + (XAccessibleValue.class, SearchedContext) ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + xAccVal.setCurrentValue(xAccVal.getMinimumValue()); + xAccVal.setCurrentValue(xAccVal.getMaximumValue()); + } + }); + + return tEnv; + + } + + public static boolean first = false; + public static XAccessibleContext SearchedContext = null; + + public static void getAccessibleObjectForRole(XAccessible xacc,short role) { + XAccessibleContext ac = xacc.getAccessibleContext(); + if (ac.getAccessibleRole()==role) { + if (first) SearchedContext = ac; + else first=true; + } else { + int k = ac.getAccessibleChildCount(); + for (int i=0;i<k;i++) { + try { + getAccessibleObjectForRole(ac.getAccessibleChild(i),role); + if (SearchedContext != null) return ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't get Child"); + } + } + } + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java new file mode 100644 index 000000000..eb66279fa --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleEndnoteView.java @@ -0,0 +1,155 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +public class SwAccessibleEndnoteView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Inserts the created endnote to the document. + * Changes zoom value to 10%(endnote must be in visible area of the document). + * Obtains accessible object for the inserted endnote. + * + * @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; + XInterface oEndnote = null; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating an endnote"); + oEndnote = UnoRuntime.queryInterface(XInterface.class, + msf.createInstance("com.sun.star.text.Endnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + XTextContent xTC = UnoRuntime.queryInterface(XTextContent.class, oEndnote); + oText.insertTextContent(oCursor, xTC, false); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + + //change zoom value to 20% + //footer should be in the visible area of the document + xPropSet.setPropertyValue("ZoomValue", Short.valueOf("20")); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.END_NOTE); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 21% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("21")); + //and back to 20% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("20")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * 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 { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java new file mode 100644 index 000000000..24ee00358 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleFooterView.java @@ -0,0 +1,159 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +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.view.XViewSettingsSupplier; + +/** +* Test of accessible object for a footer of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleFooterView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains style + * <code>Standard</code> from style family <code>PageStyles</code>. + * Changes values of property <code>FooterIsOn</code> by <code>true</code>. + * Changes zoom value to 10%(footer must be in visible area of the document). + * Obtains accessible component for the footer. + * + * @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; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standard' from style family 'PageStyles' + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + + final XPropertySet PropSet = UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + log.println( "Switching on footer" ); + PropSet.setPropertyValue("FooterIsOn", Boolean.TRUE); + + //change zoom value to 10% + //footer should be in the visible area of the document + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + xPropSet.setPropertyValue("ZoomValue", Short.valueOf("20")); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.FOOTER); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + PropSet.setPropertyValue("FooterLeftMargin", + Integer.valueOf(1000)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + throw new StatusException("Can't change footer.", e); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } + +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java new file mode 100644 index 000000000..0899108a8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleFootnoteView.java @@ -0,0 +1,156 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +public class SwAccessibleFootnoteView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Inserts the created footnote to the document. + * Changes zoom value to 10%(endnote must be in visible area of the document). + * Obtains accessible object for the inserted footnote. + * + * @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; + XFootnote oFootnote = null; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + oFootnote = UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + oText.insertTextContent(oCursor, oFootnote, false); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + + //change zoom value to 10% + //footer should be in the visible area of the document + xPropSet.setPropertyValue("ZoomValue", Short.valueOf("10")); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.FOOTNOTE); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 130% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("15")); + //and back to 10% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("10")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * 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 { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java new file mode 100644 index 000000000..b946304a0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleHeaderView.java @@ -0,0 +1,148 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.frame.XModel; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +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 of accessible object for a header of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleHeaderView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains style + * <code>Standard</code> from style family <code>PageStyles</code>. + * Changes values of properties <code>HeaderIsOn</code> and + * <code>FooterIsOn</code> by <code>true</code>. Obtains accessible component + * for header. + * + * @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; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standard' from style family 'PageStyles' + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + + final XPropertySet PropSet = UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + log.println( "Switching on header" ); + PropSet.setPropertyValue("HeaderIsOn", Boolean.TRUE); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.HEADER); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer(){ + public void fireEvent() { + try { + PropSet.setPropertyValue("HeaderLeftMargin", + Integer.valueOf(1000)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(); + throw new StatusException("Can't change footer.", e); + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java new file mode 100644 index 000000000..62f6e8454 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessiblePageView.java @@ -0,0 +1,214 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleValue; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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.URL; +import com.sun.star.util.XURLTransformer; + +public class SwAccessiblePageView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Switches the document to Print Preview mode. + * Obtains accessible object for the page view. + * + * @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; + XInterface port = null; + XInterface para = null; + XPropertySet paraP = null; + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + for (int i=0; i<2; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + + // Enumeration + XEnumerationAccess oEnumA = UnoRuntime.queryInterface(XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + para = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + XEnumerationAccess oEnumB = UnoRuntime.queryInterface( XEnumerationAccess.class, para ); + XEnumeration oEnum2 = oEnumB.createEnumeration(); + port = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum2.nextElement()); + + UnoRuntime.queryInterface(XPropertySet.class, port); + paraP = UnoRuntime.queryInterface(XPropertySet.class, para); + paraP.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_AFTER); + + util.utils.waitForEventIdle(Param.getMSF()); + + XController xController = xTextDoc.getCurrentController(); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + //switch to 'Print Preview' mode + XDispatchProvider xDispProv = UnoRuntime.queryInterface(XDispatchProvider.class, xController); + 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 = ".uno:PrintPreview"; + xParser.parseStrict(aParseURL); + URL aURL = aParseURL[0]; + XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); + if(xDispatcher != null) + xDispatcher.dispatch( aURL, null ); + + 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)); + + System.out.println("Panel: "+AccessibleRole.PANEL); + System.out.println("ScrollPane: "+AccessibleRole.SCROLL_PANE); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL,"Page"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + + TestEnvironment tEnv = new TestEnvironment(oObj); + + getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR); + final XAccessibleValue xAccVal = UnoRuntime.queryInterface + (XAccessibleValue.class, SearchedContext) ; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Integer old = (Integer) xAccVal.getCurrentValue(); + Integer newValue = Integer.valueOf(old.intValue()+10); + xAccVal.setCurrentValue(newValue); + xAccVal.setCurrentValue(old); + } + }); + + return tEnv; + + } + + public static boolean first = false; + public static XAccessibleContext SearchedContext = null; + + public static void getAccessibleObjectForRole(XAccessible xacc,short role) { + XAccessibleContext ac = xacc.getAccessibleContext(); + if (ac.getAccessibleRole()==role) { + if (first) SearchedContext = ac; + else first=true; + } else { + int k = ac.getAccessibleChildCount(); + for (int i=0;i<k;i++) { + try { + getAccessibleObjectForRole(ac.getAccessibleChild(i),role); + if (SearchedContext != null) return ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't get Child"); + } + } + } + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * 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 { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java new file mode 100644 index 000000000..01af4ed5d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleParagraphView.java @@ -0,0 +1,126 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.frame.XModel; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test of accessible object for paragraph of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleParagraphView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. Obtains accessible object + * for one of document paragraph. + * + * @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; + + XText oText = xTextDoc.getText(); + oText.setString("XAccessibleText"); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PARAGRAPH); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XText paraText = xTextDoc.getText(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + String old = paraText.getString(); + paraText.setString("Just a line"); + paraText.setString(old); + } + }); + + final String text = "XAccessibleText"; + + tEnv.addObjRelation("XAccessibleText.Text", text); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc( Param.getMSF()); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java new file mode 100644 index 000000000..c16f1f497 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableCellView.java @@ -0,0 +1,129 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; + + +/** +* Test of accessible object for the table cell of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTableCellView extends TestCase { + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a text table and inserts it to document. Then obtains accessible + * object for one of table cell. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see TestEnvironment + * @see #getTestEnvironment + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XAccessibleContext oObj = null; + XTextTable oTable = null; + + SOfficeFactory.getFactory( Param.getMSF()); + + oTable = SOfficeFactory.createTextTable(xTextDoc); + + SOfficeFactory.insertTextContent(xTextDoc, oTable); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE_CELL); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleSelection accSel = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj.getAccessibleParent()); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + accSel.selectAllAccessibleChildren(); + } + }); + + return tEnv; + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a text document"); + xTextDoc = WriterTools.createTextDoc( Param.getMSF()); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java new file mode 100644 index 000000000..1d47445ce --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTableView.java @@ -0,0 +1,147 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the table of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTableView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a text table and inserts it into the document. + * Then obtains accessible object for the table. + * + * @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; + XTextTable oTable = null; + + SOfficeFactory.getFactory(Param.getMSF()); + oTable = SOfficeFactory.createTextTable( xTextDoc ); + + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java new file mode 100644 index 000000000..e7ce3df98 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextEmbeddedObject.java @@ -0,0 +1,142 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the text embedded object of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextEmbeddedObject extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Obtains accessible object for the embedded object. + * + * @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; + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.EMBEDDED_OBJECT); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Loads the text document <code>SwXTextEmbeddedObject.sxw</code> + * with a text embedded object. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "open a text document" ); + String testdoc = utils.getFullTestURL("SwXTextEmbeddedObject.sxw"); + log.println(testdoc); + xTextDoc = WriterTools.loadTextDoc(Param.getMSF(),testdoc); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java new file mode 100644 index 000000000..133cfcb78 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextFrameView.java @@ -0,0 +1,166 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the text frame of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextFrameView extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a frame and inserts it into document. + * Obtains accessible object for the inserted text frame. + * + * @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; + XTextFrame oFrame1 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = null; + + // get a soffice factory object + SOfficeFactory.getFactory( Param.getMSF() ); + // creating Frames + log.println( "creating Frames" ); + oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + oPropSet = UnoRuntime.queryInterface( + XPropertySet.class, oFrame1 ); + oPropSet.setPropertyValue("AnchorType", + TextContentAnchorType.AS_CHARACTER); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println( "inserting Frame1" ); + XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oFrame1); + oText.insertTextContent(oCursor, the_content, true); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT_FRAME); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 15% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("15")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java new file mode 100644 index 000000000..f3b23fbdf --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwAccessibleTextGraphicObject.java @@ -0,0 +1,156 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.WriterTools; +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.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** +* Test of accessible object for the graphic object of a text document.<p> +* Object implements the following interfaces : +* <ul> +* <li> <code>::com::sun::star::accessibility::XAccessible</code></li> +* </ul> +* @see com.sun.star.accessibility.XAccessible +*/ +public class SwAccessibleTextGraphicObject extends TestCase { + + XTextDocument xTextDoc = null; + + /** + * Called to create an instance of <code>TestEnvironment</code> + * with an object to test and related objects. + * Creates a graphic object and inserts it into the document. + * Obtains accessible object for graphic object. + * + * @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; + + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + Object oGraphObj = SOF.createInstance( + xTextDoc, "com.sun.star.text.GraphicObject"); + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = UnoRuntime.queryInterface(XTextContent.class, oGraphObj); + + log.println( "inserting graphic" ); + the_text.insertTextContent(the_cursor, the_content, true); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.GRAPHIC); + + log.println("ImplementationName " + utils.getImplName(oObj)); + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + + final XPropertySet PropSet = xViewSetSup.getViewSettings(); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + //change zoom value to 20% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("20")); + //and back to 100% + PropSet.setPropertyValue("ZoomValue", Short.valueOf("100")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + + } catch ( com.sun.star.beans.PropertyVetoException e ) { + + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + + } + } + }); + + + return tEnv; + + } + + + /** + * Called while disposing a <code>TestEnvironment</code>. + * Disposes text document. + * @param Param test parameters + * @param log writer to log information while testing + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println("dispose text document"); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Called while the <code>TestCase</code> initialization. + * Creates a text document. + * + * @param Param test parameters + * @param log writer to log information while testing + * + * @see #initializeTestCase + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println( "creating a text document" ); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java new file mode 100644 index 000000000..edaa1aed9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextContainer.java @@ -0,0 +1,75 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.uno.UnoRuntime; + +/** +* Test for object which is represented by service +* <code>com.sun.star.text.AutoTextContainer</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::text::XAutoTextContainer</code></li> +* </ul> +* @see com.sun.star.container.XNameAccess +* @see com.sun.star.container.XElementAccess +* @see com.sun.star.text.XAutoTextContainer +* @see com.sun.star.text.AutoTextContainer +* @see ifc.container._XNameAccess +* @see ifc.container._XElementAccess +* @see ifc.text._XAutoTextContainer +*/ +public class SwXAutoTextContainer extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>.<p> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XAutoTextContainer oContainer = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println("creating an AutoTextContainer"); + XMultiServiceFactory myMSF = Param.getMSF(); + Object oInst = myMSF.createInstance + ("com.sun.star.text.AutoTextContainer"); + oContainer = UnoRuntime.queryInterface + (XAutoTextContainer.class,oInst); + + TestEnvironment tEnv = new TestEnvironment(oContainer); + + return tEnv; + } + +} // finish class SwXAutoTextcontainer + diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java new file mode 100644 index 000000000..30a7ada71 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextEntry.java @@ -0,0 +1,198 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DefaultDsc; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.text.XAutoTextEntry; +import com.sun.star.text.XAutoTextGroup; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +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.text.AutoTextEntry</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XAutoTextEntry</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.AutoTextEntry + * @see com.sun.star.text.AutoTextContainer + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XAutoTextEntry + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XText + * @see ifc.text._XSimpleText + * @see ifc.text._XAutoTextEntry + * @see ifc.text._XTextRange + * @see ifc.text._XText + */ +public class SwXAutoTextEntry extends TestCase { + XTextDocument xTextDoc; + XAutoTextGroup oGroup; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + XMultiServiceFactory msf = tParam.getMSF(); + SOfficeFactory SOF = SOfficeFactory.getFactory( msf ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Removes added element from AutoTextGroup + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + try { + if ( oGroup.hasByName("NewEntryName") ) { + log.println("Removing 'NewEntryName' element"); + ((com.sun.star.lang.XComponent) AnyConverter.toObject( + new Type(com.sun.star.lang.XComponent.class), + oGroup.getByName("NewEntryName"))).dispose(); + oGroup.removeByName("NewEntryName"); + } + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Cannot remove TextEntry from group..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Cannot remove TextEntry from group..."); + e.printStackTrace(log); + } + log.println( "disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>, then selects the 'mytexts' + * group from the given container using <code>XNameAccess</code> interface, + * and inserts some text entry to this group. Then entry passed as test + * component.<p> + * Object relations created : + * <ul> + * <li><code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} : creates tables 6x4</li> + * <li><code>'TEXTDOC'</code> for + * {@link ifc.text._XAutoTextEntry} : text document</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + XAutoTextEntry oEntry = null; + XAutoTextContainer oContainer; + XInterface oObj = null; + log.println( "creating a test environment" ); + XMultiServiceFactory myMSF = Param.getMSF(); + Object oInst = myMSF.createInstance + ("com.sun.star.text.AutoTextContainer"); + oContainer = UnoRuntime.queryInterface(XAutoTextContainer.class,oInst); + + XNameAccess oContNames = UnoRuntime.queryInterface(XNameAccess.class, oContainer); + + String contNames[] = oContNames.getElementNames(); + for (int i =0; i < contNames.length; i++){ + log.println("ContainerNames[ "+ i + "]: " + contNames[i]); + } + + oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName("mytexts")); + + oGroup = UnoRuntime.queryInterface + (XAutoTextGroup.class, oObj); + String[] oENames = oGroup.getElementNames(); + for (int i=0; i<oENames.length; i++) { + log.println("AutoTextEntryNames[" + i + "]: " + oENames[i]); + } + + XText oText = xTextDoc.getText(); + oText.insertString(oText.getStart(), "New AutoText", true); + XTextRange oTextRange = oText; + try { + if ( oGroup.hasByName("NewEntryName") ) { + oGroup.removeByName("NewEntryName"); + log.println("Element 'NewEntryName' exists, removing..."); + } + log.println("Adding new element 'NewEntryName' to group..."); + oGroup.insertNewByName("NewEntryName", "NewEntryTitle", oTextRange); + oEntry = (XAutoTextEntry) AnyConverter.toObject( + new Type(XAutoTextEntry.class),oGroup.getByName("NewEntryName")); + } catch ( com.sun.star.container.ElementExistException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + } + + oObj = oEntry; + + log.println("Trying to use XText as TextRange in the method applyTo"); + oEntry.applyTo(oTextRange); + + oTextRange = oText.createTextCursor(); + log.println("Trying to use XTextCursor as TextRange in the method applyTo"); + oEntry.applyTo(oTextRange); + + log.println( "creating a new environment for AutoTextEntry object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XText + DefaultDsc tDsc = new DefaultDsc("com.sun.star.text.XTextContent", + "com.sun.star.text.TextField.DateTime"); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXAutoTextEntry diff --git a/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.java new file mode 100644 index 000000000..eb9ff16e0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXAutoTextGroup.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._sw; + +import com.sun.star.container.XNameAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XAutoTextContainer; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +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 util.utils; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.AutoTextGroup</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</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> + * <li> <code>com::sun::star::text::XAutoTextGroup</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.XAutoTextGroup + * @see com.sun.star.text.AutoTextContainer + * @see ifc.container._XNamed + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._XAutoTextGroup + */ +public class SwXAutoTextGroup extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.AutoTextContainer</code>, then creates a new + * group into the container.<p> + * Object relations created : + * <ul> + * <li> <code>'TextRange'</code> for + * {@link ifc.text._XAutoTextGroup} range of text</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + XAutoTextContainer oContainer; + + log.println( "creating a test environment" ); + XMultiServiceFactory myMSF = Param.getMSF(); + Object oInst = myMSF.createInstance("com.sun.star.text.AutoTextContainer"); + oContainer = UnoRuntime.queryInterface(XAutoTextContainer.class,oInst); + String myGroupName="myNewGroup2*1"; + + XAutoTextContainer xATC = UnoRuntime.queryInterface(XAutoTextContainer.class, oContainer); + + try { + log.println("removing element with name '" + myGroupName + "'"); + xATC.removeByName(myGroupName); + } catch (com.sun.star.container.NoSuchElementException e) { + } + + log.println("adding element with name '" + myGroupName + "'"); + xATC.insertNewByName(myGroupName); + + XNameAccess oContNames = UnoRuntime.queryInterface(XNameAccess.class, oContainer); + + if (Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)){ + String contNames[] = oContNames.getElementNames(); + for (int i =0; i < contNames.length; i++){ + log.println("ContainerNames[ "+ i + "]: " + contNames[i]); + } + } + + oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class),oContNames.getByName(myGroupName)); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + log.println( "creating a new environment for AutoTextGroup object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XText oText = xTextDoc.getText(); + oText.insertString(oText.getStart(), "New AutoText", true); + + log.println( "adding TextRange as mod relation to environment" ); + tEnv.addObjRelation("TextRange", oText); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXAutoTextGroup diff --git a/qadevOOo/tests/java/mod/_sw/SwXBodyText.java b/qadevOOo/tests/java/mod/_sw/SwXBodyText.java new file mode 100644 index 000000000..e79c25993 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBodyText.java @@ -0,0 +1,136 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Text</code>.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXBodyText extends TestCase { + XTextDocument xTextDoc = null; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Obtains body text from text document. + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : text</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates 6x4 tables</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + + // get the bodytext of textdocument here + log.println( " getting the bodytext of textdocument with getText()" ); + oObj = xTextDoc.getText(); + + log.println( " creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println(" adding Text as ObjRelation"); + tEnv.addObjRelation("TEXT", oObj ); + + log.println( " adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXBodyText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXBookmark.java b/qadevOOo/tests/java/mod/_sw/SwXBookmark.java new file mode 100644 index 000000000..034a64b8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBookmark.java @@ -0,0 +1,101 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Bookmark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + */ +public class SwXBookmark extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After creating + * a bookmark, it is inserted to the text document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + XInterface oObj = null; + Object instance = null; + log.println( "creating a test environment" ); + oObj = SOfficeFactory.createBookmark( xTextDoc ); + SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj ); + instance = SOF.createInstance(xTextDoc,"com.sun.star.text.Bookmark"); + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + util.dbg.printInterfaces((XInterface) instance); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXBookmark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java b/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java new file mode 100644 index 000000000..3c830212e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXBookmarks.java @@ -0,0 +1,101 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.text.XBookmarksSupplier; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Bookmarks</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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + */ +public class SwXBookmarks extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. Method + * creates two bookmarks and inserts them to the text document. Then bookmarks + * are gotten from text document using <code>XBookmarksSupplier</code> + * interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + oObj = SOfficeFactory.createBookmark( xTextDoc ); + SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj ); + oObj = SOfficeFactory.createBookmark( xTextDoc ); + SOfficeFactory.insertTextContent( xTextDoc, (XTextContent) oObj ); + + XBookmarksSupplier oBSupp = UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDoc); + XNameAccess oBookNA = oBSupp.getBookmarks(); + oObj = oBookNA; + log.println( "creating a new environment for Bookmarks object" ); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXBookmarks + diff --git a/qadevOOo/tests/java/mod/_sw/SwXCell.java b/qadevOOo/tests/java/mod/_sw/SwXCell.java new file mode 100644 index 000000000..6773e5d59 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXCell.java @@ -0,0 +1,118 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is a cell of the table in a text document, and + * represented by service <code>com.sun.star.table.Cell</code><p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::CellProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.table.Cell + * @see com.sun.star.text.CellProperties + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._CellProperties + * @see ifc.beans._XPropertySet + */ +public class SwXCell extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After creating + * a text table, it is inserted to the text document. Finally, first cell of + * this table is gotten. + * Object relations created : + * <ul> + * <li> <code>'CellProperties.TextSection'</code> for + * {@link ifc.text._CellProperties} : range of complete paragraphs + * within a text</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextContent oTable = null; + + SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a test environment" ); + oTable = SOfficeFactory.createTextTable(xTextDoc, 3, 4); + try { + SOfficeFactory.insertTextContent( xTextDoc, oTable ); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Unable to insert TextContent..."); + e.printStackTrace(log); + } + oObj = SOfficeFactory.getFirstTableCell( oTable ); + + log.println( " creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + try { + XInterface oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + log.println(" adding TextSection object"); + tEnv.addObjRelation("CellProperties.TextSection", oTS); + } catch (com.sun.star.uno.Exception e) { + log.println("Could not get instance of TextSection"); + e.printStackTrace(log); + } + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXCell + diff --git a/qadevOOo/tests/java/mod/_sw/SwXCellRange.java b/qadevOOo/tests/java/mod/_sw/SwXCellRange.java new file mode 100644 index 000000000..7b60a1f6c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXCellRange.java @@ -0,0 +1,137 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.CellRange</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::CellProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.table.CellRange + * @see com.sun.star.text.CellProperties + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._CellProperties + * @see ifc.beans._XPropertySet + */ +public class SwXCellRange extends TestCase { + SOfficeFactory SOF; + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. At first + * method creates and initializes the table, then if text document has no + * tables, previously created table is inserted to text document. Finally, + * custom cell range is gotten from the table created. + * Object relations created : + * <ul> + * <li> <code>'CellProperties.TextSection'</code> for + * {@link ifc.text._CellProperties} : range of complete paragraphs + * within a text</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XTextTable the_table = null; + XInterface oObj = null; + the_table = SOfficeFactory.createTextTable( xTextDoc ); + the_table.initialize(5, 5); + + if( SOfficeFactory.getTableCollection( xTextDoc ).getCount() == 0 ) { + SOfficeFactory.insertTextContent(xTextDoc, the_table ); + } + XCellRange the_Range = UnoRuntime.queryInterface(XCellRange.class, the_table); + oObj = the_Range.getCellRangeByPosition(0, 0, 3, 4); + + log.println("Creating instance..."); + TestEnvironment tEnv = new TestEnvironment( oObj ); + log.println("ImplName: " + util.utils.getImplName(oObj)); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + try { + XInterface oTS = (XInterface) + oDocMSF.createInstance("com.sun.star.text.TextSection"); + log.println(" adding TextSection object"); + tEnv.addObjRelation("CellProperties.TextSection", oTS); + } catch (com.sun.star.uno.Exception e) { + log.println("Could not get instance of TextSection"); + e.printStackTrace(log); + } + + Object[][] NewData = new Object[5][]; + NewData[0] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[1] = new Double[] + {new Double(4),new Double(9),new Double(2.5),new Double(5)}; + NewData[2] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[3] = new Double[] + {new Double(2.5),new Double(5),new Double(2.5),new Double(5)}; + NewData[4] = new Double[] + {new Double(4),new Double(9),new Double(2.5),new Double(5)}; + tEnv.addObjRelation("NewData",NewData); + + // com::sun::star::chart::XChartDataArray + tEnv.addObjRelation("CRDESC", + "Column and RowDescriptions can't be changed for this Object"); + + + return tEnv; + } +} // finish class SwXCellRange + diff --git a/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java b/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java new file mode 100644 index 000000000..b219a82a0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXChapterNumbering.java @@ -0,0 +1,108 @@ +/* + * 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._sw; + +import com.sun.star.beans.PropertyValue; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XChapterNumberingSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object, which is a collection of chapter numbering rules of document. + * Object implements the following interfaces: + * <ul> + * <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::text::NumberingRules</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.NumberingRules + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._NumberingRules + */ +public class SwXChapterNumbering extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. Chapter + * numbering rules are gotten from text document using interface + * <code>XChapterNumberingSupplier</code>. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + XChapterNumberingSupplier oCNSupp = UnoRuntime.queryInterface(XChapterNumberingSupplier.class,xTextDoc); + oObj = oCNSupp.getChapterNumberingRules(); + + PropertyValue[] instance1 = null; + try { + instance1 = (PropertyValue[]) oCNSupp.getChapterNumberingRules().getByIndex(1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + } + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("INSTANCE1", instance1); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXChapterNumbering + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java new file mode 100644 index 000000000..94ff90072 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndex.java @@ -0,0 +1,118 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.DocumentIndex</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XDocumentIndex</code></li> + * <li> <code>com::sun::star::text::BaseIndex</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::DocumentIndex</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XDocumentIndex + * @see com.sun.star.text.BaseIndex + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.DocumentIndex + * @see ifc.lang._XComponent + * @see ifc.text._XDocumentIndex + * @see ifc.text._BaseIndex + * @see ifc.text._XTextContent + * @see ifc.text._DocumentIndex + */ +public class SwXDocumentIndex extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.DocumentIndex</code>, then created document index + * is inserted to the text of the document as content. + * + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + XTextContent xTC = null; + Object instance = null; + + SOfficeFactory.getFactory(tParam.getMSF()); + log.println( "creating a test environment" ); + xTC = SOfficeFactory.createIndex(xTextDoc, "com.sun.star.text.DocumentIndex"); + instance = SOfficeFactory.createIndex(xTextDoc, "com.sun.star.text.DocumentIndex"); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the Index into text document"); + oText.insertTextContent(oCursor, xTC, false); + + TestEnvironment tEnv = new TestEnvironment(xTC); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + oCursor.gotoEnd(false); + tEnv.addObjRelation("RANGE", UnoRuntime.queryInterface(XTextRange.class, oCursor)); + + // relation for XDocumentIndex + tEnv.addObjRelation("TextDoc", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXDocumentIndex + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java new file mode 100644 index 000000000..1e18e920f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexMark.java @@ -0,0 +1,124 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDocumentIndexMark; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.DocumentIndexMark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::BaseIndexMark</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * <li> <code>com::sun::star::text::DocumentIndexMark</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.BaseIndexMark + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.DocumentIndexMark + * @see ifc.lang._XComponent + * @see ifc.text._BaseIndexMark + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + * @see ifc.text._DocumentIndexMark + */ +public class SwXDocumentIndexMark extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.DocumentIndexMark</code>, attaches text to + * created DocumentIndexMark, and inserts DocumentIndexMark to the + * text document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + Object oDIM = null; + Object instance = null; + try { + oDIM = oDocMSF.createInstance + ("com.sun.star.text.DocumentIndexMark"); + instance = oDocMSF.createInstance + ("com.sun.star.text.DocumentIndexMark"); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Error:" + e); + } + + XDocumentIndexMark xDIM = UnoRuntime.queryInterface(XDocumentIndexMark.class, oDIM); + + oText.insertTextContent(oCursor, xDIM, false); + + TestEnvironment tEnv = new TestEnvironment(xDIM); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + + } // finish method getTestEnvironment + + } // finish class SwXDocumentIndexMark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java new file mode 100644 index 000000000..06459e4d7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDocumentIndexes.java @@ -0,0 +1,108 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XDocumentIndexesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for the object, which is represented by collection of document indexes. + * Object implements the following interfaces: + * <ul> + * <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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXDocumentIndexes extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.ContentIndex</code>, then created content index is + * inserted to the text document, and finally all document indexes are gotten + * from a text document using <code>XDocumentIndexesSupplier</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws Exception { + XInterface oObj = null; + SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a test environment" ); + XTextContent xTC = SOfficeFactory.createIndex(xTextDoc,"com.sun.star.text.ContentIndex"); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the Index into text document"); + oText.insertTextContent(oCursor, xTC, false); + + XDocumentIndexesSupplier xDocInd = UnoRuntime.queryInterface(XDocumentIndexesSupplier.class,xTextDoc); + + oObj = xDocInd.getDocumentIndexes(); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXDocumentIndexes + diff --git a/qadevOOo/tests/java/mod/_sw/SwXDrawPage.java b/qadevOOo/tests/java/mod/_sw/SwXDrawPage.java new file mode 100644 index 000000000..d6d44644e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXDrawPage.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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.ShapeDsc; + +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShapes; +import com.sun.star.text.XTextDocument; +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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @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 SwXDrawPage extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After + * obtaining DrawPage object several shapes are inserted to it. + * Object relations created : + * <ul> + * <li> <code>'Shape'</code> for + * {@link ifc.drawing._XShapes} : shape creator. </li> + * <li> <code>'DrawPage'</code> for + * {@link ifc.drawing._XShapeBinder}, + * {@link ifc.drawing._XShapeCombiner}, + * {@link ifc.drawing._XShapeGrouper} : DrawPage component we are + * testing.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XDrawPageSupplier XDPSupp; + XDrawPage xDP = null; + XShapes oShapes = null; + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + XDPSupp = UnoRuntime.queryInterface + (XDrawPageSupplier.class, xTextDoc); + xDP = XDPSupp.getDrawPage(); + oObj = xDP; + + log.println( "inserting some Shapes" ); + oShapes = UnoRuntime.queryInterface(XShapes.class, oObj); + oShapes.add(SOF.createShape(xTextDoc,2000,1500,1000,1000,"Line")); + oShapes.add(SOF.createShape(xTextDoc,3000,4500,15000,1000,"Ellipse")); + oShapes.add(SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle")); + + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + ShapeDsc sDsc = new ShapeDsc(15000,13500,7500,10000,"Rectangle"); + log.println( "adding Shape as mod relation to environment" ); + tEnv.addObjRelation("Shape", new InstCreator( xTextDoc, sDsc)); + tEnv.addObjRelation("DrawPage", oObj); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXDrawPage + diff --git a/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.java b/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.java new file mode 100644 index 000000000..c2dbba2d7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXEndnoteProperties.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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.dbg; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XEndnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.FootnoteSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::FootnoteSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.FootnoteSettings + * @see ifc.text._FootnoteSettings + */ +public class SwXEndnoteProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Endnote</code>. Then created endnote is inserted + * to the text document, and finally endnote settings are gotten from text + * document using <code>XEndnotesSupplier</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XEndnotesSupplier oInterface = null; + XInterface oObj = null; + XInterface oEndnote; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating an endnote"); + oEndnote = UnoRuntime.queryInterface(XInterface.class, + msf.createInstance("com.sun.star.text.Endnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + XTextContent xTC = UnoRuntime.queryInterface(XTextContent.class, oEndnote); + oText.insertTextContent(oCursor, xTC, false); + + oInterface = UnoRuntime.queryInterface(XEndnotesSupplier.class, xTextDoc); + oObj = oInterface.getEndnoteSettings(); + dbg.printPropertiesNames((XPropertySet) oObj); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java new file mode 100644 index 000000000..dcfbf1c2f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFieldEnumeration.java @@ -0,0 +1,156 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XEnumeration</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XEnumeration + * @see ifc.container._XEnumeration + */ +public class SwXFieldEnumeration extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. FieldMaster + * object is created and attached to Bibliography database. After setting + * properties of created FieldMaster object, it is attached to the TextField + * object. Then TextField is inserted as TextContent to the text document. + * At the end, TextFields of text document are obtained and + * enumeration of these fields is created.<br> + * Creates instances of the services: + * <code>com.sun.star.text.FieldMaster.Database</code>, + * <code>com.sun.star.text.TextField.Database</code>.<br> + * Object relations created : + * <ul> + * <li> <code>'ENUM'</code> for + * {@link ifc.container._XEnumeration} : text fields</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + Object FieldMaster = null; + XPropertySet PFieldMaster = null; + XDependentTextField xTF = null; + XEnumerationAccess xFEA = null; + XText the_Text; + XTextCursor the_Cursor; + XTextContent the_Field; + + log.println( "creating a test environment" ); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDoc ); + + try { + FieldMaster = oDocMSF.createInstance + ( "com.sun.star.text.FieldMaster.Database" ); + PFieldMaster = UnoRuntime.queryInterface + (XPropertySet.class,FieldMaster); + oObj = (XInterface) + oDocMSF.createInstance("com.sun.star.text.TextField.Database"); + xTF = UnoRuntime.queryInterface(XDependentTextField.class,oObj); + } catch ( com.sun.star.uno.Exception e ) { + e.printStackTrace(log); + } + + try { + PFieldMaster.setPropertyValue("DataBaseName","Bibliography"); + PFieldMaster.setPropertyValue("DataTableName","biblio"); + PFieldMaster.setPropertyValue("DataColumnName","Address"); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.PropertyVetoException e ) { + log.println("Error: can't set PropertyValue to a FieldMaster"); + e.printStackTrace(log); + } + + the_Text = xTextDoc.getText(); + the_Cursor = the_Text.createTextCursor(); + the_Field = UnoRuntime.queryInterface(XTextContent.class, oObj); + + xTF.attachTextFieldMaster(PFieldMaster); + the_Text.insertTextContent(the_Cursor,the_Field,false); + + // create testobject here + XTextFieldsSupplier oTFS = UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + xFEA = oTFS.getTextFields(); + oObj = oTFS.getTextFields().createEnumeration(); + + log.println( "creating a new environment for FieldEnumeration object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("ENUM", xFEA); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFieldEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java b/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java new file mode 100644 index 000000000..ce1009e05 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFieldMaster.java @@ -0,0 +1,99 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.FieldMaster.Database</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::TextFieldMaster</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.TextFieldMaster + * @see com.sun.star.text.FieldMaster.Database + * @see com.sun.star.beans.XPropertySet + * @see ifc.text._TextFieldMaster + * @see ifc.beans._XPropertySet + */ +public class SwXFieldMaster extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.FieldMaster.Database</code>. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + try { + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDoc ); + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.FieldMaster.Database" ); + } catch ( com.sun.star.uno.Exception e ) { + log.println("Couldn't create instance"); + e.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMaster object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFieldMaster + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnote.java b/qadevOOo/tests/java/mod/_sw/SwXFootnote.java new file mode 100644 index 000000000..745e3d69c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnote.java @@ -0,0 +1,134 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FrameDsc; +import util.InstCreator; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Footnote</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XFootnote</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::Footnote</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XFootnote + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.Footnote + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XText + * @see ifc.text._XFootnote + * @see ifc.lang._XComponent + * @see ifc.text._XSimpleText + * @see ifc.text._Footnote + * @see ifc.text._XTextContent + * @see ifc.text._XTextRange + * @see ifc.text._XText + */ +public class SwXFootnote extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created footnote + * to a text of document as content. + * Object relations created : + * <ul> + * <li><code>'XTEXTINFO'</code> for + * {@link ifc.text._XText} </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XFootnote oFootnote; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + Object instance = null; + oFootnote = UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + instance = msf.createInstance("com.sun.star.text.Footnote"); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + oText.insertTextContent(oCursor, oFootnote, false); + + TestEnvironment tEnv = new TestEnvironment(oFootnote); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + log.println( "adding InstDescriptor object" ); + FrameDsc tDsc = new FrameDsc( 3000, 6000 ); + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + return tEnv; + } + +} // finish class SwXFootnote + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java b/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java new file mode 100644 index 000000000..c86bc30c7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnoteProperties.java @@ -0,0 +1,108 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for the object, which is represented as set of footnote properties + * (instance of <code>com.sun.star.text.FootnoteSettings</code> service). + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::FootnoteSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.FootnoteSettings + * @see ifc.text._FootnoteSettings + */ +public class SwXFootnoteProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text document, and finally gets footnote settings from text + * document through <code>XFootnotesSupplier</code> interface.<br> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XFootnotesSupplier oInterface = null; + XInterface oObj = null; + XFootnote oFootnote; + + log.println( "Creating a test environment" ); + // get a soffice factory object + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + oFootnote = UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + oText.insertTextContent(oCursor, oFootnote, false); + + oInterface = UnoRuntime.queryInterface(XFootnotesSupplier.class, xTextDoc); + oObj = oInterface.getFootnoteSettings(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java b/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java new file mode 100644 index 000000000..374e89c66 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnoteText.java @@ -0,0 +1,151 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TextSectionDsc; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXFootnoteText extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text, and finally sets a string to the footnote. Then the text + * gotten from the footnote is returned as tested component.<br> + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : footnote text</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : text section creator</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws Exception { + XInterface oObj = null; + XFootnote oFootnote; + + log.println( "creating a test environment" ); + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + + oFootnote = UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + oText.insertTextContent(oCursor, oFootnote, false); + + XSimpleText oFootText = UnoRuntime.queryInterface(XSimpleText.class, oFootnote); + oFootText.setString("SwXFootnoteText"); + + oObj = oFootText.getText(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXT", oObj); + + TextSectionDsc tDsc = new TextSectionDsc(); + log.println( " adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFootnoteText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java b/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java new file mode 100644 index 000000000..d62e20971 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFootnotes.java @@ -0,0 +1,110 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Footnotes</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> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXFootnotes extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.Footnote</code>. Then inserts created Footnote + * to the text, and finally gets all footnotes of text document + * through <code>XFootnotesSupplier</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XFootnotesSupplier oInterface = null; + XInterface oObj = null; + + log.println( "Creating a test environment" ); + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + log.println("creating a footnote"); + XFootnote oFootnote; + + oFootnote = UnoRuntime.queryInterface(XFootnote.class, + msf.createInstance("com.sun.star.text.Footnote")); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting the footnote into text document"); + oText.insertTextContent(oCursor, oFootnote, false); + oInterface = UnoRuntime.queryInterface(XFootnotesSupplier.class, xTextDoc); + oObj = oInterface.getFootnotes(); + + log.println( "creating a new environment for Footnotes object" ); + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } + +} // finish class SwXFootnote + diff --git a/qadevOOo/tests/java/mod/_sw/SwXFrames.java b/qadevOOo/tests/java/mod/_sw/SwXFrames.java new file mode 100644 index 000000000..5a85e0bfe --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXFrames.java @@ -0,0 +1,116 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextFramesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XContainer</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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see ifc.container._XContainer + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXFrames extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.TextFrame</code>. Then inserts created text frame + * to the text, and finally gets all frames of text document using + * <code>XTextFramesSupplier</code> interface.<br> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XInterface oObj = null; + XTextFrame oFrame1 = null; + XText oText = null; + XTextCursor oCursor = null; + XMultiServiceFactory oDocMSF = null; + XTextFramesSupplier oInterface = null; + + log.println( "creating a test environment" ); + oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object oInt = oDocMSF.createInstance("com.sun.star.text.TextFrame"); + oFrame1 = UnoRuntime.queryInterface( XTextFrame.class, oInt ); + + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + oText.insertTextContent(oCursor, oFrame1, false); + + oInterface = UnoRuntime.queryInterface( XTextFramesSupplier.class, xTextDoc ); + + oObj = oInterface.getTextFrames(); + + log.println( "creating a new environment for Frame object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXFrames + diff --git a/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java b/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java new file mode 100644 index 000000000..7ac8e02e6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXHeadFootText.java @@ -0,0 +1,158 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameAccess; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXHeadFootText extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. At first + * style families are obtained from text document, then style 'Standard' has + * gotten from style family 'PageStyles'. At the end, document header and + * footer are switched on and document text is obtained. + * Object relations created : + * <ul> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates tables 6x4</li> + * <li> <code>'TEXTDOC'</code> for + * {@link ifc.text._XTextRangeCompare} : text document</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + XInterface oObj = null; + XPropertySet PropSet; + XNameAccess PageStyles = null; + XStyle StdStyle = null; + + log.println( "creating a test environment" ); + XStyleFamiliesSupplier StyleFam = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess StyleFamNames = StyleFam.getStyleFamilies(); + + // obtains style 'Standard' from style family 'PageStyles' + PageStyles = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),StyleFamNames.getByName("PageStyles")); + StdStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),PageStyles.getByName("Standard")); + + PropSet = UnoRuntime.queryInterface( XPropertySet.class, StdStyle); + + // changing/getting some properties + log.println( "Switching on header" ); + PropSet.setPropertyValue("HeaderIsOn", Boolean.TRUE); + log.println( "Switching on footer" ); + PropSet.setPropertyValue("FooterIsOn", Boolean.TRUE); + log.println( "Get header text" ); + oObj = UnoRuntime.queryInterface( + XText.class, PropSet.getPropertyValue("HeaderText")); + + log.println( "creating a new environment for bodytext object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + log.println( "adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + tEnv.addObjRelation( "TEXT", oObj); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXHeadFootText diff --git a/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java b/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java new file mode 100644 index 000000000..815493062 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXLineNumberingProperties.java @@ -0,0 +1,106 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.dbg; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XLineNumberingProperties; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.LineNumberingProperties</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::LineNumberingProperties</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.LineNumberingProperties + * @see ifc.text._LineNumberingProperties + */ +public class SwXLineNumberingProperties extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. After inserting + * string and control character to the text document, line numbering + * properties are gotten using <code>XLineNumberingProperties</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + + // insert some Text + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + try { + for (int i=0; i<5; i++) { + oText.insertString(oCursor, "The quick brown fox jumps "+ + "over the lazy Dog", false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + log.println("Exception occurred: " + e); + } + + XLineNumberingProperties oLNP = UnoRuntime.queryInterface(XLineNumberingProperties.class,xTextDoc); + XPropertySet lineNumProps = oLNP.getLineNumberingProperties(); + dbg.printPropertiesNames(lineNumProps); + TestEnvironment tEnv = new TestEnvironment(lineNumProps); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXLineNumberingProperties + diff --git a/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java b/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java new file mode 100644 index 000000000..f3bb2b2f2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXMailMerge.java @@ -0,0 +1,355 @@ +/* + * 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._sw; + +import com.sun.star.beans.NamedValue; + +import util.DBTools; +import util.utils; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.*; +import com.sun.star.sdbcx.XRowLocate; +import com.sun.star.task.XJob; +import com.sun.star.text.MailMergeType; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +/** +* Here <code>com.sun.star.text.MailMerge</code> service is tested.<p> +* @see com.sun.star.text.MailMerge +* @see com.sun.star.task.XJob +* @see com.sun.star.text.XMailMergeBroadcaster +*/ +public class SwXMailMerge extends TestCase { + + @Override + public void initialize( TestParameters Param, PrintWriter log ) { + if (! Param.containsKey("uniqueSuffix")){ + Param.put("uniqueSuffix", Integer.valueOf(0)); + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. <p> + * Creates <code>MailMerge</code> service * Object relations created : + * <ul> + * <li> <code>'executeArgs'</code> for + * {@link ifc.text._XMailMergeBroadcaster} : NamedValue[]</li> + * <li> <code>'Job'</code> for + * {@link ifc.text._XMailMergeBroadcaster} : XJob</li> + * <li> <code>'XJobArgs'</code> for + * {@link ifc.task._XJob} : Object[]</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + XInterface oRowSet = null; + XJob Job = null; + + log.println(" instantiate MailMerge service"); + oObj = (XInterface) Param.getMSF().createInstance + ("com.sun.star.text.MailMerge"); + + // <set some variables> + String cTestDoc = utils.getFullTestURL("MailMerge.sxw"); + //cMailMerge_DocumentURL = cTestDoc + String cOutputURL = utils.getOfficeTemp( Param.getMSF()); + String cDataSourceName = "Bibliography"; + String cDataCommand = "biblio"; + Object[] myBookMarks = new Object[2]; + // </set some variables> + + // <create XResultSet> + log.println("create a XResultSet"); + oRowSet = (XInterface) Param.getMSF().createInstance + ("com.sun.star.sdb.RowSet"); + XPropertySet oRowSetProps = UnoRuntime.queryInterface(XPropertySet.class, oRowSet); + XRowSet xRowSet = UnoRuntime.queryInterface(XRowSet.class, oRowSet); + oRowSetProps.setPropertyValue("DataSourceName",cDataSourceName); + oRowSetProps.setPropertyValue("Command",cDataCommand); + oRowSetProps.setPropertyValue("CommandType", Integer.valueOf(CommandType.TABLE)); + xRowSet.execute(); + + XResultSet oResultSet = UnoRuntime.queryInterface(XResultSet.class, oRowSet); + + + + + // <create Bookmarks> + log.println("create bookmarks"); + XRowLocate oRowLocate = UnoRuntime.queryInterface( + XRowLocate.class, oResultSet); + oResultSet.first(); + myBookMarks[0] = oRowLocate.getBookmark(); + oResultSet.next(); + myBookMarks[1] = oRowLocate.getBookmark(); + // </create Bookmarks> + + // <fill object with values> + + log.println("fill MailMerge with default connection"); + + XPropertySet oObjProps = UnoRuntime.queryInterface(XPropertySet.class, oObj); + oObjProps.setPropertyValue("ActiveConnection", getLocalXConnection(Param)); + oObjProps.setPropertyValue("DataSourceName", cDataSourceName); + oObjProps.setPropertyValue("Command", cDataCommand); + oObjProps.setPropertyValue("CommandType", Integer.valueOf(CommandType.TABLE)); + oObjProps.setPropertyValue("OutputType", Short.valueOf(MailMergeType.FILE)); + oObjProps.setPropertyValue("DocumentURL", cTestDoc); + oObjProps.setPropertyValue("OutputURL", cOutputURL); + oObjProps.setPropertyValue("FileNamePrefix", "Author"); + oObjProps.setPropertyValue("FileNameFromColumn", Boolean.FALSE); + oObjProps.setPropertyValue("Selection", new Object[0]); + + // </fill object with values> + + + // <create object relations> + Object[] vXJobArgs = new Object[4]; + NamedValue[] vXJobArg0 = new NamedValue[8]; + NamedValue[] vXJobArg1 = new NamedValue[7]; + NamedValue[] vXJobArg2 = new NamedValue[10]; + NamedValue[] vXJobArg3 = new NamedValue[0]; + + // first Arguments + vXJobArg0[0] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg0[1] = new NamedValue("Command", cDataCommand); + vXJobArg0[2] = new NamedValue("CommandType",Integer.valueOf(CommandType.TABLE)); + vXJobArg0[3] = new NamedValue("OutputType",Short.valueOf(MailMergeType.FILE)); + vXJobArg0[4] = new NamedValue("DocumentURL", cTestDoc); + vXJobArg0[5] = new NamedValue("OutputURL", cOutputURL); + vXJobArg0[6] = new NamedValue("FileNamePrefix", "Identifier"); + vXJobArg0[7] = new NamedValue("FileNameFromColumn", Boolean.TRUE); + + //second Arguments + vXJobArg1[0] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg1[1] = new NamedValue("Command", cDataCommand); + vXJobArg1[2] = new NamedValue("CommandType",Integer.valueOf(CommandType.TABLE)); + vXJobArg1[3] = new NamedValue("OutputType", + Short.valueOf(MailMergeType.PRINTER)); + vXJobArg1[4] = new NamedValue("DocumentURL", cTestDoc); + vXJobArg1[5] = new NamedValue("FileNamePrefix", "Author"); + vXJobArg1[6] = new NamedValue("FileNameFromColumn", Boolean.TRUE); + + // third Arguments + vXJobArg2[0] = new NamedValue("ActiveConnection", getLocalXConnection(Param)); + vXJobArg2[1] = new NamedValue("DataSourceName", cDataSourceName); + vXJobArg2[2] = new NamedValue("Command", cDataCommand); + vXJobArg2[3] = new NamedValue("CommandType",Integer.valueOf(CommandType.TABLE)); + vXJobArg2[4] = new NamedValue("OutputType", + Short.valueOf(MailMergeType.FILE)); + vXJobArg2[5] = new NamedValue("ResultSet", oResultSet); + vXJobArg2[6] = new NamedValue("OutputURL", cOutputURL); + vXJobArg2[7] = new NamedValue("FileNamePrefix", "Identifier"); + vXJobArg2[8] = new NamedValue("FileNameFromColumn", Boolean.TRUE); + vXJobArg2[9] = new NamedValue("Selection", myBookMarks); + + vXJobArgs[0] = vXJobArg0; + vXJobArgs[1] = vXJobArg1; + vXJobArgs[2] = vXJobArg2; + vXJobArgs[3] = vXJobArg3; + + + Job = UnoRuntime.queryInterface(XJob.class, oObj); + try{ + Job.execute(vXJobArg2); + } catch ( IllegalArgumentException e){ + System.out.println(e.toString()); + } catch ( Exception e){ + System.out.println(e.toString()); + } + + + // <create XResultSet> + log.println("create XResultSet"); + + oRowSet = (XInterface) Param.getMSF().createInstance + ("com.sun.star.sdb.RowSet"); + oRowSetProps = UnoRuntime.queryInterface(XPropertySet.class, oRowSet); + + xRowSet = UnoRuntime.queryInterface(XRowSet.class, oRowSet); + + oRowSetProps.setPropertyValue("DataSourceName",cDataSourceName); + oRowSetProps.setPropertyValue("Command",cDataCommand); + oRowSetProps.setPropertyValue("CommandType", Integer.valueOf(CommandType.TABLE)); + xRowSet.execute(); + + oResultSet = UnoRuntime.queryInterface(XResultSet.class, oRowSet); + + XResultSet oMMXResultSet = null; + oMMXResultSet = UnoRuntime.queryInterface(XResultSet.class, + Param.getMSF().createInstance("com.sun.star.sdb.RowSet")); + // </create object relations> + + TestEnvironment tEnv = new TestEnvironment(oObj) ; + + // <adding object relations> + + // com.sun.star.sdb.DataAccessDescriptor + tEnv.addObjRelation("DataAccessDescriptor.XResultSet", oResultSet); + tEnv.addObjRelation("DataAccessDescriptor.XConnection", getRemoteXConnection(Param)); + + // com.sun.star.text.MailMerge + tEnv.addObjRelation("MailMerge.XConnection", getRemoteXConnection(Param)); + tEnv.addObjRelation("MailMerge.XResultSet", oMMXResultSet); + + // com.sun.star.text.XMailMergeBroadcaster + tEnv.addObjRelation( "executeArgs", vXJobArg0); + tEnv.addObjRelation( "Job", Job); + + // com.sun.star.task.XJob + tEnv.addObjRelation("XJobArgs", vXJobArgs); + + // </adding object relations> + + return tEnv ; + } + + private XConnection getRemoteXConnection(TestParameters Param){ + + log.println("create remote connection"); + + String databaseName = null ; + XMultiServiceFactory xMSF = null ; + int uniqueSuffix = Param.getInt("uniqueSuffix"); + + try { + xMSF = Param.getMSF(); + xMSF.createInstance( "com.sun.star.sdb.DatabaseContext" ); + + // retrieving temp directory for database + String tmpDatabaseUrl = utils.getOfficeTempDir(Param.getMSF()); + + databaseName = "NewDatabaseSource" + uniqueSuffix ; + + String tmpDatabaseFile = tmpDatabaseUrl + databaseName + ".odb"; + System.out.println("try to delete '"+tmpDatabaseFile+"'"); + utils.deleteFile(Param.getMSF(), tmpDatabaseFile); + + + tmpDatabaseUrl = "sdbc:dbase:file:///" + tmpDatabaseUrl ; + + // Creating new DBase data source in the TEMP directory + XInterface newSource = (XInterface) xMSF.createInstance + ("com.sun.star.sdb.DataSource") ; + + XPropertySet xSrcProp = UnoRuntime.queryInterface(XPropertySet.class, newSource); + + xSrcProp.setPropertyValue("URL", tmpDatabaseUrl) ; + + DBTools dbt = new DBTools( Param.getMSF() ); + // registering source in DatabaseContext + log.println("register database '"+tmpDatabaseUrl+"' as '"+databaseName+"'" ); + dbt.reRegisterDB(databaseName, newSource) ; + + uniqueSuffix++; + Param.put("uniqueSuffix", Integer.valueOf(uniqueSuffix)); + + return dbt.connectToSource(newSource); + } + catch( Exception e ) { + uniqueSuffix++; + Param.put("uniqueSuffix", Integer.valueOf(uniqueSuffix)); + log.println("could not register new database" ); + e.printStackTrace(); + throw new StatusException("could not register new database", e) ; + } + } + + private XConnection getLocalXConnection(TestParameters Param){ + + log.println("create local connection"); + + XInterface oDataCont = null; + try { + oDataCont = (XInterface)Param.getMSF().createInstance + ("com.sun.star.sdb.DatabaseContext"); + } catch(Exception e) { + throw new StatusException("Couldn't create instance of 'com.sun.star.sdb.DatabaseContext'", e); + } + XNameAccess xNADataCont = UnoRuntime.queryInterface(XNameAccess.class, oDataCont); + + String[] dataNames = xNADataCont.getElementNames(); + + String dataName=""; + for (int i = 0; i < dataNames.length; i++){ + if (dataNames[i].startsWith("Biblio")) dataName=dataNames[i]; + } + + try{ + + Object oDataBase = xNADataCont.getByName(dataName); + XDataSource xDataSource = UnoRuntime.queryInterface(XDataSource.class, oDataBase); + + return xDataSource.getConnection("",""); + + } catch ( NoSuchElementException e){ + throw new StatusException("Couldn't get registered data base", e); + } catch ( WrappedTargetException e){ + throw new StatusException("Couldn't get registered data base", e); + } catch ( SQLException e){ + throw new StatusException("Couldn't get XConnection from registered data base", e); + } + + } + + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("closing connections..."); + XMultiServiceFactory xMsf = Param.getMSF(); + DBTools dbt = new DBTools( xMsf ); + + if (Param.containsKey("uniqueSuffix")){ + int uniqueSuffix = Param.getInt("uniqueSuffix"); + uniqueSuffix--; + String databaseName = ""; + while (uniqueSuffix >= 0){ + + databaseName = "NewDatabaseSource" + uniqueSuffix ; + + log.println("revoke '"+databaseName+"'"); + + try{ + dbt.revokeDB(databaseName); + } catch (com.sun.star.uno.Exception e){ + } + + uniqueSuffix--; + } + } + + } + +} + + diff --git a/qadevOOo/tests/java/mod/_sw/SwXModule.java b/qadevOOo/tests/java/mod/_sw/SwXModule.java new file mode 100644 index 000000000..6d074c86f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXModule.java @@ -0,0 +1,65 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.GlobalSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::view::XPrintSettingsSupplier</code></li> + * <li> <code>com::sun::star::view::XViewSettingsSupplier</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.view.XPrintSettingsSupplier + * @see com.sun.star.view.XViewSettingsSupplier + * @see ifc.view._XPrintSettingsSupplier + * @see ifc.view._XViewSettingsSupplier + */ +public class SwXModule extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.GlobalSettings</code>. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + Object oInterface = Param.getMSF().createInstance( + "com.sun.star.text.GlobalSettings" ); + XInterface oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXModule + diff --git a/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java b/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java new file mode 100644 index 000000000..cfc957228 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXNumberingRules.java @@ -0,0 +1,162 @@ +/* + * 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._sw; + +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.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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.text.NumberingRules</code>.<p> + * Object implements the following interfaces : + * <ul> + * <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::text::NumberingRules</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.NumberingRules + * @see ifc.beans._XPropertySet + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.text._NumberingRules + */ +public class SwXNumberingRules extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * At first some strings are inserted to a text document, then style families + * are gotten from text document using <code>XStyleFamiliesSupplier</code>. + * Then style family 'NumberingRules' is retrieved, then style indexed '0' + * is obtained. At the end property value 'NumberingRules' is obtained from + * given style. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + XInterface oObj = null; + XIndexAccess NumStyleI = null; + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + try { + for (int i=0; i<5; i++) { + oText.insertString(oCursor, "The quick brown fox jumps "+ + "over the lazy Dog", false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + XStyleFamiliesSupplier oStyleFamiliesSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + + try { + XNameAccess oStyleFamilies = oStyleFamiliesSupplier.getStyleFamilies(); + XNameContainer NumStyles = (XNameContainer) AnyConverter.toObject( + new Type(XNameContainer.class), + oStyleFamilies.getByName("NumberingStyles")); + NumStyleI = UnoRuntime.queryInterface(XIndexAccess.class,NumStyles); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error, no such style family..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + Object instance1 = null; + + try { + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),NumStyleI.getByIndex(0)); + XPropertySet props = UnoRuntime.queryInterface(XPropertySet.class, oObj); + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),props.getPropertyValue("NumberingRules")); + XIndexAccess nRules = UnoRuntime.queryInterface(XIndexAccess.class, props.getPropertyValue("NumberingRules")); + instance1 = nRules.getByIndex(0); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred..."); + e.printStackTrace(log); + } + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("INSTANCE1", instance1); + return tEnv; + } + +} // finish class SwXNumberingRules diff --git a/qadevOOo/tests/java/mod/_sw/SwXParagraph.java b/qadevOOo/tests/java/mod/_sw/SwXParagraph.java new file mode 100644 index 000000000..c32d63b28 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXParagraph.java @@ -0,0 +1,225 @@ +/* + * 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._sw; + +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.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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.XCloseable; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Paragraph</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * <li> <code>com::sun::star::text::TextContent</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.TextContent + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.lang.XComponent + * @see com.sun.star.style.CharacterPropertiesAsian + * @see com.sun.star.text.Paragraph + * @see ifc.text._XTextContent + * @see ifc.text._TextContent + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.beans._XPropertySet + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.beans._XPropertyState + * @see ifc.style._CharacterProperties + * @see ifc.style._ParagraphProperties + * @see ifc.lang._XComponent + * @see ifc.style._CharacterPropertiesAsian + */ +public class SwXParagraph extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + + /** + * Creating a TestEnvironment for the interfaces to be tested. To obtain + * test component, at first several paragraphs are inserted to a major text + * of text document. Then enumeration of text paragraphs is created, and + * some paragraph is gotten using <code>XEnumeration</code> interface.<p> + * Object relations created : + * <ul> + * <li> <code>'PARA'</code> for + * {@link ifc.style._CharacterProperties} : paragraph </li> + * <li> <code>'PORTION'</code> for + * {@link ifc.style._CharacterProperties} : some text portion of + * paragraph. To obtain text portion, enumeration of paragraph text portions is + * created, and some text portion is gotten using <code>XEnumeration</code> + * interface. </li> + * <li> <code>'NRULES'</code> for + * {@link ifc.style._ParagraphProperties} : value of property + * 'NumberingRules' of paragraph. Method changes property + * 'NumberingStyleName' of previously obtained paragraph, and gets value of + * a property 'NumberingRules'. </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + if (xTextDoc != null) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + XInterface oObj = null; + XPropertySet paraP = null; + XPropertySet portP = null; + Object nRules = null; + XInterface port = null; + XInterface para = null; + + log.println( "creating a test environment" ); + + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some lines" ); + for (int i=0; i<5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( + oCursor, ControlCharacter.LINE_BREAK, false ); + } + + // Enumeration + XEnumerationAccess oEnumA = UnoRuntime.queryInterface(XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + try { + para = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + XEnumerationAccess oEnumB = UnoRuntime.queryInterface( XEnumerationAccess.class, para ); + XEnumeration oEnum2 = oEnumB.createEnumeration(); + port = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum2.nextElement()); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.container.NoSuchElementException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + e.printStackTrace(log); + log.println("Error: exception occurred..."); + } + + portP = UnoRuntime.queryInterface(XPropertySet.class, port); + paraP = UnoRuntime.queryInterface(XPropertySet.class, para); + paraP.setPropertyValue("NumberingStyleName","Numbering IVX"); + nRules = paraP.getPropertyValue("NumberingRules"); + + + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class),oEnum.nextElement()); + + + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println("adding ObjectRelation 'PARA' for CharacterProperties"); + tEnv.addObjRelation("PARA", paraP); + + log.println("adding ObjectRelation 'PORTION' for CharacterProperties"); + tEnv.addObjRelation("PORTION", portP); + + log.println("adding ObjectRelation 'NRULES' for ParagraphProperties"); + tEnv.addObjRelation("NRULES", nRules); + + tEnv.addObjRelation("NoAttach","SwXParagraph"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXParagraph + diff --git a/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java new file mode 100644 index 000000000..3e17bfce3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXParagraphEnumeration.java @@ -0,0 +1,141 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ParagraphEnumeration</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XEnumeration</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XEnumeration + * @see ifc.container._XEnumeration + */ +public class SwXParagraphEnumeration extends TestCase { + XTextDocument xTextDoc = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After major + * text is gotten from a text document, three paragraphs (each of them + * filled by 5 strings) are inserted to major text. Finally, paragraph + * enumeration is created using <code>XEnumeration</code> interface. + * Object relations created : + * <ul> + * <li> <code>'ENUM'</code> for + * {@link ifc.container._XEnumeration} : major text of text document + * with several paragraphs inserted, queried to + * <code>XEnumerationAccess</code> interface.</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + + log.println( "creating a test environment" ); + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int i=0; i<3; i++) { + try { + oText.insertString( oCursor, "Paragraph Number: " + i, false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + + for (int j=0; j<5; j++){ + try { + oText.insertString( oCursor,"The quick brown fox jumps"+ + " over the lazy Dog: SwXParagraph", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + oText.insertString( oCursor, "THE QUICK BROWN FOX JUMPS"+ + " OVER THE LAZY DOG: SwXParagraph", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + } + + try { + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println( "EXCEPTION: " + e); + } + } + + // Enumeration + XEnumerationAccess oEnumA = UnoRuntime.queryInterface( XEnumerationAccess.class, oText ); + XEnumeration oEnum = oEnumA.createEnumeration(); + + oObj = oEnum; + + log.println("creating a new environment for ParagraphEnumeration object"); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("ENUM", oEnumA); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXParagraphEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java b/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java new file mode 100644 index 000000000..109b947f6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPrintSettings.java @@ -0,0 +1,91 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XPrintSettingsSupplier; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.PrintSettings</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::PrintSettings</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.PrintSettings + * @see ifc.text._PrintSettings + */ +public class SwXPrintSettings extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.GlobalSettings</code>, then print settings are + * gotten using <code>XPrintSettingsSupplier</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws Exception { + XInterface oObj = null; + Object oInst = null; + + log.println( "creating a test environment" ); + XMultiServiceFactory myMSF = tParam.getMSF(); + oInst = myMSF.createInstance("com.sun.star.text.GlobalSettings"); + XPrintSettingsSupplier xPSS = UnoRuntime.queryInterface(XPrintSettingsSupplier.class, oInst); + oObj = xPSS.getPrintSettings(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPrintSettings + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java b/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java new file mode 100644 index 000000000..0089c2f11 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPropertySet.java @@ -0,0 +1,71 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; + +/** + * Test for object which is represented by text document.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.beans.XPropertySet + * @see ifc.beans._XPropertySet + */ +public class SwXPropertySet extends TestCase { + XTextDocument xTextDoc; + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Method creates text document as a test component. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a text document" ); + xTextDoc = SOF.createTextDoc( null ); + + TestEnvironment tEnv = new TestEnvironment( xTextDoc ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPropertySet + diff --git a/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java b/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java new file mode 100644 index 000000000..c47e0080b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXPropertySetInfo.java @@ -0,0 +1,82 @@ +/* + * 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._sw; + +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.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by PropertySetInfo of + * text document.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::beans::XPropertySetInfo</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.beans.XPropertySetInfo + * @see ifc.beans._XPropertySetInfo + */ +public class SwXPropertySetInfo extends TestCase { + XTextDocument xTextDoc; + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters Param, PrintWriter log) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. Method + * creates text document, then obtains PropertySetInfo of created text + * document using <code>XPropertySet</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws Exception { + XInterface oObj = null; + + log.println( "creating a test environment" ); + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + + log.println( " getting the XPropertySetInfo" ); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xTextDoc); + oObj = xProp.getPropertySetInfo(); + log.println( " creating a new environment for PropertySetInfo object" ); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXPropertySetInfo + diff --git a/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java b/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java new file mode 100644 index 000000000..8b257ba13 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXReferenceMark.java @@ -0,0 +1,117 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ReferenceMark</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::lang::XComponent</code></li> + * <li> <code>com::sun::star::text::XTextContent</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.ReferenceMark + * @see ifc.container._XNamed + * @see ifc.lang._XComponent + * @see ifc.text._XTextContent + */ +public class SwXReferenceMark extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.ReferenceMark</code>, then sets new + * name of created ReferenceMark using <code>XNamed</code> interface. + * Finally, renamed ReferenceMark is inserted to a major text of text + * document as a text content. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception{ + XInterface oObj = null; + XText oText = null; + String Name = "SwXReferenceMark"; + + log.println( "creating a test environment" ); + oText = xTextDoc.getText(); + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object instance = null; + oObj = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.ReferenceMark"); + instance = oDocMSF.createInstance + ("com.sun.star.text.ReferenceMark"); + + XNamed oObjN = UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN.setName(Name); + XTextContent oObjTC = UnoRuntime.queryInterface(XTextContent.class, oObj); + + XTextCursor oCursor = oText.createTextCursor(); + oText.insertTextContent(oCursor, oObjTC, false); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXReferenceMark + diff --git a/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java b/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java new file mode 100644 index 000000000..40b99adec --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXReferenceMarks.java @@ -0,0 +1,128 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XReferenceMarksSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.ReferenceMarks</code>. <p> + * Object implements the following interfaces : + * <ul> + * <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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.text.ReferenceMarks + * @see ifc.container._XNameAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + */ +public class SwXReferenceMarks extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instances of the service + * <code>com.sun.star.text.ReferenceMark</code>, then sets new names to + * created ReferenceMark's using <code>XNamed</code> interface. Then renamed + * ReferenceMark's are inserted to a major text of text document. Finally, + * ReferenceMarks are gotten from text document using + * <code>XReferenceMarksSupplier</code> interface. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws Exception { + XInterface oObj = null; + XText oText = null; + String Name = "SwXReferenceMark01"; + String Name2 = "SwXReferenceMark02"; + + log.println( "creating a test environment" ); + oText = xTextDoc.getText(); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + // Creation and insertion of ReferenceMark01 + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" ); + XNamed oObjN = UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN.setName(Name); + XTextContent oObjTC = UnoRuntime.queryInterface(XTextContent.class, oObj); + XTextCursor oCursor = oText.createTextCursor(); + oText.insertTextContent(oCursor, oObjTC, false); + + // Creation and insertion of ReferenceMark02 + oObj = (XInterface) + oDocMSF.createInstance( "com.sun.star.text.ReferenceMark" ); + XNamed oObjN2 = UnoRuntime.queryInterface(XNamed.class, oObj); + oObjN2.setName(Name2); + + XTextContent oObjTC2 = UnoRuntime.queryInterface(XTextContent.class, oObj); + oText.insertTextContent(oCursor, oObjTC2, false); + + // getting ReferenceMarks from text document + XReferenceMarksSupplier oRefSupp = UnoRuntime.queryInterface(XReferenceMarksSupplier.class, xTextDoc); + oObj = oRefSupp.getReferenceMarks(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXReferenceMarks + diff --git a/qadevOOo/tests/java/mod/_sw/SwXShape.java b/qadevOOo/tests/java/mod/_sw/SwXShape.java new file mode 100644 index 000000000..e3309db61 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXShape.java @@ -0,0 +1,120 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.drawing.XShapes; +import com.sun.star.text.XTextDocument; +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> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @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 SwXShape extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. At first, + * DrawPage is gotten from text document using <code>XDrawPageSupplier</code> + * interface. Then shape (rectangle) is created and added to DrawPage + * obtained before, then returned as a test component. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XDrawPage oDP = null; + XShapes oShapes = null; + + log.println( "creating a test environment" ); + log.println( "getting Drawpage" ); + XDrawPageSupplier oDPS = UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDoc); + oDP = oDPS.getDrawPage(); + + log.println( "getting Shape" ); + oShapes = UnoRuntime.queryInterface(XShapes.class, oDP); + oObj = SOF.createShape(xTextDoc,5000,3500,7500,5000,"Rectangle"); + oShapes.add((XShape) oObj); + + for ( int i = 0; i < 9; i++){ + XInterface oShape = SOF.createShape(xTextDoc, + 5000 + 100*i,3500,7500,5000,"Rectangle"); + oShapes.add((XShape) oShape); + } + + log.println( "creating a new environment for XShape object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXShape + diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyle.java b/qadevOOo/tests/java/mod/_sw/SwXStyle.java new file mode 100644 index 000000000..6a01b029e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyle.java @@ -0,0 +1,181 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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.style.Style</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNamed</code></li> + * <li> <code>com::sun::star::style::Style</code></li> + * <li> <code>com::sun::star::style::XStyle</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNamed + * @see com.sun.star.style.Style + * @see com.sun.star.style.XStyle + * @see ifc.container._XNamed + * @see ifc.style._Style + * @see ifc.style._XStyle + */ +public class SwXStyle extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF = null; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * At first style families are gotten from a text document using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from this style family using <code>XIndexAccess</code> interface. + * Next, method creates an instance of the service + * <code>com.sun.star.style.CharacterStyle</code> and inserts it to a + * previously obtained style family using <code>XNameContainer</code> + * interface. Finally, method creates a cursor of a major text of text + * document and sets it's property 'CharStyleName' value to the name of + * previously created style's name. + * Object relations created : + * <ul> + * <li> <code>'PoolStyle'</code> for + * {@link ifc.style._XStyle} : style indexed '10' obtained from + * StyleFamily indexed '0' from text document using + * <code>XIndexAccess</code> interface.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + TestEnvironment tEnv = null; + XNameAccess oSFNA = null; + XStyle oStyle = null; + XStyle oMyStyle = null; + + log.println("creating a test environment"); + + log.println("getting style"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFsIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF); + oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFsIA.getByIndex(0)); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSFNA); + oStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oSFIA.getByIndex(10)); + + log.print("Creating a user-defined style... "); + XMultiServiceFactory oMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XInterface oInt = (XInterface) + oMSF.createInstance("com.sun.star.style.CharacterStyle"); + oMyStyle = UnoRuntime.queryInterface(XStyle.class, oInt); + + + if (oMyStyle == null) + log.println("FAILED"); + else + log.println("OK"); + XNameContainer oSFNC = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + if ( oSFNC.hasByName("My Style") ) + oSFNC.removeByName("My Style"); + oSFNC.insertByName("My Style", oMyStyle); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, oCursor); + + xProp.setPropertyValue("CharStyleName", oMyStyle.getName()); + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oMyStyle); + tEnv.addObjRelation("PoolStyle", oStyle); + + XPropertySet xStyleProp = UnoRuntime.queryInterface(XPropertySet.class, oMyStyle); + tEnv.addObjRelation("PropertyNames",getPropertyNames(xStyleProp)); + + return tEnv; + } + + public String[] getPropertyNames(XPropertySet props) { + Property[] the_props = props.getPropertySetInfo().getProperties(); + String[] names = new String[the_props.length]; + String placebo = ""; + for (int i=0;i<the_props.length;i++) { + boolean isWritable = + ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable) placebo=the_props[i].Name; + } + for (int i=0;i<the_props.length;i++) { + boolean isWritable = + ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable) { + names[i]=the_props[i].Name; + } else { + names[i] = placebo; + } + } + return names; + } + +} // finish class SwXStyle diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java b/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java new file mode 100644 index 000000000..ebbc4690a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyleFamilies.java @@ -0,0 +1,97 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.style.StyleFamilies</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::XIndexAccess</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.style.StyleFamilies + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XIndexAccess + */ +public class SwXStyleFamilies extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. Style families + * are gotten from text document using <code>XStyleFamiliesSupplier</code> + * interface and returned as a test component. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + + + log.println( "Creating a test environment" ); + XTextDocument xArea = UnoRuntime.queryInterface(XTextDocument.class, xTextDoc); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xArea); + XNameAccess oSF = oSFS.getStyleFamilies(); + + TestEnvironment tEnv = new TestEnvironment(oSF); + return tEnv; + } + + +} // finish class SwXStyle + diff --git a/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.java b/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.java new file mode 100644 index 000000000..c785ebd84 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXStyleFamily.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._sw; + +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.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.XTextDocument; +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.style.StyleFamily</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::container::XNameContainer</code></li> + * <li> <code>com::sun::star::container::XNameAccess</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XIndexAccess</code></li> + * <li> <code>com::sun::star::container::XNameReplace</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XNameReplace + * @see ifc.container._XNameContainer + * @see ifc.container._XNameAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XIndexAccess + * @see ifc.container._XNameReplace + */ +public class SwXStyleFamily extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. At first, + * style families of text document are gotten using + * <code>XStyleFamiliesSupplier</code> interface, then family indexed '0' is + * gotten from previously obtained style families collection using + * <code>XIndexAccess</code> interface. Finally, method creates an instance + * of the service <code>com.sun.star.style.CharacterStyle</code> and inserts + * it to a gotten style family as 'SwXStyleFamily' using + * <code>XNameContainer</code> interface. + * Object relations created : + * <ul> + * <li> <code>'XNameReplaceINDEX'</code> for + * {@link ifc.container._XNameReplace} : number of last taken instance + * of <code>com.sun.star.style.CharacterStyle</code>, when multithread + * testing is going.</li> + * <li> <code>'NAMEREPLACE'</code> for + * {@link ifc.container._XNameReplace} : name of style family, inserted + * to style families of a text document.</li> + * <li> <code>'INSTANCEn'</code> for + * {@link ifc.container._XIndexContainer}, + * {@link ifc.container._XIndexReplace}, + * {@link ifc.container._XNameContainer}, + * {@link ifc.container._XNameReplace} : several relations, which are + * represented by instances of service + * <code>com.sun.star.style.CharacterStyle</code>.</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XNameAccess oSFNA = null; + + log.println( "Creating Test Environment..." ); + + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class, xTextDoc); + XInterface oInstance = (XInterface) + SOF.createInstance(xComp, "com.sun.star.style.CharacterStyle"); + XStyleFamiliesSupplier oSFsS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess oSF = oSFsS.getStyleFamilies(); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF); + + oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFIA.getByIndex(0)); + + XNameContainer oContainer = UnoRuntime.queryInterface(XNameContainer.class, oSFNA); + + // insert a Style which can be replaced by name + try { + oContainer.insertByName("SwXStyleFamily",oInstance); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } catch ( com.sun.star.container.ElementExistException e ) { + log.println("Could not insert style family."); + e.printStackTrace(log); + } + + TestEnvironment tEnv = new TestEnvironment(oSFNA); + + int THRCNT = 1; + if ((String)Param.get("THRCNT") != null) { + THRCNT = Integer.parseInt((String)Param.get("THRCNT")); + } + String nr = Integer.toString(THRCNT+1); + + log.println( "adding NameReplaceIndex as mod relation to environment" ); + tEnv.addObjRelation("XNameReplaceINDEX", nr); + + for (int n=1; n<(THRCNT+3); n++ ) { + log.println( "adding INSTANCE"+n+" as mod relation to environment"); + tEnv.addObjRelation("INSTANCE"+n, + SOF.createInstance(xComp,"com.sun.star.style.CharacterStyle")); + } + + log.println("adding NAMEREPLACE as mod relation to environment"); + tEnv.addObjRelation("NAMEREPLACE", "SwXStyleFamily"); + + return tEnv; + } + +} // finish class SwXStyleFamily diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java b/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java new file mode 100644 index 000000000..336aba189 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableCellText.java @@ -0,0 +1,146 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TextSectionDsc; + +import com.sun.star.table.XCell; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by cell text of the text table.<p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextRangeMover</code></li> + * <li> <code>com::sun::star::text::XSimpleText</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::text::XRelativeTextContentInsert</code></li> + * <li> <code>com::sun::star::text::XTextRangeCompare</code></li> + * <li> <code>com::sun::star::container::XElementAccess</code></li> + * <li> <code>com::sun::star::container::XEnumerationAccess</code></li> + * <li> <code>com::sun::star::text::XText</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextRangeMover + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XRelativeTextContentInsert + * @see com.sun.star.text.XTextRangeCompare + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XText + * @see ifc.text._XTextRangeMover + * @see ifc.text._XSimpleText + * @see ifc.text._XTextRange + * @see ifc.text._XRelativeTextContentInsert + * @see ifc.text._XTextRangeCompare + * @see ifc.container._XElementAccess + * @see ifc.container._XEnumerationAccess + * @see ifc.text._XText + */ +public class SwXTableCellText extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After creation + * of text table, it is inserted to a text document. Then cell named 'A1' is + * obtained from table, string 'SwXTableCellText' is set to this cell, then + * cell text is gotten from cell obtained before and returned as a test + * component. + * Object relations created : + * <ul> + * <li> <code>'TEXT'</code> for + * {@link ifc.text._XTextRangeCompare} : table cell text</li> + * <li> <code>'PARA'</code> for + * {@link ifc.text._XRelativeTextContentInsert} : paragraph creator</li> + * <li> <code>'XTEXTINFO'</code> for + * {@link ifc.text._XRelativeTextContentInsert}, + * {@link ifc.text._XText} : creates text sections</li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "Creating a test environment" ); + oTable = SOfficeFactory.createTextTable( xTextDoc ); + + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + + XCell oCell = oTable.getCellByName("A1"); + XSimpleText oCellText = UnoRuntime.queryInterface(XSimpleText.class, oCell); + oCellText.setString("SwXTableCellText"); + oObj = oCellText.getText(); + + log.println( "creating a new environment for Cell object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXT", oObj); + + log.println( " adding InstCreator object" ); + TextSectionDsc tDsc = new TextSectionDsc(); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + log.println( " adding Paragraph" ); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation( "PARA", new InstCreator( xTextDoc, pDsc ) ); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTableCellText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java b/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java new file mode 100644 index 000000000..2acfbf586 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableColumns.java @@ -0,0 +1,112 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.TableColumns</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::container::XNameAccess</code></li> + * <li> <code>com::sun::star::table::XTableColumns</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.table.XTableColumns + * @see com.sun.star.table.TableColumns + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.container._XNameAccess + * @see ifc.table._XTableColumns + */ +public class SwXTableColumns extends TestCase { + XTextDocument xTextDoc; + SOfficeFactory SOF; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After creation + * of text table, it is inserted to text document, then columns are gotten + * from table. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "creating a test environment" ); + + oTable = SOfficeFactory.createTextTable( xTextDoc ); + + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + + oObj = oTable.getColumns(); + + log.println( "creating a new environment for TableColumns object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XTableColumns + tEnv.addObjRelation("XTableColumns.XCellRange", + UnoRuntime.queryInterface(XCellRange.class, oTable)); + + tEnv.addObjRelation("XIndexAccess.getByIndex.mustBeNull", Boolean.TRUE); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTableColumns + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTableRows.java b/qadevOOo/tests/java/mod/_sw/SwXTableRows.java new file mode 100644 index 000000000..1dc1be9d2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTableRows.java @@ -0,0 +1,104 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.table.TableRows</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::table::XTableRows</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.table.XTableRows + * @see ifc.container._XIndexAccess + * @see ifc.container._XElementAccess + * @see ifc.table._XTableRows + */ +public class SwXTableRows extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After creation + * of text table, it is inserted to text document, then rows are gotten + * from table. + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log ) throws StatusException { + XInterface oObj = null; + XTextTable oTable = null; + + log.println( "creating a test environment" ); + SOfficeFactory.getFactory( tParam.getMSF() ); + oTable = SOfficeFactory.createTextTable( xTextDoc ); + + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + oObj = oTable.getRows(); + + log.println( "creating a new environment for TableColumns object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XTableColumns + tEnv.addObjRelation("XTableRows.XCellRange", + UnoRuntime.queryInterface(XCellRange.class, oTable)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTableRows + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java b/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java new file mode 100644 index 000000000..d198e4468 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextColumns.java @@ -0,0 +1,168 @@ +/* + * 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._sw; + +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.container.XNameAccess; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextColumns; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +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.text.TextColumns</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextColumns</code></li> + * <li> <code>com::sun::star::text::TextColumns</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextColumns + * @see com.sun.star.text.TextColumns + * @see ifc.text._XTextColumns + * @see ifc.text._TextColumns + */ +public class SwXTextColumns extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After style + * families are gotten from text document using + * <code>XStyleFamiliesSupplier</code> interface, style family indexed '2' + * is obtained using <code>XIndexAccess</code> interface. Then style + * named 'Standard' is gotten from previously obtained style family using + * <code>XNameAccess</code> interface, and 'TextColumns' property value + * of this style is returned as a test component. Finally, several + * paragraphs within the text are inserted to a text document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + XInterface oObj = null; + TestEnvironment tEnv = null; + XStyle oStyle = null; + + log.println( "creating a test environment" ); + log.println("getting PageStyle"); + XStyleFamiliesSupplier oSFS = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDoc); + XNameAccess oSF = oSFS.getStyleFamilies(); + XIndexAccess oSFIA = UnoRuntime.queryInterface(XIndexAccess.class, oSF); + + try { + XNameAccess oSFNA = (XNameAccess) AnyConverter.toObject( + new Type(XNameAccess.class),oSFIA.getByIndex(2)); + oStyle = (XStyle) AnyConverter.toObject( + new Type(XStyle.class),oSFNA.getByName("Standard")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IndexOutOfBoundsException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.container.NoSuchElementException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Error, exception occurred while getting style."); + e.printStackTrace(log); + } + + try { + log.println("Getting property ('TextColumns') value of style " + + oStyle.getName()); + XPropertySet xProps = UnoRuntime.queryInterface(XPropertySet.class,oStyle); + oObj = (XTextColumns) AnyConverter.toObject( + new Type(XTextColumns.class),xProps.getPropertyValue("TextColumns")); + } catch ( com.sun.star.lang.WrappedTargetException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } catch ( com.sun.star.beans.UnknownPropertyException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } catch ( com.sun.star.lang.IllegalArgumentException e ) { + log.println("Exception occurred while getting style property"); + e.printStackTrace(log); + } + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println( "inserting some text to text document..." ); + try { + for (int i =0; i < 5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertString( oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertString( oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + oText.insertControlCharacter( oCursor, + ControlCharacter.LINE_BREAK, false ); + } + } catch ( com.sun.star.lang.IllegalArgumentException e ){ + log.println("Exception occurred while inserting Text"); + e.printStackTrace(log); + } + + log.println("creating a new environment for object"); + tEnv = new TestEnvironment(oObj); + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextColumns diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java new file mode 100644 index 000000000..5b641b1e7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextCursor.java @@ -0,0 +1,307 @@ +/* + * 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._sw; + +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Arrays; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.Property; +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.XPropertySet; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XParagraphCursor; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.TextCursor</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::text::XTextCursor</code></li> + * <li> <code>com::sun::star::text::XWordCursor</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::text::XTextRange</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::container::XContentEnumerationAccess</code></li> + * <li> <code>com::sun::star::beans::XPropertyState</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::text::XSentenceCursor</code></li> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::text::XParagraphCursor</code></li> + * <li> <code>com::sun::star::document::XDocumentInsertable</code></li> + * <li> <code>com::sun::star::util::XSortable</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * </ul> <p> + * This object test <b> is NOT </b> designed to be run in several + * threads concurrently. + * @see com.sun.star.text.XTextCursor + * @see com.sun.star.text.XWordCursor + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.text.XTextRange + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XContentEnumerationAccess + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.text.XSentenceCursor + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XParagraphCursor + * @see com.sun.star.document.XDocumentInsertable + * @see com.sun.star.util.XSortable + * @see com.sun.star.style.CharacterPropertiesAsian + * @see ifc.text._XTextCursor + * @see ifc.text._XWordCursor + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.text._XTextRange + * @see ifc.beans._XPropertySet + * @see ifc.container._XContentEnumerationAccess + * @see ifc.beans._XPropertyState + * @see ifc.style._CharacterProperties + * @see ifc.text._XSentenceCursor + * @see ifc.style._ParagraphProperties + * @see ifc.text._XParagraphCursor + * @see ifc.document._XDocumentInsertable + * @see ifc.util._XSortable + * @see ifc.style._CharacterPropertiesAsian + */ +public class SwXTextCursor extends TestCase { + XTextDocument xTextDoc; + + /** + * Creates text document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. After major + * text of text document is obtained, text cursor is created and several + * paragraphs within the text are inserted to a text document. Finally, + * text cursor is returned as a test component. + * Object relations created : + * <ul> + * <li> <code>'XTEXT'</code> for + * {@link ifc.text._XTextRange} : major text of text document</li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + log.println("creating a test environment"); + + + // get the bodytext of textdocument here + log.println("getting the TextCursor"); + + final XSimpleText aText = xTextDoc.getText(); + final XTextCursor textCursor = aText.createTextCursor(); + oObj = textCursor; + + log.println("inserting some text"); + + try { + for (int i = 0; i < 3; i++) { + aText.insertString(textCursor, "" + (3 - i), false); + + for (int j = 0; j < 5; j++) { + aText.insertString(textCursor, "XTextCursor,XTextCursor", + false); + aText.insertString(textCursor, "The quick brown fox ", + false); + aText.insertString(textCursor, "jumps over the lazy dog ", + false); + } + + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertControlCharacter(textCursor, + ControlCharacter.LINE_BREAK, + false); + } + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Error, insert text to text document."); + e.printStackTrace(log); + } + + log.println("creating a new environment for SwXTextCursor object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XTEXT", xTextDoc.getText()); + + XPropertySet xCursorProp = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + String[] skipNames = { "ParaBackGraphicURL" }; + String[] propertyNames = getPropertyNames(xCursorProp, skipNames); + + tEnv.addObjRelation("PropertyNames", propertyNames); + tEnv.addObjRelation("SkipProperties", propertyNames); + + //Adding relation for util.XSortable + final XParagraphCursor paragrCursor = UnoRuntime.queryInterface( + XParagraphCursor.class, + oObj); + final PrintWriter finalLog = log; + + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + textCursor.gotoEnd(false); + + try { + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "4", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "b", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "3", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "a", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "23", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + aText.insertString(textCursor, "ab", false); + aText.insertControlCharacter(textCursor, + ControlCharacter.PARAGRAPH_BREAK, + false); + } catch (com.sun.star.lang.IllegalArgumentException e) { + out.println("Unexpected exception:" + e); + } + + out.println( + "Preparing cursor to sorting. Text before sorting:"); + paragrCursor.gotoEnd(true); + + for (int i = 0; i < 6; i++) { + paragrCursor.gotoPreviousParagraph(true); + } + + out.println(textCursor.getString()); + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + String ls = System.getProperty("line.separator"); + + String text = paragrCursor.getString(); + out.println("Text after sorting:\n" + text); + + boolean res = false; + + if (isSortNumbering) { + if (isSortAscending) { + res = text.endsWith(ls+"3"+ls+"4"+ls+"23"); + + if (!res) { + out.println("Text must ends by:\n" + "\r\n3\r\n4\r\n23\r\n"); + } + } else { + res = text.startsWith("23"+ls+"4"+ls+"3"+ls); + + if (!res) { + out.println("Text must starts with:\n" + "23\r\n4\r\n3\r\n"); + } + } + } else { + if (isSortAscending) { + res = text.equals(ls+"23"+ls+"3"+ls+"4"+ls+"a"+ls+"ab"+ls+"b"); + + if (!res) { + out.println("Text must be equal to:\n" + "\r\n23\r\n3\r\n4\r\na\r\nab\r\nb\r\n"); + } + } else { + res = text.endsWith("b"+ls+"ab"+ls+"a"+ls+"4"+ls+"3"+ls+"23"+ls); + + if (!res) { + out.println("Text must be equal to:\n" + "b\r\nab\r\na\r\n4\r\n3\r\n23\r\n"); + } + } + } + + if (res) { + out.println("Sorted correctly"); + } + + return res; + } + }); + + return tEnv; + } // finish method getTestEnvironment + + public String[] getPropertyNames(XPropertySet props, String[] skipList) { + Property[] the_props = props.getPropertySetInfo().getProperties(); + ArrayList<String> names = new ArrayList<String>(); + + for (int i = 0; i < the_props.length; i++) { + boolean isWritable = ((the_props[i].Attributes & PropertyAttribute.READONLY) == 0); + if (isWritable && !Arrays.asList(skipList).contains(the_props[i].Name)) { + names.add(the_props[i].Name); + } + } + + return names.toArray(new String[names.size()]); + } +} // finish class SwXTextCursor diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java b/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java new file mode 100644 index 000000000..1b02f44d3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextDefaults.java @@ -0,0 +1,106 @@ +/* + * 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._sw; + +//API Interfaces +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.text.Defaults</code> created by a writer + * document's <code>XMultiServiceFactory</code>. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>com::sun::star::style::ParagraphProperties</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesComplex</code></li> + * <li> <code>com::sun::star::style::CharacterPropertiesAsian</code></li> + * <li> <code>com::sun::star::text::Defaults</code></li> + * <li> <code>com::sun::star::style::CharacterProperties</code></li> + * <li> <code>com::sun::star::beans::XPropertySet</code></li> + * <li> <code>com::sun::star::style::ParagraphPropertiesComplex</code></li> + * </ul> <p> + * + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.style.CharacterPropertiesComplex + * @see com.sun.star.style.CharacterPropertiesAsian + * @see com.sun.star.text.Defaults + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.style.ParagraphPropertiesComplex + * @see ifc.style._ParagraphProperties + * @see ifc.style._CharacterPropertiesComplex + * @see ifc.style._CharacterPropertiesAsian + * @see ifc.text._Defaults + * @see ifc.style._CharacterProperties + * @see ifc.beans._XPropertySet + * @see ifc.style._ParagraphPropertiesComplex + */ +public class SwXTextDefaults extends TestCase { + + XTextDocument xTextDoc; + + /** + * Creates the service <code>com.sun.star.text.Defaults</code> + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + + XMultiServiceFactory docMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class,xTextDoc); + + oObj = (XInterface) + docMSF.createInstance("com.sun.star.text.Defaults"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + } + + /** + * Creates text document. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Disposes text document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java b/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java new file mode 100644 index 000000000..442d94b2c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextDocument.java @@ -0,0 +1,215 @@ +/* + * 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._sw; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.text.XTextSection; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XWordCursor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XSelectionSupplier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.DesktopTools; + +import util.SOfficeFactory; +import util.WriterTools; + +public class SwXTextDocument extends TestCase { + XTextDocument xTextDoc; + XTextDocument xSecondTextDoc; + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + DesktopTools.closeDoc(xSecondTextDoc); + DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters Param, PrintWriter log) throws Exception { + TestEnvironment tEnv = null; + XTextTable the_table = null; + + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting some lines"); + + for (int i = 0; i < 5; i++) { + oText.insertString(oCursor, "Paragraph Number: " + i, false); + oText.insertString( + oCursor, + " The quick brown fox jumps over the lazy Dog: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + oText.insertString( + oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK, + false); + } + for (int i = 0; i < 11; i++) { + oText.insertString(oCursor, "xTextDoc ", false); + + } + + // insert two sections parent and child + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, xTextDoc); + + XInterface oTS; + XTextSection xTS; + + XTextSectionsSupplier oTSSupp = UnoRuntime.queryInterface( + XTextSectionsSupplier.class, xTextDoc); + XNameAccess oTSSuppName = oTSSupp.getTextSections(); + + oTS = (XInterface) oDocMSF + .createInstance("com.sun.star.text.TextSection"); + + XTextContent oTSC = UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + + XWordCursor oWordC = UnoRuntime.queryInterface(XWordCursor.class, + oCursor); + oCursor.setString("End of TextSection"); + oCursor.gotoStart(false); + oCursor.setString("Start of TextSection "); + oWordC.gotoEndOfWord(false); + + XInterface oTS2 = (XInterface) oDocMSF + .createInstance("com.sun.star.text.TextSection"); + oTSC = UnoRuntime.queryInterface(XTextContent.class, oTS2); + oText.insertTextContent(oCursor, oTSC, false); + + XIndexAccess oTSSuppIndex = UnoRuntime.queryInterface( + XIndexAccess.class, oTSSuppName); + log.println("getting a TextSection with the XTextSectionSupplier()"); + xTS = UnoRuntime.queryInterface(XTextSection.class, + oTSSuppIndex.getByIndex(0)); + + XNamed xTSName = UnoRuntime.queryInterface(XNamed.class, xTS); + xTSName.setName("SwXTextSection"); + + log.println(" adding TextTable"); + the_table = SOfficeFactory.createTextTable(xTextDoc, 6, 4); + + XNamed the_name = UnoRuntime.queryInterface(XNamed.class, the_table); + the_name.setName("SwXTextDocument"); + SOfficeFactory.insertTextContent(xTextDoc, the_table); + + log.println(" adding ReferenceMark"); + + XInterface aMark = (XInterface) oDocMSF + .createInstance("com.sun.star.text.ReferenceMark"); + the_name = UnoRuntime.queryInterface(XNamed.class, aMark); + the_name.setName("SwXTextDocument"); + + XTextContent oTC = UnoRuntime.queryInterface(XTextContent.class, aMark); + SOfficeFactory.insertTextContent(xTextDoc, oTC); + + log.println(" adding TextGraphic"); + WriterTools.insertTextGraphic(xTextDoc, oDocMSF, Param.getComponentContext(), + 5200, 4200, 4400, 4000, "space-metal.jpg", "SwXTextDocument"); + + log.println(" adding EndNote"); + + XInterface aEndNote = (XInterface) oDocMSF + .createInstance("com.sun.star.text.Endnote"); + oTC = UnoRuntime.queryInterface(XTextContent.class, aEndNote); + SOfficeFactory.insertTextContent(xTextDoc, oTC); + + log.println(" adding Bookmark"); + SOfficeFactory.insertTextContent(xTextDoc, + SOfficeFactory.createBookmark(xTextDoc)); + + log.println(" adding DocumentIndex"); + oTC = SOfficeFactory.createIndex(xTextDoc, + "com.sun.star.text.DocumentIndex"); + SOfficeFactory.insertTextContent(xTextDoc, oTC); + + log.println(" adding TextFrame"); + + XTextFrame frame = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + oTC = UnoRuntime.queryInterface(XTextContent.class, frame); + SOfficeFactory.insertTextContent(xTextDoc, oTC); + + log.println("creating a second textdocument"); + xSecondTextDoc = WriterTools.createTextDoc(Param.getMSF()); + + XText oText2 = xTextDoc.getText(); + XTextCursor oTextCursor = oText2.createTextCursor(); + + for (int i = 0; i < 11; i++) { + oText2.insertString(oTextCursor, "xTextDoc ", false); + } + + tEnv = new TestEnvironment(xTextDoc); + + XModel model1 = UnoRuntime.queryInterface(XModel.class, xTextDoc); + XModel model2 = UnoRuntime.queryInterface(XModel.class, xSecondTextDoc); + + XController cont1 = model1.getCurrentController(); + XController cont2 = model2.getCurrentController(); + + cont1.getFrame().setName("cont1"); + cont2.getFrame().setName("cont2"); + + XSelectionSupplier sel = UnoRuntime.queryInterface( + XSelectionSupplier.class, cont1); + + log.println("Adding SelectionSupplier and Shape to select for XModel"); + tEnv.addObjRelation("SELSUPP", sel); + tEnv.addObjRelation("TOSELECT", the_table); + + log.println("adding Controller as ObjRelation for XModel"); + tEnv.addObjRelation("CONT1", cont1); + tEnv.addObjRelation("CONT2", cont2); + + return tEnv; + } +} // finish class SwXTextDocument diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java new file mode 100644 index 000000000..59019e91d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObject.java @@ -0,0 +1,153 @@ +/* + * 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._sw; + +import com.sun.star.beans.XPropertySet; + +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.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextEmbeddedObjectsSupplier; +import com.sun.star.text.XTextFrame; +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.XCloseable; + + +/** + * + * initial description + * @see com.sun.star.container.XNamed + * @see com.sun.star.document.XEmbeddedObjectSupplier + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextEmbeddedObject + * @see com.sun.star.text.XTextContent + * + */ +public class SwXTextEmbeddedObject extends TestCase { + XTextDocument xTextDoc; + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XInterface oObj = null; + + // create testobject here + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + xTextDoc = SOF.createTextDoc(null); + + XTextCursor xCursor = xTextDoc.getText().createTextCursor(); + try { + XMultiServiceFactory xMultiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + Object o = xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" ); + XTextContent xTextContent = UnoRuntime.queryInterface(XTextContent.class, o); + String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e"; + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xTextContent); + xPropertySet.setPropertyValue( "CLSID", sChartClassID ); + + xTextDoc.getText().insertTextContent( xCursor, xTextContent, false ); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + } + + XTextEmbeddedObjectsSupplier oTEOS = UnoRuntime.queryInterface( + XTextEmbeddedObjectsSupplier.class, + xTextDoc); + + XNameAccess oEmObj = oTEOS.getEmbeddedObjects(); + XIndexAccess oEmIn = UnoRuntime.queryInterface( + XIndexAccess.class, oEmObj); + + oObj = (XInterface) AnyConverter.toObject( + new Type(XInterface.class), oEmIn.getByIndex(0)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("NoAttach", "SwXTextEmbeddedObject"); + + XTextFrame aFrame = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + XTextContent the_content = UnoRuntime.queryInterface( + XTextContent.class, aFrame); + + try { + oText.insertTextContent(oCursor, the_content, true); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Couldn't insert frame " + e.getMessage()); + } + + tEnv.addObjRelation("TextFrame", aFrame); + + tEnv.addObjRelation("NoSetSize", "SwXTextEmbeddedObject"); + tEnv.addObjRelation("NoPos", "SwXTextEmbeddedObject"); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextEmbeddedObject diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.java new file mode 100644 index 000000000..4b0e3ae72 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextEmbeddedObjects.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._sw; + +import com.sun.star.beans.XPropertySet; +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextEmbeddedObjectsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +public class SwXTextEmbeddedObjects extends TestCase { + + XTextDocument oDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + oDoc = SOF.createTextDoc(null); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(oDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) throws StatusException { + + XInterface oObj = null; + + // create testobject here + XTextCursor xCursor = oDoc.getText().createTextCursor(); + try { + XMultiServiceFactory xMultiServiceFactory = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc); + Object o = xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" ); + XTextContent xTextContent = UnoRuntime.queryInterface(XTextContent.class, o); + String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e"; + XPropertySet xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xTextContent); + xPropertySet.setPropertyValue( "CLSID", sChartClassID ); + + oDoc.getText().insertTextContent( xCursor, xTextContent, false ); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + } + + XTextEmbeddedObjectsSupplier oTEOS = UnoRuntime.queryInterface(XTextEmbeddedObjectsSupplier.class, oDoc); + + oObj = oTEOS.getEmbeddedObjects(); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextEmbeddedObjects + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextField.java b/qadevOOo/tests/java/mod/_sw/SwXTextField.java new file mode 100644 index 000000000..61afb8e30 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextField.java @@ -0,0 +1,150 @@ +/* + * 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._sw; + +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.lang.XMultiServiceFactory; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextField + * + */ +public class SwXTextField extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { + + 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" ); + + Object instance = null; + + // create testobject here + try { + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + Object FieldMaster = oDocMSF.createInstance + ( "com.sun.star.text.FieldMaster.Database" ); + XPropertySet PFieldMaster = UnoRuntime.queryInterface + (XPropertySet.class,FieldMaster); + oObj = (XInterface) oDocMSF.createInstance + ( "com.sun.star.text.TextField.Database" ); + + instance = oDocMSF.createInstance + ( "com.sun.star.text.TextField.DateTime" ); + + XDependentTextField xTF = UnoRuntime.queryInterface(XDependentTextField.class,oObj); + + PFieldMaster.setPropertyValue("DataBaseName","Address Book File"); + PFieldMaster.setPropertyValue("DataTableName","address"); + PFieldMaster.setPropertyValue("DataColumnName","FIRSTNAME"); + XText the_Text = xTextDoc.getText(); + XTextCursor the_Cursor = the_Text.createTextCursor(); + XTextContent the_Field = UnoRuntime.queryInterface(XTextContent.class,oObj); + + xTF.attachTextFieldMaster(PFieldMaster); + the_Text.insertTextContent(the_Cursor,the_Field,false); + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMaster object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextField + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java b/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java new file mode 100644 index 000000000..3f6d70705 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFieldMasters.java @@ -0,0 +1,125 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XNameAccess + * @see com.sun.star.container.XNameContainer + * @see com.sun.star.container.XNameReplace + * + */ +public class SwXTextFieldMasters extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + 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" ); + + + // create testobject here + try { + XTextFieldsSupplier oTFS = UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + + oObj = oTFS.getTextFieldMasters(); + + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldMasters object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFieldMasters + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java b/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java new file mode 100644 index 000000000..03cb9721e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFieldTypes.java @@ -0,0 +1,126 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFieldsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XContainer + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * + */ +public class SwXTextFieldTypes extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + 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" ); + + + // create testobject here + try { + XTextFieldsSupplier oTFS = UnoRuntime.queryInterface( XTextFieldsSupplier.class, xTextDoc ); + + oObj = oTFS.getTextFields(); + + } + catch (Exception ex) { + log.println("Couldn't create instance"); + ex.printStackTrace(log); + } + + log.println( "creating a new environment for FieldTypes object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFieldTypes + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java b/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java new file mode 100644 index 000000000..e3eb3c299 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFrame.java @@ -0,0 +1,138 @@ +/* + * 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._sw; + +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.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ +public class SwXTextFrame extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XTextFrame oFrame1 = null; + XTextFrame oFrame2 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = 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()); + + + // creating Frames + log.println("creating Frames"); + + + Object instance = null; + + oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + oFrame2 = SOfficeFactory.createTextFrame(xTextDoc, 1500, 1500); + oPropSet = UnoRuntime.queryInterface( + XPropertySet.class, oFrame1); + + + // AnchorTypes: 0 = paragraph, 1 = as char, 2 = page, + // 3 = frame/paragraph 4= at char + oPropSet.setPropertyValue("AnchorType", + TextContentAnchorType.AS_CHARACTER); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println("inserting Frame1"); + + XTextContent the_content = UnoRuntime.queryInterface( + XTextContent.class, oFrame1); + oText.insertTextContent(oCursor, the_content, true); + + log.println("inserting Frame2"); + the_content = UnoRuntime.queryInterface( + XTextContent.class, oFrame2); + oText.insertTextContent(oCursor, the_content, true); + + XText oFrameText = oFrame1.getText(); + oFrameText.insertString(oFrameText.getStart(), "The FrameText", + true); + + instance = SOF.createInstance(xTextDoc, + "com.sun.star.text.TextFrame"); + oObj = oFrame1; + + log.println("creating a new environment for TextFrame object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("CONTENT", + UnoRuntime.queryInterface( + XTextContent.class, instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + log.println("adding ObjRelation for XShape " + + "(get/setPosition won't work there)"); + tEnv.addObjRelation("NoPos", "SwXTextFrame"); + tEnv.addObjRelation("NoSetSize", "SwXTextFrame"); + + tEnv.addObjRelation("TextFrame", oFrame2); + + return tEnv; + } // finish method getTestEnvironment +} // finish class SwXTextFrame diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java b/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java new file mode 100644 index 000000000..1b12794f0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextFrameText.java @@ -0,0 +1,137 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.ParagraphDsc; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XEnumerationAccess + * @see com.sun.star.text.XSimpleText + * @see com.sun.star.text.XText + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XTextRangeMover + * + */ +public class SwXTextFrameText extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XTextFrame oFrame1 = null; + XPropertySet oPropSet = null; + XText oText = null; + XTextCursor oCursor = 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.getFactory(tParam.getMSF()); + + // create testobject here + + oFrame1 = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + oPropSet = UnoRuntime.queryInterface(XPropertySet.class, oFrame1); + // AnchorTypes: 0 = paragraph, 1 = as char, 2 = page, + // 3 = frame/paragraph 4= at char + oPropSet.setPropertyValue("AnchorType", Integer.valueOf(2)); + oText = xTextDoc.getText(); + oCursor = oText.createTextCursor(); + + log.println("inserting Frame1"); + oText.insertTextContent(oCursor, oFrame1, false); + + XText oFText = UnoRuntime.queryInterface(XText.class, oFrame1); + XTextCursor oFCursor = oFText.createTextCursor(); + oFText.insertString(oFCursor, "SwXTextFrameText", false); + + oObj = oFText.getText(); + + log.println("creating a new environment for TextFrameText object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("adding TextDocument as mod relation to environment"); + tEnv.addObjRelation("TEXT", oObj); + + log.println("adding InstDescriptor object"); + TableDsc tDsc = new TableDsc(6, 4); + + log.println("adding InstCreator object"); + tEnv.addObjRelation("XTEXTINFO", new InstCreator(xTextDoc, tDsc)); + + log.println(" adding Paragraph"); + ParagraphDsc pDsc = new ParagraphDsc(); + tEnv.addObjRelation("PARA", new InstCreator(xTextDoc, pDsc)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextFrameText + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java new file mode 100644 index 000000000..d078516e2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObject.java @@ -0,0 +1,187 @@ +/* + * 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._sw; + +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.beans.PropertyValue; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.TextContentAnchorType; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.graphic.XGraphic; +import com.sun.star.graphic.XGraphicProvider; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XComponentContext; + +public class SwXTextGraphicObject extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a textdoc"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xDrawDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oGObject = null; + Object xTextFrame = null; + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + Object instance = null; + + oGObject = SOF.createInstance(xTextDoc, + "com.sun.star.text.GraphicObject"); + instance = SOF.createInstance(xTextDoc, + "com.sun.star.text.GraphicObject"); + xTextFrame = SOfficeFactory.createTextFrame(xTextDoc, 500, 500); + + oObj = (XInterface) oGObject; + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = UnoRuntime.queryInterface( + XTextContent.class, oObj); + + log.println("inserting Frame"); + XTextContent Framecontent = UnoRuntime.queryInterface( + XTextContent.class, xTextFrame); + the_text.insertTextContent(the_cursor, Framecontent, true); + + log.println("inserting graphic"); + the_text.insertTextContent(the_cursor, the_content, true); + + log.println("adding graphic"); + + XComponentContext xContext = tParam.getComponentContext(); + + XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface(XGraphicProvider.class, + xContext.getServiceManager().createInstanceWithContext("com.sun.star.graphic.GraphicProvider", xContext)); + + String fullURL = util.utils.getFullTestURL("space-metal.jpg"); + + PropertyValue[] aMediaProps = new PropertyValue[] { new PropertyValue() }; + aMediaProps[0].Name = "URL"; + aMediaProps[0].Value = fullURL; + + XGraphic xGraphic = UnoRuntime.queryInterface(XGraphic.class, + xGraphicProvider.queryGraphic(aMediaProps)); + + XPropertySet oProps = UnoRuntime.queryInterface(XPropertySet.class, + oObj); + + oProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PARAGRAPH); + oProps.setPropertyValue("Graphic", xGraphic); + oProps.setPropertyValue("HoriOrientPosition", Integer.valueOf(5500)); + oProps.setPropertyValue("VertOrientPosition", Integer.valueOf(4200)); + oProps.setPropertyValue("Width", Integer.valueOf(4400)); + oProps.setPropertyValue("Height", Integer.valueOf(4000)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("adding ObjRelation for XShape " + + "(get/setPosition won't work there)"); + tEnv.addObjRelation("NoPos", "SwXTextGraphicObject"); + tEnv.addObjRelation("NoSetSize", "SwXTextGraphicObject"); + Object ImgMap = null; + // creating ObjectRelation for the property + // 'ImageMap' of 'TextGraphicObject' + try { + XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( + XMultiServiceFactory.class, xTextDoc); + ImgMap = xDocMSF + .createInstance("com.sun.star.image.ImageMapRectangleObject"); + } catch (Exception ex) { + ex.printStackTrace(); + } + + tEnv.addObjRelation("IMGMAP", ImgMap); + + tEnv.addObjRelation("CONTENT", + UnoRuntime.queryInterface(XTextContent.class, instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + // object relation for text.BaseFrameProperties + tEnv.addObjRelation("TextFrame", xTextFrame); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextGraphicObject diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.java b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.java new file mode 100644 index 000000000..4a0de3b0b --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextGraphicObjects.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._sw; + +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.beans.PropertyValue; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextGraphicObjectsSupplier; +import com.sun.star.graphic.XGraphic; +import com.sun.star.graphic.XGraphicProvider; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XComponentContext; + +public class SwXTextGraphicObjects extends TestCase { + + XTextDocument xTextDoc; + + /** + * in general this method creates a testdocument + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a textdoc"); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * + * @see TestParameters + * @see PrintWriter + * + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oGObject = null; + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + oGObject = SOF.createInstance(xTextDoc, + "com.sun.star.text.GraphicObject"); + + oObj = (XInterface) oGObject; + + XText the_text = xTextDoc.getText(); + XTextCursor the_cursor = the_text.createTextCursor(); + XTextContent the_content = UnoRuntime.queryInterface( + XTextContent.class, oObj); + + log.println("inserting graphic"); + the_text.insertTextContent(the_cursor, the_content, true); + + log.println("adding graphic"); + + XComponentContext xContext = tParam.getComponentContext(); + + XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface(XGraphicProvider.class, + xContext.getServiceManager().createInstanceWithContext("com.sun.star.graphic.GraphicProvider", xContext)); + + String fullURL = util.utils.getFullTestURL("space-metal.jpg"); + + PropertyValue[] aMediaProps = new PropertyValue[] { new PropertyValue() }; + aMediaProps[0].Name = "URL"; + aMediaProps[0].Value = fullURL; + + XGraphic xGraphic = UnoRuntime.queryInterface(XGraphic.class, + xGraphicProvider.queryGraphic(aMediaProps)); + + XPropertySet oProps = UnoRuntime.queryInterface(XPropertySet.class, + oObj); + oProps.setPropertyValue("Graphic", xGraphic); + oProps.setPropertyValue("HoriOrientPosition", Integer.valueOf(5500)); + oProps.setPropertyValue("VertOrientPosition", Integer.valueOf(4200)); + oProps.setPropertyValue("Width", Integer.valueOf(4400)); + oProps.setPropertyValue("Height", Integer.valueOf(4000)); + + XTextGraphicObjectsSupplier xTGS = UnoRuntime.queryInterface( + XTextGraphicObjectsSupplier.class, xTextDoc); + oObj = xTGS.getGraphicObjects(); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class SwXTextGraphicObjects diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java b/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java new file mode 100644 index 000000000..50fc0c532 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextPortion.java @@ -0,0 +1,154 @@ +/* + * 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._sw; + +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.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * + * @see com.sun.star.text.TextPortion + * + */ +public class SwXTextPortion extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * @return Status class + * + * @see TestParameters * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + XInterface param = null; + XPropertySet paraP = null; + XPropertySet portP = null; + + // 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 + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting Strings"); + log.println("inserting ControlCharacter"); + + for (int i = 0; i < 5; i++) { + oText.insertString(oCursor, "Paragraph Number: " + i, false); + oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK, + false); + oText.insertString( + oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph\n", + false); + oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK, + false); + oText.insertString( + oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + } + + // Enumeration + XEnumerationAccess oEnumA = UnoRuntime.queryInterface( + XEnumerationAccess.class, oText); + XEnumeration oEnum = oEnumA.createEnumeration(); + + int n = 0; + while (oEnum.hasMoreElements()) { + param = (XInterface) AnyConverter.toObject(new Type( + XInterface.class), oEnum.nextElement()); + log.println("Element Nr.: " + n); + n++; + } + + XEnumerationAccess oEnumP = UnoRuntime.queryInterface( + XEnumerationAccess.class, param); + XEnumeration oEnum2 = oEnumP.createEnumeration(); + oObj = (XInterface) AnyConverter.toObject(new Type(XInterface.class), + oEnum2.nextElement()); + + portP = UnoRuntime.queryInterface(XPropertySet.class, oObj); + paraP = UnoRuntime.queryInterface(XPropertySet.class, param); + + log.println("creating a new environment for Paragraph object"); + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("adding ObjRelation TRO for TextContent"); + tEnv.addObjRelation("TRO", Boolean.TRUE); + + log.println("adding ObjectRelation 'PARA' for CharacterProperties"); + tEnv.addObjRelation("PARA", paraP); + + log.println("adding ObjectRelation 'PORTION' for CharacterProperties"); + tEnv.addObjRelation("PORTION", portP); + + tEnv.addObjRelation("XTEXT", oText); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextPortion + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java b/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java new file mode 100644 index 000000000..b5cf80e30 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextPortionEnumeration.java @@ -0,0 +1,137 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XEnumeration; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * + * @see com.sun.star.text.TextPortion + * + */ +public class SwXTextPortionEnumeration extends TestCase { + + XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam + * class which contains additional test parameters + * @param log + * class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + XInterface param = null; + + // 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 + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + log.println("inserting Strings"); + log.println("inserting ControlCharacter"); + + for (int i = 0; i < 5; i++) { + oText.insertString(oCursor, "Paragraph Number: " + i, false); + oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK, + false); + oText.insertString( + oCursor, + "The quick brown fox jumps over the lazy Dog: SwXParagraph\n", + false); + oText.insertControlCharacter(oCursor, ControlCharacter.LINE_BREAK, + false); + oText.insertString( + oCursor, + "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG: SwXParagraph", + false); + oText.insertControlCharacter(oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + } + + // Enumeration + XEnumerationAccess oEnumA = UnoRuntime.queryInterface( + XEnumerationAccess.class, oText); + XEnumeration oEnum = oEnumA.createEnumeration(); + + while (oEnum.hasMoreElements()) { + param = (XInterface) AnyConverter.toObject(new Type( + XInterface.class), oEnum.nextElement()); + } + + XEnumerationAccess oEnumP = UnoRuntime.queryInterface( + XEnumerationAccess.class, param); + XEnumeration oEnum2 = oEnumP.createEnumeration(); + + log.println("creating a new environment for TextPortionEnumeration object"); + TestEnvironment tEnv = new TestEnvironment(oEnum2); + + log.println("adding ObjRelation ENUM for XEnumeration"); + tEnv.addObjRelation("ENUM", oEnumP); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextPortionEnumeration + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextRange.java b/qadevOOo/tests/java/mod/_sw/SwXTextRange.java new file mode 100644 index 000000000..e96c722b4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextRange.java @@ -0,0 +1,85 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +public class SwXTextRange extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + + XText aText = 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 bodytext of textdocument here + log.println( "getting the TextRange of the text document" ); + aText = xTextDoc.getText(); + XTextCursor oCursor = aText.createTextCursor(); + + XInterface oObj = oCursor.getStart(); + + log.println( "creating a new environment for textrange object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + System.out.println("Implementation Name: "+utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextRange + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java b/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java new file mode 100644 index 000000000..32e97b47d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextRanges.java @@ -0,0 +1,115 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; + +/** + * + * initial description + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * + */ +public class SwXTextRanges extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + 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" ); + + // create testobject here + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int j =0; j < 5; j++){ + try{ + oText.insertString( oCursor, + "SwXTextRanges...SwXTextRanges...SwXTextRanges", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + catch( Exception e ){ + log.println( "EXCEPTION: " + e); + } + } + + XSearchable oSearch = UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextRanges"); + + oObj = oSearch.findAll(xSDesc); + + log.println( "creating a new environment for textrange object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextRanges + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java b/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java new file mode 100644 index 000000000..0ca1bbef7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSearch.java @@ -0,0 +1,116 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.util.SearchDescriptor + * @see com.sun.star.util.XSearchDescriptor + * + */ +public class SwXTextSearch extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) { + + 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" ); + + // create testobject here + + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + for (int j =0; j < 5; j++){ + try{ + oText.insertString( oCursor, + "SwXTextSearch...SwXTextSearch...SwXTextSearch", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false ); + } + catch( Exception e ){ + log.println( "EXCEPTION: " + e); + } + } + + XSearchable oSearch = UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextSearch"); + + oObj = xSDesc; + + log.println( "creating a new environment for TextSearch object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextSearch + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSection.java b/qadevOOo/tests/java/mod/_sw/SwXTextSection.java new file mode 100644 index 000000000..9fd67a72a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSection.java @@ -0,0 +1,159 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.InstCreator; +import util.SOfficeFactory; +import util.TableDsc; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextColumns; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextSection; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.text.XWordCursor; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ + +public class SwXTextSection extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { + + XInterface oObj = null; + XInterface oTS = null; + XTextSection xTS = null; + XText oText = null; + XTextColumns TC = null; + Object instance = null; + + log.println( "creating a test environment" ); + + oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + try { + XTextSectionsSupplier oTSSupp = UnoRuntime.queryInterface + ( XTextSectionsSupplier.class, xTextDoc ); + XNameAccess oTSSuppName = oTSSupp.getTextSections(); + + //cleanup if necessary + if (oTSSuppName.hasByName("SwXTextSection")) { + XTextSection old = (XTextSection) AnyConverter.toObject( + new Type(XTextSection.class), + oTSSuppName.getByName("SwXTextSection")); + XComponent oldC = UnoRuntime.queryInterface(XComponent.class,old); + oldC.dispose(); + oText.setString(""); + } + + //insert two sections parent and child + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + instance = oDocMSF.createInstance("com.sun.star.text.TextSection"); + XTextContent oTSC = UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + XWordCursor oWordC = UnoRuntime.queryInterface(XWordCursor.class, oCursor); + oCursor.setString("End of TextSection"); + oCursor.gotoStart(false); + oCursor.setString("Start of TextSection "); + oWordC.gotoEndOfWord(false); + XInterface oTS2 = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + oTSC = UnoRuntime.queryInterface(XTextContent.class, oTS2); + oText.insertTextContent(oCursor, oTSC, false); + + XIndexAccess oTSSuppIndex = UnoRuntime.queryInterface(XIndexAccess.class, oTSSuppName); + + log.println( "getting a TextSection with the XTextSectionSupplier()" ); + xTS = (XTextSection) AnyConverter.toObject( + new Type(XTextSection.class),oTSSuppIndex.getByIndex(0)); + XNamed xTSName = UnoRuntime.queryInterface( XNamed.class, xTS); + xTSName.setName("SwXTextSection"); + } + catch(Exception e){ + System.out.println("Couldn't get Textsection " + e); + } + + oObj = xTS; + + log.println( "creating a new environment for TextSection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding InstDescriptor object" ); + TableDsc tDsc = new TableDsc( 6, 4 ); + + log.println( "adding InstCreator object" ); + tEnv.addObjRelation( "XTEXTINFO", new InstCreator( xTextDoc, tDsc ) ); + + tEnv.addObjRelation("TRO",Boolean.TRUE); + + TC = UnoRuntime.queryInterface(XTextColumns.class, + oDocMSF.createInstance("com.sun.star.text.TextColumns")); + tEnv.addObjRelation("TC",TC); + + tEnv.addObjRelation("CONTENT", UnoRuntime.queryInterface(XTextContent.class,instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } // finish method getTestEnvironment + +}// finish class SwXTextSection + + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextSections.java b/qadevOOo/tests/java/mod/_sw/SwXTextSections.java new file mode 100644 index 000000000..c00d0cb5e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextSections.java @@ -0,0 +1,122 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextSectionsSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.text.XText + * + */ +public class SwXTextSections extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = null; + XInterface oTS = null; + XNameAccess oTSSuppName = null; + + XText oText = null; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + + oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + + + log.println( "inserting TextSections" ); + + XMultiServiceFactory oDocMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + + // First TextSection + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + XTextContent oTSC = UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC, false); + + // Second TextSection + oTS = (XInterface) oDocMSF.createInstance + ("com.sun.star.text.TextSection"); + XTextContent oTSC2 = UnoRuntime.queryInterface(XTextContent.class, oTS); + oText.insertTextContent(oCursor, oTSC2, false); + + + log.println( "try to get a TextSection with the XTextSectionSupplier()" ); + + try{ + XTextSectionsSupplier oTSSupp = UnoRuntime.queryInterface( XTextSectionsSupplier.class, + xTextDoc ); + oTSSuppName = oTSSupp.getTextSections(); + } + catch(Exception e){ + System.out.println("Couldn't get Textsection " + e); + } + + + oObj = oTSSuppName; + + log.println( "creating a new environment for TextSections object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextSection diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTable.java b/qadevOOo/tests/java/mod/_sw/SwXTextTable.java new file mode 100644 index 000000000..2ff21ff52 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTable.java @@ -0,0 +1,235 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.ValueComparer; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.table.XCell; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.UnoRuntime; + + +/** + * this class tests the implementation of listed interfaces + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.container.XNamed + * @see com.sun.star.lang.XComponent + * @see com.sun.star.text.TextContent + * @see com.sun.star.text.XTextContent + * @see com.sun.star.text.XTextTable + */ +public class SwXTextTable extends TestCase { + SOfficeFactory SOF; + XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + this method creates the testenvironment + @param tParam TestParameters class which contains additional + test parameters + @param log PrintWriter class to log the test state and result + + @return TestEnvironment class + + @see TestParameters + @see PrintWriter + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) { + // creation of testobject here + XTextTable oObj = null; + TestEnvironment tEnv = null; + Object instance = null; + + oObj = SOfficeFactory.createTextTable(xTextDoc); + instance = SOfficeFactory.createTextTable(xTextDoc); + + int nRow = 6; + int nCol = 2; + oObj.initialize(nRow, nCol); + + log.println("Creating instance..."); + tEnv = new TestEnvironment(oObj); + + if (SOfficeFactory.getTableCollection(xTextDoc).getCount() == 0) { + SOfficeFactory.insertTextContent(xTextDoc, oObj); + } + + XPropertySet props = UnoRuntime.queryInterface( + XPropertySet.class, oObj); + + try { + props.setPropertyValue("ChartRowAsLabel", Boolean.TRUE); + props.setPropertyValue("ChartColumnAsLabel", Boolean.TRUE); + } catch (Exception e) { + e.printStackTrace(log); + } + + + //Adding relation for util.XTextTable + tEnv.addObjRelation("NROW", Integer.valueOf(nRow)); + tEnv.addObjRelation("NCOL", Integer.valueOf(nCol)); + + //Adding ObjRelation for XCellRangeData + Object[][] newData = new Object[6][]; + Object[] line = new Object[2]; + line[0] = new Double(1.5); + line[1] = new Double(2.5); + newData[0] = line; + newData[1] = line; + newData[2] = line; + newData[3] = line; + newData[4] = line; + newData[5] = line; + tEnv.addObjRelation("NewData", newData); + + //Adding relation for util.XSortable + final PrintWriter finalLog = log; + final XTextTable oTable = oObj; + tEnv.addObjRelation("SORTCHECKER", + new ifc.util._XSortable.XSortChecker() { + PrintWriter out = finalLog; + + public void setPrintWriter(PrintWriter log) { + out = log; + } + + public void prepareToSort() { + oTable.getCellByName("A1").setValue(4); + + XTextRange textRange = UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A2")); + textRange.setString("b"); + oTable.getCellByName("A3").setValue(3); + textRange = UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A4")); + textRange.setString("a"); + oTable.getCellByName("A5").setValue(23); + textRange = UnoRuntime.queryInterface( + XTextRange.class, + oTable.getCellByName("A6")); + textRange.setString("ab"); + + } + + public boolean checkSort(boolean isSortNumbering, + boolean isSortAscending) { + out.println("Sort checking..."); + + boolean res = false; + String[] value = new String[6]; + + for (int i = 0; i < 6; i++) { + XCell cell = oTable.getCellByName("A" + (i + 1)); + XTextRange textRange = UnoRuntime.queryInterface( + XTextRange.class, cell); + value[i] = textRange.getString(); + } + + if (isSortNumbering) { + if (isSortAscending) { + String[] rightVal = { "3", "4", "23" }; + String[] vals = { value[3], value[4], value[5] }; + res = ValueComparer.equalValue(vals, rightVal); + + if (!res) { + out.println("Expected: 3, 4, 23"); + out.println("Getting: " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } else { + String[] rightVal = { "23", "4", "3" }; + String[] vals = { value[0], value[1], value[2] }; + res = ValueComparer.equalValue(vals, rightVal); + + if (!res) { + out.println("Expected: 23, 4, 3"); + out.println("Getting: " + value[1] + ", " + + value[2] + ", " + value[3]); + } + } + } else { + if (isSortAscending) { + String[] rightVal = { "23", "3", "4", "a", "ab", "b" }; + res = ValueComparer.equalValue(value, rightVal); + + if (!res) { + out.println("Expected: 23, 3, 4, a, ab, b"); + out.println("Getting: " + value[0] + ", " + + value[1] + ", " + value[2] + + ", " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } else { + String[] rightVal = { "b", "ab", "a", "4", "3", "23" }; + res = ValueComparer.equalValue(value, rightVal); + + if (!res) { + out.println("Expected: b, ab, a, 4, 3, 23"); + out.println("Getting: " + value[0] + ", " + + value[1] + ", " + value[2] + + ", " + value[3] + ", " + + value[4] + ", " + value[5]); + } + } + } + + if (res) { + out.println("Sorted correctly"); + } else { + out.println("Sorted incorrectly"); + } + + return res; + } + }); + + tEnv.addObjRelation("CONTENT", + UnoRuntime.queryInterface( + XTextContent.class, instance)); + tEnv.addObjRelation("RANGE", xTextDoc.getText().createTextCursor()); + + return tEnv; + } +} // finish class SwXTextTable diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java new file mode 100644 index 000000000..6417a9a3e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTableCursor.java @@ -0,0 +1,104 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.XTextTableCursor + * + */ +public class SwXTextTableCursor extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws StatusException { + + 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" ); + + // get a soffice factory object + SOfficeFactory.getFactory( tParam.getMSF() ); + + // create testobject here + + XTextTable oTable = null; + oTable = SOfficeFactory.createTextTable( xTextDoc ); + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + + oObj = oTable.createCursorByCellName("A1"); + + log.println( "creating a new environment for TextTableCursor object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + tEnv.addObjRelation("STYLENAME1", "Table"); + tEnv.addObjRelation("STYLENAME2", "Text"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTableCursor + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java b/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java new file mode 100644 index 000000000..a8f4144f2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTableRow.java @@ -0,0 +1,113 @@ +/* + * 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._sw; + +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.table.XTableRows; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +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 SwXTextTableRow extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + + XInterface oObj = null; + XTextTable oTable = 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.getFactory( Param.getMSF() ); + + try { + log.println("creating a texttable"); + oTable = SOfficeFactory.createTextTable(xTextDoc,5,5); + } catch( Exception e ) { + e.printStackTrace(log); + } + + XText oText = xTextDoc.getText(); + + XTextCursor oCursor = oText.createTextCursor(); + + try { + log.println("inserting texttable"); + oText.insertTextContent(oCursor, oTable, false); + } catch (Exception e) { + log.println("Exception!"); + } + + try { + log.println("getting table row"); + XTableRows oTRn = oTable.getRows(); + XIndexAccess oIA = UnoRuntime.queryInterface + (XIndexAccess.class,oTRn); + oObj = (XPropertySet) AnyConverter.toObject( + new Type(XPropertySet.class),oIA.getByIndex(1)); + } catch( Exception e ) { + e.printStackTrace(log); + } + + log.println( "creating a new environment for TextTableRow object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTableRow + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextTables.java b/qadevOOo/tests/java/mod/_sw/SwXTextTables.java new file mode 100644 index 000000000..28ad076e4 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextTables.java @@ -0,0 +1,118 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.text.XTextTablesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * + * initial description + * @see com.sun.star.container.XElementAccess + * @see com.sun.star.container.XIndexAccess + * @see com.sun.star.container.XNameAccess + * + */ +public class SwXTextTables extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + XInterface oObj = null; + int nRow = 4; + int nCol = 5; + + + // 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.getFactory( tParam.getMSF() ); + + // create testobject here + TestEnvironment tEnv = null; + XTextTable oTable = null; + oTable = SOfficeFactory.createTextTable( xTextDoc ); + SOfficeFactory.insertTextContent(xTextDoc, oTable ); + + // Number two + XTextTable oTable2 = null; + oTable2 = SOfficeFactory.createTextTable( xTextDoc ); + SOfficeFactory.insertTextContent(xTextDoc, oTable2 ); + + XMultiServiceFactory msf = UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc); + XTextTablesSupplier oTTSupp = UnoRuntime.queryInterface(XTextTablesSupplier.class, msf); + oObj = oTTSupp.getTextTables(); + + if ( oTable != null ) { + log.println("Creating instance..."); + tEnv = new TestEnvironment(oObj); + } + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation( "TEXTDOC", xTextDoc ); + tEnv.addObjRelation( "ROW", Integer.valueOf( nRow ) ); + tEnv.addObjRelation( "COL", Integer.valueOf( nCol ) ); + tEnv.addObjRelation( "INST", SOfficeFactory.createTextTable( xTextDoc )); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class SwXTextTables + diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextView.java b/qadevOOo/tests/java/mod/_sw/SwXTextView.java new file mode 100644 index 000000000..9c72b2f0d --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextView.java @@ -0,0 +1,254 @@ +/* + * 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._sw; + +import com.sun.star.container.NoSuchElementException; +import com.sun.star.container.XNameContainer; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.WrappedTargetException; +import java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.form.XForm; +import com.sun.star.frame.XController; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.text.ControlCharacter; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextFrame; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.util.XSearchable; +import com.sun.star.view.XSelectionSupplier; +import util.FormTools; +import util.WriterTools; + +/** + * + * initial description + * @see com.sun.star.text.XTextViewCursorSupplier + * @see com.sun.star.view.XControlAccess + * @see com.sun.star.view.XSelectionSupplier + * @see com.sun.star.view.XViewSettingsSupplier + * + */ +public class SwXTextView extends TestCase { + + XTextDocument xTextDoc; + + boolean debug = false; + + /** + * in general this method creates a testdocument + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + debug = tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE); + } + + /** + * in general this method disposes the testenvironment and document + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * + * @see TestParameters + * * @see PrintWriter + * + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws com.sun.star.uno.Exception + { + + + // creation of testobject here + log.println( "creating a test environment" ); + + XController xContr = xTextDoc.getCurrentController(); + + TestEnvironment tEnv = new TestEnvironment(xContr); + + util.dbg.getSuppServices(xContr); + + SOfficeFactory SOF=SOfficeFactory.getFactory( tParam.getMSF() ); + XTextFrame first =null; + XTextFrame second =null; + + Object oFrame1 = null; + Object oFrame2 = null; + XText oText = xTextDoc.getText(); + XTextCursor oCursor = oText.createTextCursor(); + oFrame1 = SOF.createInstance + (xTextDoc, "com.sun.star.text.TextFrame" ); + first = UnoRuntime.queryInterface + ( XTextFrame.class, oFrame1); + oText.insertTextContent(oCursor,first, false); + first.getText().setString("Frame 1"); + oFrame2 = SOF.createInstance(xTextDoc, "com.sun.star.text.TextFrame" ); + second = UnoRuntime.queryInterface + ( XTextFrame.class, oFrame2); + oText.insertTextContent(oCursor,second, false); + second.getText().setString("Frame 2"); + oText.insertString( oCursor, + "SwXTextRanges...SwXTextRanges...SwXTextRanges", false); + oText.insertControlCharacter( oCursor, + ControlCharacter.PARAGRAPH_BREAK, false); + oText.insertString( oCursor, + "bla...bla...", false); + + XSearchable oSearch = UnoRuntime.queryInterface + (XSearchable.class, xTextDoc); + XSearchDescriptor xSDesc = oSearch.createSearchDescriptor(); + xSDesc.setSearchString("SwXTextRanges"); + XIndexAccess textRanges1 = oSearch.findAll(xSDesc); + + xSDesc.setSearchString("bla"); + XIndexAccess textRanges2 = oSearch.findAll(xSDesc); + + tEnv.addObjRelation("Selections", new Object[] { + oFrame1, oFrame2, textRanges1, textRanges2}); + tEnv.addObjRelation("Comparer", new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XServiceInfo serv1 = UnoRuntime.queryInterface(XServiceInfo.class, o1); + XServiceInfo serv2 = UnoRuntime.queryInterface(XServiceInfo.class, o2); + + String implName1 = serv1.getImplementationName(); + String implName2 = serv2.getImplementationName(); + if (!implName1.equals(implName2)) { + return -1; + } + + XIndexAccess indAc1 = UnoRuntime.queryInterface(XIndexAccess.class, o1); + XIndexAccess indAc2 = UnoRuntime.queryInterface(XIndexAccess.class, o2); + + if (indAc1 != null && indAc2 != null) { + int c1 = indAc1.getCount(); + int c2 = indAc2.getCount(); + return c1 == c2 ? 0 : 1; + } + + XText text1 = UnoRuntime.queryInterface(XText.class, o1); + XText text2 = UnoRuntime.queryInterface(XText.class, o2); + + if (text1 != null && text2 != null) { + return text1.getString().equals(text2.getString()) ? 0 : 1; + } + + return -1; + } + }); + + XSelectionSupplier xsel = UnoRuntime.queryInterface(XSelectionSupplier.class,xContr); + xsel.select(second); + + tEnv.addObjRelation("DOCUMENT",xTextDoc); + XForm myForm = null; + String kindOfControl="CommandButton"; + XShape aShape = null; + log.println("adding control shape '" + kindOfControl + "'"); + aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + kindOfControl); + + + log.println("adding relation for com.sun.star.view.XFormLayerAccess: XForm"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + try { + + XDrawPage xDP = WriterTools.getDrawPage(xTextDoc); + if (xDP == null) + log.println("ERROR: could not get DrawPage"); + + XNameContainer xForms = FormTools.getForms(xDP); + if (xForms == null) + log.println("ERROR: could not get Forms"); + + log.println("the draw page contains following elements:"); + String[] elements = FormTools.getForms(WriterTools.getDrawPage(xTextDoc)).getElementNames(); + for (int i = 0; i< elements.length; i++){ + log.println("Element[" + i + "] :" + elements[i]); + } + + myForm = (XForm) AnyConverter.toObject(new Type(XForm.class), xForms.getByName("Standard")); + if (myForm == null){ + log.println("ERROR: could not get 'Standard' from drawpage!"); + if (debug){ + log.println("the draw page contains following elements:"); + } + } + else + tEnv.addObjRelation("XFormLayerAccess.XForm", myForm); + } catch (WrappedTargetException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } catch (NoSuchElementException ex) { + log.println("ERROR: could not add ObjectRelation 'XFormLayerAccess.XForm': " + ex.toString()); + } + + + return tEnv; + + } // finish method getTestEnvironment +} // finish class SwXTextView diff --git a/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.java b/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.java new file mode 100644 index 000000000..1ee16ff4e --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXTextViewCursor.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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextViewCursorSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.beans.XPropertyState + * @see com.sun.star.document.XDocumentInsertable + * @see com.sun.star.style.CharacterProperties + * @see com.sun.star.style.ParagraphProperties + * @see com.sun.star.text.XPageCursor + * @see com.sun.star.text.XParagraphCursor + * @see com.sun.star.text.XSentenceCursor + * @see com.sun.star.text.XTextCursor + * @see com.sun.star.text.XTextRange + * @see com.sun.star.text.XWordCursor + * @see com.sun.star.util.XSortable + * @see com.sun.star.view.XScreenCursor + * + */ +public class SwXTextViewCursor extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) { + + 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" ); + + // create testobject here + oObj = xTextDoc.getCurrentController(); + + XTextViewCursorSupplier oTVCSupp = UnoRuntime.queryInterface(XTextViewCursorSupplier.class, oObj); + + oObj = oTVCSupp.getViewCursor(); + + log.println( "creating a new environment for TextViewCursor object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + tEnv.addObjRelation("XTEXT", xTextDoc.getText()); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXTextViewCursor diff --git a/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java b/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java new file mode 100644 index 000000000..b1ea4407c --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/SwXViewSettings.java @@ -0,0 +1,97 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** + * + * initial description + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.text.ViewSettings + * + */ +public class SwXViewSettings extends TestCase { + XTextDocument xTextDoc; + + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + + /** + * creating a TestEnvironment for the interfaces to be tested + * + * @param tParam class which contains additional test parameters + * @param log class to log the test state and result + * + * @return Status class + * + * @see TestParameters + * @see PrintWriter + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) { + + 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" ); + + // create testobject here + + oObj = xTextDoc.getCurrentController(); + XViewSettingsSupplier oVSSupp = UnoRuntime.queryInterface(XViewSettingsSupplier.class, oObj); + + oObj = oVSSupp.getViewSettings(); + + log.println( "creating a new environment for ViewSettings object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + log.println( "adding TextDocument as mod relation to environment" ); + tEnv.addObjRelation("TEXTDOC", xTextDoc); + + return tEnv; + } // finish method getTestEnvironment + + +} // finish class SwXViewSettings + diff --git a/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java b/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java new file mode 100644 index 000000000..e05a117a0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLContentExporter.java @@ -0,0 +1,178 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XTextDocument xTextDoc; + ContentFilterChecker Filter; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. A string inserted into document. This made + * for checking if this string is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) throws Exception { + + final String CONTENT = "XMLContentExporter"; + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + Filter = new ContentFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + // text added to the document + XSimpleText aText = xTextDoc.getText(); + XTextCursor curs = aText.createTextCursor(); + aText.insertString(curs, CONTENT, false); + + // adding tags which must be contained in XML output + Filter.addTag("office:document-content") ; + Filter.addTagEnclosed("office:body", "office:document-content") ; + Filter.addTagEnclosed("office:script", "office:document-content") ; + Filter.addTagEnclosed("office:body", "office:document-content") ; + Filter.addCharactersEnclosed(CONTENT, "text:p") ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class ContentFilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private ContentFilterChecker(PrintWriter log) { + super(log) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java b/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java new file mode 100644 index 000000000..e10549ced --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLContentImporter.java @@ -0,0 +1,157 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Text document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLContentImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only content tags including test text. + * After import text getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impText = "XMLContentImporter test." ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLContentImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-content", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text" + }, + {"start", "office:body"}, + {"start", "text:p"}, + {"chars", impText}, + {"end", "text:p"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final XTextDocument textDoc = UnoRuntime.queryInterface + (XTextDocument.class, xTextDoc) ; + final PrintWriter fLog = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String docText = textDoc.getText().getString() ; + fLog.println("Document text returned = '" + docText + "'") ; + return impText.equals(docText) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLExporter.java b/qadevOOo/tests/java/mod/_sw/XMLExporter.java new file mode 100644 index 000000000..4cee8fb68 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLExporter.java @@ -0,0 +1,181 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XTextDocument xTextDoc; + FilterChecker Filter; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. A string inserted into document. This made + * for checking if this string is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + final String TEST_STR = "XMLExporter"; + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + Filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),Filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + XSimpleText aText = xTextDoc.getText(); + XTextCursor curs = aText.createTextCursor(); + aText.insertString(curs, TEST_STR, false); + + // adding tags which must be contained in XML output + Filter.addTag("office:document") ; + Filter.addTagEnclosed("office:meta", "office:document") ; + Filter.addTagEnclosed("office:settings", "office:document") ; + Filter.addTagEnclosed("office:script", "office:document") ; + Filter.addTagEnclosed("office:styles", "office:document") ; + Filter.addTagEnclosed("office:body", "office:document") ; + Filter.addCharactersEnclosed(TEST_STR, "text:p") ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + return tEnv; + + } // finish method getTestEnvironment + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags() ; + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLImporter.java b/qadevOOo/tests/java/mod/_sw/XMLImporter.java new file mode 100644 index 000000000..92291cde6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLImporter.java @@ -0,0 +1,153 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XImporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Text document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported tags contain tag including tag with test text. + * After import text getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + oObj = (XInterface) xMSF.createInstance + ("com.sun.star.comp.Writer.XMLImporter"); + XImporter xIm = UnoRuntime.queryInterface + (XImporter.class,oObj); + xIm.setTargetDocument(xTextDoc); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + final String impText = "XMLImporter test." ; + String[][] xml = new String[][] { + {"start", "office:document" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "office:class", "CDATA", "text", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text"}, + {"start", "office:body" }, + {"start", "text:p" }, + {"chars", impText}, + {"end", "text:p"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + tEnv.addObjRelation("TargetDocument",xTextDoc); + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + final XTextDocument textDoc = UnoRuntime.queryInterface + (XTextDocument.class, xTextDoc) ; + final PrintWriter fLog = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String docText = textDoc.getText().getString() ; + fLog.println("Document text returned = '" + docText + "'") ; + return impText.equals(docText) ; + } + }) ; + + return tEnv; + + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java new file mode 100644 index 000000000..7c4b7df26 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java @@ -0,0 +1,178 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + + XTextDocument xTextDoc; + MetaFilterChecker Filter; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. The 'Title' metadata property is set to a value. This made + * for checking if this property is successfully exported within + * the document metadata. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) throws Exception { + final String TITLE = "Title for testing of XMLMetaExporter"; + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + Filter = new MetaFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLMetaExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + //set some meta data + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xTextDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(TITLE); + + // adding tags which must be contained in XML output + Filter.addTag("office:document-meta"); + Filter.addTagEnclosed("office:meta", "office:document-meta"); + Filter.addCharactersEnclosed(TITLE, "dc:title"); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument", xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class MetaFilterChecker extends XMLTools.XMLTagsChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private MetaFilterChecker(PrintWriter log) { + super(log) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return checkTags(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java new file mode 100644 index 000000000..354444f82 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java @@ -0,0 +1,161 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Text document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLMetaImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only meta tags including + * title tag with test name. + * After import title name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impTitle = "XMLMetaImporter test." ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLMetaImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"}, + {"start", "office:meta"} , + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xTextDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java new file mode 100644 index 000000000..f736f5869 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLSettingsExporter.java @@ -0,0 +1,187 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + + XTextDocument xTextDoc; + SettingsFilterChecker Filter; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. New document zoom is set as one of the 'View' settings. This made + * for checking if this setting is successfully exported within + * the document settings. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + final short ZOOM = 50; + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + Filter = new SettingsFilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + //set some settings + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, + xController); + XPropertySet xPropSet = xViewSetSup.getViewSettings(); + xPropSet.setPropertyValue("ZoomValue", Short.valueOf(ZOOM)); + + // adding tags which must be contained in XML output + Filter.addTag( new XMLTools.Tag("office:document-settings") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document-settings") ); + Filter.addCharactersEnclosed( + String.valueOf(ZOOM), + new XMLTools.Tag("config:config-item", + "config:name", "ZoomFactor") ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", Filter); + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class SettingsFilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private SettingsFilterChecker(PrintWriter log) { + super(log, false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java new file mode 100644 index 000000000..0c10e971a --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLSettingsImporter.java @@ -0,0 +1,187 @@ +/* + * 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._sw; + +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.frame.XController; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XViewSettingsSupplier; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Text document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLSettingsImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only settings tags including + * title tag with test zoom factor. + * After import zoom factor getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final short impZoom = 50 ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLSettingsImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + }, + {"start", "office:settings"}, + {"start", "config:config-item-set", + "config:name", "CDATA", "view-settings" + }, + {"start", "config:config-item-map-indexed", + "config:name", "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomFactor", + "config:type", "CDATA", "short" + }, + {"chars", String.valueOf(impZoom)}, + {"end", "config:config-item"}, + {"start", "config:config-item", + "config:name", "CDATA", "ZoomType", + "config:type", "CDATA", "short" + }, + {"chars", "0"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "config:config-item-set"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + XController xController = xTextDoc.getCurrentController(); + XViewSettingsSupplier xViewSetSup = UnoRuntime.queryInterface(XViewSettingsSupplier.class, xController); + final XPropertySet xPropSet = xViewSetSup.getViewSettings(); + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Short gValue = (Short) + xPropSet.getPropertyValue("ZoomValue"); + logF.println("ZoomValue property value = " + gValue) ; + return impZoom == gValue.shortValue() ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception while checking import :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java new file mode 100644 index 000000000..f676430dd --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLStylesExporter.java @@ -0,0 +1,180 @@ +/* + * 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._sw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /* + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Calc.XMLStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The text document is set as a source document for exporter + * created. Footnote property 'Prefix' is set to a new value. This made + * for checking if this property value is successfully exported within + * the document styles. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log) ; + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Writer.XMLStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface + (XExporter.class,oObj); + xEx.setSourceDocument(xTextDoc); + + // Checking Head Tag existence and that property has changed + filter.addTag(new XMLTools.Tag ("office:document-styles")); + filter.addTag(new XMLTools.Tag ("text:footnotes-configuration", + "style:num-prefix","New Property")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Obtain Footnotes properties + XFootnotesSupplier supp = UnoRuntime.queryInterface + (XFootnotesSupplier.class, xTextDoc); + XPropertySet set = supp.getFootnoteSettings(); + + // Change property "Prefix" + set.setPropertyValue("Prefix","New Property"); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"swriter: StarOffice XML (Writer)"})); + tEnv.addObjRelation("SourceDocument",xTextDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } + +} + diff --git a/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.java new file mode 100644 index 000000000..c51f1d2e0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/XMLStylesImporter.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._sw; + +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.lang.XMultiServiceFactory; +import com.sun.star.text.XFootnotesSupplier; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Writer.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XTextDocument xTextDoc; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + + log.println( "creating a textdocument" ); + xTextDoc = SOF.createTextDoc( null ); + } + + /** + * Text document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xTextDoc " ); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Writer.XMLStylesImporter</code><p> + * + * The text document is set as a target document for importer. + * Imported XML-data contains only style tags including + * title tag with test prefix. + * After import prefixes getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters tParam, + PrintWriter log ) + throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impPrefix = "Prefix" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Writer.XMLStylesImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xTextDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text" + }, + {"start", "office:styles"}, + {"start", "text:footnotes-configuration", + "style:num-prefix", "CDATA", impPrefix}, + {"end", "text:footnotes-configuration"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XFootnotesSupplier supp = UnoRuntime.queryInterface + (XFootnotesSupplier.class, xTextDoc); + final XPropertySet set = supp.getFootnoteSettings(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String prefix = (String) set.getPropertyValue("Prefix"); + logF.println("Prefix returned = '" + prefix + "'") ; + return impPrefix.equals(prefix) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_sw/package.html b/qadevOOo/tests/java/mod/_sw/package.html new file mode 100644 index 000000000..3be3b188f --- /dev/null +++ b/qadevOOo/tests/java/mod/_sw/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 'sw'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_sysdtrans/SystemClipboard.java b/qadevOOo/tests/java/mod/_sysdtrans/SystemClipboard.java new file mode 100644 index 000000000..f70dcd961 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sysdtrans/SystemClipboard.java @@ -0,0 +1,44 @@ +/* + * 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._sysdtrans; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class SystemClipboard extends TestCase { + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.datatransfer.clipboard.SystemClipboard"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_sysdtrans/package.html b/qadevOOo/tests/java/mod/_sysdtrans/package.html new file mode 100644 index 000000000..a530c6b12 --- /dev/null +++ b/qadevOOo/tests/java/mod/_sysdtrans/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 'sysdtrans'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_syssh/SystemShellExecute.java b/qadevOOo/tests/java/mod/_syssh/SystemShellExecute.java new file mode 100644 index 000000000..08b0af7dd --- /dev/null +++ b/qadevOOo/tests/java/mod/_syssh/SystemShellExecute.java @@ -0,0 +1,44 @@ +/* + * 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._syssh; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class SystemShellExecute extends TestCase { + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.system.SystemShellExecute"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_tcv/TypeConverter.java b/qadevOOo/tests/java/mod/_tcv/TypeConverter.java new file mode 100644 index 000000000..e0019b8ea --- /dev/null +++ b/qadevOOo/tests/java/mod/_tcv/TypeConverter.java @@ -0,0 +1,59 @@ +/* + * 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._tcv; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class TypeConverter extends TestCase { + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.script.Converter" ); + } + catch( Exception e ) { + log.println("Service not available" ); + } + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class TypeConverter + diff --git a/qadevOOo/tests/java/mod/_tcv/package.html b/qadevOOo/tests/java/mod/_tcv/package.html new file mode 100644 index 000000000..45007682b --- /dev/null +++ b/qadevOOo/tests/java/mod/_tcv/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 'tcv'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_tdmgr/TypeDescriptionManager.java b/qadevOOo/tests/java/mod/_tdmgr/TypeDescriptionManager.java new file mode 100644 index 000000000..f2e2a2831 --- /dev/null +++ b/qadevOOo/tests/java/mod/_tdmgr/TypeDescriptionManager.java @@ -0,0 +1,76 @@ +/* + * 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._tdmgr; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; + +public class TypeDescriptionManager extends TestCase { + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws StatusException { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, xMSF); + // get context + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, + xProp.getPropertyValue("DefaultContext")); + // get the type description manager from context + oInterface = xContext.getValueByName("/singletons/" + + "com.sun.star.reflection.theTypeDescriptionManager"); + } + catch( Exception e ) { + log.println("Introspection Service not available" ); + } + oObj = (XInterface) oInterface; + + + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Object relation for XHierarchicalNameAccess ifc + // Name of the existing object + tEnv.addObjRelation("ElementName", "com.sun.star.container.XNameAccess") ; + tEnv.addObjRelation("SearchString", "com.sun.star.loader"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class TypeDescriptionManager + diff --git a/qadevOOo/tests/java/mod/_tdmgr/package.html b/qadevOOo/tests/java/mod/_tdmgr/package.html new file mode 100644 index 000000000..277a28045 --- /dev/null +++ b/qadevOOo/tests/java/mod/_tdmgr/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 'tdmgr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_text/DefaultNumberingProvider.java b/qadevOOo/tests/java/mod/_text/DefaultNumberingProvider.java new file mode 100644 index 000000000..a673cba8d --- /dev/null +++ b/qadevOOo/tests/java/mod/_text/DefaultNumberingProvider.java @@ -0,0 +1,68 @@ +/* + * 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._text; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.text.DefaultNumberingProvider</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::text::XDefaultNumberingProvider</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.text._DefaultNumberingProvider +* @see ifc.text._XDefaultNumberingProvider +*/ +public class DefaultNumberingProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.text.DefaultNumberingProvider</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ("com.sun.star.text.DefaultNumberingProvider" ); + + oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleButton.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleButton.java new file mode 100644 index 000000000..299e366dc --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleButton.java @@ -0,0 +1,195 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Object implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> + * <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleButton extends lib.TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens 'Printer Settings' dialog using document dispatch provider running + * in a separate thread. Finds active top window (the dialog window) and + * finds accessible button 'OK' walking through the accessible component + * tree. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XMultiServiceFactory msf = Param.getMSF(); + + oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, + oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController xController = aModel.getCurrentController(); + + // Opening PrinterSetupDialog + String aSlotID = ".uno:Zoom"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( + XDispatchProvider.class, xController); + XURLTransformer xParser = UnoRuntime.queryInterface( + XURLTransformer.class, + msf.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[] { new URL() }; + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + + XDispatch xDispatcher = xDispProv.queryDispatch(aParseURL[0], "", 0); + if (xDispatcher != null) { + xDispatcher.dispatch(aParseURL[0], null); + } + + util.utils.waitForEventIdle(msf); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, + Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, "Cancel"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + action = UnoRuntime.queryInterface(XAccessibleAction.class, oObj); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + System.out.println("Grabbing focus ... "); + acomp.grabFocus(); + } + }); + + XAccessibleText text = UnoRuntime.queryInterface(XAccessibleText.class, + oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + return tEnv; + } + + /** + * Closes the dialog using accessible button 'OK' found in + * <code>createTestEnvironment()</code>. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Opens new writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) + throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } + +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleCheckBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleCheckBox.java new file mode 100644 index 000000000..8c737225a --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleCheckBox.java @@ -0,0 +1,207 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by accessible component of check box in + * 'InsertTable' dialog. + * <p> + * + * Object implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> + * <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleCheckBox extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens 'Insert Table' dialog using document dispatch provider running in a + * separate thread. Finds active top window (the dialog window) and finds + * first accessible check box walking through the accessible component tree. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XMultiServiceFactory msf = Param.getMSF(); + log.println("Creating text document"); + + if (xTextDoc == null) { + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xTextDoc = SOF.createTextDoc(null); + } + + util.utils.waitForEventIdle(Param.getMSF()); + + XInterface oObj = null; + + log.println("getting toolkit"); + + oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, + oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("Opening Dialog in second thread"); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController xController = aModel.getCurrentController(); + + // Opening PrinterSetupDialog + String aSlotID = ".uno:InsertTable"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( + XDispatchProvider.class, xController); + XURLTransformer xParser = UnoRuntime.queryInterface( + XURLTransformer.class, + msf.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[] { new URL() }; + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + + XDispatch xDispatcher = xDispProv.queryDispatch(aParseURL[0], "", 0); + if (xDispatcher != null) { + xDispatcher.dispatch(aParseURL[0], null); + } + + util.utils.waitForEventIdle(msf); + + log.println("Getting the active TopWindow"); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, + Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, "Cancel"); + + action = UnoRuntime.queryInterface(XAccessibleAction.class, oObj); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.CHECK_BOX); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + System.out.println("Grabbing focus ... "); + acomp.grabFocus(); + } + }); + + XAccessibleText text = UnoRuntime.queryInterface(XAccessibleText.class, + oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + return tEnv; + } + + /** + * Closes the dialog using accessible button 'Cancel' found in + * <code>createTestEnvironment()</code>. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + log.println("closing dialog"); + action.doAccessibleAction(0); + log.println("closing the document"); + util.DesktopTools.closeDoc(xTextDoc); + log.println("reinitialize the variable"); + xTextDoc = null; + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + } + +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleComboBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleComboBox.java new file mode 100644 index 000000000..5e04b73da --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleComboBox.java @@ -0,0 +1,194 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + +/** + * Test for object which is represented by accessible component of the 'Font' + * combo box in Format->Character... dialog box. + * <p> + * + * Object implements the following interfaces : + * <ul> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> + * <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> + * <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleComboBox extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens CharacterStyle dialog and finds AccessibleComboBox walking through + * the accessible component tree. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, + oObj); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XController xController = aModel.getCurrentController(); + + // Opening PrinterSetupDialog + String aSlotID = ".uno:FontDialog"; + XDispatchProvider xDispProv = UnoRuntime.queryInterface( + XDispatchProvider.class, xController); + 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[] { new URL() }; + aParseURL[0].Complete = aSlotID; + xParser.parseStrict(aParseURL); + + XDispatch xDispatcher = xDispProv.queryDispatch(aParseURL[0], "", 0); + if (xDispatcher != null) { + xDispatcher.dispatch(aParseURL[0], null); + } + + util.utils.waitForEventIdle(Param.getMSF()); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, "Cancel"); + action = UnoRuntime.queryInterface(XAccessibleAction.class, oObj); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PAGE_TAB_LIST); + + XAccessibleSelection xAccSel = UnoRuntime.queryInterface( + XAccessibleSelection.class, oObj); + + try { + xAccSel.selectAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + util.utils.waitForEventIdle(Param.getMSF()); + + AccessibilityTools.printAccessibleTree(log, xRoot, + Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PANEL, "", "AccessibleComboBox"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + final XAccessibleComponent acomp1 = UnoRuntime.queryInterface( + XAccessibleComponent.class, action); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acomp1.grabFocus(); + acomp.grabFocus(); + } + }); + + return tEnv; + } + + /** + * Closes the dialog using accessible button 'Cancel' found in + * <code>createTestEnvironment()</code>. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" closing dialog "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates writer doc + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) + throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory(Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } + +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownComboBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownComboBox.java new file mode 100644 index 000000000..d1b465c0e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownComboBox.java @@ -0,0 +1,123 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XWindow; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by accessible component + * of the URL locator combo box located in the left upper corner + * of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleDropDownComboBox extends TestCase { + private static XTextDocument xTextDoc = null; + + /** + * Finds AccessibleDropDownComboBox walking through the + * accessible component tree of a writer document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + XWindow xWindow = AccessibilityTools.getCurrentContainerWindow( + xTextDoc); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.COMBO_BOX, + "", "AccessibleDropDownComboBox"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleAction editAction = UnoRuntime.queryInterface( + XAccessibleAction.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + editAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + } + } + }); + + return tEnv; + } + + /** + * Creates writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes writer document. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(xTextDoc); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownListBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownListBox.java new file mode 100644 index 000000000..7adcc1c2e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleDropDownListBox.java @@ -0,0 +1,127 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XWindow; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by style list box + * on toolbar of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleDropDownListBox extends TestCase { + private static XTextDocument xTextDoc = null; + /** + * Finds AccessibleDropDownListBox walking through the + * accessible component tree of a writer document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = AccessibilityTools.getCurrentWindow( + xTextDoc); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.COMBO_BOX, + "", "AccessibleDropDownListBox"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleAction acomp = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + acomp.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + throw new StatusException("Can't perform action 0", e); + } + } + }); + + return tEnv; + } + + /** + * Creates writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + // Dock the Navigator to supply an AccessibleDropDownListBox + DesktopTools.dockNavigator(Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes writer document. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleEdit.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleEdit.java new file mode 100644 index 000000000..d28592b6c --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleEdit.java @@ -0,0 +1,194 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleEditableText; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by edit field + * of 'Insert Hyperlink' dialog. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEditableText</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEditableText + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleEditableText + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleEdit extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens 'Insert Hyperlink' dialog using document dispatch provider. + * Finds active top window (the dialog + * window) and finds first accessible edit field and + * button 'Close' (for closing this dialog when disposing) + * walking through the accessible component tree. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) Param.getMSF().createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, + "Close"); + action = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TEXT); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleEditableText edText = UnoRuntime.queryInterface( + XAccessibleEditableText.class, + oObj); + edText.setText("AccessibleEdit"); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + edText.setText("firing event ..."); + edText.setText("firing event ... 2"); + edText.setText("AccessibleEdit"); + } + }); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("XAccessibleEditableText.hasAttr", Boolean.FALSE); + + return tEnv; + } + + /** + * Closes dialog using action of button 'Close' + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog ... "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates writer document + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleFixedText.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleFixedText.java new file mode 100644 index 000000000..f7a756685 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleFixedText.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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XFixedText; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XLayoutConstrains; +import com.sun.star.awt.Size; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.utils; + + +/** + * Test for object which is represented by accessible component + * of the fixed text label in 'Hyperlink' Dialog. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleFixedText extends TestCase { + private static XWindow xWinDlg = null; + + /** + * Creates a new dialog adds fixed text control to it and + * displays it. Then the text's accessible component is + * obtained. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XMultiServiceFactory xMSF = Param.getMSF(); + XControlModel dlgModel = null; + + XControl txtControl = null; + XControlModel txtModel = null; + + try { + dlgModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlDialogModel")); + + XControl dlgControl = UnoRuntime.queryInterface( + XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlDialog")); + + dlgControl.setModel(dlgModel); + + txtModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlFixedTextModel")); + + txtControl = UnoRuntime.queryInterface(XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlFixedText")); + + txtControl.setModel(txtModel); + + XFixedText xFT = UnoRuntime.queryInterface( + XFixedText.class, txtControl); + xFT.setText("FxedText"); + + /* Set the text control to its preferred size, otherwise it + * defaults to the size hard coded in its constructor (100 x 12) */ + XLayoutConstrains xLCTxt = UnoRuntime.queryInterface( + XLayoutConstrains.class, txtControl); + Size textSize = xLCTxt.getPreferredSize(); + XWindow xWinTxt = UnoRuntime.queryInterface( + XWindow.class, txtControl); + xWinTxt.setPosSize(0, 0, textSize.Width, textSize.Height, + PosSize.SIZE); + + XControlContainer ctrlCont = UnoRuntime.queryInterface( + XControlContainer.class, + dlgControl); + + ctrlCont.addControl("Text", txtControl); + + xWinDlg = UnoRuntime.queryInterface(XWindow.class, + dlgControl); + + xWinDlg.setVisible(true); + + xWinDlg.setPosSize(0, 0, 200, 100, PosSize.SIZE); + } catch (com.sun.star.uno.Exception e) { + log.println("Error creating dialog :"); + e.printStackTrace(log); + } + + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + util.utils.waitForEventIdle(Param.getMSF()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWinDlg); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.LABEL); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XWindow xWin = UnoRuntime.queryInterface(XWindow.class, + txtControl); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + xWin.setEnable(false); + xWin.setEnable(true); + } + }); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + return tEnv; + } + + /** + * Closes dialog using action of button 'Close' + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog ... "); + if (xWinDlg != null) + xWinDlg.dispose(); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleList.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleList.java new file mode 100644 index 000000000..f88b7dbe1 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleList.java @@ -0,0 +1,191 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +public class AccessibleList extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + private static XMultiServiceFactory msf = null; + + /** + * Opens 'Insert Hyperlink' dialog using document dispatch provider. + * Finds active top window (the dialog + * window) and finds button 'Close' (for closing this dialog when + * disposing) walking through the accessible component tree. + * Then the TREE component is found and the 'New Document' tab is + * selected to make list box visible. After that list box is obtained. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) msf.createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + // obtaining 'Close' button + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, + "Close"); + action = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + // Selecting 'New Document' tab + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TREE); + + XAccessibleSelection xAccSel = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj); + xAccSel.selectAccessibleChild(3); + util.utils.waitForEventIdle(Param.getMSF()); + + log.println("# Getting the ListBox"); + + XAccessibleContext parent = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PANEL, + "", + "com.sun.star.comp.toolkit.AccessibleListBox"); + + log.println("# Getting the first child"); + + try { + oObj = parent.getAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + final XAccessibleComponent acomp1 = UnoRuntime.queryInterface( + XAccessibleComponent.class, + action); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + System.out.println("Grabbing focus ... "); + acomp1.grabFocus(); + acomp.grabFocus(); + } + }); + + return tEnv; + } + + /** + * Closes dialog using action of button 'Close' + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog ... "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates writer document + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + msf = Param.getMSF(); + + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xTextDoc = SOF.createTextDoc(null); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java new file mode 100644 index 000000000..dcbef787f --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleListBox.java @@ -0,0 +1,205 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented accessible component + * of 'File type' list box situated in 'Insert Hyperlink' + * dialog on tab 'New Document'. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleListBox extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens 'Insert Hyperlink' dialog using document dispatch provider. + * Finds active top window (the dialog + * window) and finds button 'Close' (for closing this dialog when + * disposing) walking through the accessible component tree. + * Then the TREE component is found and the 'New Document' tab is + * selected to make list box visible. After that list box is obtained. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) Param.getMSF().createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + + // obtaining 'Close' button + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, + "Close"); + action = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + // Selecting 'New Document' tab + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TREE); + + XAccessibleSelection xAccSel = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj); + xAccSel.selectAccessibleChild(3); + util.utils.waitForEventIdle(Param.getMSF()); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL, "", + "com.sun.star.comp.toolkit.AccessibleListBox"); + + Object list = AccessibilityTools.getAccessibleObjectForRole(AccessibilityTools.SearchedAccessible, + AccessibleRole.LIST); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + list); + final XAccessibleComponent acomp1 = UnoRuntime.queryInterface( + XAccessibleComponent.class, + action); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + System.out.println("Grabbing focus ... "); + acomp1.grabFocus(); + acomp.grabFocus(); + } + }); + + return tEnv; + } + + /** + * Closes dialog using action of button 'Close' + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog ... "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates writer document + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleListItem.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleListItem.java new file mode 100644 index 000000000..58726c366 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleListItem.java @@ -0,0 +1,197 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented accessible component + * of 'File type' list box item situated in 'Insert Hyperlink' + * dialog on tab 'New Document'. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleListItem extends TestCase { + private static XTextDocument xTextDoc = null; + private static XAccessibleAction action = null; + + /** + * Opens 'Insert Hyperlink' dialog using document dispatch provider. + * Finds active top window (the dialog + * window) and finds button 'Close' (for closing this dialog when + * disposing) walking through the accessible component tree. + * Then the TREE component is found and the 'New Document' tab is + * selected to make list box visible. After that listbox item is obtained. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XMultiServiceFactory msf = Param.getMSF(); + XInterface oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) msf.createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + // obtaining 'Close' button + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON, + "Close"); + action = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + // Selecting 'New Document' tab + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TREE); + + XAccessibleSelection xAccSel = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj); + xAccSel.selectAccessibleChild(3); + util.utils.waitForEventIdle(Param.getMSF()); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.LIST_ITEM,"Spr"); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acomp.grabFocus(); + } + }); + + return tEnv; + } + + /** + * Closes dialog using action of button 'Close' + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println(" Closing dialog ... "); + + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException ioe) { + log.println("Couldn't close dialog"); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Dialog already disposed"); + } + + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creates writer document + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleMenu.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenu.java new file mode 100644 index 000000000..b050f6108 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenu.java @@ -0,0 +1,158 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented accessible component of + * main menu of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleText + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleText + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleMenu extends TestCase { + private static XTextDocument xTextDoc = null; + /** + * Finds accessible component with role <code>MENU</code> + * walking through the accessible component tree of a document. + */ + @Override + protected TestEnvironment createTestEnvironment(final TestParameters Param, + PrintWriter log) throws Exception { + XMultiServiceFactory msf = Param.getMSF(); + + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XAccessibleContext menubar = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.MENU_BAR); + XInterface oObj = null; + Object menu2 = null; + + try { + oObj = menubar.getAccessibleChild(2); + menu2 = menubar.getAccessibleChild(1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleAction act1 = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + final XAccessibleAction act2 = UnoRuntime.queryInterface( + XAccessibleAction.class, menu2); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + act2.doAccessibleAction(0); + + util.utils.waitForEventIdle(Param.getMSF()); + + act1.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + }); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("EditOnly", "Can't change or select Text in Menu"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected", + Boolean.FALSE); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + return tEnv; + } + + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + util.DesktopTools.closeDoc(xTextDoc); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Object already disposed"); + } + } + +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuBar.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuBar.java new file mode 100644 index 000000000..d50050394 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuBar.java @@ -0,0 +1,126 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented accessible component of + * menu bar of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleSelection</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleSelection + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleMenuBar extends TestCase { + private static XTextDocument xTextDoc = null; + /** + * Finds accessible component with role <code>MENUBAR</code> + * walking through the accessible component tree of a document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XInterface oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.MENU_BAR); + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + System.out.println("Grabbing focus ... "); + acomp.grabFocus(); + } + }); + + tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected", + Boolean.FALSE); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + return tEnv; + } + + /** + * Creates writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(xTextDoc); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuItem.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuItem.java new file mode 100644 index 000000000..0e9fa36ea --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuItem.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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleText; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by accessible component + * of a menu item in main menu of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleMenuItem extends TestCase { + private static XTextDocument xTextDoc = null; + private static XMultiServiceFactory msf = null; + + /** + * Finds first accessible component with role <code>MENUITEM</code> + * walking through the accessible component tree of a document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) msf.createInstance("com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(Param.getMSF()); + + Object atw = tk.getActiveTopWindow(); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + atw); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XAccessibleContext MenuBar = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.MENU_BAR); + + try { + //activate Edit-Menu + XAccessible Menu = MenuBar.getAccessibleChild(1); + XAccessibleAction act = UnoRuntime.queryInterface( + XAccessibleAction.class, Menu); + act.doAccessibleAction(0); + util.utils.waitForEventIdle(Param.getMSF()); + + //get a menu-item + oObj = Menu.getAccessibleContext().getAccessibleChild(11); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleAction action = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + }); + + XAccessibleText text = UnoRuntime.queryInterface( + XAccessibleText.class, oObj); + + tEnv.addObjRelation("XAccessibleText.Text", text.getText()); + + tEnv.addObjRelation("EditOnly", + "Can't change or select Text in MenuBarItem"); + + tEnv.addObjRelation("Destroy", Boolean.TRUE); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + return tEnv; + } + + /** + * Creates writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + msf = Param.getMSF(); + + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(xTextDoc); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuSeparator.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuSeparator.java new file mode 100644 index 000000000..48e14436f --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleMenuSeparator.java @@ -0,0 +1,141 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.AccessibilityTools; +import util.SOfficeFactory; +import util.utils; + + +/** + * Test for object which is represented by accessible component + * of a menu separator in main menu of a document. <p> + * + * Object implements the following interfaces : + * <ul> + * <li> <code>::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleEventBroadcaster</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li> <code>::com::sun::star::accessibility::XAccessibleContext</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleContext + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleContext + */ +public class AccessibleMenuSeparator extends TestCase { + private static XTextDocument xTextDoc = null; + private static XMultiServiceFactory msf = null; + + /** + * Finds first accessible component with role <code>SEPARATOR</code> + * and implementation name <code>AccessibleMenuSeparator</code> + * walking through the accessible component tree of a document. + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + util.utils.waitForEventIdle(Param.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, Param.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XAccessibleContext MenuBar = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.MENU_BAR); + XAccessibleAction act = null; + XInterface oObj = null; + + try { + //activate Edit-Menu + XAccessible Menu = MenuBar.getAccessibleChild(1); + act = UnoRuntime.queryInterface( + XAccessibleAction.class, Menu); + act.doAccessibleAction(0); + + util.utils.waitForEventIdle(Param.getMSF()); + + //get a menu-separator + oObj = Menu.getAccessibleContext().getAccessibleChild(3); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + + log.println("ImplementationName " + utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleAction aAct = act; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + aAct.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + } + } + }); + + return tEnv; + } + + /** + * Creates writer document. + */ + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + msf = Param.getMSF(); + + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + xTextDoc = SOF.createTextDoc(null); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + util.DesktopTools.closeDoc(xTextDoc); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessiblePopupMenu.java b/qadevOOo/tests/java/mod/_toolkit/AccessiblePopupMenu.java new file mode 100644 index 000000000..ed60cb7dc --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessiblePopupMenu.java @@ -0,0 +1,191 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.Point; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + +public class AccessiblePopupMenu extends TestCase { + private static XTextDocument xTextDoc; + private static Point point; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + + log.println("release the popup menu"); + try { + Robot rob = new Robot(); + int x = point.X; + int y = point.Y; + rob.mouseMove(x, y); + rob.mousePress(InputEvent.BUTTON1_MASK); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document. Then obtains an accessible object with the role + * <code>AccessibleRole.PUSHBUTTON</code> and with the name + * <code>"Bold"</code>. Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: the name of button</li> + * </ul> + * + * @param tParam + * test parameters + * @param log + * writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception{ + log.println("creating a test environment"); + + if (xTextDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF()); + + XInterface toolkit = null; + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + toolkit = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + XInterface oObj = null; + + XWindow xWindow = AccessibilityTools.getCurrentWindow(aModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PANEL); + + XAccessibleComponent window = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + point = window.getLocationOnScreen(); + Rectangle rect = window.getBounds(); + + try { + Robot rob = new Robot(); + int x = point.X + (rect.Width / 2); + int y = point.Y + (rect.Height / 2); + rob.mouseMove(x, y); + rob.mousePress(InputEvent.BUTTON3_MASK); + rob.mouseRelease(InputEvent.BUTTON3_MASK); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + + util.utils.shortWait(); + + XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, + toolkit); + + try { + xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getTopWindow(0)); + + xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, + tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't get Window"); + } + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.POPUP_MENU); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + final XAccessibleSelection sel = UnoRuntime.queryInterface( + XAccessibleSelection.class, oObj); + + tEnv.addObjRelation( + "EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + sel.selectAccessibleChild(2); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't fire event"); + } + } + }); + + return tEnv; + } + + protected void closeDoc() { + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleRadioButton.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleRadioButton.java new file mode 100644 index 000000000..29cdbc71e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleRadioButton.java @@ -0,0 +1,266 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.accessibility.XAccessibleValue; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleText</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleText + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleText + */ +public class AccessibleRadioButton extends TestCase { + private static XTextDocument xTextDoc; + private static XAccessibleAction accCloseButton; + + /** + * Closes a hyperlink dialog, disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + if (accCloseButton != null) { + log.println("closing HyperlinkDialog"); + accCloseButton.doAccessibleAction(0); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } catch (com.sun.star.lang.DisposedException de) { + log.println("Already disposed"); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document, opens a hyperlink dialog, selects a first item + * in IconChoiceCtrl. + * Then obtains an accessible object with + * the role <code>AccessibleRole.RADIOBUTTON</code> with the name <code> + * "Internet"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus </li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: + * the text of the component </li> + * <li> <code>'XAccessibleValue.anotherFromGroup'</code> for + * {@link ifc.accessibility._XAccessibleValue}: + * <code>'FTP'</code> button </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening HyperlinkDialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:HyperlinkDialog"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext iconChoiceCtrl = AccessibilityTools.getAccessibleObjectForRole( + xRoot, AccessibleRole.TREE, + "IconChoiceControl"); + + XAccessibleSelection sel = UnoRuntime.queryInterface( + XAccessibleSelection.class, + iconChoiceCtrl); + + try { + sel.selectAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + } + + AccessibilityTools.printAccessibleTree(log,xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.RADIO_BUTTON, + "Web"); + + XAccessibleContext anotherButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.RADIO_BUTTON, + "FTP"); + + XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Close"); + + + accCloseButton = UnoRuntime.queryInterface( + XAccessibleAction.class, closeButton); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this component"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + final XAccessibleComponent acomp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + acomp.grabFocus(); + } + }); + + tEnv.addObjRelation("XAccessibleText.Text", "Web"); + + tEnv.addObjRelation("EditOnly", + "Can't change or select Text in AccessibleRadioButton"); + + XAccessibleValue anotherButtonValue = UnoRuntime.queryInterface( + XAccessibleValue.class, + anotherButton); + + tEnv.addObjRelation("XAccessibleValue.anotherFromGroup", + anotherButtonValue); + + return tEnv; + } + + protected void closeDoc() { + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleScrollBar.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleScrollBar.java new file mode 100644 index 000000000..e06c73423 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleScrollBar.java @@ -0,0 +1,155 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleAction</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + */ +public class AccessibleScrollBar extends TestCase { + private static XComponent xDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.SCROLLBAR</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xDoc = SOF.createDrawDoc(null); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, xDoc); + + XInterface oObj = null; + + XWindow xWindow = AccessibilityTools.getCurrentWindow( + aModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.SCROLL_BAR); + + final XAccessibleAction act = UnoRuntime.queryInterface( + XAccessibleAction.class, oObj); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + act.doAccessibleAction(1); + } catch (Exception e) { + } + } + }); + + return tEnv; + } + + protected void closeDoc() { + util.DesktopTools.closeDoc(xDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBar.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBar.java new file mode 100644 index 000000000..db248108d --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBar.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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleAction</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + */ +public class AccessibleStatusBar extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.SCROLLBAR</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + XInterface toolkit = null; + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + toolkit = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XInterface oObj = null; + + final XWindow xWindow = + UnoRuntime.queryInterface(XModel.class, xTextDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.STATUS_BAR); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + Rectangle newPosSize = xWindow.getPosSize(); + newPosSize.Width = newPosSize.Width - 20; + newPosSize.Height = newPosSize.Height - 20; + newPosSize.X = newPosSize.X + 20; + newPosSize.Y = newPosSize.Y + 20; + xWindow.setPosSize( + newPosSize.X, newPosSize.Y, newPosSize.Width, + newPosSize.Height, PosSize.POSSIZE); + } + }); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBarItem.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBarItem.java new file mode 100644 index 000000000..aa10a8b00 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleStatusBarItem.java @@ -0,0 +1,163 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleAction</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleValue + * @see com.sun.star.accessibility.XAccessibleAction + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleValue + * @see ifc.accessibility._XAccessibleAction + */ +public class AccessibleStatusBarItem extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.SCROLLBAR</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XInterface oObj = null; + XInterface secondItem = null; + + XWindow xWindow = AccessibilityTools.getCurrentContainerWindow( + aModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + XAccessibleContext statusbar = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.STATUS_BAR); + + try { + oObj = statusbar.getAccessibleChild(6); + secondItem = statusbar.getAccessibleChild(1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "Can't change or select Text in StatusBarItem"); + tEnv.addObjRelation("XAccessibleText", secondItem); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + final XTextDocument doc = xTextDoc; + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + doc.getText().setString("AccessibleStatusBarItem"); + } + }); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleTabControl.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleTabControl.java new file mode 100644 index 000000000..f73b34894 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleTabControl.java @@ -0,0 +1,225 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleSelection; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleSelection + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleSelection + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleSelection + */ +public class AccessibleTabControl extends TestCase { + private static XTextDocument xTextDoc; + private static XAccessibleAction accCloseButton = null; + + /** + * Closes an InsertFields dialog, disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + if (accCloseButton != null) { + log.println("closing InsertFields Dialog"); + accCloseButton.doAccessibleAction(0); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + } + + /** + * Creates a text document, opens an InsertField dialog. + * Then obtains an accessible object with + * the role <code>AccessibleRole.PAGETABLIST</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * selects items </li> + * <li> <code>'XAccessibleSelection.multiSelection'</code> + * of type <code>Boolean</code> for + * {@link ifc.accessibility._XAccessibleSelection}: + * indicates that component supports single selection mode.</li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleSelection + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleSelection + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening InsertField dialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:InsertField"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PAGE_TAB_LIST); + + XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Close"); + + accCloseButton = UnoRuntime.queryInterface( + XAccessibleAction.class, closeButton); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XAccessibleSelection selection = UnoRuntime.queryInterface( + XAccessibleSelection.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + selection.selectAccessibleChild(1); + selection.selectAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + }); + + tEnv.addObjRelation("XAccessibleSelection.OneAlwaysSelected", + Boolean.TRUE); + + tEnv.addObjRelation("XAccessibleSelection.multiSelection", + Boolean.FALSE); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleTabPage.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleTabPage.java new file mode 100644 index 000000000..f31182703 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleTabPage.java @@ -0,0 +1,237 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XController; +import com.sun.star.frame.XDispatch; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.URL; +import com.sun.star.util.XURLTransformer; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + */ +public class AccessibleTabPage extends TestCase { + private static XTextDocument xTextDoc; + private static XAccessibleAction accCloseButton = null; + + /** + * Closes an InsertFields dialog, disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + try { + if (accCloseButton != null) { + log.println("closing InsertFields Dialog"); + accCloseButton.doAccessibleAction(0); + util.utils.waitForEventIdle(Param.getMSF()); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Couldn't close dialog " + e.getMessage()); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document, opens an InsertField dialog. + * Then obtains an accessible object with + * the role <code>AccessibleRole.PAGETAB</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + try { + if (accCloseButton != null) { + log.println("closing InsertFields Dialog"); + accCloseButton.doAccessibleAction(0); + util.utils.waitForEventIdle(tParam.getMSF()); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } catch (com.sun.star.lang.DisposedException e) { + log.println("Couldn't close dialog " + e.getMessage()); + } + + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XModel aModel1 = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XController secondController = aModel1.getCurrentController(); + + XDispatchProvider aProv = UnoRuntime.queryInterface( + XDispatchProvider.class, + secondController); + + XURLTransformer urlTransf = null; + + XInterface transf = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.util.URLTransformer"); + urlTransf = UnoRuntime.queryInterface( + XURLTransformer.class, transf); + + XDispatch getting = null; + log.println("opening InsertField dialog"); + + URL[] url = new URL[1]; + url[0] = new URL(); + url[0].Complete = ".uno:InsertField"; + urlTransf.parseStrict(url); + getting = aProv.queryDispatch(url[0], "", 0); + + PropertyValue[] noArgs = new PropertyValue[0]; + getting.dispatch(url[0], noArgs); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface oObj = null; + + oObj = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, oObj); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getActiveTopWindow()); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XAccessibleContext closeButton = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.PUSH_BUTTON, + "Close"); + + accCloseButton = UnoRuntime.queryInterface( + XAccessibleAction.class, closeButton); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", "toolkit.AccessibleTabPage"); + tEnv.addObjRelation("LimitedBounds", "toolkit.AccessibleTabPage"); + + XAccessibleComponent accComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + oObj); + accComp.getLocationOnScreen(); + + util.utils.waitForEventIdle(tParam.getMSF()); + + XInterface xEventInt = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PAGE_TAB, "Variables"); + final XAccessibleComponent eventAccComp = UnoRuntime.queryInterface( + XAccessibleComponent.class, + xEventInt); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + eventAccComp.grabFocus(); + } + }); + + return tEnv; + } + + protected void closeDoc() { + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java new file mode 100644 index 000000000..868eac149 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBox.java @@ -0,0 +1,159 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.AccessibilityTools; +import util.SOfficeFactory; + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + */ +public class AccessibleToolBox extends TestCase { + private XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.TOOLBAR</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}: + * grabs focus + * </li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + + XMultiServiceFactory msf = tParam.getMSF(); + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory(msf); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + XInterface oObj = null; + + XWindow xWindow = UnoRuntime.queryInterface(XModel.class, xTextDoc). + getCurrentController().getFrame().getContainerWindow(); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.TOOL_BAR); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + XAccessible acc = AccessibilityTools.getAccessibleObject(oObj); + XAccessible child = null; + + try { + child = acc.getAccessibleContext().getAccessibleChild(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + + util.dbg.printInterfaces(child); + + final XAccessibleAction action = UnoRuntime.queryInterface( + XAccessibleAction.class, + child); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + action.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + System.out.println("Couldn't fire event"); + } + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBoxItem.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBoxItem.java new file mode 100644 index 000000000..c92a14b61 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleToolBoxItem.java @@ -0,0 +1,176 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleAction; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleText</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleText + * @see com.sun.star.accessibility.XAccessibleValue + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleText + * @see ifc.accessibility._XAccessibleValue + */ +public class AccessibleToolBoxItem extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + closeDoc(); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name + * <code>"Bold"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: the name of button</li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + closeDoc(); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XInterface oObj = null; + + XWindow xWindow = AccessibilityTools.getCurrentContainerWindow( + aModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, + AccessibleRole.TOGGLE_BUTTON, + "Bold"); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("EditOnly", + "This method isn't supported in this dialog"); + + tEnv.addObjRelation("LimitedBounds", "yes"); + + final XAccessibleAction oAction = UnoRuntime.queryInterface( + XAccessibleAction.class, + oObj); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + try { + oAction.doAccessibleAction(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + }); + + tEnv.addObjRelation("XAccessibleText.Text", "Bold"); + + return tEnv; + } + + protected void closeDoc() { + util.DesktopTools.closeDoc(xTextDoc); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/AccessibleWindow.java b/qadevOOo/tests/java/mod/_toolkit/AccessibleWindow.java new file mode 100644 index 000000000..ff3f63c84 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/AccessibleWindow.java @@ -0,0 +1,173 @@ +/* + * 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._toolkit; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.AccessibilityTools; +import util.SOfficeFactory; + + +/** + * Test for object that implements the following interfaces : + * <ul> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleContext</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleEventBroadcaster + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleComponent</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleExtendedComponent + * </code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleAction</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleText</code></li> + * <li><code> + * ::com::sun::star::accessibility::XAccessibleValue</code></li> + * </ul> <p> + * + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleContext + * @see com.sun.star.accessibility.XAccessibleComponent + * @see com.sun.star.accessibility.XAccessibleExtendedComponent + * @see com.sun.star.accessibility.XAccessibleAction + * @see com.sun.star.accessibility.XAccessibleText + * @see com.sun.star.accessibility.XAccessibleValue + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleContext + * @see ifc.accessibility._XAccessibleComponent + * @see ifc.accessibility._XAccessibleExtendedComponent + * @see ifc.accessibility._XAccessibleAction + * @see ifc.accessibility._XAccessibleText + * @see ifc.accessibility._XAccessibleValue + */ +public class AccessibleWindow extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Disposes the document, if exists, created in + * <code>createTestEnvironment</code> method. + */ + @Override + protected void cleanup(TestParameters Param, PrintWriter log) { + log.println("disposing xTextDoc"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + } + + /** + * Creates a text document. + * Then obtains an accessible object with + * the role <code>AccessibleRole.PUSHBUTTON</code> and with the name + * <code>"Bold"</code>. + * Object relations created : + * <ul> + * <li> <code>'EventProducer'</code> for + * {@link ifc.accessibility._XAccessibleEventBroadcaster}</li> + * <li> <code>'XAccessibleText.Text'</code> for + * {@link ifc.accessibility._XAccessibleText}: the name of button</li> + * </ul> + * + * @param tParam test parameters + * @param log writer to log information while testing + * + * @see com.sun.star.awt.Toolkit + * @see com.sun.star.accessibility.AccessibleRole + * @see ifc.accessibility._XAccessibleEventBroadcaster + * @see ifc.accessibility._XAccessibleText + * @see com.sun.star.accessibility.XAccessibleEventBroadcaster + * @see com.sun.star.accessibility.XAccessibleText + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + log.println("creating a test environment"); + + if (xTextDoc != null) { + util.DesktopTools.closeDoc(xTextDoc); + } + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + XInterface toolkit = null; + + log.println("creating a text document"); + xTextDoc = SOF.createTextDoc(null); + toolkit = (XInterface) tParam.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XModel aModel = UnoRuntime.queryInterface(XModel.class, + xTextDoc); + + XInterface oObj = null; + + XWindow xWindow = AccessibilityTools.getCurrentWindow( + aModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + + oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL); + + log.println("ImplementationName: " + util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + final XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + tEnv.addObjRelation("EventProducer", + new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() { + public void fireEvent() { + XWindow xWin = UnoRuntime.queryInterface( + XWindow.class, tk.getActiveTopWindow()); + Rectangle newPosSize = xWin.getPosSize(); + newPosSize.Width = newPosSize.Width - 20; + newPosSize.Height = newPosSize.Height - 20; + newPosSize.X = newPosSize.X + 20; + newPosSize.Y = newPosSize.Y + 20; + xWin.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, + newPosSize.Height, PosSize.POSSIZE); + } + }); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/MutableTreeDataModel.java b/qadevOOo/tests/java/mod/_toolkit/MutableTreeDataModel.java new file mode 100644 index 000000000..10a5f2d1d --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/MutableTreeDataModel.java @@ -0,0 +1,98 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.tree.XMutableTreeDataModel; +import com.sun.star.awt.tree.XMutableTreeNode; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class MutableTreeDataModel extends TestCase { + private static XTextDocument xTextDoc; + private static XInterface oObj = null; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.tree.MutableTreeDataModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for MutableTreeDataModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "toolkit.MutableTreeDataModel"); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + tEnv.addObjRelation("XTreeDataModelListenerEvent", new XTreeDataModelListenerEvent()); + + return tEnv; + } // finish method getTestEnvironment + + private class XTreeDataModelListenerEvent implements ifc.awt.tree._XTreeDataModel.XTreeDataModelListenerEvent{ + + public void fireEvent(){ + + XMutableTreeDataModel xModel = UnoRuntime.queryInterface(XMutableTreeDataModel.class, oObj); + XMutableTreeNode node = xModel.createNode("EventNode", true); + try { + xModel.setRoot(node); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + log.println("ERROR: could not perform event: " + ex.toString()); + ex.printStackTrace(); + } + + } + } +} // finish class UnoControlListBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/MutableTreeNode.java b/qadevOOo/tests/java/mod/_toolkit/MutableTreeNode.java new file mode 100644 index 000000000..e08d2dd65 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/MutableTreeNode.java @@ -0,0 +1,153 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.tree.XMutableTreeDataModel; +import com.sun.star.awt.tree.XMutableTreeNode; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.CommandAbortedException; +import com.sun.star.ucb.XSimpleFileAccess; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import ifc.awt.tree._XMutableTreeNode.XMutableTreeNodeCreator; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + + +public class MutableTreeNode extends TestCase { + private static XInterface oObj = null; + private static XMutableTreeDataModel mXTreeDataModel; + private static XMultiServiceFactory mxMSF; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + mxMSF = tParam.getMSF(); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XMutableTreeNode xNode; + + mXTreeDataModel = UnoRuntime.queryInterface(XMutableTreeDataModel.class, + mxMSF.createInstance("com.sun.star.awt.tree.MutableTreeDataModel")); + + xNode = mXTreeDataModel.createNode("UnoTreeControl", false); + + String sDisplayValue = "UnoTreeControl"; + String sExpandedGraphicURL = "private:graphicrepository/sd/res/triangle_down.png"; + String sCollapsedGraphicURL = "private:graphicrepository/sd/res/triangle_right.png"; + String sNodeGraphicURL = "private:graphicrepository/sw/res/nc20010.png"; + + xNode.setDisplayValue( sDisplayValue); + xNode.setDataValue(sDisplayValue); + xNode.setExpandedGraphicURL(sExpandedGraphicURL); + xNode.setCollapsedGraphicURL(sCollapsedGraphicURL); + xNode.setNodeGraphicURL(sNodeGraphicURL); + xNode.setHasChildrenOnDemand(true); + + fillNode(xNode); + + TestEnvironment tEnv = new TestEnvironment(xNode); + + tEnv.addObjRelation("OBJNAME", "toolkit.MutableTreeDataModel"); + log.println("ImplementationName: " + utils.getImplName(oObj)); + + tEnv.addObjRelation("XTreeNode_DisplayValue", sDisplayValue); + tEnv.addObjRelation("XTreeNode_ExpandedGraphicURL", sExpandedGraphicURL); + tEnv.addObjRelation("XTreeNode_CollapsedGraphicURL", sCollapsedGraphicURL); + tEnv.addObjRelation("XTreeNode_NodeGraphicURL", sNodeGraphicURL); + + tEnv.addObjRelation("XMutableTreeNode_NodeToAppend", + mXTreeDataModel.createNode("XMutableTreeNode_NodeToAppend", true)); + + tEnv.addObjRelation("XMutableTreeNodeCreator", new XMutableTreeNodeCreator(){ + public XMutableTreeNode createNode(String name){ + return mXTreeDataModel.createNode(name, true); + } + }); + + return tEnv; + } // finish method getTestEnvironment + + private void fillNode( XMutableTreeNode xNode ) throws com.sun.star.uno.Exception { + + if( xNode.getChildCount() == 0 ) + { + xNode.getDataValue(); + + String officeUserPath = utils.getOfficeUserPath(mxMSF); + Object fileacc = mxMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc); + + + dirlist(officeUserPath, xNode); + } + } + + private void dirlist(String dir, XMutableTreeNode xNode){ + + Object fileacc = null; + try { + fileacc = mxMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + XSimpleFileAccess sfa = UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc); + XMutableTreeNode xChildNode = null; + try { + xChildNode = mXTreeDataModel.createNode(dir.substring(dir.lastIndexOf("/")+1, dir.length()), sfa.isFolder(dir)); + xChildNode.setDataValue(dir); + sfa.isFolder(dir); + if (sfa.isFolder(dir)){ + xChildNode.setExpandedGraphicURL( "private:graphicrepository/sd/res/triangle_down.png"); + xChildNode.setCollapsedGraphicURL("private:graphicrepository/sd/res/triangle_right.png"); + String[] children = sfa.getFolderContents(dir, true); + if (children != null){ + for (int i=0; i<children.length; i++) { + // Get filename of file or directory + String filename = children[i]; + dirlist( filename , xChildNode); + } + } + } + else{ + xChildNode.setNodeGraphicURL( "private:graphicrepository/sw/res/nc20010.png"); + } + } catch (CommandAbortedException ex) { + ex.printStackTrace(); + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + + try { + xNode.appendChild( xChildNode ); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + ex.printStackTrace(); + } + } +} // finish class UnoControlListBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/TabController.java b/qadevOOo/tests/java/mod/_toolkit/TabController.java new file mode 100644 index 000000000..0f483bb04 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/TabController.java @@ -0,0 +1,126 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XTabControllerModel; +import com.sun.star.drawing.XControlShape; +import com.sun.star.form.XForm; +import com.sun.star.text.XTextDocument; +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.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.FormTools; +import util.WriterTools; +import util.utils; + + +public class TabController extends TestCase { + private static XTextDocument xTextDoc = null; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters param, PrintWriter log) { + log.println("disposing xTextDoc"); + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters param, + PrintWriter log) + throws com.sun.star.uno.Exception + { + XInterface oObj = null; + XControl xCtrl1 = null; + XTabControllerModel tabCtrlModel = null; + XControlContainer aCtrlContainer = null; + + + // create object relations + FormTools.insertForm(xTextDoc, + FormTools.getForms(WriterTools.getDrawPage( + xTextDoc)), "MyForm"); + + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "CommandButton", + "UnoControlButton"); + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel model = aShape.getControl(); + XControlAccess access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + try { + xCtrl1 = access.getControl(model); + } catch (Exception e) { + } + + XForm form = null; + + try { + Object temp = FormTools.getForms( WriterTools.getDrawPage(xTextDoc) ).getByName("MyForm"); + form = (XForm) AnyConverter.toObject(new Type(XForm.class), temp); + } catch (Exception e) { + log.println("Couldn't get Form"); + e.printStackTrace(log); + } + + tabCtrlModel = UnoRuntime.queryInterface( + XTabControllerModel.class, form); + + aCtrlContainer = UnoRuntime.queryInterface( + XControlContainer.class, xCtrl1.getContext()); + + // create object + try { + oObj = (XInterface) param.getMSF().createInstance( + "com.sun.star.awt.TabController"); + } catch (Exception e) { + } + + TestEnvironment tEnv = new TestEnvironment(oObj); + + String objName = "TabController"; + tEnv.addObjRelation("OBJNAME", "toolkit." + objName); + tEnv.addObjRelation("MODEL", tabCtrlModel); + tEnv.addObjRelation("CONTAINER", aCtrlContainer); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/TabControllerModel.java b/qadevOOo/tests/java/mod/_toolkit/TabControllerModel.java new file mode 100644 index 000000000..1c227f0b3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/TabControllerModel.java @@ -0,0 +1,83 @@ +/* + * 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._toolkit; + +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; +import util.utils; + + +public class TabControllerModel extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc(Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters param, PrintWriter log) { + log.println("disposing xTextDoc"); + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters param, + PrintWriter log) throws Exception { + XInterface oObj = null; + + log.println("inserting some ControlShapes"); + + XControlShape shape1 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 1000, + "CommandButton"); + XControlShape shape2 = FormTools.createControlShape(xTextDoc, 5000, + 3500, 7500, 5000, + "TextField"); + + oObj = (XInterface) param.getMSF().createInstance( + "com.sun.star.awt.TabControllerModel"); + + log.println("creating a new environment for TabControllerModel"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", + "stardiv.vcl.controlmodel.TabController"); + tEnv.addObjRelation("Model1", shape1.getControl()); + tEnv.addObjRelation("Model2", shape2.getControl()); + + + //Object Relation for XPersistObject + tEnv.addObjRelation("noPS", Boolean.TRUE); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class TabControllerModel diff --git a/qadevOOo/tests/java/mod/_toolkit/Toolkit.java b/qadevOOo/tests/java/mod/_toolkit/Toolkit.java new file mode 100644 index 000000000..346ef21f5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/Toolkit.java @@ -0,0 +1,118 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +/** +* Test for <code>com.sun.star.awt.Toolkit</code> service. +*/ +public class Toolkit extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + util.DesktopTools.closeDoc(xTextDoc); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates <code>com.sun.star.awt.Toolkit</code> service. + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XWindow win = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createControlShape(xTextDoc, 3000, + 4500, 15000, 10000, + "CommandButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + XController cntrlr = UnoRuntime.queryInterface( + XController.class, + xTextDoc.getCurrentController()); + + //now get the toolkit + win = cntrlr.getFrame().getContainerWindow(); + + the_win = the_access.getControl(the_Model).getPeer(); + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.Toolkit"); + + XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + + log.println(" creating a new environment for toolkit object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + log.println("Implementation Name: " + utils.getImplName(oObj)); + + tEnv.addObjRelation("WINPEER", the_win); + + tEnv.addObjRelation("XModel", xModel); + + + // adding relation for XDataTransferProviderAccess + tEnv.addObjRelation("XDataTransferProviderAccess.XWindow", win); + + return tEnv; + } // finish method getTestEnvironment +} // finish class Toolkit diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlButton.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlButton.java new file mode 100644 index 000000000..3522c9629 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlButton.java @@ -0,0 +1,129 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlButton extends TestCase { + private static XTextDocument xTextDoc; + private static XTextDocument xTD2; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + xTD2 = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + util.DesktopTools.closeDoc(xTD2); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XWindow anotherWindow = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "CommandButton", + "UnoControlButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the ButtonControl for the needed Object relations + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlButton object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + XController aController = xTD2.getCurrentController(); + XFrame aFrame = aController.getFrame(); + anotherWindow = aFrame.getComponentWindow(); + + + // Object Relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlButton diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlButtonModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlButtonModel.java new file mode 100644 index 000000000..24be3535d --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlButtonModel.java @@ -0,0 +1,71 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; +import util.utils; + + +public class UnoControlButtonModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlButtonModel"); + + log.println( + "creating a new environment for UnoControlButtonModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.Button"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlButtonModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBox.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBox.java new file mode 100644 index 000000000..0132bd4b0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBox.java @@ -0,0 +1,137 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XCheckBox; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlCheckBox extends TestCase { + private static XTextDocument xTextDoc; + private static XTextDocument xTD2; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + xTD2 = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + util.DesktopTools.closeDoc(xTD2); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XWindow anotherWindow = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "CheckBox", + "UnoControlCheckBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the CheckBoxControl for the needed Object relations + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlCheckBox object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // adding object relation for XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener(); + XCheckBox check = UnoRuntime.queryInterface( + XCheckBox.class, oObj); + check.addItemListener(listener); + tEnv.addObjRelation("TestItemListener", listener); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + XController aController = xTD2.getCurrentController(); + XFrame aFrame = aController.getFrame(); + anotherWindow = aFrame.getComponentWindow(); + + + // Object Relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlCheckBox diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBoxModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBoxModel.java new file mode 100644 index 000000000..0a2930756 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlCheckBoxModel.java @@ -0,0 +1,71 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.WriterTools; +import util.utils; + + +public class UnoControlCheckBoxModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlCheckBoxModel"); + + log.println( + "creating a new environment for UnoControlCheckBoxModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.CheckBox"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlCheckBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBox.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBox.java new file mode 100644 index 000000000..243e90c26 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBox.java @@ -0,0 +1,138 @@ +/* + * 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._toolkit; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + + +public class UnoControlComboBox extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + +util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "ComboBox", + "UnoControlComboBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the ComboBoxControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlComboBox object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlComboBox diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBoxModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBoxModel.java new file mode 100644 index 000000000..7c6477321 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlComboBoxModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlComboBoxModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlComboBoxModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlComboBoxModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.ComboBox"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlComboBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlContainer.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlContainer.java new file mode 100644 index 000000000..7c872dfaa --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlContainer.java @@ -0,0 +1,204 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; +import util.utils; + + +public class UnoControlContainer extends TestCase { + private static XTextDocument xTextDoc; + private static XTextDocument xTD2; + private static XControl xCtrl1; + private static XControl xCtrl2; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTD2 = WriterTools.createTextDoc( + Param.getMSF()); + xTextDoc = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + util.DesktopTools.closeDoc(xTD2); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters param, + PrintWriter log) throws Exception { + // create Object Relations ------------------------------------------- + XInterface oObj = null; + XControlShape shape = null; + XControlModel model = null; + XControlAccess access = null; + XWindow anotherWindow = null; + + // for XControl + XWindowPeer the_win = null; + XToolkit the_kit = null; + + XControlContainer ctrlCont = null; + + XGraphics aGraphic = null; + + + // create 3 XControls + // create first XControl + shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 10000, "TextField"); + WriterTools.getDrawPage(xTextDoc).add(shape); + model = shape.getControl(); + access = UnoRuntime.queryInterface( + XControlAccess.class, xTextDoc.getCurrentController()); + + access.getControl(model); + + + // create second XControl + shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 10000, "TextField"); + WriterTools.getDrawPage(xTextDoc).add(shape); + model = shape.getControl(); + access = UnoRuntime.queryInterface( + XControlAccess.class, xTextDoc.getCurrentController()); + + xCtrl1 = access.getControl(model); + + + // create third XControl + shape = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000, + 10000, "CommandButton"); + WriterTools.getDrawPage(xTextDoc).add(shape); + model = shape.getControl(); + access = UnoRuntime.queryInterface( + XControlAccess.class, xTextDoc.getCurrentController()); + + xCtrl2 = access.getControl(model); + + // create XToolkit, XWindowPeer, XDevice + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "CommandButton", + "UnoControlButton"); + + WriterTools.getDrawPage(xTD2).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTD2.getCurrentController()); + + //get the ButtonControl for the needed Object relations + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + + XDevice aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + XController aController = xTD2.getCurrentController(); + XFrame aFrame = aController.getFrame(); + anotherWindow = aFrame.getComponentWindow(); + + // finished create Object Relations ----------------------------------- + // create the UnoControlContainer + oObj = (XInterface) param.getMSF().createInstance( + "com.sun.star.awt.UnoControlContainer"); + + XControl xCtrl = UnoRuntime.queryInterface( + XControl.class, oObj); + xCtrl.setModel(the_Model); + + ctrlCont = UnoRuntime.queryInterface( + XControlContainer.class, oObj); + ctrlCont.addControl("jupp", access.getControl(aShape.getControl())); + + log.println( + "creating a new environment for UnoControlContainer object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, oObj); + Rectangle ps = xWindow.getPosSize(); + xWindow.setPosSize(ps.X+10, ps.Y+10, ps.Width+10, ps.Height+10, PosSize.POSSIZE); + + String objName = "UnoControlContainer"; + tEnv.addObjRelation("OBJNAME", "toolkit." + objName); + + + // Object relation for XContainer + tEnv.addObjRelation("XContainer.Container", ctrlCont); + tEnv.addObjRelation("INSTANCE", xCtrl); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + // Object Relation for XControlContainer + tEnv.addObjRelation("CONTROL1", xCtrl1); + tEnv.addObjRelation("CONTROL2", xCtrl2); + + + // Object Relation for XControl + tEnv.addObjRelation("CONTEXT", xTD2); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + + // Object Relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlContainerModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlContainerModel.java new file mode 100644 index 000000000..cd3845560 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlContainerModel.java @@ -0,0 +1,47 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + + +public class UnoControlContainerModel extends TestCase { + @Override + public TestEnvironment createTestEnvironment(TestParameters param, + PrintWriter log) throws Exception { + XInterface oObj = (XInterface) param.getMSF().createInstance( + "com.sun.star.awt.UnoControlContainerModel"); + + log.println( + "creating a new environment for UnoControlContainer object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + tEnv.addObjRelation("OBJNAME", + "stardiv.vcl.controlmodel.ControlContainer"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyField.java new file mode 100644 index 000000000..60c65000c --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyField.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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlCurrencyField extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "CurrencyField", + "UnoControlCurrencyField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the CurrencyFieldControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlCurrencyField object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlCurrencyField diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyFieldModel.java new file mode 100644 index 000000000..65f9b528c --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlCurrencyFieldModel.java @@ -0,0 +1,78 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlCurrencyFieldModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlCurrencyFieldModel"); + } catch (Exception e) { + } + + log.println("creating a new environment for " + + "UnoControlCurrencyFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", + "stardiv.vcl.controlmodel.CurrencyField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlCurrencyFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlDateField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlDateField.java new file mode 100644 index 000000000..f9abc3c69 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlDateField.java @@ -0,0 +1,139 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlDateField extends TestCase { + private static XTextDocument xTextDoc; + private static XTextDocument xTD2; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + xTD2 = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + util.DesktopTools.closeDoc(xTD2); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XWindow anotherWindow = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "DateField", + "UnoControlDateField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the DateFieldControl for the needed Object relations + oObj = the_access.getControl(the_Model); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlDateField object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + XController aController = xTD2.getCurrentController(); + XFrame aFrame = aController.getFrame(); + anotherWindow = aFrame.getComponentWindow(); + + + // Object Relation for XWindow + tEnv.addObjRelation("XWindow.AnotherWindow", anotherWindow); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlDateField diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlDateFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlDateFieldModel.java new file mode 100644 index 000000000..82344269d --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlDateFieldModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlDateFieldModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlDateFieldModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlDateFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.DateField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlDateFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlDialog.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlDialog.java new file mode 100644 index 000000000..2f0e6ddc7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlDialog.java @@ -0,0 +1,241 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.PosSize; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTabController; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.SOfficeFactory; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.awt.UnoControlDialog</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::awt::XWindow</code></li> +* <li> <code>com::sun::star::awt::XDialog</code></li> +* <li> <code>com::sun::star::awt::XControl</code></li> +* <li> <code>com::sun::star::awt::XTopWindow</code></li> +* <li> <code>com::sun::star::awt::XControlContainer</code></li> +* <li> <code>com::sun::star::awt::XView</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.lang.XComponent +* @see com.sun.star.awt.XWindow +* @see com.sun.star.awt.XDialog +* @see com.sun.star.awt.XControl +* @see com.sun.star.awt.XTopWindow +* @see com.sun.star.awt.XControlContainer +* @see com.sun.star.awt.XView +* @see ifc.lang._XComponent +* @see ifc.awt._XWindow +* @see ifc.awt._XDialog +* @see ifc.awt._XControl +* @see ifc.awt._XTopWindow +* @see ifc.awt._XControlContainer +* @see ifc.awt._XView +*/ +public class UnoControlDialog extends TestCase { + private static XWindow xWinDlg = null; + private static XTextDocument xTextDoc; + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates a Dialog Control and Model instance defines Model + * for Control, adds to Dialog a button, sets its size and + * sets the dialog visible. <p> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + XMultiServiceFactory xMSF = Param.getMSF(); + XControlModel dlgModel = null; + + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + + XControl butControl = null; + XControl butControl1 = null; + XControl butControl2 = null; + XTabController tabControl1 = null; + XTabController tabControl2 = null; + + XControlContainer ctrlCont = null; + + if (xWinDlg != null) { + xWinDlg.dispose(); + } + + try { + dlgModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlDialogModel")); + + XControl dlgControl = UnoRuntime.queryInterface( + XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlDialog")); + + dlgControl.setModel(dlgModel); + + XControlModel butModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButtonModel")); + + butControl = UnoRuntime.queryInterface(XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButton")); + + butControl.setModel(butModel); + + + // creating additional controls for XUnoControlContainer + tabControl1 = UnoRuntime.queryInterface( + XTabController.class, + xMSF.createInstance( + "com.sun.star.awt.TabController")); + + tabControl2 = UnoRuntime.queryInterface( + XTabController.class, + xMSF.createInstance( + "com.sun.star.awt.TabController")); + + + // creating additional controls for XControlContainer + butModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButtonModel")); + + butControl1 = UnoRuntime.queryInterface(XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButton")); + + butControl1.setModel(butModel); + + butModel = UnoRuntime.queryInterface( + XControlModel.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButtonModel")); + + butControl2 = UnoRuntime.queryInterface(XControl.class, + xMSF.createInstance( + "com.sun.star.awt.UnoControlButton")); + + butControl2.setModel(butModel); + + ctrlCont = UnoRuntime.queryInterface( + XControlContainer.class, dlgControl); + + xWinDlg = UnoRuntime.queryInterface(XWindow.class, + dlgControl); + + xWinDlg.setVisible(true); + + xWinDlg.setPosSize(10, 10, 220, 110, PosSize.SIZE); + + the_win = dlgControl.getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(220, 220); + aGraphic = aDevice.createGraphics(); + + oObj = dlgControl; + } catch (com.sun.star.uno.Exception e) { + log.println("Error creating dialog :"); + e.printStackTrace(log); + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", dlgModel); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", dlgModel); + + tEnv.addObjRelation("INSTANCE", butControl); + tEnv.addObjRelation("XContainer.Container", ctrlCont); + + + // adding relations for XUnoControlContainer + tEnv.addObjRelation("TABCONTROL1", tabControl1); + tEnv.addObjRelation("TABCONTROL2", tabControl2); + + + // adding relations for XControlContainer + tEnv.addObjRelation("CONTROL1", butControl1); + tEnv.addObjRelation("CONTROL2", butControl2); + + XWindow forObjRel = xTextDoc.getCurrentController().getFrame() + .getComponentWindow(); + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + return tEnv; + } // finish method getTestEnvironment + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println("Disposing dialog ..."); + xWinDlg.dispose(); + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + tParam.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlDialogModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlDialogModel.java new file mode 100644 index 000000000..8e2aa77b0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlDialogModel.java @@ -0,0 +1,173 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.awt.UnoControlDialogModel</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlDialogModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.awt.UnoControlDialogModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.lang.XComponent +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see ifc.awt._UnoControlDialogModel +* @see ifc.io._XPersistObject +* @see ifc.lang._XComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XMultiPropertySet +*/ +public class UnoControlDialogModel extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.awt.UnoControlDialogModel</code>. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XInterface dialogModel = null; + String _buttonName = "MyButton"; + String _labelName = "MyLabel"; + String _labelPrefix = "MyLabelPrefix"; + XMultiServiceFactory xMultiServiceFactory = null; + + dialogModel = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlDialogModel"); + + // create the dialog model and set the properties + XPropertySet xPSetDialog = UnoRuntime.queryInterface( + XPropertySet.class, dialogModel); + xPSetDialog.setPropertyValue("PositionX", Integer.valueOf(100)); + xPSetDialog.setPropertyValue("PositionY", Integer.valueOf(100)); + xPSetDialog.setPropertyValue("Width", Integer.valueOf(150)); + xPSetDialog.setPropertyValue("Height", Integer.valueOf(100)); + xPSetDialog.setPropertyValue("Title", "Runtime Dialog Demo"); + + // get the service manager from the dialog model + xMultiServiceFactory = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + dialogModel); + + // create the button model and set the properties + Object buttonModel = xMultiServiceFactory.createInstance( + "com.sun.star.awt.UnoControlButtonModel"); + XPropertySet xPSetButton = UnoRuntime.queryInterface( + XPropertySet.class, buttonModel); + xPSetButton.setPropertyValue("PositionX", Integer.valueOf(50)); + xPSetButton.setPropertyValue("PositionY", Integer.valueOf(30)); + xPSetButton.setPropertyValue("Width", Integer.valueOf(50)); + xPSetButton.setPropertyValue("Height", Integer.valueOf(14)); + xPSetButton.setPropertyValue("Name", _buttonName); + xPSetButton.setPropertyValue("TabIndex", Short.valueOf((short) 0)); + xPSetButton.setPropertyValue("Label", "Click Me"); + + // create the label model and set the properties + Object labelModel = xMultiServiceFactory.createInstance( + "com.sun.star.awt.UnoControlFixedTextModel"); + XPropertySet xPSetLabel = UnoRuntime.queryInterface( + XPropertySet.class, labelModel); + xPSetLabel.setPropertyValue("PositionX", Integer.valueOf(40)); + xPSetLabel.setPropertyValue("PositionY", Integer.valueOf(60)); + xPSetLabel.setPropertyValue("Width", Integer.valueOf(100)); + xPSetLabel.setPropertyValue("Height", Integer.valueOf(14)); + xPSetLabel.setPropertyValue("Name", _labelName); + xPSetLabel.setPropertyValue("TabIndex", Short.valueOf((short) 1)); + xPSetLabel.setPropertyValue("Label", _labelPrefix); + + // insert the control models into the dialog model + XNameContainer xNameCont = UnoRuntime.queryInterface( + XNameContainer.class, + dialogModel); + xNameCont.insertByName(_buttonName, buttonModel); + xNameCont.insertByName(_labelName, labelModel); + + // create the dialog control and set the model + XControl dialog = UnoRuntime.queryInterface( + XControl.class, + Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlDialog")); + XControl xControl = UnoRuntime.queryInterface( + XControl.class, dialog); + XControlModel xControlModel = UnoRuntime.queryInterface( + XControlModel.class, + dialogModel); + xControl.setModel(xControlModel); + + oObj = dialogModel; + + log.println("creating a new environment for object"); + + UnoRuntime.queryInterface( + XMultiServiceFactory.class, oObj); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + try { + // XNameReplace + tEnv.addObjRelation("INSTANCE1", + xMultiServiceFactory.createInstance( + "com.sun.star.awt.UnoControlFixedTextModel")); + + + //XContainer + tEnv.addObjRelation("INSTANCE", + xMultiServiceFactory.createInstance( + "com.sun.star.awt.UnoControlFixedTextModel")); + } catch (com.sun.star.uno.Exception e) { + log.println("Could not add object relations 'INSTANCEn'"); + e.printStackTrace(log); + } + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.Dialog"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlEdit.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlEdit.java new file mode 100644 index 000000000..0199acd57 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlEdit.java @@ -0,0 +1,139 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlEdit extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "TextField", + "UnoControlEdit"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the EditControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlEdit object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlEdit diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlEditModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlEditModel.java new file mode 100644 index 000000000..e312b64a6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlEditModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlEditModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlEditModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlEditModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.Edit"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlEditModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControl.java new file mode 100644 index 000000000..ab4486a70 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControl.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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlFileControl extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "FileControl", + "UnoControlFileControl"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the FileControlControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlFileControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlFileControl diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControlModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControlModel.java new file mode 100644 index 000000000..63f2a8309 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFileControlModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlFileControlModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlFileControlModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlFileControlModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.FileControl"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlFileControlModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedLineModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedLineModel.java new file mode 100644 index 000000000..fffcca77b --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedLineModel.java @@ -0,0 +1,88 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.awt.UnoControlFixedLineModel</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlFixedLineModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.awt.UnoControlFixedLineModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.lang.XComponent +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see ifc.awt._UnoControlFixedLineModel +* @see ifc.io._XPersistObject +* @see ifc.lang._XComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XMultiPropertySet +*/ +public class UnoControlFixedLineModel extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.awt.UnoControlFixedLineModel</code>. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws StatusException { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlFixedLineModel"); + } catch (Exception e) { + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.FixedLine"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedText.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedText.java new file mode 100644 index 000000000..16951a36c --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedText.java @@ -0,0 +1,130 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlFixedText extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "FixedText", + "UnoControlFixedText"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the FixedTextControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlFixedText object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlFixedText diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedTextModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedTextModel.java new file mode 100644 index 000000000..9433d8c26 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFixedTextModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlFixedTextModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlFixedTextModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlFixedTextModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.FixedText"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlFixedTextModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedField.java new file mode 100644 index 000000000..d2091caba --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedField.java @@ -0,0 +1,145 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlFormattedField extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "DatabaseFormattedField", + "UnoControlFormattedField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + XPropertySet xPS = UnoRuntime.queryInterface( + XPropertySet.class, the_Model); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the EditControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + xPS.setPropertyValue("Spin", Boolean.TRUE); + + log.println("creating a new environment for UnoControlEdit object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedFieldModel.java new file mode 100644 index 000000000..bb5e1b355 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlFormattedFieldModel.java @@ -0,0 +1,78 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlFormattedFieldModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlFormattedFieldModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlFormattedFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", + "stardiv.vcl.controlmodel.FormattedField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlFormattedFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBox.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBox.java new file mode 100644 index 000000000..714085696 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBox.java @@ -0,0 +1,129 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlGroupBox extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "GroupBox", + "UnoControlGroupBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the GroupBoxControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlGroupBox object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlGroupBox diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBoxModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBoxModel.java new file mode 100644 index 000000000..1a6cae71e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlGroupBoxModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlGroupBoxModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlGroupBoxModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlGroupBoxModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.GroupBox"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlGroupBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControl.java new file mode 100644 index 000000000..ea320d043 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControl.java @@ -0,0 +1,138 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlImageControl extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "DatabaseImageControl", + "UnoControlImageControl"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XPropertySet xPS = UnoRuntime.queryInterface( + XPropertySet.class, the_Model); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the ImageControlControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + String imgUrl = util.utils.getFullTestURL("poliball.gif"); + + xPS.setPropertyValue("ImageURL", imgUrl); + + log.println( + "creating a new environment for UnoControlImageControl object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlImageControl diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControlModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControlModel.java new file mode 100644 index 000000000..e0f0ff0ad --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlImageControlModel.java @@ -0,0 +1,53 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +public class UnoControlImageControlModel extends TestCase { + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlImageControlModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlImageControlModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.ImageControl"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlImageControlModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlListBox.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlListBox.java new file mode 100644 index 000000000..1d733bd06 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlListBox.java @@ -0,0 +1,139 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XListBox; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlListBox extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "ListBox", + "UnoControlListBox"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the ListBoxControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println("creating a new environment for UnoControlListBox object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + // adding object relation for XItemListener + ifc.awt._XItemListener.TestItemListener listener = + new ifc.awt._XItemListener.TestItemListener(); + XListBox list = UnoRuntime.queryInterface(XListBox.class, + oObj); + list.addItemListener(listener); + tEnv.addObjRelation("TestItemListener", listener); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlListBox diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlListBoxModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlListBoxModel.java new file mode 100644 index 000000000..a0d26319c --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlListBoxModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlListBoxModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlListBoxModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlListBoxModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.ListBox"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlListBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericField.java new file mode 100644 index 000000000..073b63756 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericField.java @@ -0,0 +1,150 @@ +/* + * 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._toolkit; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.util.XCloseable; +import com.sun.star.view.XControlAccess; + + +public class UnoControlNumericField extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + try { + XCloseable closer = UnoRuntime.queryInterface( + XCloseable.class, xTextDoc); + closer.close(true); + } catch (com.sun.star.util.CloseVetoException e) { + log.println("couldn't close document"); + } catch (com.sun.star.lang.DisposedException e) { + log.println("couldn't close document"); + } + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "NumericField", + "UnoControlNumericField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the NumericFieldControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlNumericField object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + tEnv.addObjRelation("XTextComponent.onlyNumbers", ""); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlNumericField diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericFieldModel.java new file mode 100644 index 000000000..bcee5feaf --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlNumericFieldModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoControlNumericFieldModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlNumericFieldModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlNumericFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.NumericField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlNumericFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternField.java new file mode 100644 index 000000000..72a864373 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternField.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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlPatternField extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "PatternField", + "UnoControlPatternField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the PatternFieldControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlPatternField object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlPatternField diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternFieldModel.java new file mode 100644 index 000000000..e2dcd18cf --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlPatternFieldModel.java @@ -0,0 +1,53 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +public class UnoControlPatternFieldModel extends TestCase { + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlPatternFieldModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlPatternFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.PatternField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlPatternFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlProgressBarModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlProgressBarModel.java new file mode 100644 index 000000000..f36d39d0b --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlProgressBarModel.java @@ -0,0 +1,85 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.awt.UnoControlProgressBarModel</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlProgressBarModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.awt.UnoControlProgressBarModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.lang.XComponent +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see ifc.awt._UnoControlProgressBarModel +* @see ifc.io._XPersistObject +* @see ifc.lang._XComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XMultiPropertySet +*/ +public class UnoControlProgressBarModel extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.awt.UnoControlProgressBarModel</code>. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws StatusException { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlProgressBarModel"); + } catch (Exception e) { + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.ProgressBar"); + + return tEnv; + } // finish method getTestEnvironment +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButton.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButton.java new file mode 100644 index 000000000..1f13ae6c0 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButton.java @@ -0,0 +1,130 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlRadioButton extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "RadioButton", + "UnoControlRadioButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the RadioButtonControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlRadioButton object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlRadioButton diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButtonModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButtonModel.java new file mode 100644 index 000000000..859280865 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlRadioButtonModel.java @@ -0,0 +1,53 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +public class UnoControlRadioButtonModel extends TestCase { + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlRadioButtonModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlRadioButtonModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.RadioButton"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlRadioButtonModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlScrollBarModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlScrollBarModel.java new file mode 100644 index 000000000..1a8e21a38 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlScrollBarModel.java @@ -0,0 +1,88 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +/** +* Test for object which is represented by service +* <code>com.sun.star.awt.UnoControlScrollBarModel</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::awt::UnoControlScrollBarModel</code></li> +* <li> <code>com::sun::star::io::XPersistObject</code></li> +* <li> <code>com::sun::star::lang::XComponent</code></li> +* <li> <code>com::sun::star::beans::XPropertySet</code></li> +* <li> <code>com::sun::star::beans::XMultiPropertySet</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.awt.UnoControlScrollBarModel +* @see com.sun.star.io.XPersistObject +* @see com.sun.star.lang.XComponent +* @see com.sun.star.beans.XPropertySet +* @see com.sun.star.beans.XMultiPropertySet +* @see ifc.awt._UnoControlScrollBarModel +* @see ifc.io._XPersistObject +* @see ifc.lang._XComponent +* @see ifc.beans._XPropertySet +* @see ifc.beans._XMultiPropertySet +*/ +public class UnoControlScrollBarModel extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.awt.UnoControlScrollBarModel</code>. + * Object relations created : + * <ul> + * <li> <code>'OBJNAME'</code> for + * {@link ifc.io._XPersistObject} </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws StatusException { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlScrollBarModel"); + } catch (Exception e) { + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.ScrollBar"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeField.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeField.java new file mode 100644 index 000000000..574330987 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeField.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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XTextComponent; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoControlTimeField extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "TimeField", + "UnoControlTimeField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the TimeFieldControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlTimeField object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + tEnv.addObjRelation("XWindow.ControlShape", aShape); + + // Adding relation for XTextListener + ifc.awt._XTextListener.TestTextListener listener = + new ifc.awt._XTextListener.TestTextListener(); + XTextComponent textComp = UnoRuntime.queryInterface( + XTextComponent.class, oObj); + textComp.addTextListener(listener); + tEnv.addObjRelation("TestTextListener", listener); + + log.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlTimeField diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeFieldModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeFieldModel.java new file mode 100644 index 000000000..90f75d027 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoControlTimeFieldModel.java @@ -0,0 +1,53 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +public class UnoControlTimeFieldModel extends TestCase { + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlTimeFieldModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for UnoControlTimeFieldModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "stardiv.vcl.controlmodel.TimeField"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlTimeFieldModel diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoScrollBarControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoScrollBarControl.java new file mode 100644 index 000000000..3a6b27474 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoScrollBarControl.java @@ -0,0 +1,156 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XModel; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.SOfficeFactory; +import util.WriterTools; +import util.utils; + + +public class UnoScrollBarControl extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + xTextDoc = SOF.createTextDoc(null); + + log.println("maximize the window size"); + XModel xModel = UnoRuntime.queryInterface(XModel.class, xTextDoc); + XFrame xFrame = xModel.getCurrentController().getFrame(); + XWindow xWin = xFrame.getContainerWindow(); + + Toolkit.getDefaultToolkit(); + Dimension dim = new Dimension(800, 600); + + Rectangle newPosSize = xWin.getPosSize(); + newPosSize.Width = (int) dim.getWidth(); + newPosSize.Height = (int) dim.getHeight(); + newPosSize.X = 0; + newPosSize.Y = 0; + + xWin.setPosSize(newPosSize.X, newPosSize.Y, newPosSize.Width, + newPosSize.Height, com.sun.star.awt.PosSize.POSSIZE); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "ScrollBar", + "UnoControlScrollBar"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the ScrollBarControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlScrollBar object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //adding Object-Relation for XScrollBar + tEnv.addObjRelation("Document", xTextDoc); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java new file mode 100644 index 000000000..df8506f9e --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControl.java @@ -0,0 +1,133 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDevice; +import com.sun.star.awt.XGraphics; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.awt.XWindowPeer; +import com.sun.star.drawing.XControlShape; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.view.XControlAccess; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.FormTools; +import util.WriterTools; +import util.utils; + + +public class UnoSpinButtonControl extends TestCase { + private static XTextDocument xTextDoc; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + Param.getMSF()); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) throws Exception { + XInterface oObj = null; + XWindowPeer the_win = null; + XToolkit the_kit = null; + XDevice aDevice = null; + XGraphics aGraphic = null; + XControl aControl = null; + + //Insert a ControlShape and get the ControlModel + XControlShape aShape = FormTools.createUnoControlShape(xTextDoc, 3000, + 4500, 15000, + 10000, + "SpinButton", + "UnoControlSpinButton"); + + WriterTools.getDrawPage(xTextDoc).add(aShape); + + XControlModel the_Model = aShape.getControl(); + + XControlShape aShape2 = FormTools.createControlShape(xTextDoc, 3000, + 4500, 5000, 10000, + "TextField"); + + WriterTools.getDrawPage(xTextDoc).add(aShape2); + + XControlModel the_Model2 = aShape2.getControl(); + + //Try to query XControlAccess + XControlAccess the_access = UnoRuntime.queryInterface( + XControlAccess.class, + xTextDoc.getCurrentController()); + + //get the SpinButtonControl for the needed Object relations + oObj = the_access.getControl(the_Model); + aControl = the_access.getControl(the_Model2); + the_win = the_access.getControl(the_Model).getPeer(); + the_kit = the_win.getToolkit(); + aDevice = the_kit.createScreenCompatibleDevice(200, 200); + aGraphic = aDevice.createGraphics(); + + log.println( + "creating a new environment for UnoControlSpinButton object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + + //adding Object-Relation for XScrollBar + tEnv.addObjRelation("Document", xTextDoc); + + + //Adding ObjRelation for XView + tEnv.addObjRelation("GRAPHICS", aGraphic); + + + //Adding ObjRelation for XControl + tEnv.addObjRelation("CONTEXT", xTextDoc); + tEnv.addObjRelation("WINPEER", the_win); + tEnv.addObjRelation("TOOLKIT", the_kit); + tEnv.addObjRelation("MODEL", the_Model); + + XWindow forObjRel = UnoRuntime.queryInterface(XWindow.class, + aControl); + + tEnv.addObjRelation("XWindow.AnotherWindow", forObjRel); + + tEnv.addObjRelation("Document", xTextDoc); + + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControlModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControlModel.java new file mode 100644 index 000000000..911e81b96 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoSpinButtonControlModel.java @@ -0,0 +1,60 @@ +/* + * 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._toolkit; + +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.utils; + + +public class UnoSpinButtonControlModel extends TestCase { + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.awt.UnoControlSpinButtonModel</code>. + */ + @Override + public TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) + throws StatusException { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.UnoControlSpinButtonModel"); + } catch (Exception e) { + } + + log.println("creating a new environment for object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", + "com.sun.star.awt.UnoControlSpinButtonModel"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoTreeControl.java b/qadevOOo/tests/java/mod/_toolkit/UnoTreeControl.java new file mode 100644 index 000000000..95f9c56d9 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoTreeControl.java @@ -0,0 +1,265 @@ +/* + * 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._toolkit; + +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; +import com.sun.star.awt.XControlModel; +import com.sun.star.awt.XDialog; +import com.sun.star.awt.XToolkit; +import com.sun.star.awt.tree.XMutableTreeDataModel; +import com.sun.star.awt.tree.XMutableTreeNode; +import com.sun.star.awt.tree.XTreeControl; +import com.sun.star.awt.tree.XTreeNode; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.CommandAbortedException; +import com.sun.star.ucb.XSimpleFileAccess; +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 java.io.PrintWriter; +import java.util.Comparator; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.utils; + + +public class UnoTreeControl extends TestCase { + private static XMutableTreeDataModel mXTreeDataModel; + private static XMultiServiceFactory mxMSF; + + @Override + protected void initialize(TestParameters Param, PrintWriter log) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( + Param.getMSF()); + + log.println("creating a textdocument"); + SOF.createTextDoc(null); + } + + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + String sTreeControlName = "UnoTreeControl-Test"; + mxMSF = Param.getMSF(); + XInterface oObj = null; + XMutableTreeNode xNode = null; + + try { + + mXTreeDataModel = UnoRuntime.queryInterface(XMutableTreeDataModel.class, + mxMSF.createInstance("com.sun.star.awt.tree.MutableTreeDataModel")); + + xNode = mXTreeDataModel.createNode("UnoTreeControl", false); + + xNode.setDataValue( "UnoTreeControl"); + xNode.setExpandedGraphicURL( "private:graphicrepository/sd/res/triangle_down.png"); + xNode.setCollapsedGraphicURL( "private:graphicrepository/sd/res/triangle_right.png"); + + fillNode(xNode); + + mXTreeDataModel.setRoot(xNode); + + XControlModel xDialogModel = UnoRuntime.queryInterface(XControlModel.class, + mxMSF.createInstance("com.sun.star.awt.UnoControlDialogModel")); + + XPropertySet xDialogPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xDialogModel); + xDialogPropertySet.setPropertyValue( "PositionX", Integer.valueOf(50) ); + xDialogPropertySet.setPropertyValue( "PositionY", Integer.valueOf(50) ); + xDialogPropertySet.setPropertyValue( "Width", Integer.valueOf(256) ); + xDialogPropertySet.setPropertyValue( "Height", Integer.valueOf(256) ); + xDialogPropertySet.setPropertyValue( "Title", "Tree Control Test"); + + XMultiServiceFactory xDialogMSF = UnoRuntime.queryInterface(XMultiServiceFactory.class, xDialogModel); + + XControlModel xTreeControlModel = UnoRuntime.queryInterface(XControlModel.class, + xDialogMSF.createInstance("com.sun.star.awt.tree.TreeControlModel")); + + XPropertySet XTreeControlModelSet = UnoRuntime.queryInterface(XPropertySet.class, xTreeControlModel); + + XTreeControlModelSet.setPropertyValue( "SelectionType",com.sun.star.view.SelectionType.NONE); + XTreeControlModelSet.setPropertyValue( "PositionX", Integer.valueOf(3 )); + XTreeControlModelSet.setPropertyValue( "PositionY", Integer.valueOf(3 )); + XTreeControlModelSet.setPropertyValue( "Width", Integer.valueOf(253)); + XTreeControlModelSet.setPropertyValue( "Height", Integer.valueOf(253) ); + XTreeControlModelSet.setPropertyValue( "DataModel", mXTreeDataModel ); + XTreeControlModelSet.setPropertyValue( "ShowsRootHandles", Boolean.FALSE); + XTreeControlModelSet.setPropertyValue( "ShowsHandles", Boolean.FALSE); + XTreeControlModelSet.setPropertyValue( "RootDisplayed", Boolean.TRUE); + XTreeControlModelSet.setPropertyValue( "Editable", Boolean.TRUE); + + XNameContainer xDialogModelContainer = UnoRuntime.queryInterface(XNameContainer.class, xDialogModel); + + xDialogModelContainer.insertByName( sTreeControlName, xTreeControlModel); + + XControl xDialogControl = UnoRuntime.queryInterface(XControl.class, + mxMSF.createInstance("com.sun.star.awt.UnoControlDialog")); + + xDialogControl.setModel( xDialogModel ); + + XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, + mxMSF.createInstance("com.sun.star.awt.Toolkit" )); + + xDialogControl.createPeer( xToolkit, null ); + + // get the peers of the sub controls from the dialog peer container + XControlContainer xDialogContainer = UnoRuntime.queryInterface(XControlContainer.class ,xDialogControl); + + XTreeControl xTreeControl = UnoRuntime.queryInterface(XTreeControl.class, xDialogContainer.getControl( sTreeControlName )); + + xTreeControl.expandNode(xNode); + oObj = xTreeControl; + + XDialog xDialog = UnoRuntime.queryInterface(XDialog.class, xDialogControl); + + execurteDialog aDialog = new execurteDialog(xDialog); + + aDialog.start(); + + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("XTreeControl_Node", xNode); + + //com.sun.star.view.XSelectionSupplier + try { + + System.out.println("count of children: " + xNode.getChildCount()); + tEnv.addObjRelation("Selections", new Object[]{xNode.getChildAt(0), xNode}); + } catch (com.sun.star.lang.IndexOutOfBoundsException ex) { + log.println("ERROR: could not add object relation 'Selections' because 'xNode.getChildAt(1) failed: " + + ex.toString()); + } + + tEnv.addObjRelation("Comparer", + new Comparator<Object>() { + public int compare(Object o1, Object o2) { + XMutableTreeNode xNode1 = UnoRuntime.queryInterface( + XMutableTreeNode.class, o1); + XTreeNode xNode2a = null; + try { + xNode2a = (XTreeNode) AnyConverter.toObject(new Type(XTreeNode.class), o2); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + ex.printStackTrace(); + } + + XMutableTreeNode xNode2 = UnoRuntime.queryInterface( + XMutableTreeNode.class, xNode2a); + + if (((String) xNode1.getDataValue()).equals(xNode2.getDataValue())) { + return 0; + } + + return -1; + } + }); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment + + private void fillNode( XMutableTreeNode xNode ){ + + if( xNode.getChildCount() == 0 ) + { + xNode.getDataValue(); + + String officeUserPath = utils.getOfficeUserPath(mxMSF); + Object fileacc = null; + try { + fileacc = mxMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc); + + + dirlist(officeUserPath, xNode); + } + } + + private void dirlist(String dir, XMutableTreeNode xNode){ + + Object fileacc = null; + try { + fileacc = mxMSF.createInstance("com.sun.star.comp.ucb.SimpleFileAccess"); + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + XSimpleFileAccess sfa = UnoRuntime.queryInterface(XSimpleFileAccess.class,fileacc); + XMutableTreeNode xChildNode = null; + try { + xChildNode = mXTreeDataModel.createNode(dir.substring(dir.lastIndexOf("/")+1, dir.length()), sfa.isFolder(dir)); + xChildNode.setDataValue(dir); + sfa.isFolder(dir); + if (sfa.isFolder(dir)){ + xChildNode.setExpandedGraphicURL( "private:graphicrepository/sd/res/triangle_down.png"); + xChildNode.setCollapsedGraphicURL("private:graphicrepository/sd/res/triangle_right.png"); + String[] children = sfa.getFolderContents(dir, true); + if (children != null){ + for (int i=0; i<children.length; i++) { + // Get filename of file or directory + String filename = children[i]; + dirlist( filename , xChildNode); + } + } + } + else{ + xChildNode.setNodeGraphicURL( "private:graphicrepository/sw/res/nc20010.png"); + } + } catch (CommandAbortedException ex) { + ex.printStackTrace(); + } catch (com.sun.star.uno.Exception ex) { + ex.printStackTrace(); + } + + try { + xNode.appendChild( xChildNode ); + } catch (com.sun.star.lang.IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + + private static class execurteDialog extends Thread{ + private final XDialog mXDialog; + + public execurteDialog(XDialog xDialog){ + mXDialog = xDialog; + } + + @Override + public void run() { + mXDialog.endExecute(); + } + } + + +} // finish class UnoControlRadioButton diff --git a/qadevOOo/tests/java/mod/_toolkit/UnoTreeModel.java b/qadevOOo/tests/java/mod/_toolkit/UnoTreeModel.java new file mode 100644 index 000000000..bb7534ebd --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/UnoTreeModel.java @@ -0,0 +1,77 @@ +/* + * 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._toolkit; + +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import util.WriterTools; +import util.utils; + + +public class UnoTreeModel extends TestCase { + private static XTextDocument xTextDoc; + + /** + * Creates StarOffice Writer document. + */ + @Override + protected void initialize(TestParameters tParam, PrintWriter log) throws Exception { + log.println("creating a textdocument"); + xTextDoc = WriterTools.createTextDoc( + tParam.getMSF()); + } + + /** + * Disposes StarOffice Writer document. + */ + @Override + protected void cleanup(TestParameters tParam, PrintWriter log) { + log.println(" disposing xTextDoc "); + + util.DesktopTools.closeDoc(xTextDoc); + } + + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, + PrintWriter log) { + XInterface oObj = null; + + try { + oObj = (XInterface) Param.getMSF().createInstance( + "com.sun.star.awt.tree.TreeControlModel"); + } catch (Exception e) { + } + + log.println( + "creating a new environment for TreeControlModel object"); + + TestEnvironment tEnv = new TestEnvironment(oObj); + + tEnv.addObjRelation("OBJNAME", "com.sun.star.awt.tree.TreeControlModel"); + System.out.println("ImplementationName: " + utils.getImplName(oObj)); + + return tEnv; + } // finish method getTestEnvironment +} // finish class UnoControlListBoxModel diff --git a/qadevOOo/tests/java/mod/_toolkit/package.html b/qadevOOo/tests/java/mod/_toolkit/package.html new file mode 100644 index 000000000..1ab783205 --- /dev/null +++ b/qadevOOo/tests/java/mod/_toolkit/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 'toolkit'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_typeconverter/uno/TypeConverter.java b/qadevOOo/tests/java/mod/_typeconverter/uno/TypeConverter.java new file mode 100644 index 000000000..775c6bad5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_typeconverter/uno/TypeConverter.java @@ -0,0 +1,54 @@ +/* + * 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._typeconverter.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class TypeConverter extends TestCase { + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.script.Converter" ); + } + catch( Exception e ) { + log.println("Service not available" ); + } + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class TypeConverter + diff --git a/qadevOOo/tests/java/mod/_typeconverter/uno/package.html b/qadevOOo/tests/java/mod/_typeconverter/uno/package.html new file mode 100644 index 000000000..45007682b --- /dev/null +++ b/qadevOOo/tests/java/mod/_typeconverter/uno/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 'tcv'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_typemgr/uno/TypeDescriptionManager.java b/qadevOOo/tests/java/mod/_typemgr/uno/TypeDescriptionManager.java new file mode 100644 index 000000000..8fd210c0a --- /dev/null +++ b/qadevOOo/tests/java/mod/_typemgr/uno/TypeDescriptionManager.java @@ -0,0 +1,71 @@ +/* + * 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._typemgr.uno; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.uno.XInterface; +import java.io.PrintWriter; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class TypeDescriptionManager extends TestCase { + + /** + * creating a TestEnvironment for the interfaces to be tested + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = Param.getMSF(); + XPropertySet xProp = UnoRuntime.queryInterface( + XPropertySet.class, xMSF); + // get context + XComponentContext xContext = UnoRuntime.queryInterface(XComponentContext.class, + xProp.getPropertyValue("DefaultContext")); + // get the type description manager from context + oInterface = xContext.getValueByName("/singletons/" + + "com.sun.star.reflection.theTypeDescriptionManager"); + } + catch( Exception e ) { + log.println("Introspection Service not available" ); + } + oObj = (XInterface) oInterface; + + + + log.println( " creating a new environment for Introspection object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // Object relation for XHierarchicalNameAccess ifc + // Name of the existing object + tEnv.addObjRelation("ElementName", "com.sun.star.container.XNameAccess") ; + tEnv.addObjRelation("SearchString", "com.sun.star.loader"); + + return tEnv; + } // finish method getTestEnvironment + +} // finish class TypeDescriptionManager + diff --git a/qadevOOo/tests/java/mod/_typemgr/uno/package.html b/qadevOOo/tests/java/mod/_typemgr/uno/package.html new file mode 100644 index 000000000..277a28045 --- /dev/null +++ b/qadevOOo/tests/java/mod/_typemgr/uno/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 'tdmgr'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_ucb/UcbContentProviderProxyFactory.java b/qadevOOo/tests/java/mod/_ucb/UcbContentProviderProxyFactory.java new file mode 100644 index 000000000..b24ca70e7 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucb/UcbContentProviderProxyFactory.java @@ -0,0 +1,63 @@ +/* + * 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._ucb; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.ContentProviderFactory</code>. <p> +*/ +public class UcbContentProviderProxyFactory extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.ContentProviderFactory</code>. + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters Param,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.UcbContentProviderProxyFactory" ); + + oObj = (XInterface) oInterface; + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class UcbContentProviderProxyFactory + diff --git a/qadevOOo/tests/java/mod/_ucb/UcbPropertiesManager.java b/qadevOOo/tests/java/mod/_ucb/UcbPropertiesManager.java new file mode 100644 index 000000000..5f04e3864 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucb/UcbPropertiesManager.java @@ -0,0 +1,54 @@ +/* + * 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._ucb; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class UcbPropertiesManager extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.UcbPropertiesManager" ); + + oObj = (XInterface) oInterface; + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class UcbPropertiesManager + diff --git a/qadevOOo/tests/java/mod/_ucb/UcbStore.java b/qadevOOo/tests/java/mod/_ucb/UcbStore.java new file mode 100644 index 000000000..784210db5 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucb/UcbStore.java @@ -0,0 +1,62 @@ +/* + * 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._ucb; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.Store</code>. <p> +*/ +public class UcbStore extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.Store</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance( "com.sun.star.comp.ucb.UcbStore" ); + + oObj = (XInterface) oInterface; + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class UcbStore + diff --git a/qadevOOo/tests/java/mod/_ucb/UniversalContentBroker.java b/qadevOOo/tests/java/mod/_ucb/UniversalContentBroker.java new file mode 100644 index 000000000..17f415569 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucb/UniversalContentBroker.java @@ -0,0 +1,73 @@ +/* + * 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._ucb; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.UniversalContentBroker</code>. <p> +*/ +public class UniversalContentBroker extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucb.UniversalContentBroker</code>. + */ + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,oObj); + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + + tEnv.addObjRelation("CONTENT1", + "vnd.sun.star.webdav://localhost/davhome/"); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class UniversalContentBroker + diff --git a/qadevOOo/tests/java/mod/_ucpchelp/CHelpContentProvider.java b/qadevOOo/tests/java/mod/_ucpchelp/CHelpContentProvider.java new file mode 100644 index 000000000..0cc406fd2 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucpchelp/CHelpContentProvider.java @@ -0,0 +1,67 @@ +/* + * 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._ucpchelp; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class CHelpContentProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + Object aUCB = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.ucb.HelpContentProvider" ); + aUCB = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,aUCB); + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + tEnv.addObjRelation("CONTENT1", "vnd.sun.star.help://swriter?System=WIN&Language=de&Query=text&HitCount=120&Scope=Heading"); + tEnv.addObjRelation("CONTENT2", + util.utils.getFullTestURL("SwXTextEmbeddedObject.sdw")); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class FileProvider + diff --git a/qadevOOo/tests/java/mod/_ucpdav/WebDAVContentProvider.java b/qadevOOo/tests/java/mod/_ucpdav/WebDAVContentProvider.java new file mode 100644 index 000000000..cc0736f32 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucpdav/WebDAVContentProvider.java @@ -0,0 +1,68 @@ +/* + * 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._ucpdav; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Creates a <code>com.sun.star.ucb.WebDAVContentProvider</code> instance. + */ +public class WebDAVContentProvider extends TestCase { + /** + * Creates a <code>com.sun.star.ucb.WebDAVContentProvider</code> instance + * and adds a <code>XContentIdentifierFactory</code> instance as a "FACTORY" + * relation for <code>XContentProviderTest</code>. + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface xInt; + + log.println("creating WebDAVContentProvider instance"); + xInt = (XInterface)xMSF.createInstance( + "com.sun.star.ucb.WebDAVContentProvider"); + + TestEnvironment tEnv = new TestEnvironment(xInt); + + log.println("creating XContentIdentifierFactory"); + XContentIdentifierFactory xCIF; + + xCIF = UnoRuntime.queryInterface( + XContentIdentifierFactory.class, + xMSF.createInstance( + "com.sun.star.comp.ucb.UniversalContentBroker")); + + tEnv.addObjRelation("FACTORY", xCIF); + + tEnv.addObjRelation("CONTENT1", + "vnd.sun.star.webdav://localhost/davhome/"); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_ucpfile/FileProvider.java b/qadevOOo/tests/java/mod/_ucpfile/FileProvider.java new file mode 100644 index 000000000..f4fab5e9b --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucpfile/FileProvider.java @@ -0,0 +1,65 @@ +/* + * 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._ucpfile; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class FileProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.FileProvider" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,oObj); + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + tEnv.addObjRelation("CONTENT1", + util.utils.getOfficeTemp(Param.getMSF())); + tEnv.addObjRelation("CONTENT2", + util.utils.getFullTestURL("SwXTextEmbeddedObject.sdw")); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class FileProvider + diff --git a/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java b/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java new file mode 100644 index 000000000..7bb047214 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucpftp/FTPContentProvider.java @@ -0,0 +1,66 @@ +/* + * 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._ucpftp; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class FTPContentProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + Object aUCB = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.ucb.FTPContentProvider" ); + aUCB = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,aUCB); + + log.println("ImplementationName: "+util.utils.getImplName(oObj)); + util.dbg.printInterfaces(oObj); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + tEnv.addObjRelation("CONTENT1","ftp:///ftp.sun.com"); + tEnv.addObjRelation("CONTENT2","ftp:///ftp.openoffice.org"); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class FileProvider + diff --git a/qadevOOo/tests/java/mod/_ucphier/HierarchyContentProvider.java b/qadevOOo/tests/java/mod/_ucphier/HierarchyContentProvider.java new file mode 100644 index 000000000..1d0cf0e81 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucphier/HierarchyContentProvider.java @@ -0,0 +1,65 @@ +/* + * 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._ucphier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class HierarchyContentProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + Object ucb = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.HierarchyContentProvider" ); + ucb = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,ucb); + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + tEnv.addObjRelation("CONTENT1","vnd.sun.star.hier:/"); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class HierarchyContentProvider + diff --git a/qadevOOo/tests/java/mod/_ucphier/HierarchyDataSource.java b/qadevOOo/tests/java/mod/_ucphier/HierarchyDataSource.java new file mode 100644 index 000000000..c0d5a8146 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucphier/HierarchyDataSource.java @@ -0,0 +1,60 @@ +/* + * 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._ucphier; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Creates <code>HierarchyDataSource</code> implementation of + * <code>ucphier</code> module. + * + * @see ifc.lang._XMultiServiceFactory + */ +public class HierarchyDataSource extends TestCase { + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) { + XInterface oObj = null; + Object oInterface = null; + + try { + XMultiServiceFactory xMSF = tParam.getMSF(); + oInterface = xMSF.createInstance( + "com.sun.star.ucb.DefaultHierarchyDataSource"); + } + catch( com.sun.star.uno.Exception e ) { + log.println("Service not available" ); + } + + oObj = (XInterface) oInterface; + + log.println( " creating a new environment for object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } +} + diff --git a/qadevOOo/tests/java/mod/_ucppkg/PackageContentProvider.java b/qadevOOo/tests/java/mod/_ucppkg/PackageContentProvider.java new file mode 100644 index 000000000..72b7f3577 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucppkg/PackageContentProvider.java @@ -0,0 +1,68 @@ +/* + * 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._ucppkg; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class PackageContentProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInterface = null; + Object ucb = null; + + XMultiServiceFactory xMSF = Param.getMSF(); + oInterface = xMSF.createInstance + ( "com.sun.star.comp.ucb.PackageContentProvider" ); + ucb = xMSF.createInstance + ( "com.sun.star.comp.ucb.UniversalContentBroker" ); + + oObj = (XInterface) oInterface; + + XContentIdentifierFactory CIF = UnoRuntime.queryInterface(XContentIdentifierFactory.class,ucb); + + System.out.println("ImplementationName: "+util.utils.getImplName(oObj)); + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //Adding ObjRelation for XContentProvider + tEnv.addObjRelation("FACTORY",CIF); + tEnv.addObjRelation("CONTENT1", + "vnd.sun.star.pkg://file:%2F%2F%2Fe:%2Fmy.xsw/"); + tEnv.addObjRelation("CONTENT2", + "vnd.sun.star.pkg://file:%2F%2F%2Fe:%2Fyour.xsw/"); + + return tEnv; + + } // finish method getTestEnvironment + +} // finish class PackageContentProvider + diff --git a/qadevOOo/tests/java/mod/_ucprmt/ContentProvider.java b/qadevOOo/tests/java/mod/_ucprmt/ContentProvider.java new file mode 100644 index 000000000..22c788522 --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucprmt/ContentProvider.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._ucprmt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.ucb.RemoteAccessContentProvider</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::ucb::XContentProvider</code></li> +* <li> <code>com::sun::star::ucb::XFileIdentifierConverter</code></li> +* <li> <code>com::sun::star::ucb::XContentIdentifierFactory</code></li> +* <li> <code>com::sun::star::ucb::XParameterizedContentProvider</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see com.sun.star.ucb.XContentProvider +* @see com.sun.star.ucb.XFileIdentifierConverter +* @see com.sun.star.ucb.XContentIdentifierFactory +* @see com.sun.star.ucb.XParameterizedContentProvider +* @see ifc.ucb._XContentProvider +* @see ifc.ucb._XFileIdentifierConverter +* @see ifc.ucb._XContentIdentifierFactory +* @see ifc.ucb._XParameterizedContentProvider +*/ +public class ContentProvider extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.ucprmt.ContentProvider</code>. <p> + * Object relations created : + * <ul> + * <li> <code>'FACTORY'</code> for + * {@link ifc.ucb._XContentProvider} factory for + * content identifiers. Here it is + * <code>UniversalContentBroker</code> service.</li> + * <li> <code>'CONTENT1'</code> for + * {@link ifc.ucb._XContentProvider}: suitable + * content URL for this provider </li> + * <li> <code>'CONTENT2'</code> for + * {@link ifc.ucb._XContentProvider}: another suitable + * content URL for this provider </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log ) throws Exception { + XInterface oObj = null; + XMultiServiceFactory xMSF = Param.getMSF(); + XContentIdentifierFactory cntIDFac = null ; + + oObj = (XInterface) xMSF.createInstance + ("com.sun.star.ucb.RemoteAccessContentProvider"); + cntIDFac = UnoRuntime.queryInterface + (XContentIdentifierFactory.class, oObj) ; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XContentProvider + tEnv.addObjRelation("FACTORY", cntIDFac) ; + tEnv.addObjRelation("CONTENT1","vnd.sun.star.wfs:///user/work"); + tEnv.addObjRelation("CONTENT2","vnd.sun.star.wfs:///user/config"); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_ucprmt/ProviderAcceptor.java b/qadevOOo/tests/java/mod/_ucprmt/ProviderAcceptor.java new file mode 100644 index 000000000..733b8d1be --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucprmt/ProviderAcceptor.java @@ -0,0 +1,52 @@ +/* + * 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._ucprmt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.ucb.XRemoteContentProviderAcceptor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ProviderAcceptor extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + (TestParameters Param, PrintWriter log) throws Exception { + + Object oInterface = Param.getMSF().createInstance + ("com.sun.star.ucb.RemoteContentProviderAcceptor"); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + //adding ObjRelation for XRemoteContentProviderAcceptor + XRemoteContentProviderAcceptor xRCPA = UnoRuntime.queryInterface(XRemoteContentProviderAcceptor.class,oObj); + + tEnv.addObjRelation("RCPA",xRCPA); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_ucprmt/ProxyProvider.java b/qadevOOo/tests/java/mod/_ucprmt/ProxyProvider.java new file mode 100644 index 000000000..2c075ca0d --- /dev/null +++ b/qadevOOo/tests/java/mod/_ucprmt/ProxyProvider.java @@ -0,0 +1,57 @@ +/* + * 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._ucprmt; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ucb.XContentIdentifierFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +public class ProxyProvider extends TestCase { + + @Override + public TestEnvironment createTestEnvironment + ( TestParameters Param, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = Param.getMSF(); + XInterface oObj = (XInterface) xMSF.createInstance + ("com.sun.star.ucb.RemoteProxyContentProvider"); + XContentIdentifierFactory cntIDFac = UnoRuntime.queryInterface + (XContentIdentifierFactory.class, oObj) ; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation for XContentProvider + tEnv.addObjRelation("FACTORY", cntIDFac) ; + tEnv.addObjRelation("CONTENT1","vnd.sun.star.pkg:///user/work"); + tEnv.addObjRelation("CONTENT1","vnd.sun.star.wfs://"); + + tEnv.addObjRelation("NoCONTENT",Boolean.TRUE); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_uui/UUIInteractionHandler.java b/qadevOOo/tests/java/mod/_uui/UUIInteractionHandler.java new file mode 100644 index 000000000..bcabde63d --- /dev/null +++ b/qadevOOo/tests/java/mod/_uui/UUIInteractionHandler.java @@ -0,0 +1,63 @@ +/* + * 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._uui; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** +* Test for object which is represented by service +* <code>com.sun.star.uui.InteractionHandler</code>. <p> +* Object implements the following interfaces : +* <ul> +* <li> <code>com::sun::star::task::XInteractionHandler</code></li> +* </ul> +* This object test <b> is NOT </b> designed to be run in several +* threads concurrently. +* @see ifc.task._XInteractionHandler +*/ +public class UUIInteractionHandler extends TestCase { + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.uui.InteractionHandler</code>. + */ + @Override + public TestEnvironment createTestEnvironment( TestParameters Param, + PrintWriter log ) + throws Exception { + XMultiServiceFactory xMSF = Param.getMSF(); + Object oInterface = xMSF.createInstance + ( "com.sun.star.uui.InteractionHandler" ); + XInterface oObj = (XInterface) oInterface; + + TestEnvironment tEnv = new TestEnvironment( oObj ); + + return tEnv; + } // finish method getTestEnvironment + +} + diff --git a/qadevOOo/tests/java/mod/_uuresolver/UnoUrlResolver.java b/qadevOOo/tests/java/mod/_uuresolver/UnoUrlResolver.java new file mode 100644 index 000000000..594c67178 --- /dev/null +++ b/qadevOOo/tests/java/mod/_uuresolver/UnoUrlResolver.java @@ -0,0 +1,65 @@ +/* + * 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._uuresolver; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +public class UnoUrlResolver extends TestCase { + + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.UnoUrlResolver"); + TestEnvironment tEnv = new TestEnvironment(xInt); + Object oBFctr = xMSF.createInstance( + "com.sun.star.bridge.BridgeFactory"); + tEnv.addObjRelation("BRIDGEFACTORY", oBFctr); + + Object oAcctr = xMSF.createInstance( + "com.sun.star.connection.Acceptor") ; + tEnv.addObjRelation("ACCEPTOR", oAcctr); + + String os = System.getProperty("OS"); + System.out.println("OS: " + os); + int port = 20004; + if (os.equalsIgnoreCase("wntmsci")) + port = 20004; + if (os.equalsIgnoreCase("unxsols")) + port = 20004; + if (os.equalsIgnoreCase("unxsoli")) + port = 30004; + if (os.equalsIgnoreCase("unxlngi")) + port = 20006; + + tEnv.addObjRelation("PORT", Integer.valueOf(port)); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_uuresolver/package.html b/qadevOOo/tests/java/mod/_uuresolver/package.html new file mode 100644 index 000000000..20c38e20e --- /dev/null +++ b/qadevOOo/tests/java/mod/_uuresolver/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 'uuresolver'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_uuresolver/uno/UnoUrlResolver.java b/qadevOOo/tests/java/mod/_uuresolver/uno/UnoUrlResolver.java new file mode 100644 index 000000000..ffb7c5820 --- /dev/null +++ b/qadevOOo/tests/java/mod/_uuresolver/uno/UnoUrlResolver.java @@ -0,0 +1,54 @@ +/* + * 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._uuresolver.uno; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; + +public class UnoUrlResolver extends TestCase { + + + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, + PrintWriter log) throws Exception { + XMultiServiceFactory xMSF = tParam.getMSF(); + + XInterface xInt = (XInterface)xMSF.createInstance( + "com.sun.star.bridge.UnoUrlResolver"); + TestEnvironment tEnv = new TestEnvironment(xInt); + Object oBFctr = xMSF.createInstance( + "com.sun.star.bridge.BridgeFactory"); + tEnv.addObjRelation("BRIDGEFACTORY", oBFctr); + + Object oAcctr = xMSF.createInstance( + "com.sun.star.connection.Acceptor") ; + tEnv.addObjRelation("ACCEPTOR", oAcctr); + + int port = util.utils.getNextFreePort(20004); + tEnv.addObjRelation("PORT", Integer.valueOf(port)); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_uuresolver/uno/package.html b/qadevOOo/tests/java/mod/_uuresolver/uno/package.html new file mode 100644 index 000000000..20c38e20e --- /dev/null +++ b/qadevOOo/tests/java/mod/_uuresolver/uno/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 'uuresolver'.</P> +</BODY> +</HTML> diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java new file mode 100644 index 000000000..9edbe3aa3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentExporter.java @@ -0,0 +1,182 @@ +/* + * 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._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The chart document is set as a source document for exporter + * created. A new 'main title' is set for chart. This made + * for checking if this title is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String exportStr = "XMLContentExporter" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + Object oTitle = xChartDoc.getTitle() ; + XPropertySet xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + xTitleProp.setPropertyValue("String", exportStr) ; + + filter.addTag(new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document-content")); + filter.addCharactersEnclosed(exportStr, + new XMLTools.Tag("chart:title")) ; + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java new file mode 100644 index 000000000..1481e0134 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLContentImporter.java @@ -0,0 +1,188 @@ +/* + * 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._xmloff.Chart; + +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.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLContentImporter</code><p> + * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag which specifies the title + * of a chart. + * After import title name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLContentImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + final XPropertySet xTitleProp ; + oInt = xMSF.createInstance + ("com.sun.star.comp.Chart.XMLContentImporter") ; + + + Object oTitle = xChartDoc.getTitle() ; + xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-content", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "chart:chart"}, + {"start", "chart:title"}, + {"start", "text:p"}, + {"chars", impValue}, + {"end", "text:p"}, + {"end", "chart:title"}, + {"end", "chart:chart"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String title = (String) + xTitleProp.getPropertyValue("String") ; + logF.println("Title returned = '" + title + "'") ; + return impValue.equals(title) ; + } catch (com.sun.star.uno.Exception e) { + logF.println + ("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java new file mode 100644 index 000000000..6a4eda292 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLExporter.java @@ -0,0 +1,184 @@ +/* + * 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._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The chart document is set as a source document for exporter + * created. A new 'main title' is set for chart. This made + * for checking if this title is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String exportStr = "XMLExporter test." ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + Object oTitle = xChartDoc.getTitle() ; + XPropertySet xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + xTitleProp.setPropertyValue("String", exportStr) ; + + filter.addTag(new XMLTools.Tag("office:document")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document")); + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document")); + filter.addCharactersEnclosed(exportStr, + new XMLTools.Tag("chart:title")) ; + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.java new file mode 100644 index 000000000..eb60684b8 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLImporter.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._xmloff.Chart; + +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.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLImporter</code><p> + * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag which specifies the title + * of a chart. + * After import title name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + final XPropertySet xTitleProp ; + oInt = xMSF.createInstance("com.sun.star.comp.Chart.XMLImporter") ; + + Object oTitle = xChartDoc.getTitle() ; + xTitleProp = UnoRuntime.queryInterface + (XPropertySet.class, oTitle) ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "chart:chart"}, + {"start", "chart:title"}, + {"start", "text:p"}, + {"chars", impValue}, + {"end", "text:p"}, + {"end", "chart:title"}, + {"end", "chart:chart"}, + {"end", "office:body"}, + {"end", "office:document-content"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + String title = (String) + xTitleProp.getPropertyValue("String") ; + logF.println("Title returned = '" + title + "'") ; + return impValue.equals(title) ; + } catch (com.sun.star.uno.Exception e) { + logF.println + ("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java new file mode 100644 index 000000000..66f46ba52 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesExporter.java @@ -0,0 +1,171 @@ +/* + * 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._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + XChartDocument xChartDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * Existing of some tags checked in XML data exported. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Chart.XMLStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xChartDoc); + + + filter.addTag(new XMLTools.Tag("office:document-styles")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:styles"), + new XMLTools.Tag("office:document-styles")); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"schart: StarOffice XML (Chart)"})); + tEnv.addObjRelation("SourceDocument",xChartDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java new file mode 100644 index 000000000..4944e1806 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Chart/XMLStylesImporter.java @@ -0,0 +1,161 @@ +/* + * 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._xmloff.Chart; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.chart.XChartDocument; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Chart.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XComponent comp ; + XChartDocument xChartDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a chartdocument" ); + xChartDoc = SOF.createChartDoc(); + + comp = xChartDoc; + } + + /** + * Close document + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + if( xChartDoc!=null ) { + log.println( " closing xChartDoc" ); + util.DesktopTools.closeDoc(xChartDoc); + xChartDoc = null; + comp = null; + } + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Chart.XMLStylesImporter</code><p> + * + * The chart document is set as a target document for importer. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Chart.XMLStylesImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", comp) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:text", "CDATA", "http://openoffice.org/2000/text", + "xmlns:chart", "CDATA", "http://openoffice.org/2000/chart", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "office:class", "CDATA", "chart", + "office:version", "CDATA", "1.0" + }, + {"start", "office:styles"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + logF.println("No ways to check styles import were not found."); + logF.println(" TRUE returned."); + return true ; + } + }) ; + + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentExporter.java new file mode 100644 index 000000000..e0e26b710 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentExporter.java @@ -0,0 +1,190 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +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.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLOasisContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLOasisContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The draw document is set as a source document for exporter + * created. Then a new page (Slide) created in this document and + * both two pages renamed to 'NewSlide1' and 'NewSlide2'. After this + * filter checks that new tags exist in the XML output. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + // Adding tags for checking existence of head tag and other tags + filter.addTag(new XMLTools.Tag("office:document-content")); + filter.addTag(new XMLTools.Tag("office:body")); + filter.addTagEnclosed( + new XMLTools.Tag("draw:page"), + new XMLTools.Tag("office:body")); + filter.addTag(new XMLTools.Tag("draw:page","draw:name","NewSlide1")); + filter.addTag(new XMLTools.Tag("draw:page","draw:name","NewSlide2")); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Draw.XMLOasisContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + + XDrawPagesSupplier supp = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages set = supp.getDrawPages(); + + // This is an XML-export BUG (new slide named "NewSlide2" + // can not be exported to XML) + set.insertNewByIndex(1); + + XDrawPage page1 = UnoRuntime.queryInterface(XDrawPage.class, set.getByIndex(0)); + XNamed NPage1 = UnoRuntime.queryInterface(XNamed.class,page1); + NPage1.setName("NewSlide1"); + XDrawPage page2 = UnoRuntime.queryInterface(XDrawPage.class, set.getByIndex(1)); + XNamed NPage2 = UnoRuntime.queryInterface(XNamed.class,page2); + NPage2.setName("NewSlide2"); + xEx.setSourceDocument(xDrawDoc); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"sdraw: StarOffice XML (Draw)"})); + tEnv.addObjRelation("SourceDocument",xDrawDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + + diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentImporter.java new file mode 100644 index 000000000..7225b192b --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLContentImporter.java @@ -0,0 +1,192 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLContentImporter</code><p> + * + * The Draw document is set as a target document for importer. + * Imported XML-data contains only content tags including pages + * named 'NewSlide1' and 'NewSlide2'. + * Pages getting from target document is checked after import + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Draw.XMLContentImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xDrawDoc) ; + + // New XML document generated to be imported to Draw document + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing", + "office:class", "CDATA", "drawing" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", "NewSlide1", + "draw:master-page-name", "CDATA", "Default"}, + {"end", "draw:page"}, + {"start", "draw:page", "draw:name", "CDATA", "NewSlide2", + "draw:master-page-name", "CDATA", "Default"}, + {"end","draw:page"}, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"}}; + + // adding relation for XDocumentHandler + tEnv.addObjRelation("XDocumentHandler.XMLData", xml); + + //save to log content before import + final PrintWriter fLog = log; + + // Checking target document after import + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + XDrawPagesSupplier supp = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xDrawDoc); + final XDrawPages xPages = supp.getDrawPages(); + XNamed[] pageArray = new XNamed[ xPages.getCount() ]; + for (int i=0; i < xPages.getCount(); i++) { + try { + pageArray[i] = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(i)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(fLog) ; + throw new StatusException + ("Can't get page name by index.", e) ; + } + } + fLog.println("Slide names after import:"); + for ( int i = 0; i < xPages.getCount(); i++ ) { + if ((pageArray[i].getName().equals("NewSlide1")) + || (pageArray[i].getName().equals("NewSlide2"))) { + fLog.println(" " + pageArray[i].getName()); + } + else { + fLog.println("Error: some imported values are not exist in target document!"); + return false; + } + } + return true; + } + }); + + return tEnv; + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLExporter.java new file mode 100644 index 000000000..5bf74b1cb --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLExporter.java @@ -0,0 +1,190 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +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.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The draw document is set as a source document for exporter + * created. Then a new page (Slide) created in this document and + * both two pages renamed to 'NewSlide1' and 'NewSlide2'. After this + * filter checks that new tags exist in the XML output. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + // Adding tags for checking existence of head tag and other tags + filter.addTag(new XMLTools.Tag("office:document")); + filter.addTag(new XMLTools.Tag("office:body")); + filter.addTagEnclosed( + new XMLTools.Tag("draw:page"), + new XMLTools.Tag("office:body")); + filter.addTag(new XMLTools.Tag("draw:page","draw:name","NewSlide1")); + filter.addTag(new XMLTools.Tag("draw:page","draw:name","NewSlide2")); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Draw.XMLExporter", new Object[] {arg}); + + + XDrawPagesSupplier supp = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xDrawDoc); + XDrawPages set = supp.getDrawPages(); + + // This is an XML-export BUG (new slide named "NewSlide2" can not be exported to XML) + set.insertNewByIndex(1); + + XDrawPage page1 = UnoRuntime.queryInterface(XDrawPage.class, set.getByIndex(0)); + XNamed NPage1 = UnoRuntime.queryInterface(XNamed.class,page1); + NPage1.setName("NewSlide1"); + XDrawPage page2 = UnoRuntime.queryInterface(XDrawPage.class, set.getByIndex(1)); + XNamed NPage2 = UnoRuntime.queryInterface(XNamed.class,page2); + NPage2.setName("NewSlide2"); + + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xDrawDoc); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"sdraw: StarOffice XML (Draw)"})); + tEnv.addObjRelation("SourceDocument",xDrawDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLImporter.java new file mode 100644 index 000000000..b550ffea6 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLImporter.java @@ -0,0 +1,192 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLImporter</code><p> + * + * The Draw document is set as a target document for importer. + * Imported XML-data contains only content tags including pages + * named 'NewSlide1' and 'NewSlide2'. + * Pages getting from target document are checked after import. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance("com.sun.star.comp.Draw.XMLImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xDrawDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing", + "office:class", "CDATA", "drawing" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", "NewSlide1", + "draw:master-page-name", "CDATA", "Default"}, + {"end", "draw:page"}, + {"start", "draw:page", + "draw:name", "CDATA", "NewSlide2", + "draw:master-page-name", "CDATA", "Default"}, + {"end","draw:page"}, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + //save to log content before import + final PrintWriter fLog = log; + + // Checking target document after import + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + XDrawPagesSupplier supp = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xDrawDoc); + final XDrawPages xPages = supp.getDrawPages(); + XNamed[] pageArray = new XNamed[ xPages.getCount() ]; + for (int i=0; i < xPages.getCount(); i++) { + try { + pageArray[i] = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(i)); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(fLog) ; + throw new StatusException + ("Can't get page name by index.", e) ; + } + } + fLog.println("Slide names after import:"); + for ( int i = 0; i < xPages.getCount(); i++ ) { + if ((pageArray[i].getName().equals("NewSlide1")) + || (pageArray[i].getName().equals("NewSlide2"))) { + fLog.println(" " + pageArray[i].getName()); + } + else { + fLog.println("Error: some imported values are not exist in target document!"); + return false; + } + } + return true; + } + }); + + return tEnv; + } // end of getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java new file mode 100644 index 000000000..0e2835d41 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java @@ -0,0 +1,183 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLOasisMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLOasisMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The draw document is set as a source document for exporter + * created. Set title of document to 'XMLMetaExporter'. + * This made for checking if this title is successfully exported within + * the document meta information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String TITLE = "XMLMetaExporter"; + + FilterChecker filter = new FilterChecker(log) ; + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Draw.XMLOasisMetaExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class, oObj); + xEx.setSourceDocument(xDrawDoc); + + //set some meta data + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xDrawDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(TITLE); + + // Checking Head Tag existence and that property has changed + filter.addTag(new XMLTools.Tag ("office:document-meta")); + filter.addTagEnclosed( + new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document-meta") ); + filter.addTagEnclosed( + new XMLTools.Tag("dc:title"), + new XMLTools.Tag("office:meta") ); + filter.addCharactersEnclosed( TITLE, + new XMLTools.Tag("dc:title") ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"sdraw: StarOffice XML (Draw)"})); + tEnv.addObjRelation("SourceDocument", xDrawDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java new file mode 100644 index 000000000..8bcf5b355 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java @@ -0,0 +1,162 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Draw document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLMetaImporter</code><p> + * + * The draw document is set as a target document for importer. + * Imported XML-data contains only meta tags including + * title tag with test name. + * After import title name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance("com.sun.star.comp.Draw.XMLMetaImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xDrawDoc) ; + + final String impTitle = "XMLMetaImporter" ; + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:meta", "CDATA", "http://openoffice.org/2000/meta", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/" + }, + {"start", "office:meta"}, + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + //set some meta data + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xDrawDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsExporter.java new file mode 100644 index 000000000..261852b8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsExporter.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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLOasisSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>om.sun.star.comp.Draw.XMLSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The draw document is set as a source document for exporter + * created. Property 'IsLayerMode' set to true. + * This made for checking if this property is successfully exported within + * the document styles information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + FilterChecker filter = new FilterChecker(log) ; + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Draw.XMLOasisSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class, oObj); + xEx.setSourceDocument(xDrawDoc); + + //set some settings + XModel xDrawModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + XController xController = xDrawModel.getCurrentController(); + XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + xPropSet.setPropertyValue("IsLayerMode", Boolean.TRUE); + + // Checking Head Tag existence and that property has changed + filter.addTag(new XMLTools.Tag ("office:document-settings")); + filter.addTagEnclosed( + new XMLTools.Tag ("office:settings"), + new XMLTools.Tag ("office:document-settings") ); + filter.addTagEnclosed( + new XMLTools.Tag ("config:config-item-set"), + new XMLTools.Tag ("office:settings") ); + filter.addTagEnclosed( + new XMLTools.Tag ("config:config-item-map-indexed"), + new XMLTools.Tag ("config:config-item-set") ); + filter.addCharactersEnclosed( "true", + new XMLTools.Tag( "config:config-item", + "config:name", + "IsLayerMode" )); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"sdraw: StarOffice XML (Draw)"})); + tEnv.addObjRelation("SourceDocument", xDrawDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsImporter.java new file mode 100644 index 000000000..ec6d5625d --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLSettingsImporter.java @@ -0,0 +1,178 @@ +/* + * 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._xmloff.Draw; + +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.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Text draw destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLSettingsImporter</code><p> + * + * The draw document is set as a target document for importer. + * Imported XML-data contains only settings tags including + * tag with property 'IsLayerMode'. + * After import property 'IsLayerMode' getting from target + * document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Draw.XMLSettingsImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xDrawDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config"}, + {"start", "office:settings"}, + {"start", "config:config-item-set", + "config:name", "CDATA", "view-settings"}, + {"start", "config:config-item-map-indexed", + "config:name", "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start", "config:config-item", + "config:name", "CDATA", "IsLayerMode", + "config:type", "CDATA", "boolean"}, + {"chars", "true"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "config:config-item-set"}, + {"end", "office:settings"}, + {"end", "office:document-settings"} }; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml); + final PrintWriter logF = log; + XModel xDrawModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc); + XController xController = xDrawModel.getCurrentController(); + final XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Boolean value = (Boolean) + xPropSet.getPropertyValue("IsLayerMode"); + logF.println("'IsLayerMode' property value is '" + + value + "'"); + return value.booleanValue(); + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception while checking import :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesExporter.java new file mode 100644 index 000000000..2fbf238ca --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesExporter.java @@ -0,0 +1,193 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLOasisStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + XComponent xDrawDoc = null; + protected static int counter = 0; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xDrawDoc " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLOasisStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The draw document is set as a source document for exporter + * created. New style is added to the style family 'graphics' with unique name + * every time. This made for checking if this style is successfully exported + * within the document styles information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment( + TestParameters tParam, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log) ; + Any arg = new Any(new Type(XDocumentHandler.class),filter); + final String STYLE_NAME = "New style" + counter++ ; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Draw.XMLOasisStylesExporter", new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xDrawDoc); + + //obtain style families + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xDrawDoc); + XNameAccess StyleFamilies = styleSup.getStyleFamilies(); + //obtain all style family names + String[] styleFamiliesNames = StyleFamilies.getElementNames(); + String styleFamilyName = styleFamiliesNames[0]; + //obtain style family with name[0] + Object objectStyle = StyleFamilies.getByName(styleFamilyName); + XNameContainer xStyleFamilyName = UnoRuntime.queryInterface(XNameContainer.class, objectStyle); + //create new style + Object SC = SOF.createInstance(xDrawDoc, "com.sun.star.style.Style"); + XStyle Style = UnoRuntime.queryInterface(XStyle.class,SC); + //add new style to style family with name[0] + xStyleFamilyName.insertByName(STYLE_NAME,Style); + + // Checking Head Tag existence and that property has changed + filter.addTag(new XMLTools.Tag ("office:document-styles")); + filter.addTag(new XMLTools.Tag ("office:styles")); + filter.addTagEnclosed( + new XMLTools.Tag("style:style"), + new XMLTools.Tag("office:styles") ); + filter.addTag(new XMLTools.Tag("style:style", "style:name", STYLE_NAME)); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"sdraw: StarOffice XML (Draw)"})); + tEnv.addObjRelation("SourceDocument",xDrawDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, false) ; + } + + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} + diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesImporter.java new file mode 100644 index 000000000..63dae1c1b --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLStylesImporter.java @@ -0,0 +1,176 @@ +/* + * 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._xmloff.Draw; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Draw.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XComponent xDrawDoc = null; + + /** + * New draw document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating a drawdocument" ); + xDrawDoc = SOF.createDrawDoc(null); + } + + /** + * Text draw destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xDrawDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Draw.XMLStylesImporter</code><p> + * + * The draw document is set as a target document for importer. + * Imported XML-data contains only styles tags including + * tag with new style. + * After import checked existing of this new style in style + * collection obtained from target document. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Draw.XMLStylesImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xDrawDoc) ; + + final String impStyleName = "New style for test XMLStylesImporter"; + final String impFamilyName = "graphics"; + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style"}, + {"start", "office:styles"}, + {"start", "style:style", + "style:name", "CDATA", impStyleName, + "style:family", "CDATA", impFamilyName}, + {"end", "style:style"}, + {"end", "office:styles"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log; + //obtain style families + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface (XStyleFamiliesSupplier.class, xDrawDoc) ; + final XNameAccess StyleFamilies = styleSup.getStyleFamilies(); + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + Object objectStyle = + StyleFamilies.getByName(impFamilyName); + XNameContainer StyleFamilyName = UnoRuntime.queryInterface + (XNameContainer.class, objectStyle); + boolean hasStyle = + StyleFamilyName.hasByName(impStyleName); + logF.println("Does style with name '" + impStyleName + + "' exist? " + hasStyle ); + return hasStyle; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception while checking import :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java new file mode 100644 index 000000000..b5a46cfff --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentExporter.java @@ -0,0 +1,187 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLOasisContentExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLContentExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisContentExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. The existing draw page is gotten a new name. This made + * for checking if this new name is successfully exported within + * the document content. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + final String expPageName = "XMLContentExporter" ; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisContentExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // assigning a draw page a new name + XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xImpressDoc) ; + XDrawPages xPages = xPagesSup.getDrawPages() ; + XNamed xPageName = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(0)) ; + xPageName.setName(expPageName) ; + + // adding tags required to be in XML data exported. + filter.addTag(new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed(new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document-content")) ; + filter.addTagEnclosed( + new XMLTools.Tag("draw:page", "draw:name", expPageName), + new XMLTools.Tag("office:body")) ; + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + + log.println("Implementation Name: "+util.utils.getImplName(oObj)); + + return tEnv; + + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check() ; + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java new file mode 100644 index 000000000..23ed91b47 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLContentImporter.java @@ -0,0 +1,201 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLContentImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLContentImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New chart document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Disposes document. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLContentImporter</code><p> + * + * The chart document is set as a target document for importer. + * Imported XML-data contains the tag with a new page which has + * some name. + * After import page name getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam,PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impPageName = "XMLImporterPage" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLContentImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:presentation", "CDATA", "http://openoffice.org/2000/presentation", + "xmlns:svg", "CDATA", "http://openoffice.org/2000/svg", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing", + "office:class", "CDATA", "presentation" + ,"office:version", "CDATA", "1.0" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", impPageName, + "draw:master-page-name", "CDATA", "Default" + }, + {"start", "presentation:notes"}, + {"start", "draw:page-thumbnail", + "draw:style-name", "CDATA", "gr1", + "draw:layer", "CDATA", "layout", + "svg:width", "CDATA", "12.768cm", + "svg:height", "CDATA", "9.576cm", + "svg:x", "CDATA", "4.411cm", + "svg:y", "CDATA", "2.794cm", + "presentation:class", "CDATA", "page", + "draw:page-number", "CDATA", "1" + }, + {"end", "draw:page-thumbnail"}, + {"start", "draw:text-box", + "presentation:style-name", "CDATA", "Default-notes", + "draw:layer", "CDATA", "layout", + "svg:width", "CDATA", "15.021cm", + "svg:height", "CDATA", "10.63cm", + "svg:x", "CDATA", "3.292cm", + "svg:y", "CDATA", "13.299cm", + "presentation:class", "CDATA", "notes", + "presentation:placeholder", "CDATA", "true" + }, + {"end", "draw:text-box"}, + {"end", "presentation:notes"}, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + try { + XDrawPagesSupplier xPagesSup = UnoRuntime.queryInterface + (XDrawPagesSupplier.class, xImpressDoc) ; + XDrawPages xPages = xPagesSup.getDrawPages() ; + XNamed xPageName = UnoRuntime.queryInterface + (XNamed.class, xPages.getByIndex(0)) ; + String gName = xPageName.getName() ; + logF.println("Page name returned = '" + gName + "'") ; + return impPageName.equals(gName) ; + } catch (com.sun.star.uno.Exception e) { + logF.println("Exception occurred while checking filter :") ; + e.printStackTrace(logF) ; + return false ; + } + } + }) ; + + return tEnv; + } // finish method getTestEnvironment +} + diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java new file mode 100644 index 000000000..03080f9d3 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLExporter.java @@ -0,0 +1,188 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNamed; +import com.sun.star.document.XExporter; +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.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. A new draw page with specific name created. This made + * for checking if this draw page is successfully exported within + * the document. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + protected TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + FilterChecker Filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), Filter); + + final String NAME = "XMLExporter"; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLExporter", new Object[] {arg}); + + //get draw pages + XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages drawPages = drawPagesSupplier.getDrawPages(); + //insert new draw page + XDrawPage newDrawPage = drawPages.insertNewByIndex(0); + //set specific test name + XNamed newPageNamed = UnoRuntime.queryInterface(XNamed.class, newDrawPage); + newPageNamed.setName(NAME); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // adding tags which must be contained in XML output + Filter.addTag( new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("office:body"), + new XMLTools.Tag("office:document") ); + Filter.addTagEnclosed( + new XMLTools.Tag("draw:page", "draw:name", NAME), + new XMLTools.Tag("office:body") ); + + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", Filter) ; + + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.java new file mode 100644 index 000000000..1331d9130 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLImporter.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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.drawing.XDrawPages; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLImporter</code><p> + * + * The impress document is set as a target document for importer. + * Imported tags contain page with the specific name. + * After import existence of the page with this specific + * name is checked in the target document. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xImpressDoc) ; + + final String impName = "XMLImporter"; + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing" + }, + {"start", "office:body"}, + {"start", "draw:page", + "draw:name", "CDATA", impName }, + {"end", "draw:page"}, + {"end", "office:body"}, + {"end", "office:document"} }; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml); + + //get draw pages + XDrawPagesSupplier drawPagesSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class, xImpressDoc); + XDrawPages drawPages = drawPagesSupplier.getDrawPages(); + final XNameAccess xNamePages = UnoRuntime.queryInterface(XNameAccess.class, drawPages); + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + return xNamePages.hasByName(impName); + } + } ); + + return tEnv; + } // finish method getTestEnvironment +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java new file mode 100644 index 000000000..360a3ac3a --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java @@ -0,0 +1,184 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLOasisMetaExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLMetaExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( "disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisMetaExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The impress document is set as a source document for exporter + * created. A meta property 'Title' is set to specific value. This made + * for checking if this value is successfully exported within + * the document meta information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class), filter); + final String NAME = "XMLMetaExporter"; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisMetaExporter", + new Object[]{arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // change title name + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(NAME); + + // Checking tags existence and changed property value + filter.addTag(new XMLTools.Tag ("office:document-meta")); + filter.addTagEnclosed( + new XMLTools.Tag("office:meta"), + new XMLTools.Tag("office:document-meta") ); + filter.addTagEnclosed( + new XMLTools.Tag("dc:title"), + new XMLTools.Tag("office:meta") ); + filter.addCharactersEnclosed( + NAME, + new XMLTools.Tag ("dc:title") ); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument", xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter) ; + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, true); + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java new file mode 100644 index 000000000..c50782e7e --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java @@ -0,0 +1,161 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLMetaImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLMetaImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLMetaImporter</code><p> + * + * The impress document is set as a target document for importer. + * Imported XML-data contains only meta tags including title tag + * with test title name. After import title name getting from + * target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam,PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impTitle = "XMLImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLMetaImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-meta" , + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/"}, + {"start", "office:meta"} , + {"start", "dc:title"}, + {"chars", impTitle}, + {"end", "dc:title"}, + {"end", "office:meta"}, + {"end", "office:document-meta"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + final PrintWriter logF = log ; + + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; + } + } ); + + return tEnv; + } // finish method getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java new file mode 100644 index 000000000..b733d67fd --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsExporter.java @@ -0,0 +1,187 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.document.XExporter; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLOasisSettingsExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLSettingsExporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New text document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Document disposed here. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisSettingsExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The Impress document is set as a source document for exporter + * created. Then setting 'IsLayerMode' is changed to a new value. + * After this filter checks that value has changed in the XML output. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XMultiServiceFactory xMSF = tParam.getMSF(); + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + final boolean NewDataValue; + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisSettingsExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + //set some settings + XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + XController xController = xImpressModel.getCurrentController(); + XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + NewDataValue = ! ((Boolean) xPropSet.getPropertyValue + ("IsLayerMode")).booleanValue(); + xPropSet.setPropertyValue("IsLayerMode", + Boolean.valueOf(NewDataValue)); + + + // Adding tags for checking existence of head tag and other tags + filter.addTagEnclosed(new XMLTools.Tag("office:settings"), + new XMLTools.Tag("office:document-settings")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-set"), + new XMLTools.Tag("office:settings")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-map-indexed"), + new XMLTools.Tag("config:config-item-set")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item-map-entry"), + new XMLTools.Tag("config:config-item-map-indexed")); + filter.addTagEnclosed(new XMLTools.Tag("config:config-item"), + new XMLTools.Tag("config:config-item-map-entry")); + filter.addCharactersEnclosed(String.valueOf(NewDataValue), + new XMLTools.Tag("config:config-item","config:name","IsLayerMode")); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log,false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java new file mode 100644 index 000000000..32860a675 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLSettingsImporter.java @@ -0,0 +1,183 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.StatusException; +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLSettingsImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLSettingsImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New impress document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Impress document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code><p> + * + * The Impress document is set as a target document for importer. + * Value of a property "IsLayerMode" has imported as 'true' to a target + * document. After import property value getting from target document + * is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLSettingsImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xImpressDoc) ; + + // adding relation for XDocumentHandler + String[][] xml = new String[][] { + {"start", "office:document-settings", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink", + "xmlns:presentation", "CDATA", + "http://openoffice.org/2000/presentation", + "xmlns:config", "CDATA", "http://openoffice.org/2001/config", + "office:version", "CDATA", "1.0"}, + {"start", "office:settings"}, + {"start", "config:config-item-map-indexed", "config:name", + "CDATA", "Views"}, + {"start", "config:config-item-map-entry"}, + {"start","config:config-item", "config:name", "CDATA", + "IsLayerMode"}, + {"chars", "true"}, + {"end", "config:config-item"}, + {"end", "config:config-item-map-entry"}, + {"end", "config:config-item-map-indexed"}, + {"end", "office:settings"}, + {"end", "office:document-settings"}} ; + + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + + // get property before import + XModel xImpressModel = UnoRuntime.queryInterface(XModel.class, xImpressDoc); + XController xController = xImpressModel.getCurrentController(); + final XPropertySet xPropSet = UnoRuntime.queryInterface(XPropertySet.class, xController); + log.println("Property \"IsLayerMode\" before import is " + + xPropSet.getPropertyValue("IsLayerMode")); + final PrintWriter logF = log; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + Boolean propValue; + try { + propValue = (Boolean) xPropSet.getPropertyValue + ("IsLayerMode"); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(logF); + throw new StatusException + ("Can't get property value.", e); + } + logF.println("Property \"IsLayerMode\" after import is " + + propValue); + return propValue.booleanValue(); + } + }); + + return tEnv; + } // end of getTestEnvironment + +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java new file mode 100644 index 000000000..2a44f8a8e --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesExporter.java @@ -0,0 +1,185 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; +import util.XMLTools; + +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.document.XExporter; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyle; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.Any; +import com.sun.star.uno.Exception; +import com.sun.star.uno.Type; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.xml.sax.XDocumentHandler; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLOasisStylesExporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::ExportFilter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::XExporter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.ExportFilter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.XExporter + * @see com.sun.star.beans.XPropertySet + * @see ifc.lang._XInitialization + * @see ifc.document._ExportFilter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + */ +public class XMLStylesExporter extends TestCase { + XComponent xImpressDoc = null; + protected static int counter = 0; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Spreadsheet document disposed + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing xImpressDoc " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLOasisStylesExporter</code> with + * argument which is an implementation of <code>XDocumentHandler</code> + * and which can check if required tags and character data is + * exported. <p> + * The Impress document is set as a source document for exporter + * created. New style 'NewStyle' added to style family "Graphics". + * This made for checking if this style is successfully exported within + * the document styles information. + * Object relations created : + * <ul> + * <li> <code>'MediaDescriptor'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'XFilter.Checker'</code> for + * {@link ifc.document._XFilter} interface </li> + * <li> <code>'SourceDocument'</code> for + * {@link ifc.document._XExporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log) throws Exception { + + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() ); + XMultiServiceFactory xMSF = tParam.getMSF() ; + XInterface oObj = null; + FilterChecker filter = new FilterChecker(log); + Any arg = new Any(new Type(XDocumentHandler.class),filter); + + String newName = "NewGraphicsStyle" + counter++; + // Adding tags for checking existence of head tag and property value + filter.addTag(new XMLTools.Tag("office:document-styles")); + filter.addTag(new XMLTools.Tag("office:styles")); + filter.addTag(new XMLTools.Tag("style:style","style:name", newName)); + + oObj = (XInterface) xMSF.createInstanceWithArguments( + "com.sun.star.comp.Impress.XMLOasisStylesExporter", + new Object[] {arg}); + XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); + xEx.setSourceDocument(xImpressDoc); + + // Obtaining and changing property values + XStyleFamiliesSupplier styleSup = UnoRuntime.queryInterface + (XStyleFamiliesSupplier.class, xImpressDoc) ; + XNameAccess styleFamilies = styleSup.getStyleFamilies(); + String[] styleFamiliesNames = styleFamilies.getElementNames(); + XNameContainer StyleFamilyName = UnoRuntime.queryInterface(XNameContainer.class, + styleFamilies.getByName(styleFamiliesNames[0])); + Object SC = SOF.createInstance + (xImpressDoc, "com.sun.star.style.Style"); + XStyle StylePage = UnoRuntime.queryInterface(XStyle.class,SC); + StyleFamilyName.insertByName(newName, StylePage); + + // create testobject here + log.println( "creating a new environment" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( + new String[] {"FilterName"}, + new Object[] {"simpress: StarOffice XML (Impress)"})); + tEnv.addObjRelation("SourceDocument",xImpressDoc); + tEnv.addObjRelation("XFilter.Checker", filter); + return tEnv; + } + + /** + * This class checks the XML for tags and data required and returns + * checking result to <code>XFilter</code> interface test. All + * the information about errors occurred in XML data is written + * to log specified. + * @see ifc.document._XFilter + */ + private class FilterChecker extends XMLTools.XMLChecker + implements ifc.document._XFilter.FilterChecker { + + /** + * Creates a class which will write information + * into log specified. + */ + private FilterChecker(PrintWriter log) { + super(log, false) ; + } + /** + * <code>_XFilter.FilterChecker</code> interface method + * which returns the result of XML checking. + * @return <code>true</code> if the XML data exported was + * valid (i.e. all necessary tags and character data exists), + * <code>false</code> if some errors occurred. + */ + public boolean checkFilter() { + return check(); + } + } +} diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java new file mode 100644 index 000000000..4b0823b44 --- /dev/null +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLStylesImporter.java @@ -0,0 +1,180 @@ +/* + * 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._xmloff.Impress; + +import java.io.PrintWriter; + +import lib.TestCase; +import lib.TestEnvironment; +import lib.TestParameters; +import util.SOfficeFactory; + +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.style.XStyleFamiliesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Test for object which is represented by service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code>. <p> + * Object implements the following interfaces : + * <ul> + * <li><code>com::sun::star::lang::XInitialization</code></li> + * <li><code>com::sun::star::document::XImporter</code></li> + * <li><code>com::sun::star::document::XFilter</code></li> + * <li><code>com::sun::star::document::ImportFilter</code></li> + * <li><code>com::sun::star::beans::XPropertySet</code></li> + * <li><code>com::sun::star::xml::sax::XDocumentHandler</code></li> + + * </ul> + * @see com.sun.star.lang.XInitialization + * @see com.sun.star.document.XImporter + * @see com.sun.star.document.XFilter + * @see com.sun.star.document.ImportFilter + * @see com.sun.star.beans.XPropertySet + * @see com.sun.star.xml.sax.XDocumentHandler + * @see ifc.lang._XInitialization + * @see ifc.document._XImporter + * @see ifc.document._XFilter + * @see ifc.document._XExporter + * @see ifc.beans._XPropertySet + * @see ifc.xml.sax._XDocumentHandler + */ +public class XMLStylesImporter extends TestCase { + XComponent xImpressDoc = null; + + /** + * New spreadsheet document created. + */ + @Override + protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { + // get a soffice factory object + SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); + log.println( "creating an impress document" ); + xImpressDoc = SOF.createImpressDoc(null); + } + + /** + * Spreadsheet document destroyed. + */ + @Override + protected void cleanup( TestParameters tParam, PrintWriter log ) { + log.println( " disposing document " ); + xImpressDoc.dispose(); + } + + /** + * Creating a TestEnvironment for the interfaces to be tested. + * Creates an instance of the service + * <code>com.sun.star.comp.Impress.XMLStylesImporter</code><p> + * + * The Impress document is set as a target document for importer. + * Imported XML-data contains only style tags including tag + * with new style name. + * After import style names getting from target document is checked. + * Object relations created : + * <ul> + * <li> <code>'XDocumentHandler.XMLData'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'XDocumentHandler.ImportChecker'</code> for + * {@link ifc.xml.sax._XDocumentHandler} interface </li> + * <li> <code>'TargetDocument'</code> for + * {@link ifc.document._XImporter} interface </li> + * </ul> + */ + @Override + public TestEnvironment createTestEnvironment + (TestParameters tParam, PrintWriter log ) throws Exception { + + XInterface oObj = null; + Object oInt = null ; + final String impValue = "XMLImporter_test" ; + + // creation of testobject here + // first we write what we are intend to do to log file + log.println( "creating a test environment" ); + + XMultiServiceFactory xMSF = tParam.getMSF() ; + + oInt = xMSF.createInstance + ("com.sun.star.comp.Impress.XMLStylesImporter") ; + + oObj = (XInterface) oInt ; + + // create testobject here + log.println( "creating a new environment for Paragraph object" ); + TestEnvironment tEnv = new TestEnvironment( oObj ); + + // adding relation + tEnv.addObjRelation("TargetDocument", xImpressDoc) ; + + String[][] xml = new String[][] { + {"start", "office:document-styles", + "xmlns:office", "CDATA", "http://openoffice.org/2000/office", + "xmlns:style", "CDATA", "http://openoffice.org/2000/style", + "xmlns:fo", "CDATA", "http://www.w3.org/1999/XSL/Format", + "xmlns:table", "CDATA", "http://openoffice.org/2000/table"}, + {"start", "office:styles"}, + {"start", "style:style", + "style:name", "CDATA", impValue, + "style:family", "CDATA", "graphics", + "style:parent-style-name", "CDATA", "standard"}, + {"end", "style:style"}, + {"end", "office:styles"}, + {"end", "office:document-styles"}} ; + + // adding relation for XDocumentHandler + tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; + XNameAccess styles = null ; + try { + XStyleFamiliesSupplier sup = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, + xImpressDoc); + XNameAccess oStyleFamilies = sup.getStyleFamilies(); + Object family = oStyleFamilies.getByName("graphics") ; + styles = UnoRuntime.queryInterface + (XNameAccess.class, family) ; + log.println("Styles before:") ; + String[] names = styles.getElementNames() ; + for (int i = 0; i < names.length; i++) { + log.println(" " + names[i]) ; + } + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log) ; + } + final XNameAccess stylesF = styles ; + final PrintWriter logF = log ; + tEnv.addObjRelation("XDocumentHandler.ImportChecker", + new ifc.xml.sax._XDocumentHandler.ImportChecker() { + public boolean checkImport() { + logF.println("Styles after:") ; + String[] names = stylesF.getElementNames() ; + for (int i = 0; i < names.length; i++) { + logF.println(" " + names[i]) ; + } + return stylesF.hasByName(impValue) ; + } + }) ; + + return tEnv; + } // end of getTestEnvironment + +} + |