Skip to content

Commit 9f922a6

Browse files
author
Lucio Moser
committed
Adding a unit test module for SceneCacheReader.
1 parent e559734 commit 9f922a6

14 files changed

+266
-0
lines changed

test/IECoreNuke/All.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
from ParameterisedHolderTest import ParameterisedHolderTest
4848
from ObjectKnobTest import ObjectKnobTest
4949
from OpHolderTest import OpHolderTest
50+
from SceneCacheReaderTest import SceneCacheReaderTest
51+
5052
if IECore.withPNG() :
5153
from PNGReaderTest import PNGReaderTest
5254

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
82.2 KB
Binary file not shown.
21.3 KB
Binary file not shown.
23.1 KB
Binary file not shown.
24.9 KB
Binary file not shown.
27.5 KB
Binary file not shown.
31.6 KB
Binary file not shown.
36.4 KB
Binary file not shown.
40.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)