tests: replace placebo assertions with real behavior checks
This commit is contained in:
@@ -688,8 +688,8 @@ fn node_behavior_defaults() {
|
||||
assert!(b.value_hint_for_input("in").is_none());
|
||||
assert_eq!(b.connected_render_output(&core, "in", -1), None);
|
||||
let tr = TimeRange::new(Rational::new(0, 1), Rational::new(5, 1));
|
||||
assert_eq!(b.input_time_adjustment("in", -1, tr, true), tr);
|
||||
assert_eq!(b.output_time_adjustment("in", -1, tr, false), tr);
|
||||
assert_eq!(b.input_time_adjustment(&core, "in", -1, tr, true), tr);
|
||||
assert_eq!(b.output_time_adjustment(&core, "in", -1, tr, false), tr);
|
||||
|
||||
// value / process_samples / generate_frame no-ops.
|
||||
let mut table = NodeValueTable::default();
|
||||
|
||||
@@ -248,10 +248,9 @@ fn add_entry_reclaims_the_free_slot() {
|
||||
let fresh = g.add_node(core, Box::new(TestNode { id: "fresh" }));
|
||||
assert_ne!(fresh, victim, "the fresh node takes a different slot");
|
||||
assert!(g.is_valid(victim), "the restored node survives add_node");
|
||||
assert_eq!(
|
||||
g.get(victim).map(|e| e.core.label.as_str()),
|
||||
g.get(victim).map(|e| e.core.label.as_str()),
|
||||
);
|
||||
// The fresh node must not clobber the restored node's slot: the
|
||||
// victim keeps its original (default empty) label.
|
||||
assert_eq!(g.get(victim).map(|e| e.core.label.as_str()), Some(""));
|
||||
assert_eq!(g.node_count(), count_before + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,6 +319,7 @@ fn connected_input_uses_adjusted_time() {
|
||||
}
|
||||
fn input_time_adjustment(
|
||||
&self,
|
||||
_core: &NodeCore,
|
||||
input: &str,
|
||||
_element: i32,
|
||||
time: TimeRange,
|
||||
@@ -353,3 +354,47 @@ fn connected_input_uses_adjusted_time() {
|
||||
"the upstream was evaluated at the doubled time"
|
||||
);
|
||||
}
|
||||
|
||||
/// The real TimeOffsetNode (not a test double) remaps its upstream's
|
||||
/// evaluation time through the trait: the keyframable offset lives on
|
||||
/// the node core, which the trait method now receives. Evaluating the
|
||||
/// offset at t=10 with `time_in` = 5 pulls the upstream at t=15 (C++
|
||||
/// `get_remapped_time`: `input + time_in`).
|
||||
#[test]
|
||||
fn time_offset_node_shifts_upstream_evaluation_time() {
|
||||
struct TimeEcho;
|
||||
impl NodeBehavior for TimeEcho {
|
||||
fn name(&self) -> &str {
|
||||
"TimeEcho"
|
||||
}
|
||||
fn type_id(&self) -> &str {
|
||||
"test.timeecho"
|
||||
}
|
||||
fn duplicate(&self, _c: &NodeCore) -> Option<Box<dyn NodeBehavior>> {
|
||||
Some(Box::new(TimeEcho))
|
||||
}
|
||||
fn value(&self, _c: &NodeCore, _i: &NodeValueRow, t: Rational, table: &mut NodeValueTable) {
|
||||
table.push(ValueType::Rational, NodeValue::Rational(t), None);
|
||||
}
|
||||
}
|
||||
|
||||
let mut g = Graph::new();
|
||||
let src = node_with_input(&mut g, Box::new(TimeEcho));
|
||||
let (mut core, behavior) = oak_node::factory::Factory::global()
|
||||
.create_any("org.olivevideoeditor.Olive.timeoffset")
|
||||
.expect("timeoffset registered");
|
||||
core.set_standard_value("time_in", -1, NodeValue::Rational(Rational::new(5, 1)));
|
||||
let offset = g.add_node(core, behavior);
|
||||
g.connect(src, offset, "input_in", -1).unwrap();
|
||||
|
||||
let mut t = Traverser::new();
|
||||
let mut hooks = Noop;
|
||||
let table = t
|
||||
.evaluate(&g, &EvalRequest::new(offset, Rational::new(10, 1)), &mut hooks)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
table.get(ValueType::Rational),
|
||||
Some(&NodeValue::Rational(Rational::new(15, 1))),
|
||||
"the upstream must be evaluated at the offset time (10 + 5)"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user