Skip to content

Commit

Permalink
[tests] CV 2 devicetests (#25078)
Browse files Browse the repository at this point in the history
* [tests] Run Device tests with CV2

* Make sure to run on UI thread
  • Loading branch information
rmarinho authored Oct 4, 2024
1 parent add2226 commit cfef6a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ protected override void DisconnectHandler(UIView platformView)
{
ItemsView.ScrollToRequested -= ScrollToRequested;
_layout = null;
Controller?.DisposeItemsSource();
MauiContext?.GetDispatcher()?.Dispatch(() =>
{
Controller?.DisposeItemsSource();
});
base.DisconnectHandler(platformView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void Items.MauiCollectionView.ICustomMauiCollectionViewDelegate.MovedToWindow(UI
DetachingFromWindow();
}
}

internal void DisposeItemsSource()
{
ItemsSource?.Dispose();
Expand Down
10 changes: 10 additions & 0 deletions src/Core/tests/DeviceTests.Shared/MauiProgramDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public static MauiApp CreateMauiApp(List<Assembly> testAssemblies)
{
RequiresUIContext = true,
});
#endif

#if IOS || MACCATALYST

appBuilder.ConfigureMauiHandlers(handlers =>
{
handlers.AddHandler<Microsoft.Maui.Controls.CollectionView, Microsoft.Maui.Controls.Handlers.Items2.CollectionViewHandler2>();
handlers.AddHandler<Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls.Handlers.Items2.CarouselViewHandler2>();
});

#endif
appBuilder.UseVisualRunner();

Expand Down

0 comments on commit cfef6a3

Please sign in to comment.