<s> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferUI <EOL> import GafferUITest <EOL> class LinearContainerTest ( GafferUITest . TestCase ) : <EOL> def testConstruction ( self ) : <EOL> c = GafferUI . LinearContainer ( ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . X ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Centre ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Increasing ) <EOL> c = GafferUI . LinearContainer ( name = "<STR_LIT:a>" ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT:a>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . X ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Centre ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Increasing ) <EOL> c = GafferUI . LinearContainer ( spacing = <NUM_LIT:10> ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . X ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Centre ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Increasing ) <EOL> c = GafferUI . LinearContainer ( orientation = GafferUI . LinearContainer . Orientation . Y ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . Y ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Centre ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Increasing ) <EOL> c = GafferUI . LinearContainer ( alignment = GafferUI . LinearContainer . Alignment . Min ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . X ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Min ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Increasing ) <EOL> c = GafferUI . LinearContainer ( direction = GafferUI . LinearContainer . Direction . Decreasing ) <EOL> self . assertEqual ( c . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( c . getOrientation ( ) , GafferUI . LinearContainer . Orientation . X ) <EOL> self . assertEqual ( c . getAlignment ( ) , GafferUI . LinearContainer . Alignment . Centre ) <EOL> self . assertEqual ( c . getSpacing ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( c . getDirection ( ) , GafferUI . LinearContainer . Direction . Decreasing ) <EOL> self . assert_ ( c . bound ( ) . isEmpty ( ) ) <EOL> def testHorizontalCentred ( self ) : <EOL> twoByFour = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> fourByFour = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:2> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> fourByTwo = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:2> , - <NUM_LIT:1> ) , IECore . V2f ( <NUM_LIT:2> , <NUM_LIT:1> ) ) ) <EOL> ) <EOL> c = GafferUI . LinearContainer ( ) <EOL> c [ "<STR_LIT>" ] = twoByFour <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> ) ) ) <EOL> c [ "<STR_LIT>" ] = fourByFour <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:3> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( - <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> c [ "<STR_LIT>" ] = fourByTwo <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:5> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( - <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( - <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByTwo . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> ) ) ) <EOL> def testVerticalMin ( self ) : <EOL> twoByFour = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> fourByFour = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:2> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> fourByTwo = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:2> , - <NUM_LIT:1> ) , IECore . V2f ( <NUM_LIT:2> , <NUM_LIT:1> ) ) ) <EOL> ) <EOL> c = GafferUI . LinearContainer ( orientation = GafferUI . LinearContainer . Orientation . Y , alignment = GafferUI . LinearContainer . Alignment . Min ) <EOL> c [ "<STR_LIT>" ] = twoByFour <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> ) ) ) <EOL> c [ "<STR_LIT>" ] = fourByFour <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:2> , - <NUM_LIT:4> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> c [ "<STR_LIT>" ] = fourByTwo <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:2> , - <NUM_LIT:5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( twoByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:3> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByFour . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( fourByTwo . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:4> , <NUM_LIT:0> ) ) ) <EOL> def testPadding ( self ) : <EOL> twoByFour = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> c = GafferUI . LinearContainer ( orientation = GafferUI . LinearContainer . Orientation . Y ) <EOL> c . addChild ( twoByFour ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( c . getPadding ( ) , IECore . Box3f ( IECore . V3f ( <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:0> ) ) ) <EOL> c . setPadding ( IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ) <EOL> self . assertEqual ( c . getPadding ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:2> , - <NUM_LIT:4> , - <NUM_LIT:3> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:3> ) ) ) <EOL> def testDirection ( self ) : <EOL> first = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> second = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> , - <NUM_LIT:2> ) , IECore . V2f ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> ) <EOL> c = GafferUI . LinearContainer ( orientation = GafferUI . LinearContainer . Orientation . Y ) <EOL> c [ "<STR_LIT>" ] = first <EOL> c [ "<STR_LIT>" ] = second <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:4> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( first . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , - <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( second . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> c . setDirection ( GafferUI . LinearContainer . Direction . Decreasing ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:4> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( first . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> self . assertEqual ( second . getTransform ( ) , IECore . M44f . createTranslated ( IECore . V3f ( <NUM_LIT:0> , - <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> def testDirectionAndSpacing ( self ) : <EOL> c = GafferUI . LinearContainer ( orientation = GafferUI . LinearContainer . Orientation . Y ) <EOL> c [ "<STR_LIT>" ] = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> ) , IECore . V2f ( <NUM_LIT:1> ) ) ) <EOL> ) <EOL> c [ "<STR_LIT>" ] = GafferUI . RenderableGadget ( <EOL> IECore . MeshPrimitive . createPlane ( IECore . Box2f ( IECore . V2f ( - <NUM_LIT:1> ) , IECore . V2f ( <NUM_LIT:1> ) ) ) <EOL> ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:2> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> ) ) ) <EOL> c . setSpacing ( <NUM_LIT:2> ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:3> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> ) ) ) <EOL> c . setDirection ( GafferUI . LinearContainer . Direction . Decreasing ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> , - <NUM_LIT:3> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> ) ) ) <EOL> def testChildVisibility ( self ) : <EOL> g1 = GafferUI . SpacerGadget ( IECore . Box3f ( IECore . V3f ( <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> ) ) ) <EOL> g2 = GafferUI . SpacerGadget ( IECore . Box3f ( IECore . V3f ( <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> ) ) ) <EOL> g3 = GafferUI . SpacerGadget ( IECore . Box3f ( IECore . V3f ( <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:0> ) ) ) <EOL> c = GafferUI . LinearContainer ( spacing = <NUM_LIT:1> ) <EOL> c . addChild ( g1 ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:0.5> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> c . addChild ( g2 ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:2> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> g2 . setVisible ( False ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:0.5> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> g2 . setVisible ( True ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:2> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:2> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> c . addChild ( g3 ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:5> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:5> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> g1 . setVisible ( False ) <EOL> self . assertEqual ( c . bound ( ) , IECore . Box3f ( IECore . V3f ( - <NUM_LIT:4> , - <NUM_LIT:0.5> , <NUM_LIT:0> ) , IECore . V3f ( <NUM_LIT:4> , <NUM_LIT:0.5> , <NUM_LIT:0> ) ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
