Composition test
@@ -15,6 +15,7 @@ fn uri() -> winrt::Result<()> {
let compositor = Compositor::new()?;
let visual = compositor.create_sprite_visual()?;
let red = Colors::red()?;
+
assert!(
red == Color {
a: 255,
@@ -32,6 +33,7 @@ fn uri() -> winrt::Result<()> {
y: 2.0,
z: 3.0,
})?;
+
assert!(
visual.offset()?
== Vector3 {
@@ -40,6 +42,75 @@ fn uri() -> winrt::Result<()> {
z: 3.0
}
);
+
+ let children = visual.children()?;
+
+ let child = compositor.create_sprite_visual()?;
+ child.set_offset(Vector3 {
+ x: 1.0,
+ y: 0.0,
+ z: 0.0,
+ })?;
+ children.insert_at_bottom(child)?;
+
+ let child = compositor.create_sprite_visual()?;
+ child.set_offset(Vector3 {
+ x: 2.0,
+ y: 0.0,
+ z: 0.0,
+ })?;
+ children.insert_at_bottom(child)?;
+
+ let child = compositor.create_sprite_visual()?;
+ child.set_offset(Vector3 {
+ x: 3.0,
+ y: 0.0,
+ z: 0.0,
+ })?;
+ children.insert_at_bottom(child)?;
+
+ assert!(children.count()? == 3);
+
+ // TODO: Collection iteration is still crude but at least the underlying collection interfaces are working.
+
+ let iterator = children.first()?;
+ assert!(iterator.has_current()?);
+
+ assert!(
+ iterator.current()?.offset()?
+ == Vector3 {
+ x: 1.0,
+ y: 0.0,
+ z: 0.0,
+ }
+ );
+
+ assert!(iterator.move_next()?);
+ assert!(iterator.has_current()?);
+
+ assert!(
+ iterator.current()?.offset()?
+ == Vector3 {
+ x: 2.0,
+ y: 0.0,
+ z: 0.0,
+ }
+ );
+
+ assert!(iterator.move_next()?);
+ assert!(iterator.has_current()?);
+
+ assert!(
+ iterator.current()?.offset()?
+ == Vector3 {
+ x: 3.0,
+ y: 0.0,
+ z: 0.0,
+ }
+ );
+
+ assert!(iterator.move_next()? == false);
+ assert!(iterator.has_current()? == false);
}
Ok(())
