Update composition test to run and pass
@@ -5,14 +5,41 @@ winrt::import!(
"windows.ui.composition"
);
+#[link(name = "coremessaging")]
+extern "stdcall" {
+ fn CreateDispatcherQueueController(
+ options: DispatcherQueueOptions,
+ dispatcherQueueController: *mut winrt::RawPtr,
+ ) -> i32;
+}
+
+#[repr(C)]
+struct DispatcherQueueOptions {
+ size: u32,
+ thread_type: i32,
+ apartment_type: i32,
+}
+
#[test]
-fn uri() -> winrt::Result<()> {
- if false {
+fn composition() -> winrt::Result<()> {
use windows::foundation::numerics::*;
use windows::ui::composition::*;
use windows::ui::*;
use winrt::*;
+ // We need a DispatcherQueue on our thread to properly create a Compositor. Note that since
+ // we aren't pumping messages, the Compositor won't commit. This is fine for the test for now.
+ let options = DispatcherQueueOptions {
+ size: std::mem::size_of::<DispatcherQueueOptions>() as u32,
+ thread_type: 2, // DQTYPE_THREAD_CURRENT
+ apartment_type: 0, // DQTAT_COM_NONE
+ };
+ let _queue_controller = unsafe {
+ let mut interop_ptr = winrt::IUnknown::default();
+ winrt::ErrorCode(CreateDispatcherQueueController(options, interop_ptr.set())).ok()?;
+ interop_ptr
+ };
+
let compositor = Compositor::new()?;
let visual = compositor.create_sprite_visual()?;
let red = Colors::red()?;
@@ -87,7 +114,7 @@ fn uri() -> winrt::Result<()> {
assert!(
iterator.current()?.offset()?
== Vector3 {
- x: 1.0,
+ x: 3.0,
y: 0.0,
z: 0.0,
}
@@ -111,7 +138,7 @@ fn uri() -> winrt::Result<()> {
assert!(
iterator.current()?.offset()?
== Vector3 {
- x: 3.0,
+ x: 1.0,
y: 0.0,
z: 0.0,
}
@@ -119,7 +146,6 @@ fn uri() -> winrt::Result<()> {
assert!(iterator.move_next()? == false);
assert!(iterator.has_current()? == false);
- }
Ok(())
}
