diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /qadevOOo/tests/java/mod/_fwk | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'qadevOOo/tests/java/mod/_fwk')
29 files changed, 2464 insertions, 0 deletions
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 + +} |