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/ifc/ui | |
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/ifc/ui')
21 files changed, 2582 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/ui/_XContextMenuInterception.java b/qadevOOo/tests/java/ifc/ui/_XContextMenuInterception.java new file mode 100644 index 000000000..062810730 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XContextMenuInterception.java @@ -0,0 +1,201 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +package ifc.ui; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.Point; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.IndexOutOfBoundsException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.ui.XContextMenuInterception; +import com.sun.star.ui.XContextMenuInterceptor; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import helper.ContextMenuInterceptor; +import java.awt.Robot; +import java.awt.event.InputEvent; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.AccessibilityTools; +import util.DesktopTools; + +public class _XContextMenuInterception extends MultiMethodTest { + + private XModel docModel = null; + private XContextMenuInterceptor xCI = null; + public XContextMenuInterception oObj = null; + private XWindow xWindow = null; + private XMultiServiceFactory xMSF = null; + private Point point = null; + + @Override + public void before() { + docModel = UnoRuntime.queryInterface( + XModel.class,tEnv.getObjRelation("FirstModel")); + + xCI = UnoRuntime.queryInterface( + XContextMenuInterceptor.class, new ContextMenuInterceptor()); + + xMSF = tParam.getMSF(); + + //ensure that the first model is focused + + log.println("ensure that the first model is focused"); + DesktopTools.bringWindowToFront(docModel); + + waitForEventIdle(); + } + + @Override + public void after() { + if (xCI != null) { + oObj.releaseContextMenuInterceptor(xCI); + } + } + + public void _registerContextMenuInterceptor() { + oObj.registerContextMenuInterceptor(xCI); + openContextMenu(docModel); + boolean res = checkHelpEntry(); + releasePopUp(); + tRes.tested("registerContextMenuInterceptor()",res); + } + + public void _releaseContextMenuInterceptor() { + requiredMethod("registerContextMenuInterceptor()"); + oObj.releaseContextMenuInterceptor(xCI); + openContextMenu(docModel); + boolean res = checkHelpEntry(); + releasePopUp(); + tRes.tested("releaseContextMenuInterceptor()",!res); + } + + private boolean checkHelpEntry(){ + XInterface toolkit = null; + boolean res = true; + + log.println("get accessibility..."); + try{ + toolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e){ + log.println("could not get Toolkit " + e.toString()); + } + XExtendedToolkit tk = UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + XAccessible xRoot = null; + + try { + xWindow = UnoRuntime.queryInterface(XWindow.class, + tk.getTopWindow(0)); + + xRoot = AccessibilityTools.getAccessibleObject(xWindow); + AccessibilityTools.printAccessibleTree(log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE)); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't get Window"); + } + + XAccessibleContext oPopMenu = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.POPUP_MENU,true); + + log.println("ImplementationName: " + util.utils.getImplName(oPopMenu)); + + XAccessible xHelp = null; + try{ + log.println("Try to get second entry of context menu..."); + xHelp = oPopMenu.getAccessibleChild(1); + + } catch (IndexOutOfBoundsException e){ + throw new StatusException("Not possible to get second entry of context menu",e); + } + + if (xHelp == null) throw new StatusException(new Status("second entry of context menu is NULL", false)); + + XAccessibleContext xHelpCont = xHelp.getAccessibleContext(); + + if ( xHelpCont == null ) + throw new StatusException(new Status("No able to retrieve accessible context from first entry of context menu",false)); + + String aAccessibleName = xHelpCont.getAccessibleName(); + if ( !aAccessibleName.equals( "Help" )) { + log.println("Accessible name found = "+aAccessibleName ); + log.println("Second entry of context menu is not from context menu interceptor"); + res=false; + } + + return res; + + } + + private void openContextMenu(XModel xModel){ + + log.println("try to open context menu..."); + + xWindow = AccessibilityTools.getCurrentWindow(xModel); + + XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow); + + XInterface oObj = AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL); + + XAccessibleComponent window = UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + point = window.getLocationOnScreen(); + Rectangle rect = window.getBounds(); + + log.println("click mouse button..."); + try { + Robot rob = new Robot(); + int x = point.X + (rect.Width / 2); + int y = point.Y + (rect.Height / 2); + rob.mouseMove(x, y); + System.out.println("Press Button"); + rob.mousePress(InputEvent.BUTTON3_MASK); + System.out.println("Release Button"); + rob.mouseRelease(InputEvent.BUTTON3_MASK); + System.out.println("done"); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + + waitForEventIdle(); + + } + + private void releasePopUp() { + log.println("release the popup menu"); + try { + Robot rob = new Robot(); + int x = point.X; + int y = point.Y; + rob.mouseMove(x, y); + rob.mousePress(InputEvent.BUTTON1_MASK); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + } +} diff --git a/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManager.java b/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManager.java new file mode 100644 index 000000000..ec3a14d6b --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManager.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 ifc.ui; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.ui.XModuleUIConfigurationManager; +import lib.MultiMethodTest; + +public class _XModuleUIConfigurationManager extends MultiMethodTest { + + public XModuleUIConfigurationManager oObj = null; + private String resourceUrl = null; + + @Override + public void before() { + resourceUrl = (String)tEnv.getObjRelation("XModuleUIConfigurationManager.ResourceURL"); + } + + public void _isDefaultSettings() { + boolean result; + try { + result = oObj.isDefaultSettings(resourceUrl); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("'" + resourceUrl + "' is an illegal resource."); + result = false; + } + String notPossibleUrl = "private:resource/menubar/dingsbums"; + try { + result &= !oObj.isDefaultSettings(notPossibleUrl); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("'" + notPossibleUrl + "' is an illegal resource."); + result = false; + } + + tRes.tested("isDefaultSettings()", result); + } + + public void _getDefaultSettings() { + boolean result; + try { + XIndexAccess xIndexAcc = oObj.getDefaultSettings(resourceUrl); + result = xIndexAcc != null; + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("'" + resourceUrl + "' is an illegal resource."); + result = false; + } + catch(com.sun.star.container.NoSuchElementException e) { + log.println("No resource '" + resourceUrl + "' available."); + result = false; + } + tRes.tested("getDefaultSettings()", result); + } + +} diff --git a/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManagerSupplier.java b/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManagerSupplier.java new file mode 100644 index 000000000..8a9dfe7b3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XModuleUIConfigurationManagerSupplier.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 ifc.ui; + +import com.sun.star.lang.XServiceInfo; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.ui.XModuleUIConfigurationManagerSupplier; +import lib.MultiMethodTest; + +public class _XModuleUIConfigurationManagerSupplier extends MultiMethodTest { + + public XModuleUIConfigurationManagerSupplier oObj; + + public void _getUIConfigurationManager() { + String configManagerName = null; + String implementationName = null; + try { + configManagerName = (String)tEnv.getObjRelation("XModuleUIConfigurationManagerSupplier.ConfigurationManager"); + implementationName = (String)tEnv.getObjRelation("XModuleUIConfigurationManagerSupplier.ConfigManagerImplementationName"); + + // get a config manager for the StartModule + Object o = oObj.getUIConfigurationManager(configManagerName); + XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, o); + String impName = xServiceInfo.getImplementationName(); + boolean result = impName.equals(implementationName); + if (!result) { + log.println("Returned implementation was '" + impName + + "' but should have been '" + implementationName + "'"); + } + tRes.tested("getUIConfigurationManager()", result); + return; + } + catch(com.sun.star.container.NoSuchElementException e) { + log.println("Could not get a configuration manager called '" + configManagerName + "'"); + e.printStackTrace(log); + } + tRes.tested("getUIConfigurationManager()", false); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/ui/_XUIConfiguration.java b/qadevOOo/tests/java/ifc/ui/_XUIConfiguration.java new file mode 100644 index 000000000..73290288c --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIConfiguration.java @@ -0,0 +1,94 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui; + +import com.sun.star.ui.XUIConfiguration; +import com.sun.star.ui.XUIConfigurationListener; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.ui.XUIConfiguration</code> +* interface methods : +* <ul> +* <li><code> addConfigurationListener()</code></li> +* <li><code> removeConfigurationListener()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* After test completion object environment has to be recreated. +* @see com.sun.star.ui.XUIConfiguration +*/ + +public class _XUIConfiguration extends MultiMethodTest { + + public XUIConfiguration oObj; + XUIConfigurationListenerImpl xListener = null; + + /** + * Interface for the Listener of the object relation + * <CODE>XUIConfiguration.XUIConfigurationListenerImpl</CODE> + * @see com.sun.star.ui.XUIConfigurationListener + */ + public interface XUIConfigurationListenerImpl + extends XUIConfigurationListener { + void reset(); + void fireEvent(); + boolean actionWasTriggered(); + } + + + /** + * try to get a listener out of the object relation + * <CODE>XUIConfiguration.XUIConfigurationListenerImpl</CODE> + */ + @Override + public void before() { + xListener = (XUIConfigurationListenerImpl)tEnv.getObjRelation( + "XUIConfiguration.XUIConfigurationListenerImpl"); + } + + /** + * adds a listener and fires an event + * Has <B>OK</B> status if listener was called + */ + public void _addConfigurationListener() { + oObj.addConfigurationListener(xListener); + xListener.fireEvent(); + tRes.tested("addConfigurationListener()", xListener.actionWasTriggered()); + } + + /** + * removes the listener and calls an event. + * Has <B>OK</B> status if listener is not called. + */ + public void _removeConfigurationListener() { + requiredMethod("addConfigurationListener()"); + oObj.removeConfigurationListener(xListener); + xListener.reset(); + xListener.fireEvent(); + tRes.tested("removeConfigurationListener()", !xListener.actionWasTriggered()); + } + + /** + * Dispose because the UIConfigurationManager has to be recreated + */ + @Override + public void after() { + disposeEnvironment(); + } +} diff --git a/qadevOOo/tests/java/ifc/ui/_XUIConfigurationListener.java b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationListener.java new file mode 100644 index 000000000..b1ef75528 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationListener.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 ifc.ui; + +import com.sun.star.ui.ConfigurationEvent; +import com.sun.star.ui.XUIConfigurationListener; +import lib.MultiMethodTest; + +public class _XUIConfigurationListener extends MultiMethodTest { + + public XUIConfigurationListener oObj = null; + + public void _elementInserted() { + ConfigurationEvent event = new ConfigurationEvent(); + oObj.elementInserted(event); + tRes.tested("elementInserted()", true); + } + public void _elementRemoved() { + ConfigurationEvent event = new ConfigurationEvent(); + oObj.elementRemoved(event); + tRes.tested("elementRemoved()", true); + } + public void _elementReplaced() { + ConfigurationEvent event = new ConfigurationEvent(); + oObj.elementReplaced(event); + tRes.tested("elementReplaced()", true); + } +} diff --git a/qadevOOo/tests/java/ifc/ui/_XUIConfigurationManager.java b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationManager.java new file mode 100644 index 000000000..83923634b --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationManager.java @@ -0,0 +1,354 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package ifc.ui; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexContainer; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; +import com.sun.star.ui.UIElementType; +import com.sun.star.ui.XImageManager; +import com.sun.star.ui.XUIConfigurationManager; +import java.io.PrintWriter; +import lib.MultiMethodTest; + +public class _XUIConfigurationManager extends MultiMethodTest { + + public XUIConfigurationManager oObj; + private static final String msResourceUrl = "private:resource/menubar/menubar"; + private static final String msMyResourceUrl = "private:resource/menubar/mymenubar"; + private XIndexContainer mxSettings = null; + private XIndexAccess mxMenuBarSettings = null; + private XMultiServiceFactory mxMSF = null; + private String sShortCutManagerServiceName = null; + + + /** + * Some stuff before the tests: + * extract the multi service factory. + */ + @Override + protected void before() { + mxMSF = tParam.getMSF(); + sShortCutManagerServiceName = (String)tEnv.getObjRelation("XConfigurationManager.ShortCutManager"); + + } + + /** + * reset all changes: do at the end. + */ + public void _reset() { + requiredMethod("removeSettings()"); + oObj.reset(); + tRes.tested("reset()", true); + } + + public void _getUIElementsInfo() { + boolean result = true; + try { + PropertyValue[][]props = oObj.getUIElementsInfo(UIElementType.UNKNOWN); + for (int i=0; i<props.length; i++) + for(int j=0; j<props[i].length; j++) + log.println("Prop["+i+"]["+j+"]: " + props[i][j].Name + " " + props[i][j].Value.toString()); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + tRes.tested("getUIElementsInfo()", result); + } + + public void _createSettings() { + mxSettings = oObj.createSettings(); + util.dbg.printInterfaces(mxSettings); + tRes.tested("createSettings()", mxSettings != null); + } + + public void _hasSettings() { + boolean result = false; + try { + result = oObj.hasSettings(msResourceUrl); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + log.println(e); + result = false; + } + tRes.tested("hasSettings()", result); + } + + public void _getSettings() { + requiredMethod("hasSettings()"); + boolean result = true; + try { + mxMenuBarSettings = oObj.getSettings(msResourceUrl, true); + for (int i=0; i<mxMenuBarSettings.getCount(); i++) { + Object[] o = (Object[])mxMenuBarSettings.getByIndex(i); + log.println("+++++++++ i = " + i); + for (int j=0; j<o.length; j++) { + PropertyValue prop = (PropertyValue)o[j]; + log.println("Property" + j + ": " + prop.Name + " " + prop.Value.toString()); + } + } + } + catch(com.sun.star.container.NoSuchElementException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + result = false; + e.printStackTrace(log); + } + tRes.tested("getSettings()", result); + } + + public void _replaceSettings() { + requiredMethod("getSettings()"); + boolean result = true; + PropertyValue[] prop = createMenuBarEntry("My Entry", mxMenuBarSettings, mxMSF, log); + if (prop == null) { + tRes.tested("replaceSettings()", false); + return; + } + + createMenuBarItem("Click for Macro", UnoRuntime.queryInterface( + XIndexContainer.class, prop[3].Value), log); + + XIndexContainer x = UnoRuntime.queryInterface(XIndexContainer.class, mxMenuBarSettings); + try { + x.insertByIndex(x.getCount(), prop); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + result = false; + e.printStackTrace(log); + } + + try { + oObj.replaceSettings(msResourceUrl, mxMenuBarSettings); + } + catch(com.sun.star.container.NoSuchElementException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalAccessException e) { + result = false; + e.printStackTrace(log); + } + _getSettings(); + tRes.tested("replaceSettings()", result); + } + + public void _removeSettings() { + requiredMethod("insertSettings()"); + boolean result = true; + try { + oObj.removeSettings(msMyResourceUrl); + } + catch(com.sun.star.container.NoSuchElementException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalAccessException e) { + e.printStackTrace(log); + result = false; + } + tRes.tested("removeSettings()", result); + } + + public void _insertSettings() { + requiredMethod("createSettings()"); + requiredMethod("replaceSettings()"); + boolean result = true; + util.dbg.printInterfaces(mxSettings); + PropertyValue[] prop = createMenuBarEntry("A new entry", mxSettings, mxMSF, log); + if (prop == null) { + tRes.tested("replaceSettings()", false); + return; + } + + createMenuBarItem("A new sub entry", UnoRuntime.queryInterface( + XIndexContainer.class, prop[3].Value), log); + + XIndexContainer x = UnoRuntime.queryInterface(XIndexContainer.class,mxSettings); + try { + int count = x.getCount(); + x.insertByIndex(count, prop); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + result = false; + e.printStackTrace(log); + } + + try { + oObj.insertSettings(msMyResourceUrl, mxSettings); + } + catch(com.sun.star.container.ElementExistException e) { + e.printStackTrace(log); + result = false; + } + catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + result = false; + } + catch(com.sun.star.lang.IllegalAccessException e) { + e.printStackTrace(log); + result = false; + } + tRes.tested("insertSettings()", result); + } + + /** + * Only a short test. + * See complex.imageManager.CheckImageManager for a more extensive test of + * this implementation. + */ + public void _getImageManager() { + Object o = oObj.getImageManager(); + log.println("###### ImageManager "); + XImageManager xImageManager = UnoRuntime.queryInterface(XImageManager.class, o); + tRes.tested("getImageManager()", xImageManager != null); + } + + + /** + * get a shortcut manager + */ + public void _getShortCutManager() { + Object o = oObj.getShortCutManager(); + XServiceInfo xSI = UnoRuntime.queryInterface(XServiceInfo.class,o); + String[] serviceNames = xSI.getSupportedServiceNames(); + boolean bSupportedServiceFound = false; + for (int i=0; i<serviceNames.length; i++) { + log.println("SuppService: " + serviceNames[i]); + if (serviceNames[i].equals(sShortCutManagerServiceName)) { + bSupportedServiceFound = true; + } + } + tRes.tested("getShortCutManager()", bSupportedServiceFound); + } + + public void _getEventsManager() { + Object o = oObj.getEventsManager(); + tRes.tested("getEventsManager()", o == null); + } + + /** + * Create a menu bar entry for adding to the menu bar of the Office. + * @param sLabelName The name of the new entry. + * @param xMenuBarSettings The existing menu bar settings, used for creating the new entry. + * @return An array of properties of the new entry. + */ + public static PropertyValue[] createMenuBarEntry(String sLabelName, XIndexAccess xMenuBarSettings, XMultiServiceFactory xMSF, PrintWriter log) { + PropertyValue[] prop = new PropertyValue[4]; + prop[0] = new PropertyValue(); + prop[0].Name = "CommandURL"; + prop[0].Value = "vnd.openoffice.org:MyMenu"; + prop[1] = new PropertyValue(); + prop[1].Name = "Label"; + prop[1].Value = sLabelName; + prop[2] = new PropertyValue(); + prop[2].Name = "Type"; + prop[2].Value = Short.valueOf((short)0); + prop[3] = new PropertyValue(); + prop[3].Name = "ItemDescriptorContainer"; + + XSingleComponentFactory xFactory = UnoRuntime.queryInterface( + XSingleComponentFactory.class, xMenuBarSettings); + try { + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xMSF); + XComponentContext xContext = UnoRuntime.queryInterface( + XComponentContext.class, xProp.getPropertyValue("DefaultContext")); + prop[3].Value = xFactory.createInstanceWithContext(xContext); + } + catch(com.sun.star.uno.Exception e) { + log.println("Could not create an instance for ItemDescriptorContainer property."); + e.printStackTrace(log); + return null; + } + return prop; + } + + /** + * Create a sub entry to the menu bar. + * @param sLabelName The name of the entry in the UI. + * @param xDescriptionContainer The parent entry in the menu bar where + * this entry is added. + */ + public static void createMenuBarItem(String sLabelName, XIndexContainer xDescriptionContainer, PrintWriter log) { + PropertyValue[]aMenuItem = new PropertyValue[3]; + // create a menu item + aMenuItem[0] = new PropertyValue(); + aMenuItem[0].Name = "CommandURL"; + aMenuItem[0].Value = "macro:///Standard.Module1.Test()"; + aMenuItem[1] = new PropertyValue(); + aMenuItem[1].Name = "Label"; + aMenuItem[1].Value = sLabelName; + aMenuItem[2] = new PropertyValue(); + aMenuItem[2].Name = "Type"; + aMenuItem[2].Value = Short.valueOf((short)0); + + try { + xDescriptionContainer.insertByIndex(0, aMenuItem); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + } + catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + } + } +} diff --git a/qadevOOo/tests/java/ifc/ui/_XUIConfigurationPersistence.java b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationPersistence.java new file mode 100644 index 000000000..a7a7b5c43 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationPersistence.java @@ -0,0 +1,75 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui; + +import com.sun.star.embed.XStorage; +import com.sun.star.ui.XUIConfigurationPersistence; +import lib.MultiMethodTest; + +public class _XUIConfigurationPersistence extends MultiMethodTest { + + public XUIConfigurationPersistence oObj; + private XStorage xStore = null; + + @Override + public void before() { + xStore = (XStorage)tEnv.getObjRelation("XUIConfigurationStorage.Storage"); + } + + public void _reload() { + try { + oObj.reload(); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + } + tRes.tested("reload()", true); + } + + public void _store() { + try { + oObj.store(); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(log); + } + tRes.tested("store()", true); + } + + public void _storeToStorage() { + boolean result = true; + try { + oObj.storeToStorage(xStore); + } + catch(com.sun.star.uno.Exception e) { + result = false; + e.printStackTrace(log); + } + tRes.tested("storeToStorage()", result); + } + + public void _isModified() { + tRes.tested("isModified()", !oObj.isModified()); + } + + public void _isReadOnly() { + tRes.tested("isReadOnly()", !oObj.isReadOnly()); + } + +} diff --git a/qadevOOo/tests/java/ifc/ui/_XUIConfigurationStorage.java b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationStorage.java new file mode 100644 index 000000000..1e40a0577 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIConfigurationStorage.java @@ -0,0 +1,68 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui; + +import com.sun.star.embed.XStorage; +import com.sun.star.ui.XUIConfigurationStorage; +import lib.MultiMethodTest; +/** +* Testing <code>com.sun.star.ui.XUIConfigurationStorage</code> +* interface methods : +* <ul> +* <li><code> setStorage()</code></li> +* <li><code> hasStorage()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XUIConfigurationStorage +*/ + +public class _XUIConfigurationStorage extends MultiMethodTest { + + public XUIConfigurationStorage oObj; + private XStorage xStore = null; + + @Override + public void before() { + xStore = (XStorage)tEnv.getObjRelation("XUIConfigurationStorage.Storage"); + } + + /** + * Set the object relation <code>XUIConfigurationStorage.Storage</code> + * as storage. + * Has <b>OK</b> status if no exception is thrown. + */ + public void _setStorage() { + if (!oObj.hasStorage()) + oObj.setStorage(xStore); + else + log.println("For initializing this object, the setStorage() method was already called at the object."); + tRes.tested("setStorage()", true); + } + + /** + * Queries object for a storage. + * Has <b>OK</b> status if <code>hasStorage</code> returns <code>OK</code> + */ + public void _hasStorage() { + requiredMethod("setStorage()"); + boolean has = oObj.hasStorage(); + tRes.tested("hasStorage()", has); + } + +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/ui/_XUIElementFactory.java b/qadevOOo/tests/java/ifc/ui/_XUIElementFactory.java new file mode 100644 index 000000000..1883c081d --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIElementFactory.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 ifc.ui; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.ui.XUIElement; +import com.sun.star.ui.XUIElementFactory; +import lib.MultiMethodTest; + +public class _XUIElementFactory extends MultiMethodTest { + + public XUIElementFactory oObj; + + public void _createUIElement() { + boolean result = true; + PropertyValue[] prop = new PropertyValue[0]; + try { + XUIElement element = oObj.createUIElement("private:resource/menubar/menubar", prop); + result = (element!= null); + } + catch(com.sun.star.container.NoSuchElementException e) { + result = false; + e.printStackTrace(log); + } + catch(com.sun.star.lang.IllegalArgumentException e) { + result = false; + e.printStackTrace(log); + } + tRes.tested("createUIElement()", result); + } +} diff --git a/qadevOOo/tests/java/ifc/ui/_XUIElementFactoryRegistration.java b/qadevOOo/tests/java/ifc/ui/_XUIElementFactoryRegistration.java new file mode 100644 index 000000000..e2540e49d --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/_XUIElementFactoryRegistration.java @@ -0,0 +1,72 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.ui.XUIElementFactory; +import com.sun.star.ui.XUIElementFactoryRegistration; +import lib.MultiMethodTest; + +public class _XUIElementFactoryRegistration extends MultiMethodTest { + + public XUIElementFactoryRegistration oObj; + + public void _registerFactory() { + boolean result = true; + try { + oObj.registerFactory("private:resource/menubar/menubar", "MyOwnMenubar", "", "com.sun.star.comp.framework.MenuBarFactory"); + } + catch(com.sun.star.container.ElementExistException e) { + result = false; + e.printStackTrace(log); + } + tRes.tested("registerFactory()", result); + } + + public void _getRegisteredFactories() { + requiredMethod("registerFactory()"); + PropertyValue[][]props = oObj.getRegisteredFactories(); + if (props == null) { + log.println("Null was returned as PropertyValue[][]"); + props = new PropertyValue[0][0]; + } + for(int i=0; i<props.length; i++) + for(int j=0; j<props[i].length; j++) + log.println("Factory: " + props[i][j].Name + " - " + props[i][j].Value); + tRes.tested("getRegisteredFactories()", props.length != 0); + } + + public void _getFactory() { + requiredMethod("registerFactory()"); + XUIElementFactory xFactory = oObj.getFactory("private:resource/menubar/menubar", ""); + tRes.tested("getFactory()", xFactory != null); + } + + public void _deregisterFactory() { + executeMethod("getRegisteredFactory()"); + executeMethod("getFactory()"); + try { + oObj.deregisterFactory("private:resource/menubar/menubar", "MyOwnMenubar", ""); + } + catch(com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + } + tRes.tested("deregisterFactory()", true); + } +} diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_FilePicker.java b/qadevOOo/tests/java/ifc/ui/dialogs/_FilePicker.java new file mode 100644 index 000000000..32f8c1f16 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_FilePicker.java @@ -0,0 +1,27 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiPropertyTest; + +public class _FilePicker extends MultiPropertyTest { + + +} // EOF Calendar + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java new file mode 100644 index 000000000..e290ab4d9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java @@ -0,0 +1,133 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.ui.dialogs.XControlAccess; +import com.sun.star.ui.dialogs.XControlInformation; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.ui.XFilePicker</code> +* interface methods : +* <ul> +* <li><code> setControlProperty()</code></li> +* <li><code> getControlProperty()</code></li> +* </ul> <p> +* +* For testing this interface the component must implement +* <code>com.sun.star.ui.dialogs.XControlInformation</code> +* interface. <p> +* +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XFolderPicker +*/ +public class _XControlAccess extends MultiMethodTest { + + public XControlAccess oObj = null; + private String[] supControls = null ; + private String[][] supProperties = null ; + + /** + * Tries to query <code>com.sun.star.ui.dialogs.XControlInformation</code> + * interface, and obtain properties' names of each available + * control. <p> + * + * @throw StatusException if interface is not supported or + * properties couldn't be get. + */ + @Override + protected void before() { + XControlInformation xCI = UnoRuntime.queryInterface + (XControlInformation.class, oObj); + + if (xCI == null) throw new StatusException + (Status.failed("XControlInformation not supported")) ; + + supControls = xCI.getSupportedControls(); + supProperties = new String[supControls.length][]; + for (int i = 0; i < supControls.length; i++) { + try { + supProperties[i] = + xCI.getSupportedControlProperties(supControls[i]); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + throw new StatusException + ("Exception while init.", e) ; + } + } + } + + /** + * Tries to change each property of each control. + * Has <b>OK</b> status if values are properly changed. + */ + public void _setControlProperty() { + boolean result = true ; + String error = ""; + + for (int i = 0; i < supControls.length; i++) { + log.println("Checking properties for control " + supControls[i]); + for (int j = 0; j < supProperties[i].length; j++) { + log.println("\t" + supProperties[i][j]); + try { + Object oldVal = oObj.getControlProperty(supControls[i], + supProperties[i][j]); + Object newVal = util.ValueChanger.changePValue(oldVal); + if (supProperties[i][j].startsWith("Help")) { + newVal = "HID:133"; + } + oObj.setControlProperty + (supControls[i], supProperties[i][j], newVal) ; + Object resVal = oObj.getControlProperty(supControls[i], + supProperties[i][j]); + log.println("\t Old:" + oldVal + ",New:" + newVal + + ",Result:" + resVal); + if (!util.ValueComparer.equalValue(newVal, resVal)) { + error += "####Property '"+supProperties[i][j]+ + " of "+supControls[i]+" didn't work\n\r"+ + "\t Old:" + oldVal + ",New:" + newVal + + ",Result:" + resVal+ "\n\r"; + } + result &= util.ValueComparer.equalValue(newVal, resVal); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception:" ); + e.printStackTrace(log); + result = false ; + } + } + } + + log.println(error); + + tRes.tested("setControlProperty()", result) ; + tRes.tested("getControlProperty()", result) ; + } + + /** + * Does nothing. Testing performed in <code>setControlProperty</code> + * method test. + */ + public void _getControlProperty() {} +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XControlInformation.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlInformation.java new file mode 100644 index 000000000..1da743110 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XControlInformation.java @@ -0,0 +1,178 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.ui.dialogs.XControlInformation; + +/** +* Testing <code>com.sun.star.ui.XControlInformation</code> +* interface methods : +* <ul> +* <li><code> getSupportedControls()</code></li> +* <li><code> isControlSupported()</code></li> +* <li><code> getSupportedControlProperties()</code></li> +* <li><code> isControlPropertySupported()</code></li> +* </ul> <p> +* +* @see com.sun.star.ui.XFolderPicker +*/ +public class _XControlInformation extends MultiMethodTest { + + public XControlInformation oObj = null; + private String[] supControls = null ; + private String[][] supProperties = null ; + + /** + * Gets supported controls and stores them. <p> + * Has <b>OK</b> status if not <code>null</code> returned. + */ + public void _getSupportedControls() { + supControls = oObj.getSupportedControls(); + + tRes.tested("getSupportedControls()", supControls != null) ; + } + + /** + * For every available control check if it is supported. + * Also wrong control name (non-existent and empty) are checked.<p> + * + * Has <b>OK</b> status if <code>true</code> returned for valid + * control names and <code>false</code> for invalid.<p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSupportedControls </code> to have + * valid control names</li> + * </ul> + */ + public void _isControlSupported() { + requiredMethod("getSupportedControls()") ; + + boolean result = true ; + + log.println("Supported controls :"); + for (int i = 0; i < supControls.length; i++) { + log.println(" " + supControls[i]); + result &= oObj.isControlSupported(supControls[i]) ; + } + + result &= !oObj.isControlSupported("SuchNameMustNotExist"); + result &= !oObj.isControlSupported(""); + + tRes.tested("isControlSupported()", result) ; + } + + /** + * For each control obtains its properties and stores them. Then tries to + * obtain properties for control with invalid name. <p> + * + * Has <b>OK</b> status if properties arrays are not null and exception + * thrown or null returned for control with invalid name <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSupportedControls </code> to have + * valid control names</li> + * </ul> + */ + public void _getSupportedControlProperties() { + requiredMethod("getSupportedControls()") ; + + supProperties = new String[supControls.length][]; + for (int i = 0; i < supControls.length; i++) { + log.println("Getting properties for control: " + supControls[i]); + try { + supProperties[i] = + oObj.getSupportedControlProperties(supControls[i]); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception:" + e); + } + } + + try { + oObj.getSupportedControlProperties("NoSuchControl"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception getting properties " + + "for wrong control:" + e); + } + + tRes.tested("getSupportedControlProperties()", true) ; + } + + /** + * <ul> + * <li>For each property of each control checks if it is supported.</li> + * <li>For each control checks if non-existent property + * (with wrong name and with empty name) supported.</li> + * <li>Tries to check the property of non-existent control </li> + * </ul> + * <p> + * Has <b>OK</b> status if <code>true</code> returned for the first case, + * <code>false</code> for the second, and <code>false</code> or exception + * for the third.<p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSupportedControlProperties </code> to have a set of + * valid properties </li> + * </ul> + */ + public void _isControlPropertySupported() { + requiredMethod("getSupportedControlProperties()") ; + + boolean result = true; + + for (int i = 0; i < supControls.length; i++) { + log.println("Checking properties for control " + supControls[i]); + for (int j = 0; j < supProperties[i].length; j++) { + log.println(" " + supProperties[i][j]); + try { + result &= oObj.isControlPropertySupported + (supControls[i], supProperties[i][j]) ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Unexpected exception:" + e); + result = false ; + } + } + + try { + result &= !oObj.isControlPropertySupported + (supControls[i], "NoSuchPropertyForThisControl") ; + result &= !oObj.isControlPropertySupported + (supControls[i], "") ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println + ("Unexpected exception (just false must be returned):" + e); + result = false ; + } + } + + try { + result &= !oObj.isControlPropertySupported("NoSuchControl", "") ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception: " + e); + } + + tRes.tested("isControlPropertySupported()", result) ; + } +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XExecutableDialog.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XExecutableDialog.java new file mode 100644 index 000000000..eddf139c6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XExecutableDialog.java @@ -0,0 +1,176 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.ui.dialogs.XExecutableDialog; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCancellable; + +/** + * Testing <code>com.sun.star.ui.dialogs.XExecutableDialog</code> + * interface methods : + * <ul> + * <li><code> setTitle()</code></li> + * <li><code> execute()</code></li> + * </ul> <p> + * + * These interface methods can't be checked, thereby methods + * are just called. <code>execute</code> method is not called + * at all as the dialog shown can't be disposed. <p> + * + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.ui.dialogs.XExecutableDialog + */ +public class _XExecutableDialog extends MultiMethodTest { + + public XExecutableDialog oObj = null; + private ExecThread eThread = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method successfully returns + * and no exceptions were thrown. <p> + */ + public void _setTitle() { + oObj.setTitle("The Title"); + tRes.tested("setTitle()",true); + } + + /** + * This method is excluded from automated test since + * we can't close the dialog. <p> + * Always has <b>OK</b> status. + */ + public void _execute() { + String aName = tEnv.getTestCase().getObjectName(); + boolean result = false; + if (aName.startsWith("OData") || aName.startsWith("OSQL")) { + log.println("dbaccess dialogs can't be closed via API"); + log.println("therefore they aren't executed"); + log.println("and the result is set to true"); + result = true; + } else { + eThread = new ExecThread(oObj); + log.println("Starting Dialog"); + eThread.start(); + XCancellable canc = UnoRuntime.queryInterface + (XCancellable.class, tEnv.getTestObject()); + waitForEventIdle(); + if (canc != null) { + closeDialog(); + short res = eThread.execRes; + log.println("result: "+res); + result = (res == 0); + } else { + this.disposeEnvironment(); + result=true; + log.println("XCancellable isn't supported and the "+ + "environment is killed hard"); + } + + + } + tRes.tested("execute()",result); + } + + /** + * Calls <code>execute()</code> method in a separate thread. + * Necessary to check if this method works + */ + protected class ExecThread extends Thread { + + public short execRes = (short) 17; + private final XExecutableDialog Diag; + + public ExecThread(XExecutableDialog Diag) { + this.Diag = Diag ; + } + + @Override + public void run() { + try { + execRes = Diag.execute(); + System.out.println("HERE: "+execRes); + } catch(Exception e) { + log.println("Thread has been interrupted ... "); + } + } + } + + @Override + public void after() { + if (eThread.isAlive()) { + log.println("Thread didn't die ... cleaning up"); + disposeEnvironment(); + } + } + + private void closeDialog() { + XCancellable canc = UnoRuntime.queryInterface( + XCancellable.class, tEnv.getTestObject()); + if (canc != null) { + log.println("Cancelling Dialog"); + canc.cancel(); + } else { + this.disposeEnvironment(); + } + + long st = System.currentTimeMillis(); + boolean toLong = false; + + log.println("waiting for dialog to close"); + + while (eThread.isAlive() && !toLong) { + //wait for dialog to close + toLong = (System.currentTimeMillis()-st > 10000); + } + + log.println("done"); + + try { + if (eThread.isAlive()) { + log.println("Interrupting Thread"); + eThread.interrupt(); + Thread.yield(); + } + } catch (Exception e) { + // who cares ;-) + } + + st = System.currentTimeMillis(); + toLong = false; + + log.println("waiting for interruption to work"); + + while (eThread.isAlive() && !toLong) { + //wait for dialog to close + toLong = (System.currentTimeMillis()-st > 10000); + } + + log.println("DialogThread alive: "+eThread.isAlive()); + + log.println("done"); + + } + +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePicker.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePicker.java new file mode 100644 index 000000000..3a2a71ec9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePicker.java @@ -0,0 +1,151 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.ui.dialogs.XFilePicker2; + +/** +* Testing <code>com.sun.star.ui.XFilePicker</code> +* interface methods : +* <ul> +* <li><code> setMultiSelectionMode()</code></li> +* <li><code> setDefaultName()</code></li> +* <li><code> setDisplayDirectory()</code></li> +* <li><code> getDisplayDirectory()</code></li> +* <li><code> getPath()</code></li> +* </ul> <p> +* The following predefined files needed to complete the test: +* <ul> +* <li> <code>'space-metal.jpg'</code> : just to exist. </li> +* <ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XFolderPicker +*/ +public class _XFilePicker extends MultiMethodTest { + + public XFilePicker2 oObj = null; + private String dir = null ; + private static final String fname = "space-metal.jpg" ; + + /** + * Sets the current directory to the test document directory. <p> + * Has <b>OK</b> status if no exceptions occurred. + */ + public void _setDisplayDirectory() { + boolean result = true ; + dir = util.utils.getFullTestURL("") ; + + log.println("Trying to set dir '" + dir + "'") ; + try { + oObj.setDisplayDirectory(dir) ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Directory '" + dir + "' not found :" + e) ; + result = false ; + } + + tRes.tested("setDisplayDirectory()", result) ; + } + + /** + * Gets the current directory. <p> + * Has <b>OK</b> status if get value is equal to set value + * passed to <code>setDisplayDirectory</code> <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setDisplayDirectory </code> </li> + * </ul> + */ + public void _getDisplayDirectory() { + requiredMethod("setDisplayDirectory()") ; + + String gDir = oObj.getDisplayDirectory() ; + + log.println("Get dir '" + gDir + "'") ; + + tRes.tested("getDisplayDirectory()", dir.equals(gDir)) ; + } + + /** + * Sets default name to file name existing in test document + * directory ('space-metal.jpg'). <p> + * Has <b>OK</b> status if no exceptions occurred. + */ + public void _setDefaultName() { + boolean result = true ; + + try { + oObj.setDefaultName(fname) ; + } catch (Exception e) { + log.println("Exception setting default name :" + e) ; + result = false ; + } + + tRes.tested("setDefaultName()", result) ; + } + + /** + * Just switch object to MultiSelectionMode. There is no ways + * to check this method (only interactively). <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _setMultiSelectionMode() { + + oObj.setMultiSelectionMode(true) ; + + tRes.tested("setMultiSelectionMode()", true) ; + } + + /** + * Gets completed path from dialog. If <code>execute()</code> + * method was not called then zero length array is returned. + * So to check actual functionality of this method interactive + * testing is required. <p> + * Has <b>OK</b> status if zero length array returned (this + * occurs if <code>execute()</code> + * method was not called yet) or if array contains at least one + * element and it equals to <code>[Directory set] + + * [Default file name set]</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setDisplayDirectory </code> </li> + * <li> <code> setDefaultName </code> </li> + * </ul> + */ + public void _getFiles() { + requiredMethod("setDisplayDirectory()"); + requiredMethod("setDefaultName()"); + + String[] files = oObj.getSelectedFiles(); + + if (files.length > 0) { + log.println("Path get : '" + files[0] + "'") ; + + tRes.tested("getFiles()", (dir + fname).equals(files[0])) ; + } else { + log.println("No files were selected or execute() method was not called.") ; + + tRes.tested("getFiles()", true); + } + } + +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerControlAccess.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerControlAccess.java new file mode 100644 index 000000000..d559716a0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerControlAccess.java @@ -0,0 +1,194 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.ValueChanger; +import util.ValueComparer; + +import com.sun.star.ui.dialogs.XFilePickerControlAccess; + +/** +* Testing <code>com.sun.star.ui.XFilePickerControlAccess</code> +* interface methods : +* <ul> +* <li><code> setValue()</code></li> +* <li><code> getValue()</code></li> +* <li><code> setLabel()</code></li> +* <li><code> getLabel()</code></li> +* <li><code> getFocused()</code></li> +* <li><code> enableControl()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'XFilePickerControlAccess.ControlID'</code> (of type +* <code>Short</code>) : control identifier in the extended +* FilePicker dialog. </li> +* <li> <code>'XFilePickerControlAccess.ControlValue'</code> (of type +* <code>Object</code>) <b>optional</b> (but mostly desirable +* since the control has empty initial value): +* the value which can set for the control . </li> +* <ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XFilePickerControlAccess +*/ +public class _XFilePickerControlAccess extends MultiMethodTest { + + public XFilePickerControlAccess oObj = null; + private short cntlID = -1 ; + private Object oldVal = null ; + private String oldLab = null ; + + /** + * Retrieves object relations. + * @throws StatusException If one of relations not found. + */ + @Override + public void before() { + Short ID = (Short) tEnv.getObjRelation + ("XFilePickerControlAccess.ControlID") ; + if (ID == null) { + log.println("!!! Relation not found !!!") ; + throw new StatusException(Status.failed("Relation not found")) ; + } + + cntlID = ID.shortValue() ; + } + + /** + * Gets the value of the control and stores it. <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _getValue() { + boolean result = true ; + + try { + oldVal = oObj.getValue(cntlID,(short)0); + } catch (Exception e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("getValue()", result) ; + } + + /** + * Changes the value gotten by <code>getValue</code> method, + * or gets the value from relation if it exits. + * Sets this value and then check if it was properly set. <p> + * Has <b>OK</b> status if <code>getValue</code> method returns + * the same value which was set. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getValue </code> </li> + * </ul> + */ + public void _setValue() { + requiredMethod("getValue()") ; + boolean result = true ; + + Object newVal = tEnv.getObjRelation + ("XFilePickerControlAccess.ControlValue"); + if (newVal == null) { + newVal = ValueChanger.changePValue(oldVal) ; + } + + Object getVal = null ; + + try { + oObj.setValue(cntlID, (short)0 , newVal) ; + getVal = oObj.getValue(cntlID,(short)0) ; + } catch (Exception e) { + e.printStackTrace(log) ; + result = false ; + } + + result &= ValueComparer.equalValue(newVal, getVal) ; + + tRes.tested("setValue()", result) ; + } + + /** + * Gets the label of the control and stores it. <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _getLabel() { + + try { + oldLab = oObj.getLabel(cntlID); + } catch (Exception e) { + e.printStackTrace(log) ; + } + + tRes.tested("getLabel()", oldLab != null) ; + } + + /** + * Changes the label gotten by <code>getLabel</code> method, + * set this label and then check if it was properly set. <p> + * Has <b>OK</b> status if <code>getLabel</code> method returns + * the same value which was set. <p> + * The following method tests are to be completed successfully before: + * <ul> + * <li> <code> getLabel </code> </li> + * </ul> + */ + public void _setLabel() { + requiredMethod("getLabel()") ; + boolean result = true ; + + String newVal = oldLab + "_" ; + String getVal = null ; + + try { + oObj.setLabel(cntlID, newVal) ; + getVal = oObj.getLabel(cntlID) ; + } catch (Exception e) { + e.printStackTrace(log) ; + result = false ; + } + + result &= newVal.equals(getVal) ; + + tRes.tested("setLabel()", result) ; + } + + /** + * Disables and then enables the control. Can be checked only + * interactively. <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _enableControl() { + boolean result = true ; + + try { + oObj.enableControl(cntlID, false) ; + oObj.enableControl(cntlID, true) ; + } catch (Exception e) { + e.printStackTrace(log) ; + result = false ; + } + + tRes.tested("enableControl()", result) ; + } +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerNotifier.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerNotifier.java new file mode 100644 index 000000000..54858bfcf --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePickerNotifier.java @@ -0,0 +1,270 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.lang.EventObject; +import com.sun.star.ui.dialogs.FilePickerEvent; +import com.sun.star.ui.dialogs.XExecutableDialog; +import com.sun.star.ui.dialogs.XFilePicker; +import com.sun.star.ui.dialogs.XFilePickerListener; +import com.sun.star.ui.dialogs.XFilePickerNotifier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XCancellable; + + +/** + * Testing <code>com.sun.star.ui.XFilePickerNotifier</code> + * interface methods : + * <ul> + * <li><code> addFilePickerListener()</code></li> + * <li><code> removeFilePickerListener()</code></li> + * </ul> <p> + * The object must implement <code>XFilePicker</code> + * interface to check if a listener was called. <p> + * Test is <b> NOT </b> multithread compliant. <p> + * @see com.sun.star.ui.XFilePickerNotifier + */ +public class _XFilePickerNotifier extends MultiMethodTest { + + public XFilePickerNotifier oObj = null; + private XFilePicker fps = null ; + private String dir1 = null, + dir2 = null ; + ExecThread eThread = null; + + + /** + * Listener implementation which sets a flag if some of its + * methods was called. + */ + protected class TestListener implements XFilePickerListener { + public boolean called = false ; + + public void dialogSizeChanged() { + called = true; + } + + public void fileSelectionChanged(FilePickerEvent e) { + called = true; + } + + public void directoryChanged(FilePickerEvent e) { + log.println("***** Directory Changed *****"); + called = true; + } + + public String helpRequested(FilePickerEvent e) { + called = true; + return "help"; + } + + public void controlStateChanged(FilePickerEvent e) { + called = true; + } + + public void disposing(EventObject e) {} + } + + TestListener listener = new TestListener() ; + + /** + * Tries to query object for <code>XFilePicker</code> interface, and + * initializes two different URLs for changing file picker directory. <p> + * @throw StatusException If object doesn't support <code>XFilePicker</code> + * interface. + */ + @Override + public void before() { + fps = UnoRuntime.queryInterface + (XFilePicker.class, oObj) ; + + if (fps == null) { + log.println("The object doesn't implement XFilePicker") ; + throw new StatusException(Status.failed + ("The object doesn't implement XFilePicker")); + } + + XExecutableDialog exD = UnoRuntime.queryInterface( + XExecutableDialog.class, tEnv.getTestObject()); + + dir1 = util.utils.getOfficeTemp(tParam.getMSF()); + dir2 = util.utils.getFullTestURL(""); + eThread = new ExecThread(exD); + } + + /** + * Adds a listener, then tries to change display directory and + * checks if the listener was called. <p> + * Has <b>OK</b> status if a listener method was called. + */ + public void _addFilePickerListener() { + oObj.addFilePickerListener(listener) ; + + try { + log.println("***** Setting DisplayDirectory to " + dir1); + fps.setDisplayDirectory(dir1) ; + log.println("***** Getting: " + fps.getDisplayDirectory()); + openDialog(); + log.println("***** Setting DisplayDirectory to " + dir2); + fps.setDisplayDirectory(dir2) ; + log.println("***** Getting: " + fps.getDisplayDirectory()); + + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("!!! Exception changing dir !!!") ; + e.printStackTrace(log) ; + } + + waitForEventIdle(); + + if (!listener.called) { + log.println("Listener wasn't called :-("); + } + + closeDialog(); + + tRes.tested("addFilePickerListener()", listener.called) ; + } + + /** + * Removes the listener and changes display directory. <p> + * Has <b>OK</b> status if the listener wasn't called. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addFilePickerListener </code> </li> + * </ul> + */ + public void _removeFilePickerListener() { + requiredMethod("addFilePickerListener()") ; + + oObj.removeFilePickerListener(listener) ; + + listener.called = false ; + + try { + fps.setDisplayDirectory(dir1) ; + openDialog(); + fps.setDisplayDirectory(dir2) ; + } catch(com.sun.star.lang.IllegalArgumentException e) { + log.println("!!! Exception changing dir !!!") ; + e.printStackTrace(log) ; + } + + waitForEventIdle(); + + closeDialog(); + + tRes.tested("removeFilePickerListener()", !listener.called) ; + } + + /** + * Calls <code>execute()</code> method in a separate thread. + * Necessary to check if this method works + */ + protected class ExecThread extends Thread { + + public short execRes = (short) 17 ; + private final XExecutableDialog Diag; + + public ExecThread(XExecutableDialog Diag) { + this.Diag = Diag ; + } + + @Override + public void run() { + try { + execRes = Diag.execute(); + System.out.println("HERE: "+execRes); + } catch (Exception e) { + log.println("Thread has been interrupted ..."); + } + } + } + + private void closeDialog() { + XCancellable canc = UnoRuntime.queryInterface( + XCancellable.class, tEnv.getTestObject()); + if (canc != null) { + log.println("Cancelling Dialog"); + canc.cancel(); + } else { + this.disposeEnvironment(); + } + + long st = System.currentTimeMillis(); + boolean toLong = false; + + log.println("waiting for dialog to close"); + + while (eThread.isAlive() && !toLong) { + //wait for dialog to close + toLong = (System.currentTimeMillis()-st > 10000); + } + + log.println("done"); + + try { + if (eThread.isAlive()) { + log.println("Interrupting Thread"); + eThread.interrupt(); + Thread.yield(); + } + } catch (Exception e) { + // who cares ;-) + } + + st = System.currentTimeMillis(); + toLong = false; + + log.println("waiting for interruption to work"); + + while (eThread.isAlive() && !toLong) { + //wait for dialog to close + toLong = (System.currentTimeMillis()-st > 10000); + } + + log.println("DialogThread alive: "+eThread.isAlive()); + + log.println("done"); + + } + + private void openDialog() { + log.println("Starting Dialog"); + if (eThread.isAlive()) { + log.println("second interrupt"); + eThread.interrupt(); + Thread.yield(); + } + + XExecutableDialog exD = UnoRuntime.queryInterface( + XExecutableDialog.class, tEnv.getTestObject()); + + dir1 = util.utils.getOfficeTemp(tParam.getMSF()); + dir2 = util.utils.getFullTestURL(""); + eThread = new ExecThread(exD); + + eThread.start(); + } +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePreview.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePreview.java new file mode 100644 index 000000000..9ba9c7825 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilePreview.java @@ -0,0 +1,113 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.ui.dialogs.XFilePreview; + +public class _XFilePreview extends MultiMethodTest { + + public XFilePreview oObj=null; + + /** + * _getSupportedImageFormats() gets all formats and + * stores them in an Array of short.<br> + * Is OK is the resulting Array isn't empty + */ + public void _getSupportedImageFormats() { + short[] formats = oObj.getSupportedImageFormats(); + tRes.tested("getSupportedImageFormats()", formats.length > 0); + } + + /** + * _getTargetColorDepth() gets the color depth + * and stores it in an int.<br> + * Is OK is the resulting int isn't 1 + */ + public void _getTargetColorDepth() { + int CDepth = oObj.getTargetColorDepth(); + tRes.tested("getTargetColorDepth()",CDepth != 1); + } + + /** + * _getAvailableWidth() gets the width + * and stores it in an int.<br> + * Is OK is the resulting int isn't 1 + */ + public void _getAvailableWidth() { + int the_width = oObj.getAvailableWidth(); + tRes.tested("getAvailableWidth()", the_width != 1); + } + + /** + * _getAvailableHeight() gets the width + * and stores it in an int.<br> + * Is OK is the resulting int isn't 1 + */ + public void _getAvailableHeight() { + int the_height = oObj.getAvailableHeight(); + tRes.tested("getAvailableHeight()", the_height != 1); + } + + /** + * sets the empty image. + * Is OK if no exception no exceptions were thrown. + */ + public void _setImage() { + boolean bOK = true; + try { + oObj.setImage + (com.sun.star.ui.dialogs.FilePreviewImageFormats.BITMAP,null); + } catch(com.sun.star.lang.IllegalArgumentException e) { + bOK = false; + throw new StatusException( "Can't set empty image", e ); + } + tRes.tested("setImage()", bOK); + } + + boolean prev_state; + + /** + * _setShowState() sets the state + * to the opposite value returned by getShowState.<br> + * Is OK is the returned result is false or if + * the value that was set is equal to the value + * that was returned by getShowState. + */ + public void _setShowState() { + requiredMethod("getShowState()"); + boolean success = oObj.setShowState(!prev_state); + boolean res_state = oObj.getShowState(); + tRes.tested("setShowState()", !success || res_state != prev_state); + } + + /** + * _getShowState() gets the state + * and sets it to the opposite.<br> + * Is OK if no exceptions were thrown + */ + public void _getShowState() { + prev_state = oObj.getShowState(); + tRes.tested("getShowState()", true); + } + +} + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterGroupManager.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterGroupManager.java new file mode 100644 index 000000000..cd47c96c3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterGroupManager.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 ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.beans.StringPair; +import com.sun.star.ui.dialogs.XFilterGroupManager; + +/** +* Testing <code>com.sun.star.ui.dialogs.XFilterGroupManager</code> +* @see com.sun.star.ui.XFilterGroupManager +*/ +public class _XFilterGroupManager extends MultiMethodTest { + + public XFilterGroupManager oObj = null; + + /** + * Appends a new FilterGroup (for extension 'txt'). <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _appendFilterGroup() { + boolean res = true; + try { + StringPair[] args = new StringPair[1]; + args[0] = new StringPair(); + args[0].First = "ApiTextFiles"; + args[0].Second = "txt"; + oObj.appendFilterGroup("TestFilter", args); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + res=false; + } + + tRes.tested("appendFilterGroup()", res) ; + } + +} + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterManager.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterManager.java new file mode 100644 index 000000000..d9eb5a5b1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFilterManager.java @@ -0,0 +1,97 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +package ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.ui.dialogs.XFilterManager; + +/** +* Testing <code>com.sun.star.ui.XFilterManager</code> +* interface methods : +* <ul> +* <li><code> appendFilter()</code></li> +* <li><code> setCurrentFilter()</code></li> +* <li><code> getCurrentFilter()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XFilterManager +*/ +public class _XFilterManager extends MultiMethodTest { + + public XFilterManager oObj = null; + + /** + * Appends a new filter (for extension 'txt'). <p> + * Has <b>OK</b> status if no runtime exceptions occurred. + */ + public void _appendFilter() { + boolean res = true; + try { + oObj.appendFilter("TestFilter", "txt"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + res=false; + } + + tRes.tested("appendFilter()", res) ; + } + + /** + * Sets the current filter to that which was appended before.<p> + * Has <b>OK</b> status if no exceptions occurred, else one of + * <code>appendFilter</code> and <code>setCurrentFilter</code> + * methods failed. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> appendFilter </code> </li> + * </ul> + */ + public void _setCurrentFilter() { + requiredMethod("appendFilter()") ; + boolean result = true; + + try { + oObj.setCurrentFilter("TestFilter") ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("setCurrentFilter() or appendFilter() failed") ; + result = false ; + } + + tRes.tested("setCurrentFilter()", result) ; + } + + /** + * Gets current filter name and compares it filter name set before.<p> + * Has <b>OK</b> status if set and get filter names are equal.<p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setCurrentFilter </code> </li> + * </ul> + */ + public void _getCurrentFilter() { + requiredMethod("setCurrentFilter()") ; + + String gVal = oObj.getCurrentFilter() ; + + tRes.tested("getCurrentFilter()", "TestFilter".equals(gVal)) ; + } +} + + diff --git a/qadevOOo/tests/java/ifc/ui/dialogs/_XFolderPicker.java b/qadevOOo/tests/java/ifc/ui/dialogs/_XFolderPicker.java new file mode 100644 index 000000000..07c6e014f --- /dev/null +++ b/qadevOOo/tests/java/ifc/ui/dialogs/_XFolderPicker.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 ifc.ui.dialogs; + +import lib.MultiMethodTest; + +import com.sun.star.ui.dialogs.XFolderPicker; + +/** +* Testing <code>com.sun.star.ui.XFolderPicker</code> +* interface methods : +* <ul> +* <li><code> setDisplayDirectory()</code></li> +* <li><code> getDisplayDirectory()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compliant. <p> +* @see com.sun.star.ui.XFolderPicker +*/ +public class _XFolderPicker extends MultiMethodTest { + + public XFolderPicker oObj = null; + private String dir = null ; + + /** + * Sets the current directory to SOffice temp dir. <p> + * Has <b>OK</b> status if no exceptions occurred. + */ + public void _setDisplayDirectory() { + boolean result = true ; + dir = util.utils.getOfficeTemp(tParam.getMSF()) ; + + log.println("Trying to set dir '" + dir + "'") ; + try { + oObj.setDisplayDirectory(dir) ; + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Directory '" + dir + "' not found :" + e) ; + result = false ; + } + + tRes.tested("setDisplayDirectory()", result) ; + } + + /** + * Gets the current directory. <p> + * Has <b>OK</b> status if get value is equal to set value + * passed to <code>setDisplayDirectory</code> <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setDisplayDirectory </code> </li> + * </ul> + */ + public void _getDisplayDirectory() { + requiredMethod("setDisplayDirectory()") ; + + String gDir = oObj.getDisplayDirectory() ; + + log.println("Get dir '" + gDir + "'") ; + + tRes.tested("getDisplayDirectory()", dir.equals(gDir)) ; + } + + /** + * Gets the directory chosen by the user. <p> + * Has <b>OK</b> status if get value is not NULL <p> + */ + public void _getDirectory() { + + String gDir = oObj.getDirectory() ; + + log.println("Get dir '" + gDir + "'") ; + + tRes.tested("getDirectory()", gDir != null) ; + } + + /** + * Sets the Description for the dialog. <p> + * Has <b>OK</b> status if no error occurs <p> + */ + public void _setDescription() { + + oObj.setDescription("XFolderPicker") ; + //to visually check if the method works + //oObj.execute(); + tRes.tested("setDescription()", true) ; + } + +} + + |