summaryrefslogtreecommitdiff
path: root/qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba
diff options
context:
space:
mode:
Diffstat (limited to 'qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba')
-rw-r--r--qadevOOo/tests/basic/ifc/beans/XPropertySet/beans_XPropertySet.xba357
1 files changed, 357 insertions, 0 deletions
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: '" &amp; aReadOnlyProps(i) &amp; "'")
+ 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: '" &amp; aNormalProps(i) &amp; "'")
+ 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: " &amp; aConstrainedProps(i) &amp; " Listener1 must be called: " &amp; vetoCalled1)
+ Out.Log("addVetoableChangeListener: " &amp; aConstrainedProps(i) &amp; " Listener2 must be called: " &amp; 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: " &amp; aConstrainedProps(i) &amp; " Listener1 must not be called: " &amp; NOT vetoCalled1)
+ Out.Log("removeVetoableChangeListener: " &amp; aConstrainedProps(i) &amp; " Listener2 must not be called: " &amp; 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: " &amp; aBoundProps(i) &amp; " Listener1 must be called :" &amp; propCalled1)
+ Out.Log("addPropertyChangeListener: " &amp; aBoundProps(i) &amp; " Listener2 must be called :" &amp; 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: " &amp; aBoundProps(i) &amp; " Listener must not be called: " &amp; 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("" &amp; nNormalCount &amp; " Normal properties found")
+ Out.Log("" &amp; nBoundCount &amp; " Bound properties found")
+ Out.Log("" &amp; nConstrainedCount &amp; " Constrained properties found")
+ Out.Log("" &amp; nReadOnlyCount &amp; " 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 &amp; " " &amp; aAllProps(i).Name &amp; " 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>