blob: e9cdebc91a4fe0dc6b7f07535fe526b685f7d53d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 51503, "NullReferenceException on VisualElement Finalize", PlatformAffected.All)]
public class Bugzilla51503 : TestNavigationPage
{
protected override void Init()
{
PushAsync(new RootPage());
}
[Preserve(AllMembers = true)]
class RootPage : ContentPage
{
public RootPage()
{
Button button = new Button
{
AutomationId = "Button",
Text = "Open"
};
button.Clicked += Button_Clicked;
Content = button;
}
async void Button_Clicked(object sender, EventArgs e)
{
GC.Collect();
GC.WaitForPendingFinalizers();
await Navigation.PushAsync(new ChildPage());
}
}
[Preserve(AllMembers = true)]
class ChildPage : ContentPage
{
public ChildPage()
{
Content = new Label
{
AutomationId = "VisualElement",
Text = "Navigate 3 times to this page",
Triggers =
{
new EventTrigger()
}
};
}
}
#if UITEST
[Test]
public void Issue51503Test()
{
for (int i = 0; i < 3; i++)
{
RunningApp.WaitForElement(q => q.Marked("Button"));
RunningApp.Tap(q => q.Marked("Button"));
RunningApp.WaitForElement(q => q.Marked("VisualElement"));
RunningApp.Back();
}
}
#endif
}
}
|