Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] [WinUI3] Window cleanup after test runs #4415

Draft
wants to merge 1 commit into
base: winui
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions UnitTests/UnitTests.Notifications.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using Microsoft.UI.Xaml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;

namespace UnitTests.Notifications.WinUI
Expand Down Expand Up @@ -49,5 +50,17 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs e)
// replace back with e.Arguments when https://github.com/microsoft/microsoft-ui-xaml/issues/3368 is fixed
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
}

[AssemblyCleanup]
public static void CleanupWindow()
{
if (_window != null)
{
_window.DispatcherQueue.TryEnqueue(() =>
{
_window.Close();
});
}
}
}
}
13 changes: 13 additions & 0 deletions UnitTests/UnitTests.WinUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
using UnitTests.WinUI;
Expand Down Expand Up @@ -90,5 +91,17 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// replace back with e.Arguments when https://github.com/microsoft/microsoft-ui-xaml/issues/3368 is fixed
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine);
}

[AssemblyCleanup]
public static void CleanupWindow()
{
if(_window != null)
{
DispatcherQueue.TryEnqueue(() =>
{
_window.Close();
});
}
}
}
}