Skip to content

Commit

Permalink
Added a failing test case to GafferImageTest.ImageTransformTest that …
Browse files Browse the repository at this point in the history
…highlights a bug that has

been introduced since the node was first written.
  • Loading branch information
goddardl authored and johnhaddon committed May 12, 2014
1 parent 5fc6096 commit 4798997
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions python/GafferImageTest/ImageTransformTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##########################################################################
#
# Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
# Copyright (c) 2013-2014, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
Expand All @@ -26,8 +26,8 @@
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR
# PROFITS OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Expand Down Expand Up @@ -59,10 +59,36 @@ def testIdentityHash( self ) :
c["image:channelName"] = "R"
c["image:tileOrigin"] = IECore.V2i( 0 )
with c :
h1 = t["out"].hash();
h2 = r["out"].hash();
h1 = t["out"].hash()
h2 = r["out"].hash()
self.assertEqual( h1, h2 )


def testKnownFailure( self ) :
'''Highlights a bug that has been introduced since a previous version (tested against 0.83.0).'''

r = GafferImage.ImageReader()
r["fileName"].setValue( os.path.join( self.path, "rgb.100x100.exr" ) )

t = GafferImage.ImageTransform()
t["in"].setInput( r["out"] )
t["transform"]["rotate"].setValue( 1. )
t["transform"]["scale"].setValue( IECore.V2f( 1.5, 1. ) )
imageToTest = t["out"].image()
imageToTest.blindData().clear()

r2 = GafferImage.ImageReader()
r2["fileName"].setValue( os.path.join( self.path, "knownTransformBug.exr" ) )
expectedImage = r2['out'].image()
expectedImage.blindData().clear()

op = IECore.ImageDiffOp()
res = op(
imageA = imageToTest,
imageB = expectedImage
)

self.assertFalse( res.value )

def testScaleHash( self ) :

r = GafferImage.ImageReader()
Expand All @@ -71,9 +97,9 @@ def testScaleHash( self ) :
t = GafferImage.ImageTransform()
t["in"].setInput( r["out"] )

h1 = t["__scaledFormat"].hash();
t["transform"]["scale"].setValue( IECore.V2f( 2., 2. ) );
h2 = t["__scaledFormat"].hash();
h1 = t["__scaledFormat"].hash()
t["transform"]["scale"].setValue( IECore.V2f( 2., 2. ) )
h2 = t["__scaledFormat"].hash()
self.assertNotEqual( h1, h2 )

def testDirtyPropagation( self ) :
Expand All @@ -85,7 +111,7 @@ def testDirtyPropagation( self ) :
t["in"].setInput( r["out"] )

cs = GafferTest.CapturingSlot( t.plugDirtiedSignal() )
t["transform"]["scale"].setValue( IECore.V2f( 2., 2. ) );
t["transform"]["scale"].setValue( IECore.V2f( 2., 2. ) )

dirtiedPlugs = set( [ x[0].relativeName( x[0].node() ) for x in cs ] )
self.assertEqual( len( dirtiedPlugs ), 8 )
Expand All @@ -105,7 +131,7 @@ def testOutputFormat( self ) :

t = GafferImage.ImageTransform()
t["in"].setInput( r["out"] )
t["transform"]["translate"].setValue( IECore.V2f( 2., 2. ) );
t["transform"]["translate"].setValue( IECore.V2f( 2., 2. ) )

c = Gaffer.Context()
c["image:channelName"] = "R"
Expand All @@ -128,7 +154,7 @@ def testHashPassThrough( self ) :
with c :
self.assertEqual( r["out"].hash(), t["out"].hash() )

t["transform"]["translate"].setValue( IECore.V2f( 20., 20.5 ) );
t["transform"]["translate"].setValue( IECore.V2f( 20., 20.5 ) )
self.assertNotEqual( r["out"].hash(), t["out"].hash() )

def testDisabled( self ) :
Expand All @@ -144,8 +170,8 @@ def testDisabled( self ) :
c["image:tileOrigin"] = IECore.V2i( 0 )
with c:
cs = GafferTest.CapturingSlot( t.plugDirtiedSignal() )
t["transform"]["translate"].setValue( IECore.V2f( 2., 2. ) );
t["transform"]["rotate"].setValue( 90 );
t["transform"]["translate"].setValue( IECore.V2f( 2., 2. ) )
t["transform"]["rotate"].setValue( 90 )
t["enabled"].setValue( True )
self.assertNotEqual( r["out"].hash(), t["out"].hash() )

Expand Down
Binary file added python/GafferTest/images/knownTransformBug.exr
Binary file not shown.

0 comments on commit 4798997

Please sign in to comment.