diff options
author | Andreas Schlüns <as@openoffice.org> | 2000-10-06 10:36:22 +0000 |
---|---|---|
committer | Andreas Schlüns <as@openoffice.org> | 2000-10-06 10:36:22 +0000 |
commit | 130942ef1dcc0b0b0e253856fa61d9f3deb45bdc (patch) | |
tree | 282d6c3065735d752239423341a7fc967041754f /framework/test | |
parent | de704dc755334f066b39550ebf2f240fde33aa68 (diff) |
#79212# implement test scene for component enumeration
Diffstat (limited to 'framework/test')
-rw-r--r-- | framework/test/test_componentenumeration.bas | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/framework/test/test_componentenumeration.bas b/framework/test/test_componentenumeration.bas new file mode 100644 index 000000000000..77b64bb96939 --- /dev/null +++ b/framework/test/test_componentenumeration.bas @@ -0,0 +1,78 @@ +rem _______________________________________________________________________________________________________________________________________ +rem Test script for helper class "framework/helper/OComponentAccess and OComponentEnumeration. +rem These two classes are used for "framework/baeh_services/Desktop::getComponents()" only. +rem _______________________________________________________________________________________________________________________________________ + + +Sub Main + + rem ___________________________________________________________________________________________________________________________________ + rem Get all current components of the frame tree as an enumeration access object. + rem The return value must be a valid reference! + xComponentAccess = StarDesktop.Components + if( isNull(xComponentAccess) = TRUE ) then + msgbox "Error: Desktop return null reference as enumeration access to all tree components!" + exit Sub + endif + + rem ___________________________________________________________________________________________________________________________________ + rem Control service specification of helper class "framework/helper/OComponentAccess". + rem The follow output must occure: com.sun.star.lang.XTypeProvider + rem com.sun.star.container.XEnumerationAccess -> com.sun.star.container.XElementAccess + msgbox xComponentAccess.dbg_supportedInterfaces + + rem ___________________________________________________________________________________________________________________________________ + rem Test interface XElementAccess of helper OComponentAcces. + + rem Method hasElements() must return TRUE, because if you call this from the basic IDE at least one task must exist ... + rem the IDE by himself. Normaly two tasks exist - an empty writer document and a basic frame. + rem Attention: Not all tasks or frames must support a full implemented component! + if( xComponentAccess.hasElements <> TRUE ) then + msgbox "Error: xComponentAccess has no elements - but I can't believe it!" + exit Sub + endif + + rem Method getElementType() must return the cppu type of XComponent. + rem Otherwise something is wrong or implementation has changed. + if( xComponentAccess.getElementType.Name <> "com.sun.star.lang.XComponent" ) then + msgbox "Error: xComponentAccess return wrong type as element type! - Has implementation changed?" + exit Sub + endif + + rem ___________________________________________________________________________________________________________________________________ + rem Test interface XEnumerationAccess of helper OComponentAcces. + rem The return value must be a valid reference! + xComponentEnumeration = xComponentAccess.createEnumeration + if( isNull(xComponentEnumeration) = TRUE ) then + msgbox "Error: Could not create a component enumeration!" + exit Sub + endif + + rem ___________________________________________________________________________________________________________________________________ + rem Control service specification of helper class "framework/helper/OComponentEnumeration". + rem The follow output must occure: com.sun.star.lang.XTypeProvider + rem com.sun.star.lang.XEventListener + rem com.sun.star.container.XEnumeration + msgbox xComponentEnumeration.dbg_supportedInterfaces + + rem ___________________________________________________________________________________________________________________________________ + rem Test interface XEnumeration of helper OComponentEnumeration. + nElementCounter = 0 + while( xComponentEnumeration.hasMoreElements = TRUE ) + xElement = xComponentEnumeration.nextElement + if( isNull(xElement) = TRUE ) then + msgbox "Error: An empty component in enumeration detected! Whats wrong?" + exit Sub + endif + nElementCounter = nElementCounter + 1 + wend + if( nElementCounter < 1 ) then + msgbox "Warning: The enumeration was empty. I think it's wrong ... please check it again." + endif + msgbox "Info: An enumeration with " + nElementCounter + " element(s) was detected." + + rem ___________________________________________________________________________________________________________________________________ + rem If this point arrived our test was successful. + msgbox "Test of framework/helper/OComponentAccess & OComponentEnumeration was successful!" + +End Sub |