Skip to content

Commit 3ab03c5

Browse files
committed
Fix tests, probably
1 parent 9a38e02 commit 3ab03c5

File tree

2 files changed

+39
-23
lines changed

2 files changed

+39
-23
lines changed

node-graph/gcore/src/raster/adjustments.rs

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,28 +1414,6 @@ async fn color_overlay<F: 'n + Copy + Send, T: Adjust<Color>>(
14141414
input
14151415
}
14161416

1417-
#[test]
1418-
fn color_overlay_multiply() {
1419-
use crate::raster::Image;
1420-
1421-
let image_color = Color::from_rgbaf32_unchecked(0.7, 0.6, 0.5, 0.4);
1422-
let image = ImageFrame {
1423-
image: Image::new(1, 1, image_color),
1424-
..Default::default()
1425-
};
1426-
1427-
// Color { red: 0., green: 1., blue: 0., alpha: 1. }
1428-
let overlay_color = Color::GREEN;
1429-
1430-
// 100% of the output should come from the multiplied value
1431-
let opacity = 100_f64;
1432-
1433-
let result = color_overlay(image, overlay_color, BlendMode::Multiply, opacity);
1434-
1435-
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
1436-
assert_eq!(result.image.data[0], Color::from_rgbaf32_unchecked(0., image_color.g(), 0., image_color.a()));
1437-
}
1438-
14391417
#[cfg(feature = "alloc")]
14401418
pub use index_node::IndexNode;
14411419

@@ -1453,3 +1431,41 @@ mod index_node {
14531431
}
14541432
}
14551433
}
1434+
1435+
#[cfg(test)]
1436+
mod test {
1437+
use crate::raster::{BlendMode, Image, ImageFrame};
1438+
use crate::{Color, Node};
1439+
use std::pin::Pin;
1440+
1441+
#[derive(Clone)]
1442+
pub struct FutureWrapperNode<T: Clone>(T);
1443+
1444+
impl<'i, T: 'i + Clone + Send> Node<'i, ()> for FutureWrapperNode<T> {
1445+
type Output = Pin<Box<dyn core::future::Future<Output = T> + 'i + Send>>;
1446+
fn eval(&'i self, _input: ()) -> Self::Output {
1447+
let value = self.0.clone();
1448+
Box::pin(async move { value })
1449+
}
1450+
}
1451+
1452+
#[tokio::test]
1453+
async fn color_overlay_multiply() {
1454+
let image_color = Color::from_rgbaf32_unchecked(0.7, 0.6, 0.5, 0.4);
1455+
let image = ImageFrame {
1456+
image: Image::new(1, 1, image_color),
1457+
..Default::default()
1458+
};
1459+
1460+
// Color { red: 0., green: 1., blue: 0., alpha: 1. }
1461+
let overlay_color = Color::GREEN;
1462+
1463+
// 100% of the output should come from the multiplied value
1464+
let opacity = 100_f64;
1465+
1466+
let result = super::color_overlay((), &FutureWrapperNode(image), overlay_color, BlendMode::Multiply, opacity).await;
1467+
1468+
// The output should just be the original green and alpha channels (as we multiply them by 1 and other channels by 0)
1469+
assert_eq!(result.image.data[0], Color::from_rgbaf32_unchecked(0., image_color.g(), 0., image_color.a()));
1470+
}
1471+
}

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ mod test {
748748
async fn morph() {
749749
let source = Subpath::new_rect(DVec2::ZERO, DVec2::ONE * 100.);
750750
let target = Subpath::new_ellipse(DVec2::NEG_ONE * 100., DVec2::ZERO);
751-
let sample_points = super::morph(Footprint::default(), &vector_node(source), &vector_node(target), 0, 0.5).await;
751+
let sample_points = super::morph(Footprint::default(), &vector_node(source), &vector_node(target), 0.5, 0).await;
752752
assert_eq!(
753753
&sample_points.point_domain.positions()[..4],
754754
vec![DVec2::new(-25., -50.), DVec2::new(50., -25.), DVec2::new(25., 50.), DVec2::new(-50., 25.)]

0 commit comments

Comments
 (0)