Update NavigationUnitTest.cs
This commit is contained in:
Родитель
29ad85ff19
Коммит
a2fee1d21e
|
@ -559,6 +559,26 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
Assert.That (popped, Is.Null);
|
||||
Assert.That (navPage.CurrentPage, Is.SameAs (root));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Property("Bugzilla", 31171)]
|
||||
public async Task ReleasesPoppedPage()
|
||||
{
|
||||
var root = new ContentPage { Title = "Root" };
|
||||
var navPage = new NavigationPage(root);
|
||||
|
||||
var isFinalized = false;
|
||||
|
||||
await navPage.PushAsync(new PageWithFinalizer(() => isFinalized = true));
|
||||
await navPage.PopAsync();
|
||||
|
||||
await Task.Delay(100);
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
Assert.IsTrue(isFinalized);
|
||||
}
|
||||
}
|
||||
|
||||
internal class BackButtonPage : ContentPage
|
||||
|
@ -574,4 +594,18 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
return Handle;
|
||||
}
|
||||
}
|
||||
|
||||
internal class PageWithFinalizer : Page
|
||||
{
|
||||
Action OnFinalize;
|
||||
public PageWithFinalizer(Action onFinalize)
|
||||
{
|
||||
OnFinalize = onFinalize;
|
||||
}
|
||||
|
||||
~PageWithFinalizer()
|
||||
{
|
||||
OnFinalize();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче