/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* 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.beans;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Arrays;
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 compliant.
* 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 Object[] values = null;
private Set
* 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 :
*
* 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 :
*
* The following method tests are to be completed successfully before :
*
* Has OK status no exceptions were thrown.
* The following method tests are to be completed successfully before :
*
* Has OK status if all properties properly changed
* and no exceptions were thrown.
* The following method tests are to be completed successfully before :
* PropertySetInfo
object is stored
*
*/
public void _getPropertyValues() {
requiredMethod("getPropertySetInfo()");
boolean bResult = true;
Property[] properties = propertySetInfo.getProperties();
ArrayList getPropertySetInfo()
: to have a list
* of properties.
*
*/
public void _addPropertiesChangeListener() {
requiredMethod("getPropertyValues()");
// Creating listener
oObj.addPropertiesChangeListener(testPropsNames, PClistener);
if ((testPropsAmount==1) && (testPropsNames[0].equals("none"))) {
testPropsAmount = 0;
}
if (testPropsAmount == 0) {
log.println("all properties are read only");
tRes.tested("addPropertiesChangeListener()", Status.skipped(true));
return;
}
// Change one of the property to be sure that this event was caught.
for (int i=0; i getPropertyValues()
: to collect bound
* properties.
*
*/
public void _firePropertiesChangeEvent() {
requiredMethod("addPropertiesChangeListener()");
propertiesChanged = false ;
oObj.firePropertiesChangeEvent(testPropsNames, PClistener);
waitForEventIdle();
tRes.tested("firePropertiesChangeEvent()", propertiesChanged);
}
/**
* Removes listener added before. addPropertiesChangeListener()
: listener to
* be added.
*
*/
public void _removePropertiesChangeListener() {
requiredMethod("firePropertiesChangeEvent()");
boolean bResult = true;
oObj.removePropertiesChangeListener(PClistener);
tRes.tested("removePropertiesChangeListener()", bResult);
}
/**
* Changes all properties, then set them to new values, get them
* and checks if their values were changed properly. addPropertiesChangeListener()
: listener to
* be added.
*
*/
public void _setPropertyValues() {
requiredMethod("getPropertyValues()");
boolean bResult = true;
if ((testPropsNames.length==1)&&(testPropsNames[0].equals("none"))) {
log.println("all properties are readOnly");
tRes.tested("setPropertyValues()",Status.skipped(true));
return;
}
log.println("Changing all properties");
Object[] gValues = oObj.getPropertyValues(testPropsNames);
for (int i=0; i getPropertyValues()
: to collect bound
* properties.