Exemple #1
0
    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        listener = MyAttachListener(self)
        self._olayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._olayout.addListener(listener, IComponentDetachListener)

        self._gridlayout = GridLayout()
        listener = MyAttachListener(self)
        self._gridlayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._gridlayout.addListener(listener, IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        listener = MyAttachListener(self)
        self._absolutelayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._absolutelayout.addListener(listener, IComponentDetachListener)

        self._csslayout = CssLayout()
        listener = MyAttachListener(self)
        self._csslayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._csslayout.addListener(listener, IComponentDetachListener)
    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        self._olayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._olayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._gridlayout = GridLayout()
        self._gridlayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._gridlayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        self._absolutelayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._absolutelayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._csslayout = CssLayout()
        self._csslayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._csslayout.addListener(MyDetachListener(self),
                IComponentDetachListener)
Exemple #3
0
    def testPartialCssReset(self):
        """Add component setting all attributes using CSS, then reset
        using partial CSS; assert getters agree and the appropriate
        attributes are unset.
        """
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)
        layout.getPosition(b).setCSSString(self._PARTIAL_CSS)

        self.assertEquals(self._CSS_VALUE, layout.getPosition(b).getTopValue())
        self.assertIsNone(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(self._CSS_VALUE,
                          layout.getPosition(b).getLeftValue())
        self.assertIsNone(layout.getPosition(b).getRightValue())

        self.assertEquals(ISizeable.UNITS_PIXELS,
                          layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                          layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getRightUnits())
        self.assertEquals(-1, layout.getPosition(b).getZIndex())
        self.assertEquals(self._PARTIAL_CSS,
                          layout.getPosition(b).getCSSString())
Exemple #4
0
    def testPartialCss(self):
        """Add component, setting some attributes using CSS, assert
        getters agree"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._PARTIAL_CSS)

        self.assertEquals(self._CSS_VALUE, layout.getPosition(b).getTopValue())
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(self._CSS_VALUE,
                          layout.getPosition(b).getLeftValue())
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals(ISizeable.UNITS_PIXELS,
                          layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                          layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getRightUnits())
        self.assertEquals(-1, layout.getPosition(b).getZIndex())
        self.assertEquals(self._PARTIAL_CSS,
                          layout.getPosition(b).getCSSString())
Exemple #5
0
    def testFullCss(self):
        """Add component, setting all attributes using CSS, assert
        getter agree"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)

        self.assertEquals(self._CSS_VALUE, layout.getPosition(b).getTopValue())
        self.assertEquals(self._CSS_VALUE,
                          layout.getPosition(b).getBottomValue())
        self.assertEquals(self._CSS_VALUE,
                          layout.getPosition(b).getLeftValue())
        self.assertEquals(self._CSS_VALUE,
                          layout.getPosition(b).getRightValue())

        self.assertEquals(ISizeable.UNITS_PIXELS,
                          layout.getPosition(b).getTopUnits())
        self.assertEquals(ISizeable.UNITS_PICAS,
                          layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                          layout.getPosition(b).getLeftUnits())
        self.assertEquals(ISizeable.UNITS_PERCENTAGE,
                          layout.getPosition(b).getRightUnits())

        self.assertEquals(7, layout.getPosition(b).getZIndex())
        self.assertEquals(self._CSS, layout.getPosition(b).getCSSString())
Exemple #6
0
    def testUnsetPosition(self):
        """Add component, set all attributes using CSS, unset some using
        method calls, assert getters agree.
        """
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)

        layout.getPosition(b).setTopValue(None)
        layout.getPosition(b).setRightValue(None)
        layout.getPosition(b).setBottomValue(None)
        layout.getPosition(b).setLeftValue(None)
        layout.getPosition(b).setZIndex(-1)

        self.assertEquals(layout.getPosition(b).getTopValue(), None)
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(layout.getPosition(b).getLeftValue(), None)
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals('', layout.getPosition(b).getCSSString())
Exemple #7
0
    def testNoPosition(self):
        """Add component w/o giving positions, assert that everything
        is unset"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b)

        self.assertEquals(layout.getPosition(b).getTopValue(), None)
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(layout.getPosition(b).getLeftValue(), None)
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getBottomUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                          layout.getPosition(b).getRightUnits())

        self.assertEquals(-1, layout.getPosition(b).getZIndex())
        self.assertEquals('', layout.getPosition(b).getCSSString())
Exemple #8
0
    def testSetPosition2(self):
        """Add component, then set all position attributes with combined
        setters for value and units; assert getters agree.
        """
        SIZE = float(12)
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b)

        layout.getPosition(b).setTop(SIZE, ISizeable.UNITS_CM)
        layout.getPosition(b).setRight(SIZE, ISizeable.UNITS_EX)
        layout.getPosition(b).setBottom(SIZE, ISizeable.UNITS_INCH)
        layout.getPosition(b).setLeft(SIZE, ISizeable.UNITS_MM)

        self.assertEquals(SIZE, layout.getPosition(b).getTopValue())
        self.assertEquals(SIZE, layout.getPosition(b).getRightValue())
        self.assertEquals(SIZE, layout.getPosition(b).getBottomValue())
        self.assertEquals(SIZE, layout.getPosition(b).getLeftValue())

        self.assertEquals(ISizeable.UNITS_CM,
                          layout.getPosition(b).getTopUnits())
        self.assertEquals(ISizeable.UNITS_EX,
                          layout.getPosition(b).getRightUnits())
        self.assertEquals(ISizeable.UNITS_INCH,
                          layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_MM,
                          layout.getPosition(b).getLeftUnits())
class ComponentAttachDetachListenerTest(TestCase):

    def resetVariables(self):
        # Attach
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False

        # Detach
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Common
        self._indexOfComponent = -1
        self._componentArea = None
        self._componentPosition = None


    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        self._olayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._olayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._gridlayout = GridLayout()
        self._gridlayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._gridlayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        self._absolutelayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._absolutelayout.addListener(MyDetachListener(self),
                IComponentDetachListener)

        self._csslayout = CssLayout()
        self._csslayout.addListener(MyAttachListener(self),
                IComponentAttachListener)
        self._csslayout.addListener(MyDetachListener(self),
                IComponentDetachListener)


    def testOrderedLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._olayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._olayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The index of the component should not be -1
        self.assertFalse(self._indexOfComponent == -1)


    def testOrderedLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._olayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._olayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._olayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The index of the component should be -1
        self.assertEquals(-1, self._indexOfComponent)


    def testGridLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._gridlayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The grid area should not be null
        self.assertIsNotNone(self._componentArea)


    def testGridLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._gridlayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._gridlayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The grid area should be null
        self.assertIsNone(self._componentArea)


    def testAbsoluteLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._absolutelayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The component position should not be null
        self.assertIsNotNone(self._componentPosition)


    def testAbsoluteLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._absolutelayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._absolutelayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The component position should be null
        self.assertIsNone(self._componentPosition)


    def testCSSLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._csslayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._csslayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)


    def testCSSLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._csslayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._csslayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._csslayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)
    def testPartialCss(self):
        """Add component, setting some attributes using CSS, assert
        getters agree"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._PARTIAL_CSS)

        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getTopValue())
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getLeftValue())
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals(ISizeable.UNITS_PIXELS,
                layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getRightUnits())
        self.assertEquals(-1,
                layout.getPosition(b).getZIndex())
        self.assertEquals(self._PARTIAL_CSS,
                layout.getPosition(b).getCSSString())
    def testFullCss(self):
        """Add component, setting all attributes using CSS, assert
        getter agree"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)

        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getTopValue())
        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getBottomValue())
        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getLeftValue())
        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getRightValue())

        self.assertEquals(ISizeable.UNITS_PIXELS,
                layout.getPosition(b).getTopUnits())
        self.assertEquals(ISizeable.UNITS_PICAS,
                layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                layout.getPosition(b).getLeftUnits())
        self.assertEquals(ISizeable.UNITS_PERCENTAGE,
                layout.getPosition(b).getRightUnits())

        self.assertEquals(7, layout.getPosition(b).getZIndex())
        self.assertEquals(self._CSS, layout.getPosition(b).getCSSString())
    def testNoPosition(self):
        """Add component w/o giving positions, assert that everything
        is unset"""
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b)

        self.assertEquals(layout.getPosition(b).getTopValue(), None)
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(layout.getPosition(b).getLeftValue(), None)
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getBottomUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getRightUnits())

        self.assertEquals(-1, layout.getPosition(b).getZIndex())
        self.assertEquals('', layout.getPosition(b).getCSSString())
    def testUnsetPosition(self):
        """Add component, set all attributes using CSS, unset some using
        method calls, assert getters agree.
        """
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)

        layout.getPosition(b).setTopValue(None)
        layout.getPosition(b).setRightValue(None)
        layout.getPosition(b).setBottomValue(None)
        layout.getPosition(b).setLeftValue(None)
        layout.getPosition(b).setZIndex(-1)

        self.assertEquals(layout.getPosition(b).getTopValue(), None)
        self.assertEquals(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(layout.getPosition(b).getLeftValue(), None)
        self.assertEquals(layout.getPosition(b).getRightValue(), None)

        self.assertEquals('', layout.getPosition(b).getCSSString())
    def testSetPosition2(self):
        """Add component, then set all position attributes with combined
        setters for value and units; assert getters agree.
        """
        SIZE = float(12)
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b)

        layout.getPosition(b).setTop(SIZE, ISizeable.UNITS_CM)
        layout.getPosition(b).setRight(SIZE, ISizeable.UNITS_EX)
        layout.getPosition(b).setBottom(SIZE, ISizeable.UNITS_INCH)
        layout.getPosition(b).setLeft(SIZE, ISizeable.UNITS_MM)

        self.assertEquals(SIZE, layout.getPosition(b).getTopValue())
        self.assertEquals(SIZE, layout.getPosition(b).getRightValue())
        self.assertEquals(SIZE, layout.getPosition(b).getBottomValue())
        self.assertEquals(SIZE, layout.getPosition(b).getLeftValue())

        self.assertEquals(ISizeable.UNITS_CM,
                layout.getPosition(b).getTopUnits())
        self.assertEquals(ISizeable.UNITS_EX,
                layout.getPosition(b).getRightUnits())
        self.assertEquals(ISizeable.UNITS_INCH,
                layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_MM,
                layout.getPosition(b).getLeftUnits())
    def testPartialCssReset(self):
        """Add component setting all attributes using CSS, then reset
        using partial CSS; assert getters agree and the appropriate
        attributes are unset.
        """
        layout = AbsoluteLayout()
        b = Button()
        layout.addComponent(b, self._CSS)
        layout.getPosition(b).setCSSString(self._PARTIAL_CSS)

        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getTopValue())
        self.assertIsNone(layout.getPosition(b).getBottomValue(), None)
        self.assertEquals(self._CSS_VALUE,
                layout.getPosition(b).getLeftValue())
        self.assertIsNone(layout.getPosition(b).getRightValue())

        self.assertEquals(ISizeable.UNITS_PIXELS,
                layout.getPosition(b).getTopUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getBottomUnits())
        self.assertEquals(ISizeable.UNITS_EM,
                layout.getPosition(b).getLeftUnits())
        self.assertEquals(self._UNIT_UNSET,
                layout.getPosition(b).getRightUnits())
        self.assertEquals(-1,
                layout.getPosition(b).getZIndex())
        self.assertEquals(self._PARTIAL_CSS,
                layout.getPosition(b).getCSSString())
Exemple #16
0
class ComponentAttachDetachListenerTest(TestCase):
    def resetVariables(self):
        # Attach
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False

        # Detach
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Common
        self._indexOfComponent = -1
        self._componentArea = None
        self._componentPosition = None

    def setUp(self):
        super(ComponentAttachDetachListenerTest, self).setUp()

        # General variables
        self._attachCounter = 0
        self._attachedComponent = None
        self._attachTarget = None
        self._foundInContainer = False
        self._detachCounter = 0
        self._detachedComponent = None
        self._detachedTarget = None

        # Ordered layout specific variables
        self._indexOfComponent = -1

        # Grid layout specific variables
        self._componentArea = None

        # Absolute layout specific variables
        self._componentPosition = None

        self._olayout = HorizontalLayout()
        listener = MyAttachListener(self)
        self._olayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._olayout.addListener(listener, IComponentDetachListener)

        self._gridlayout = GridLayout()
        listener = MyAttachListener(self)
        self._gridlayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._gridlayout.addListener(listener, IComponentDetachListener)

        self._absolutelayout = AbsoluteLayout()
        listener = MyAttachListener(self)
        self._absolutelayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._absolutelayout.addListener(listener, IComponentDetachListener)

        self._csslayout = CssLayout()
        listener = MyAttachListener(self)
        self._csslayout.addListener(listener, IComponentAttachListener)
        listener = MyDetachListener(self)
        self._csslayout.addListener(listener, IComponentDetachListener)

    def testOrderedLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._olayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._olayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The index of the component should not be -1
        self.assertFalse(self._indexOfComponent == -1)

    def testOrderedLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._olayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._olayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._olayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The index of the component should be -1
        self.assertEquals(-1, self._indexOfComponent)

    def testGridLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._gridlayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The grid area should not be null
        self.assertIsNotNone(self._componentArea)

    def testGridLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._gridlayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._gridlayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._gridlayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The grid area should be null
        self.assertIsNone(self._componentArea)

    def testAbsoluteLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._absolutelayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

        # The component position should not be null
        self.assertIsNotNone(self._componentPosition)

    def testAbsoluteLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._absolutelayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._absolutelayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._absolutelayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)

        # The component position should be null
        self.assertIsNone(self._componentPosition)

    def testCSSLayoutAttachListener(self):
        # Reset state variables
        self.resetVariables()

        # Add component -> Should trigger attach listener
        comp = Label()
        self._csslayout.addComponent(comp)

        # Attach counter should get incremented
        self.assertEquals(1, self._attachCounter)

        # The attached component should be the label
        self.assertEquals(comp, self._attachedComponent)

        # The attached target should be the layout
        self.assertEquals(self._csslayout, self._attachTarget)

        # The attached component should be found in the container
        self.assertTrue(self._foundInContainer)

    def testCSSLayoutDetachListener(self):
        # Add a component to detach
        comp = Label()
        self._csslayout.addComponent(comp)

        # Reset state variables (since they are set by the attach listener)
        self.resetVariables()

        # Detach the component -> triggers the detach listener
        self._csslayout.removeComponent(comp)

        # Detach counter should get incremented
        self.assertEquals(1, self._detachCounter)

        # The detached component should be the label
        self.assertEquals(comp, self._detachedComponent)

        # The detached target should be the layout
        self.assertEquals(self._csslayout, self._detachedTarget)

        # The detached component should not be found in the container
        self.assertFalse(self._foundInContainer)