Skip to content

Commit

Permalink
chore: Partial fix only for UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Dec 20, 2023
1 parent cd058ca commit 256db03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ internal set
/// <returns></returns>
public static async Task WaitForIdle()
{
await RootElementDispatcher.RunAsync(UnitTestDispatcherCompat.Priority.Idle, () => { });
await RootElementDispatcher.RunAsync(UnitTestDispatcherCompat.Priority.Idle, () => { });
#if WINDOWS_WINUI || HAS_UNO_WINUI
// This is a wrong implementation. It doesn't really wait for "Idle".
await RootElementDispatcher.RunAsync(UnitTestDispatcherCompat.Priority.Low, () => { });
await RootElementDispatcher.RunAsync(UnitTestDispatcherCompat.Priority.Low, () => { });
#else
await RootElementDispatcher.RunIdleAsync(_ => { /* Empty to wait for the idle queue to be reached */ });
await RootElementDispatcher.RunIdleAsync(_ => { /* Empty to wait for the idle queue to be reached */ });
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ namespace Uno.UI.RuntimeTests.Internal.Helpers;

public partial class UnitTestDispatcherCompat
{
public enum Priority { Idle = -2, Low = -1, Normal = 0, High = 1 }
public enum Priority { Low = -1, Normal = 0, High = 1 }

private static _Priority RemapPriority(Priority priority) => priority switch
{
Priority.Idle => _Priority.Idle,
Priority.Low => _Priority.Low,
Priority.Normal => _Priority.Normal,
Priority.High => _Priority.High,
Expand All @@ -52,7 +51,12 @@ public UnitTestDispatcherCompat(_Impl impl)
this._impl = impl;
}

public static UnitTestDispatcherCompat From(UIElement x) =>
#if !WINDOWS_WINUI && !HAS_UNO_WINUI
public Windows.Foundation.IAsyncAction RunIdleAsync(Windows.UI.Core.IdleDispatchedHandler agileCallback)
=> _impl.RunIdleAsync(agileCallback);
#endif

public static UnitTestDispatcherCompat From(UIElement x) =>
#if HAS_UNO_WINUI || WINDOWS_WINUI
new UnitTestDispatcherCompat(x.DispatcherQueue);
#else
Expand Down

0 comments on commit 256db03

Please sign in to comment.