From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../tests/java/ifc/ui/dialogs/_XControlAccess.java | 133 +++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java (limited to 'qadevOOo/tests/java/ifc/ui/dialogs/_XControlAccess.java') 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 com.sun.star.ui.XFilePicker +* interface methods : +*

+* +* For testing this interface the component must implement +* com.sun.star.ui.dialogs.XControlInformation +* interface.

+* +* Test is NOT multithread compliant.

+* @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 com.sun.star.ui.dialogs.XControlInformation + * interface, and obtain properties' names of each available + * control.

+ * + * @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 OK 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 setControlProperty + * method test. + */ + public void _getControlProperty() {} +} + + -- cgit v1.2.3