Permalink
Browse files

Add test and fix for trimmed_range_in_parent (#401)

If you ask for the trimmed_range_in_parent() for a clip that is completely trimmed out, then it returns None.
  • Loading branch information...
ssteinbach authored and jminor committed Dec 14, 2018
1 parent bbf248a commit 68ab3449baa6d598a01b46c98afac5e5018a04df
Showing with 65 additions and 1 deletion.
  1. +1 −1 opentimelineio/core/composition.py
  2. +64 −0 tests/test_composition.py
@@ -374,7 +374,7 @@ def trimmed_range_of_child(self, child, reference_space=None):
result_range.start_time += parent_range.start_time
current = parent

if not self.source_range:
if not self.source_range or not result_range:
return result_range

new_start_time = max(
@@ -903,6 +903,70 @@ def test_range_of_child(self):
with self.assertRaises(otio.exceptions.NotAChildError):
otio.schema.Clip().trimmed_range_in_parent()

def test_range_trimmed_out(self):
track = otio.schema.Track(
name="top_track",
children=[
otio.schema.Clip(
name="clip1",
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(
value=100,
rate=24
),
duration=otio.opentime.RationalTime(
value=50,
rate=24
)
)
),
otio.schema.Clip(
name="clip2",
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(
value=101,
rate=24
),
duration=otio.opentime.RationalTime(
value=50,
rate=24
)
)
),
],
# should trim out clip 1
source_range=otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(60, 24),
duration=otio.opentime.RationalTime(10, 24)
)
)

# should be trimmed out, at the moment, the sentinel for that is None
nothing = track.trimmed_range_of_child_at_index(0)
self.assertIsNone(nothing)

# should the same as above
nothing = track[0].trimmed_range_in_parent()
self.assertIsNone(nothing)

not_nothing = track.trimmed_range_of_child_at_index(1)
self.assertEqual(not_nothing, track.source_range)

# should trim out second clip
track.source_range = otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(10, 24)
)

nothing = track.trimmed_range_of_child_at_index(1)
self.assertIsNone(nothing)

nothing = track[1].trimmed_range_in_parent()
self.assertIsNone(nothing)

not_nothing = track.trimmed_range_of_child_at_index(0)
self.assertEqual(not_nothing, track.source_range)

def test_range_nested(self):
track = otio.schema.Track(
name="inner",

0 comments on commit 68ab344

Please sign in to comment.