|
| 1 | +########################################################################## |
| 2 | +# |
| 3 | +# Copyright (c) 2014, Image Engine Design Inc. All rights reserved. |
| 4 | +# |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions are |
| 7 | +# met: |
| 8 | +# |
| 9 | +# * Redistributions of source code must retain the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer. |
| 11 | +# |
| 12 | +# * Redistributions in binary form must reproduce the above copyright |
| 13 | +# notice, this list of conditions and the following disclaimer in the |
| 14 | +# documentation and/or other materials provided with the distribution. |
| 15 | +# |
| 16 | +# * Neither the name of Image Engine Design nor the names of any |
| 17 | +# other contributors to this software may be used to endorse or |
| 18 | +# promote products derived from this software without specific prior |
| 19 | +# written permission. |
| 20 | +# |
| 21 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 22 | +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 23 | +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 24 | +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 25 | +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 26 | +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 27 | +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 28 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 29 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | +# |
| 33 | +########################################################################## |
| 34 | + |
| 35 | +import unittest |
| 36 | +import IECoreNuke |
| 37 | +import IECore |
| 38 | +import os |
| 39 | +import nuke |
| 40 | +from glob import glob |
| 41 | + |
| 42 | +class SceneCacheReaderTest( IECoreNuke.TestCase ) : |
| 43 | + |
| 44 | + def setUp( self ) : |
| 45 | + nuke.scriptClear() |
| 46 | + |
| 47 | + def tearDown( self ) : |
| 48 | + nuke.scriptClear() |
| 49 | + for f in glob( "test/IECoreNuke/scripts/data/sceneCacheTestResults*.exr" ) : |
| 50 | + try: |
| 51 | + os.remove(f) |
| 52 | + except: |
| 53 | + pass |
| 54 | + |
| 55 | + def testLoadedScriptWithRetime( self ) : |
| 56 | + |
| 57 | + nuke.scriptOpen("test/IECoreNuke/scripts/sceneCacheTest.nk" ) |
| 58 | + w = nuke.toNode("Write1") |
| 59 | + frames = [ 1, 10, 20, 30, 40, 50, 60, 70, 80 ] |
| 60 | + nuke.executeMultiple( [ w ], map( lambda f: (f,f,1), frames ) ) |
| 61 | + for f in frames : |
| 62 | + imageA = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheExpectedResults.%04d.exr" % f )() |
| 63 | + imageB = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheTestResults.%04d.exr" % f )() |
| 64 | + self.assertEqual( IECore.ImageDiffOp()( imageA = imageA, imageB = imageB, maxError = 0.05 ).value, False ) |
| 65 | + |
| 66 | + n = nuke.toNode("ieSceneCacheReader4") |
| 67 | + v = n.knob('sceneView') |
| 68 | + self.assertEqual( set(v.getSelectedItems()), set(['/root/A/a']) ) |
| 69 | + |
| 70 | + # now force loading A+B and test in frame 20 |
| 71 | + v.setSelectedItems(['/root/A/a', '/root/B/b']) |
| 72 | + self.assertEqual( set(v.getSelectedItems()), set(['/root/A/a', '/root/B/b']) ) |
| 73 | + nuke.executeMultiple( [ w ], [(20,20,1)] ) |
| 74 | + imageA = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheExpectedResultsB.0020.exr" )() |
| 75 | + imageB = IECore.Reader.create( "test/IECoreNuke/scripts/data/sceneCacheTestResults.0020.exr" )() |
| 76 | + self.assertEqual( IECore.ImageDiffOp()( imageA = imageA, imageB = imageB, maxError = 0.05 ).value, False ) |
| 77 | + |
| 78 | +if __name__ == "__main__": |
| 79 | + unittest.main() |
| 80 | + |
0 commit comments