diff options
Diffstat (limited to 'qadevOOo/tests/basic/ifc/beans')
18 files changed, 1424 insertions, 0 deletions
diff --git a/qadevOOo/tests/basic/ifc/beans/XExactName/beans_XExactName.xba b/qadevOOo/tests/basic/ifc/beans/XExactName/beans_XExactName.xba new file mode 100644 index 000000000000..d22b00f4efaa --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XExactName/beans_XExactName.xba @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="XExactName" script:language="StarBasic"> + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + +'************************************************************************* +' This Interface/Service test depends on the following object relations +' variables, which must be specified in the object creation: + +' ObjectRelation: oObjRelation(0).Name = "expectedName" +' ObjectRelation: oObjRelation(0).Value = "MyExpectedName" + +'************************************************************************* + +' Be sure that all variables are dimensioned: +option explicit + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XExactName +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + + Dim cExpectedName as Variant + cExpectedName = utils.getObjectRelation("expectedName") + if isNull(cExpectedName) then + out.log("Object relation 'expectedName' is missing") + end if + + Test.StartMethod("getExactName()") + + out.log("getting exact name for " + cExpectedName) + bOK = TRUE + Dim cResult as String + cResult = oObj.getExactName(cExpectedName) + bOK = bOK AND (cResult = cExpectedName) + + out.log("getting exact name for " + LCase(cExpectedName)) + bOK = TRUE + cResult = oObj.getExactName(LCase(cExpectedName)) + bOK = bOK AND (cResult = cExpectedName) + + out.log("getting exact name for " + UCase(cExpectedName)) + bOK = TRUE + cResult = oObj.getExactName(UCase(cExpectedName)) + bOK = bOK AND (cResult = cExpectedName) + + Test.MethodTested("getExactName()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XExactName/script.xlb b/qadevOOo/tests/basic/ifc/beans/XExactName/script.xlb new file mode 100644 index 000000000000..bd759a0334b8 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XExactName/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> + <library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XExactName" library:readonly="false" library:passwordprotected="false"> + <library:element library:name="beans_XExactName"/> + </library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/beans_XFastPropertySet.xba b/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/beans_XFastPropertySet.xba new file mode 100644 index 000000000000..8961bec8d24c --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/beans_XFastPropertySet.xba @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XFastPropertySet" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XFastPropertySet +'************************************************************************* +On Error Goto ErrHndl + + Dim bOK As Boolean + Dim oPropertySetInfo As Object + Dim oProperties As Variant + Dim nIndex As Long, nHanlde As Long + Dim nCount As Integer + Dim vMemVal As Variant, vNewVal As Variant + Dim bBoolean As Boolean + Dim nInteger As Integer + Dim nLong As Long + Dim nSingle As Single + Dim nDouble As Double + + oPropertySetInfo = oObj.GetPropertySetInfo() + oProperties = oPropertySetInfo.Properties + nCount = uBound(oProperties) + + nIndex = 0 + nMem = nIndex + 'find at first a Boolean Value, if not available a String Property + While (NOT bFound) AND (nCount >= nIndex) + If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 11 Then ' it is a Boolean Proerty + bFound = true + nMem = nIndex + else + If VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle)) = 8 Then ' it is a String Property + nMem = nIndex + end if + end if + nIndex = nIndex + 1 + Wend + nIndex = nMem + Out.Log("Property selected: '" + oProperties(nIndex).Name + "'") + + 'memory the old Value + vMemVal = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + ' change the Value + select case VarType(oObj.getFastPropertyValue(oProperties(nIndex).Handle) + case 11 'boolean + bBoolean = NOT oObj.getFastPropertyValue(oProperties(nIndex).Handle) + vNewVal = bBoolean + case 2 'integer + nInteger = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 + vNewVal = nInteger + case 3 'long + nLong = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 + vNewVal = nLong + case 4 'single + nSingle = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 + vNewVal = nSingle + case 5 'double + nDouble = oObj.getFastPropertyValue(oProperties(nIndex).Handle) + 1 + vNewVal = nDouble + case 8 'string + vNewVal = oObj.getPropertyValue(oProperties(nIndex).Name) + cIfcShortName + end select + + nHandle = oProperties(nIndex).Handle + + Test.StartMethod("getFastPropertyValue()") + bOK = true + bOK = bOK AND (vMemVal = oObj.getFastPropertyValue(nHandle)) + Test.MethodTested("getFastPropertyValue()", bOK) + + Test.StartMethod("setFastPropertyValue()") + bOK = true + oObj.setFastPropertyValue(nHandle, vNewVal) + bOK = bOK AND (vMemVal <> oObj.getFastPropertyValue(nHandle)) + Test.MethodTested("setFastPropertyValue()", bOK) + + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/script.xlb b/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/script.xlb new file mode 100644 index 000000000000..3f8c3c6736e5 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XFastPropertySet/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XFastPropertySet" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XFastPropertySet"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XIntrospection/beans_XIntrospection.xba b/qadevOOo/tests/basic/ifc/beans/XIntrospection/beans_XIntrospection.xba new file mode 100644 index 000000000000..40209b24e54d --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XIntrospection/beans_XIntrospection.xba @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XIntrospection" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XIntrospection +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim xInspAccess As Object + + + Test.StartMethod("inspect()") + bOK = true + xInspAccess = oObj.inspect(oObj) + bOK = bOK AND hasUnoInterfaces(xInspAccess, "com.sun.star.beans.XIntrospectionAccess") + Test.MethodTested("inspect()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XIntrospection/script.xlb b/qadevOOo/tests/basic/ifc/beans/XIntrospection/script.xlb new file mode 100644 index 000000000000..69ffa481df6d --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XIntrospection/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XIntrospection" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XIntrospection"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/beans_XMultiPropertySet.xba b/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/beans_XMultiPropertySet.xba new file mode 100644 index 000000000000..7ad82a14a229 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/beans_XMultiPropertySet.xba @@ -0,0 +1,261 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XMultiPropertySet" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + +' Be sure that all variables are dimensioned: +option explicit + + +Dim nCB1Val As Integer, nCB2Val As Integer + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XMultiPropertySet +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim oPropertySetInfo As Object + Dim oProperties As Variant + Dim aProp(0 to 1) As new com.sun.star.beans.PropertyValue + Dim cType As String + Dim oListener1 As Object, oListener2 As Object + Dim n As Integer, nMem As Integer, nIndex As Integer + Dim m As Integer + Dim bFound As Boolean + Dim nCount As Integer + Dim bBoolean As Boolean + Dim nInteger As Integer + Dim nLong As Long + Dim nSingle As Single + Dim nDouble As Double + Dim vMemVal As Variant + Dim nCB1ValMem As Integer + Dim nCB2ValMem As Integer + + bOK = true + bFound = false + nCB1Val = 0 + nCB2Val = 0 + m = 0 + oPropertySetInfo = oObj.GetPropertySetInfo + oProperties = oPropertySetInfo.Properties + nCount = uBound(oProperties) + Out.Log("The Object has " + nCount + " properties" + + Out.Log("Create linsteners...") + oListener1 = createUNOListener("CB1_","com.sun.star.beans.XPropertiesChangeListener") + oListener2 = createUNOListener("CB2_","com.sun.star.beans.XPropertiesChangeListener") + Out.Log("oListener1 and oListener2 created" + + 'create sequences of Propertie-Names and Values + 'fist get the amount of valid properties + for n = 0 to (nCount) + 'look for readonly-properties + If (oProperties(n).Attributes AND com.sun.star.beans.PropertyAttribute.READONLY) = 0 Then + 'look for MAYBEVOID-Properties + If (oProperties(n).Attributes AND com.sun.star.beans.PropertyAttribute.MAYBEVOID) = 0 Then + 'is the Property testable + m = m + 1 + End If + End If + next n + + Out.Log("Amount of testable properites (without readonly and MAYBEVOID) is " + m) + + 'now store the names in sProperites + Dim searchProperties(0 to m-1) As String + m = 0 + for n = 0 to (nCount) + 'kick off readonly-properties + If (oProperties(n).Attributes AND com.sun.star.beans.PropertyAttribute.READONLY) = 0 Then + 'kick off MYBEVOID-Properties + If (oProperties(n).Attributes AND com.sun.star.beans.PropertyAttribute.MAYBEVOID) = 0 Then + searchProperties(m) = oProperties(n).Name + Out.Log("" + m + " " + searchProperties(m) + " " + oObj.getPropertySetInfo.getPropertyByName(searchProperties(m)).Type.Name + " " + n) + Dim pVal As Variant + + pVal = oObj.getPropertyValue(searchProperties(m)) + oObj.setPropertyValues(Array(searchProperties(m)), Array(pVal)) + m = m + 1 + End If + End If + next n + nCount = m - 1 + + Dim sProperties(0 to nCount) As String + Dim vValues(0 to nCount) As Variant + For n = 0 to nCount + sProperties(n) = searchProperties(n) + next n + + vValues() = oObj.getPropertyValues(sProperties()) + + 'add ChangeListener + oObj.addPropertiesChangeListener(sProperties(),oListener1) + oObj.addPropertiesChangeListener(sProperties(),oListener2) + Out.Log("oListener1 and oListener2 added to object") + + nIndex = 0 + nMem = nIndex + 'find at first a Boolean Value, if not available a String Property + While (NOT bFound) AND ((nCount >= nIndex)) + 'get the property-type + cType = oObj.getPropertySetInfo.getPropertyByName(sProperties(nIndex)).Type.Name + If cType = "boolean" Then ' it is a Boolean Proerty + bFound = true + nMem = nIndex + else + If cType = "string" Then ' it is a String Property + nMem = nIndex + end if + end if + nIndex = nIndex + 1 + Wend + + nIndex = nIndex - 1 + Out.Log("Property to change is: """ + sProperties(nIndex) + """ Type: """ + oObj.getPropertySetInfo.getPropertyByName(sProperties(nIndex)).Type.Name + """") + nIndex = nMem + + 'memory the old Value + vMemVal = vValues(nIndex) + + 'change a value of a property, hopefully a boolean or string property + select case VarType(vValues(nIndex) + case 11 'boolean + bBoolean = NOT vValues(nIndex) + vValues(nIndex) = bBoolean + case 2 'integer + nInteger = vValues(nIndex) + 1 + vValues(nIndex) = nInteger + case 3 'long + nLong = vValues(nIndex) + 1 + vValues(nIndex) = nLong + case 4 'single + nSingle = vValues(nIndex) + 1 + vValues(nIndex) = nSingle + case 5 'double + nDouble = vValues(nIndex) + 1 + vValues(nIndex) = nDouble + case 8 'string + vValues(nIndex) = vValues(nIndex) + cIfcShortName + end select + + Test.StartMethod("getPropertySetInfo()") + bOK = bOK AND (uBound(oProperties) > 0) + Test.MethodTested("getPropertySetInfo()", bOK) + + Test.StartMethod("getPropertyValues()") + bOK = bOK AND (uBound(vValues()) > 0) + Test.MethodTested("getPropertyValues()", bOK) + + Test.StartMethod("setPropertyValues()") + oObj.setPropertyValues(sProperties(), vValues()) + vValues() = oObj.getPropertyValues(sProperties()) + bOK = bOK AND (vValues(nIndex) <> vMemVal) + Test.MethodTested("setPropertyValues()", bOK) + + Test.StartMethod("addPropertiesChangeListener()") + bOK = (nCB1Val >= 1) AND (nCB2Val >= 1) + nCB1ValMem = nCB1Val + nCB2ValMem = nCb2Val + Test.MethodTested("addPropertiesChangeListener()", bOK) + + 'fire !!! + Out.Log("Try to fire property change event...") + oObj.firePropertiesChangeEvent(sProperties(),oListener1) + oObj.firePropertiesChangeEvent(sProperties(),oListener2) + + Test.StartMethod("firePropertiesChangeEvent()") + bOK = (nCB1Val >= nCB1ValMem) AND (nCB2Val >= nCB2ValMem) + Test.MethodTested("firePropertiesChangeEvent()", bOK) + nCB1ValMem = nCB1Val + nCB2ValMem = nCb2Val + + + 'remove one Listener and fire + Test.StartMethod("removePropertiesChangeListener()") + oObj.removePropertiesChangeListener(oListener1) + Out.Log("oListener1 removed") + select case VarType(vValues(nIndex) + case 11 'boolean + bBoolean = NOT vValues(nIndex) + vValues(nIndex) = bBoolean + case 2 'integer + nInteger = vValues(nIndex) + 1 + vValues(nIndex) = nInteger + case 3 'long + nLong = vValues(nIndex) + 1 + vValues(nIndex) = nLong + case 4 'single + nSingle = vValues(nIndex) + 1 + vValues(nIndex) = nSingle + case 5 'double + nDouble = vValues(nIndex) + 1 + vValues(nIndex) = nDouble + case 8 'string + vValues(nIndex) = vValues(nIndex) + cIfcShortName + end select + + Out.Log("The property '" + sProperties(nIndex) + "' was changed") + + oObj.setPropertyValues(sProperties(), vValues()) + + bOK = (nCB1Val = nCB1ValMem) AND (nCB2Val >= nCB2ValMem) + Test.MethodTested("removePropertiesChangeListener()", bOK) + + 'remove the last Listener + oObj.removePropertiesChangeListener(oListener2) + Out.Log("oListener2 removed") + + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +'callback routine called firePropertiesChangeEvent +Sub CB1_propertiesChange + Out.Log("CallBack for Listener 1 was called.") + nCB1Val = nCB1Val + 1 +end Sub + +Sub CB2_propertiesChange + Out.Log("CallBack for Listener 2 was called.") + nCB2Val = nCB2Val + 1 +end Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/script.xlb b/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/script.xlb new file mode 100644 index 000000000000..55637429dd36 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XMultiPropertySet/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XMultiPropertySet" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XMultiPropertySet"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/beans_XMultiPropertyStates.xba b/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/beans_XMultiPropertyStates.xba new file mode 100644 index 000000000000..6858ab51a28f --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/beans_XMultiPropertyStates.xba @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XMultiPropertyStates" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + +' Be sure that all variables are dimensioned: +option explicit + + +Function getPropNames(xPropSet As Object) As Variant + Dim props As Variant + Dim propNames As Variant + Dim i As Integer, propCount As Integer + + props = xPropSet.getPropertySetInfo().getProperties() + propCount = 0 + for i = 0 to ubound (props) + if (props(i).Attributes AND com.sun.star.beans.PropertyAttribute.READONLY) = 0 _ + then propCount = propCount + 1 + next i + + propNames = DimArray(propCount - 1) + aProps = DimArray(propCount - 1) + + propCount = 0 + for i = 0 to ubound(props) + if (props(i).Attributes AND com.sun.star.beans.PropertyAttribute.READONLY) = 0 then + propNames(propCount) = props(i).Name + aProps(propCount) = props(i) + propCount = propCount + 1 + endif + next i + + getPropNames = propNames +End Function + +Dim aProps As Variant + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XMultiPropertyStates +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + + Dim aPropNames As Variant + Dim aDefaults As Variant + Dim aStates As Variant + + if NOT hasUnoInterfaces(oObj, "com.sun.star.beans.XPropertySet") then + Out.Log("The compoent doesn't support XPropertySet this test must be reviewed !!!") + exit sub + end if + + bOK = true + aPropNames = getPropNames(oObj) + + if NOT utils.isSorted(aPropNames) then + Out.Log("Property names are not sorted : sorting ...") + utils.bubbleSort(aPropNames, false, aProps) + end if + + Out.Log("Totally " + (ubound(aPropNames) + 1) + " properties encountered.") + + Test.StartMethod("getPropertyDefaults()") + + aDefaults = oObj.getPropertyDefaults(aPropNames) + Out.Log("Number of default values: " + (ubound(aDefaults) + 1)) + bOK = ubound(aDefaults) = ubound(aPropNames) + + Test.MethodTested("getPropertyDefaults()", bOK) + + + Test.StartMethod("getPropertyStates()") + bOK = true + + aStates = oObj.getPropertyStates(aPropNames) + Out.Log("Number of states: " + (ubound(aStates) + 1)) + bOK = ubound(aStates) = ubound(aPropNames) + + Test.MethodTested("getPropertyStates()", bOK) + + Test.StartMethod("setPropertiesToDefault()") + bOK = true + + Dim propName As String + Dim propIdx As Integer + Dim mayBeDef As Boolean + Dim i As Integer + propName = aPropNames(0) + propIdx = 0 + mayBeDef = false + + ' searching for property which currently don't have default value and preferable has MAYBEDEFAULT attr + ' if no such properties are found then the first one is selected + for i = 0 to ubound(aPropNames) + if NOT mayBeDef AND aStates(i) <> com.sun.star.beans.PropertyState.DEFAULT_VALUE then + propName = aPropNames(i) + propIdx = i + if (aProps(i).Attributes AND com.sun.star.beans.PropertyAttribute.MAYBEDEFAULT) > 0 then + Out.Log("Property " + propName + " 'may be default' and doesn't have default value") + mayBeDef = true + end if + end if + next i + Out.Log("The property " + propName + " selected") + + oObj.setPropertiesToDefault(Array(propName)) + + aStates = oObj.getPropertyStates(aPropNames) + if aStates(propIdx) <> com.sun.star.beans.PropertyState.DEFAULT_VALUE then + Out.Log("The property didn't change its state to default ...") + if mayBeDef then + Out.Log(" ... and it may be default - FAILED") + bOK = false + else + Out.Log(" ... but it may not be default - OK") + end if + end if + + Test.MethodTested("setPropertiesToDefault()", bOK) + + Test.StartMethod("setAllPropertiesToDefault()") + bOK = true + + oObj.setAllPropertiesToDefault() + + Out.Log("Checking that all properties are now in DEFAULT state excepting may be those which 'cann't be default'") + aStates = oObj.getPropertyStates(aPropNames) + for i = 0 to ubound(aStates) + if aStates(i) <> com.sun.star.beans.PropertyState.DEFAULT_VALUE then + Out.Log("The property " + aPropNames(i) + " didn't change its state to default ...") + if (aProps(i).Attributes AND com.sun.star.beans.PropertyAttribute.MAYBEDEFAULT) > 0 then + Out.Log(" ... and it has MAYBEDEFAULT attribute - FAILED") + bOK = false + else + Out.Log(" ... but it has no MAYBEDEFAULT attribute - OK") + end if + end if + next i + + Test.MethodTested("setAllPropertiesToDefault()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/script.xlb b/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/script.xlb new file mode 100644 index 000000000000..283aa20cf01e --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XMultiPropertyStates/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XMultiPropertyStates" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XMultiPropertyStates"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XProperty/beans_XProperty.xba b/qadevOOo/tests/basic/ifc/beans/XProperty/beans_XProperty.xba new file mode 100644 index 000000000000..b6c372df2ea3 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XProperty/beans_XProperty.xba @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="XProperty" script:language="StarBasic"> + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + +' Be sure that all variables are dimensioned: +option explicit + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XProperty +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + + Test.StartMethod("getAsProperty()") + bOK = TRUE + Dim vProperty as new com.sun.star.beans.Property + vProperty = oObj.getAsProperty() + bOK = bOK and not isNull(vProperty) + Test.MethodTested("getAsProperty()", bOK) + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XProperty/script.xlb b/qadevOOo/tests/basic/ifc/beans/XProperty/script.xlb new file mode 100644 index 000000000000..733318087ab3 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XProperty/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> + <library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XProperty" library:readonly="false" library:passwordprotected="false"> + <library:element library:name="beans_XProperty"/> + </library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba b/qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba new file mode 100644 index 000000000000..ace2dc6775f3 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba @@ -0,0 +1,357 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XPropertySet" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + +'************************************************************************* +'Change-Listener needs bound-Properties +'Veto-Listener needs constrained-Propperties + +'************************************************************************* + + + + +Const BOUND = 2 +Const CONSTRAINED = 4 +Const MAYBENULL = 8 +Const READONLY = 16 + +Dim aBoundProps() As String +Dim aConstrainedProps() As String +Dim aNormalProps() As String +Dim aReadOnlyProps() As String + +Dim nBoundCount As Integer +Dim nConstrainedCount As Integer +Dim nNormalCount As Integer +Dim nReadOnlyCount As Integer + +Dim aAllProps As Object + +Dim vetoCalled1 As Boolean +Dim propCalled1 As Boolean +Dim vetoCalled2 As Boolean +Dim propCalled2 As Boolean + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XPropertySet +'************************************************************************* +On Error Goto ErrHndl +If (bErrHndl) Then On Error Goto ErrHndl + Dim oPCListener1 As Object + Dim oVListener1 As Object + Dim oPCListener2 As Object + Dim oVListener2 As Object + Dim bOK As boolean + + Test.StartMethod("getPropertySetInfo()") + bOK = true + bOK = NOT isNULL(oObj.PropertySetInfo) + Test.MethodTested("getPropertySetInfo()", bOK) + + Out.Log("Get properties()") + bOK = GetProps() + + Out.Log("Create Listeners") + oPCListener1 = createUNOListener("CB1_","com.sun.star.beans.XPropertyChangeListener") + oVListener1 = createUNOListener("CB1_","com.sun.star.beans.XVetoableChangeListener") + oPCListener2 = createUNOListener("CB2_","com.sun.star.beans.XPropertyChangeListener") + oVListener2 = createUNOListener("CB2_","com.sun.star.beans.XVetoableChangeListener") + + Test.StartMethod("getPropertyValue()") + bOK = true + bOK = bOK AND test_getPropertyValue() + Test.MethodTested("getPropertyValue()", bOK) + + Test.StartMethod("setPropertyValue()") + bOK = true + Dim bReadOnlyOK As Boolean + Dim bNormalOK As Boolean + bReadOnlyOK = false + bNormalOK = false + Dim bCVOK As boolean + + if (nReadOnlyCount = 0) then + bReadOnlyOK = true + Out.Log("No ReadOnly properties!") + else + for i = 0 to nReadOnlyCount - 1 + Out.Log("READONLY: '" & aReadOnlyProps(i) & "'") + if (aReadOnlyProps(i) = "Preview") then + bCVOK = true + else + bCVOK = PropertyTester.TestPropertyWithoutParams(aReadOnlyProps(i), true) + end if + Out.Log(bCVOK) + Out.Log("") + bReadOnlyOK = bReadOnlyOK OR bCVOK + next i + end if + + bOK = bOK AND bReadOnlyOK + + if (nNormalCount = 0) then + bNormalOK = true + Out.Log("No Normal properties!") + else + for i = 0 to nNormalCount - 1 + Out.Log("NORMAL: '" & aNormalProps(i) & "'") + bCVOK = PropertyTester.TestPropertyWithoutParams(aNormalProps(i), false) + Out.Log(bCVOK) + Out.Log("") + bNormalOK = bNormalOK OR bCVOK + next i + end if + + bOK = bOK AND bNormalOK + + Test.MethodTested("setPropertyValue()", bOK) + + Test.StartMethod("addVetoableChangeListener()") + Test.StartMethod("removeVetoableChangeListener()") + Dim bAddVeto As Boolean + Dim bRmvVeto As Boolean + bRmvVeto = true + bAddVeto = true + + if (nConstrainedCount = 0) then + Out.Log("No Constrained properties!") + bAddVeto = true + bRmvVeto = true + else + for i = 0 to nConstrainedCount - 1 + vetoCalled1 = false + vetoCalled2 = false + oObj.addVetoableChangeListener(aConstrainedProps(i), oVListener1) + oObj.addVetoableChangeListener(aConstrainedProps(i), oVListener2) + PropertyTester.TestPropertyWithoutParams(aConstrainedProps(i), false) + bAddVeto = bAddVeto OR (vetoCalled1 AND vetoCalled2) + Out.Log("addVetoableChangeListener: " & aConstrainedProps(i) & " Listener1 must be called: " & vetoCalled1) + Out.Log("addVetoableChangeListener: " & aConstrainedProps(i) & " Listener2 must be called: " & vetoCalled2) + + vetoCalled1 = false + vetoCalled2 = false + oObj.removeVetoableChangeListener(aConstrainedProps(i), oVListener1) + PropertyTester.TestPropertyWithoutParams(aConstrainedProps(i), false) + bRmvVeto = bRmvVeto OR (NOT vetoCalled1 AND vetoCalled2) + Out.Log("removeVetoableChangeListener: " & aConstrainedProps(i) & " Listener1 must not be called: " & NOT vetoCalled1) + Out.Log("removeVetoableChangeListener: " & aConstrainedProps(i) & " Listener2 must not be called: " & NOT vetoCalled2) + oObj.removeVetoableChangeListener(aConstrainedProps(i), oVListener2) + next i + end if + Test.MethodTested("addVetoableChangeListener()", bAddVeto) + Test.MethodTested("removeVetoableChangeListener()", bRmvVeto) + + Test.StartMethod("addPropertyChangeListener()") + Test.StartMethod("removePropertyChangeListener()") + Dim bAddProp As Boolean + Dim bRmvProp As Boolean + bRmvProp = true + bAddProp = true + + if (nBoundCount = 0) then + Out.Log("No Bound properties!") + bAddProp = true + bRmvProp = true + else + for i = 0 to nBoundCount - 1 + propCalled1 = false + propCalled2 = false + oObj.addPropertyChangeListener(aBoundProps(i), oPCListener1) + oObj.addPropertyChangeListener(aBoundProps(i), oPCListener2) + PropertyTester.TestPropertyWithoutParams(aBoundProps(i), false) + bAddProp = bAddProp OR (propCalled1 AND propCalled2) + Out.Log("addPropertyChangeListener: " & aBoundProps(i) & " Listener1 must be called :" & propCalled1) + Out.Log("addPropertyChangeListener: " & aBoundProps(i) & " Listener2 must be called :" & propCalled2) + + propCalled1 = false + propCalled2 = false + oObj.removePropertyChangeListener(aBoundProps(i), oPCListener1) + PropertyTester.TestPropertyWithoutParams(aBoundProps(i), false) + bRmvProp = bRmvProp OR (NOT propCalled1 AND propCalled2) + Out.Log("removePropertyChangeListener: " & aBoundProps(i) & " Listener must not be called: " & NOT propCalled) + oObj.removePropertyChangeListener(aBoundProps(i), oPCListener2) + next i + end if + + Test.MethodTested("addPropertyChangeListener()", bAddProp) + Test.MethodTested("removePropertyChangeListener()", bRmvProp) + + ReCreateObj() + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub + +Function GetProps() As Boolean +On Error Goto ErrHndl + Dim bOK as Boolean + Dim i As Integer + Dim attr As Variant + bOK = true + + aAllProps = oObj.propertySetInfo.getProperties + nNormalCount = 0 + nBoundCount = 0 + nConstrainedCount = 0 + nReadOnlyCount = 0 + + 'first we should find out how many properties of different kinds exists + for i = lbound(aAllProps) to ubound(aAllProps) + attr = aAllProps(i).Attributes + if (attr AND READONLY) OR (attr AND BOUND) OR (attr AND CONSTRAINED) then + if (attr AND BOUND) then + nBoundCount = nBoundCount + 1 + end if + if (attr AND CONSTRAINED) then + nConstrainedCount = nConstrainedCount + 1 + end if + if (attr AND READONLY) then + nReadOnlyCount = nReadOnlyCount + 1 + end if + else + if (NOT isNULL(oObj.getPropertyValue(aAllProps(i).Name))) then + nNormalCount = nNormalCount + 1 + end if + end if + next i + + Out.Log("" & nNormalCount & " Normal properties found") + Out.Log("" & nBoundCount & " Bound properties found") + Out.Log("" & nConstrainedCount & " Constrained properties found") + Out.Log("" & nReadOnlyCount & " ReadOnly properties found") + + Dim AN(nNormalCount) As String + aNormalProps = AN() + + Dim AB(nBoundCount) As String + aBoundProps = AB() + + Dim AC(nConstrainedCount) As String + aConstrainedProps = AC() + + Dim AR(nReadOnlyCount) As String + aReadOnlyProps = AR() + + 'Filling up arrays... + + nNormalCount = 0 + nBoundCount = 0 + nConstrainedCount = 0 + nReadOnlyCount = 0 + for i = lbound(aAllProps) to ubound(aAllProps) + attr = aAllProps(i).Attributes + if (attr AND READONLY) OR (attr AND BOUND) OR (attr AND CONSTRAINED) then + if (attr AND BOUND) then + aBoundProps(nBoundCount) = aAllProps(i).Name + nBoundCount = nBoundCount + 1 + end if + if (attr AND CONSTRAINED) then + aConstrainedProps(nConstrainedCount) = aAllProps(i).Name + nConstrainedCount = nConstrainedCount + 1 + end if + if (attr AND READONLY) then + aReadOnlyProps(nReadOnlyCount) = aAllProps(i).Name + nReadOnlyCount = nReadOnlyCount + 1 + end if + else + if (NOT isNULL(oObj.getPropertyValue(aAllProps(i).Name))) then + aNormalProps(nNormalCount) = aAllProps(i).Name + nNormalCount = nNormalCount + 1 + end if + end if + next i + + GetProps = bOK +Exit Function +ErrHndl: + Test.Exception() + resume next +End Function + +Function test_GetPropertyValue() As Boolean +On Error goto ErrHndl + + Dim bOK As Boolean + Dim i As Integer + Dim propName As String + Dim propVal As Variant + bOK = false + + for i = lbound(aAllProps) to ubound(aAllProps) + propName = aAllProps(i).Name + propVal = oObj.getPropertyValue(propName) + bOK = true + if (isNULL(propVal)) AND NOT(aAllProps(i).Attributes AND MAYBENULL) then + Out.Log(cIfcShortName & " " & aAllProps(i).Name & " is NULL, but it is not MAYBENULL") + end if + next i + + test_GetPropertyValue() = bOK +Exit Function +ErrHndl: + Test.Exception() + bOK = false + resume next +End Function + +Sub CB1_propertyChange + Out.Log("CallBack 'PropertyChange' for listener 1 was called.") + propCalled1 = true + CB1_propertyChange = true +End Sub + +Sub CB1_vetoableChange + Out.Log("CallBack 'vetoableChange' for listener 1 was called.") + vetoCalled1 = true +End Sub + +Sub CB2_propertyChange + Out.Log("CallBack 'PropertyChange' for listener 2 was called.") + propCalled2 = true + CB2_propertyChange = true +End Sub + +Sub CB2_vetoableChange + Out.Log("CallBack 'vetoableChange' for listener 2 was called.") + vetoCalled2 = true +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertySet/script.xlb b/qadevOOo/tests/basic/ifc/beans/XPropertySet/script.xlb new file mode 100644 index 000000000000..b5800efed317 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertySet/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XPropertySet" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XPropertySet"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/beans_XPropertySetInfo.xba b/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/beans_XPropertySetInfo.xba new file mode 100644 index 000000000000..4907ef848c4b --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/beans_XPropertySetInfo.xba @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XPropertySetInfo" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XPropertySetInfo +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + Dim aProperties As Variant + Dim vPropertie As Variant + + + Test.StartMethod("getProperties()") + bOK = true + aProperties = oObj.getProperties() + bOK = bOk AND not isNull(aProperties) + Test.MethodTested("getProperties()", bOK) + + Test.StartMethod("getPropertyByName()") + bOK = true + vPropertie = oObj.getPropertyByName(aProperties(0).Name) + bOK = bOK AND NOT isNull(vPropertie) + Test.MethodTested("getPropertyByName()", bOK) + + Test.StartMethod("hasPropertyByName()") + bOK = true + bOK = bOK AND oObj.hasPropertyByName(aProperties(0).Name) + Test.MethodTested("hasPropertyByName()", bOK) + + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/script.xlb b/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/script.xlb new file mode 100644 index 000000000000..702547f945d2 --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertySetInfo/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XPropertySetInfo" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XPropertySetInfo"/> +"</library:library> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertyState/beans_XPropertyState.xba b/qadevOOo/tests/basic/ifc/beans/XPropertyState/beans_XPropertyState.xba new file mode 100644 index 000000000000..783563acb21d --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertyState/beans_XPropertyState.xba @@ -0,0 +1,178 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> +<script:module xmlns:script="http://openoffice.org/2000/script" script:name="beans_XPropertyState" script:language="StarBasic"> + + +'************************************************************************* +' +' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +' +' Copyright 2000, 2010 Oracle and/or its affiliates. +' +' OpenOffice.org - a multi-platform office productivity suite +' +' This file is part of OpenOffice.org. +' +' OpenOffice.org is free software: you can redistribute it and/or modify +' it under the terms of the GNU Lesser General Public License version 3 +' only, as published by the Free Software Foundation. +' +' OpenOffice.org is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU Lesser General Public License version 3 for more details +' (a copy is included in the LICENSE file that accompanied this code). +' +' You should have received a copy of the GNU Lesser General Public License +' version 3 along with OpenOffice.org. If not, see +' <http://www.openoffice.org/license.html> +' for a copy of the LGPLv3 License. +' +'************************************************************************* +'************************************************************************* + + + + +Const BOUND = 2 +Const CONSTRAINED = 4 +Const MAYBENULL = 8 +Const READONLY = 16 + + +Sub RunTest() + +'************************************************************************* +' INTERFACE: +' com.sun.star.beans.XPropertyState +'************************************************************************* +On Error Goto ErrHndl + Dim bOK As Boolean + + Dim oProperties As Variant + Dim nAllProps As Integer + Dim aValue As Variant + Dim n As Integer + Dim oCoreRefl As Object + Dim bTypesEq As Boolean + + bOK = true + + oCoreRefl = createUnoService("com.sun.star.reflection.CoreReflection") + + oProperties = oObj.GetPropertySetInfo().Properties + nAllProps = uBound(oProperties) + Dim AllPropsNames(nAllProps) As String + Out.Log("Found " & nAllProps & " properties.") + + for n = 0 to (nAllProps) + AllPropsNames(n) = oProperties(n).Name + next n + + Test.StartMethod("getPropertyStates()") + Out.Log("getting states for all properties.") + bOK = true + + Dim aStates As Variant + + aStates() = oObj.getPropertyStates(AllPropsNames()) + bOK = bOK AND isArray(aStates()) + if (bOK) then Out.Log("Length of returned array is " & ubound(aStates())) + bOK = bOK AND ubound(aStates()) = nAllProps + + Dim nState As Integer + nState = aStates(nAllProps / 2) + bOK = bOK AND (nState = com.sun.star.beans.PropertyState.DIRECT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.DEFAULT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) + Test.MethodTested("getPropertyStates()", bOK) + + Test.StartMethod("getPropertyState()") + bOK = false + n = 0 + + ' Here testing getPropertyState method. Method is OK when at least one + ' property works correctly. + + while (bOK = false AND n < nAllProps) + bOK = true + nState = oObj.getPropertyState(AllPropsNames(n)) + bOK = bOK AND (nState = com.sun.star.beans.PropertyState.DIRECT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.DEFAULT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) + n = n + 1 + wend + Test.MethodTested("getPropertyState()", bOK) + + Test.StartMethod("getPropertyDefault()") + bOK = false + n = 0 + + ' Here testing getPropertyDefault method. Method is OK when at least one + ' property works correctly. + + while (bOK = false AND n < nAllProps) + bOK = true + aValue = oObj.getPropertyDefault(AllPropsNames(n)) + bOK = bOK AND (oProperties(n).Type.Name = oCoreRefl.getType(aValue).Name) + n = n + 1 + wend + Test.MethodTested("getPropertyDefault()", bOK) + + Test.StartMethod("setPropertyToDefault()") + bOK = false + n = 0 + + ' Here testing setPropertyToDefault method. Method is OK when at least one + ' property works correctly. + + while (bOK = false AND n < nAllProps) + bOK = true + oObj.setPropertyToDefault(AllPropsNames(n)) + n = n + 1 + wend + Test.MethodTested("setPropertyToDefault()", bOK) + + + ' Here testing getPropertyState for ALL properties. This will + ' put all exceptions to .log file (if this method doesn't work with some properties) + ' but without any affect to test status. + + n = 0 + while (n < nAllProps) + bOK = true + nState = oObj.getPropertyState(AllPropsNames(n)) + bOK = bOK AND (nState = com.sun.star.beans.PropertyState.DIRECT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.DEFAULT_VALUE OR _ + nState = com.sun.star.beans.PropertyState.AMBIGUOUS_VALUE) + + if (NOT bOK) then + Out.Log("Error while testing getPropertyState() for '" & AllPropsNames(n) & "' FAILED.") + else + Out.Log("getPropertyState() for property '" & AllPropsNames(n) & "' is OK") + end if + + bOK = true + aValue = oObj.getPropertyDefault(AllPropsNames(n)) + bTypesEq = false + if (bOK AND (TypeName(aValue) <> "Empty")) then + bTypesEq = (oProperties(n).Type.Name = oCoreRefl.getType(aValue).Name) + end if + + if (NOT bOK) then ' exception was occured + Out.Log("Error while testing getPropertyDefault() for '" & AllPropsNames(n) & "' FAILED.") + elseif ((TypeName(aValue) <> "Empty") AND (NOT bTypesEq)) then + Out.Log("Types: '" & oProperties(n).Type.Name & "' and '" & oCoreRefl.getType(aValue).Name & "' are different.") + else + Out.Log("getPropertyDefault() for property '" & AllPropsNames(n) & "' is OK") + end if + n = n + 1 + wend + +Exit Sub +ErrHndl: + Test.Exception() + bOK = false + resume next +End Sub +</script:module> diff --git a/qadevOOo/tests/basic/ifc/beans/XPropertyState/script.xlb b/qadevOOo/tests/basic/ifc/beans/XPropertyState/script.xlb new file mode 100644 index 000000000000..4a57254d9d4c --- /dev/null +++ b/qadevOOo/tests/basic/ifc/beans/XPropertyState/script.xlb @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd"> +<library:library xmlns:library="http://openoffice.org/2000/library" library:name="beans_XPropertyState" library:readonly="false" library:passwordprotected="false"> +"<library:element library:name="beans_XPropertyState"/> +"</library:library> |