<s> import unittest <EOL> import weakref <EOL> import IECore <EOL> import GafferTest <EOL> import GafferUI <EOL> class RenderableGadgetTest ( unittest . TestCase ) : <EOL> class TestProcedural ( IECore . ParameterisedProcedural ) : <EOL> def __init__ ( self , level = <NUM_LIT:0> ) : <EOL> IECore . ParameterisedProcedural . __init__ ( self , "<STR_LIT>" ) <EOL> self . __level = level <EOL> def doBound ( self , args ) : <EOL> return IECore . Box3f ( IECore . V3f ( - <NUM_LIT:1> ) , IECore . V3f ( <NUM_LIT:1> ) ) <EOL> def doRender ( self , renderer , args ) : <EOL> if self . __level < <NUM_LIT:3> : <EOL> RenderableGadgetTest . TestProcedural ( self . __level + <NUM_LIT:1> ) . render ( renderer ) <EOL> def testSetRenderableWithThreadedProcedural ( self ) : <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:100> ) : <EOL> b = GafferUI . RenderableGadget ( None ) <EOL> b . setRenderable ( self . TestProcedural ( ) ) <EOL> def testConstructWithThreadedProcedural ( self ) : <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:100> ) : <EOL> b = GafferUI . RenderableGadget ( self . TestProcedural ( ) ) <EOL> def testDefaultConstructor ( self ) : <EOL> b = GafferUI . RenderableGadget ( ) <EOL> self . assertEqual ( b . getRenderable ( ) , None ) <EOL> def testRenderRequestSignal ( self ) : <EOL> g = GafferUI . RenderableGadget ( ) <EOL> def f ( gg ) : <EOL> self . failUnless ( g . isSame ( gg ) ) <EOL> c = g . renderRequestSignal ( ) . connect ( f ) <EOL> g . setRenderable ( IECore . SpherePrimitive ( ) ) <EOL> def testSelection ( self ) : <EOL> g = GafferUI . RenderableGadget ( ) <EOL> selection = g . getSelection ( ) <EOL> self . assertEqual ( selection , set ( ) ) <EOL> w = weakref . ref ( selection ) <EOL> del selection <EOL> self . failUnless ( w ( ) is None ) <EOL> cs = GafferTest . CapturingSlot ( g . selectionChangedSignal ( ) ) <EOL> g . setSelection ( set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( g . getSelection ( ) , set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( len ( cs ) , <NUM_LIT:1> ) <EOL> g . setSelection ( set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( g . getSelection ( ) , set ( [ "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( len ( cs ) , <NUM_LIT:1> ) <EOL> g . setSelection ( set ( [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( g . getSelection ( ) , set ( [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( len ( cs ) , <NUM_LIT:2> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
