/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
package ifc.beans;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import lib.MultiMethodTest;
import lib.Status;
import util.ValueChanger;
import com.sun.star.beans.Property;
import com.sun.star.beans.PropertyAttribute;
import com.sun.star.beans.PropertyChangeEvent;
import com.sun.star.beans.XMultiPropertySet;
import com.sun.star.beans.XPropertiesChangeListener;
import com.sun.star.beans.XPropertySetInfo;
import com.sun.star.lang.EventObject;
/**
* Testing com.sun.star.beans.XMultiPropertySet
* interface methods :
*
getPropertySetInfo()
setPropertyValues()
getPropertyValues()
addPropertiesChangeListener()
removePropertiesChangeListener()
firePropertiesChangeEvent()
* * Required relations : *
'XMultiPropertySet.ExcludeProps'
* (optional) : java.util.Set.
* Has property names which must be skipped from testing in
* some reasons (for example property accepts restricted set
* of values).
* * * Test is NOT multithread compilant.
* After test completion object environment has to be recreated.
* @see com.sun.star.beans.XMultiPropertySet
*/
public class _XMultiPropertySet extends MultiMethodTest {
public XMultiPropertySet oObj = null;
private boolean propertiesChanged = false;
private XPropertySetInfo propertySetInfo = null;
private String [] testPropsNames = null;
private int testPropsAmount = 0;
private PrintWriter _log = null;
private Object[] values = null;
private Set exclProps = null;
/**
* Initializes some fields.
*/
public void before() {
_log = log;
exclProps = (Set) tEnv.getObjRelation("XMultiPropertySet.ExcludeProps");
if (exclProps == null) exclProps = new HashSet(0);
}
/**
* Listener implementation which sets a flag when
* listener was called.
*/
public class MyChangeListener implements XPropertiesChangeListener {
public void propertiesChange(PropertyChangeEvent[] e) {
//_log.println("Listener was called");
propertiesChanged = true;
}
public void disposing (EventObject obj) {}
};
private XPropertiesChangeListener PClistener =
new MyChangeListener();
/**
* Test calls the method and checks return value.
* PropertySetInfo
object is stored
* Has OK status if the method returns not null value * and no exceptions were thrown.
*/ public void _getPropertySetInfo() { boolean bResult = true; propertySetInfo = oObj.getPropertySetInfo(); if (propertySetInfo == null) { log.println("getPropertySetInfo() method returned null"); bResult = false; } tRes.tested("getPropertySetInfo()", bResult) ; } /** * Test collects all property names and retrieves their values, * then checks the value returned. Finally it also collects * bound properties for other methods tests.
* Has OK status if the method returns non null value * and no exceptions were thrown.
* The following method tests are to be completed successfully before : *
getPropertySetInfo()
: to have a list
* of properties.* Has OK status if on each property change the listener was * called and no exceptions were thrown.
* The following method tests are to be completed successfully before : *
getPropertyValues()
: to collect bound
* properties.* The following method tests are to be completed successfully before : *
addPropertiesChangeListener()
: listener to
* be added.* Has OK status no exceptions were thrown.
* The following method tests are to be completed successfully before : *
addPropertiesChangeListener()
: listener to
* be added.* Has OK status if all properties properly changed * and no exceptions were thrown.
* The following method tests are to be completed successfully before : *
getPropertyValues()
: to collect bound
* properties.