-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
GitHub1355.cs
64 lines (56 loc) · 1.3 KB
/
GitHub1355.cs
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
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Navigation)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1355, "Setting Main Page in quick succession causes crash on Android",
PlatformAffected.Android)]
public class Issue1355 : TestContentPage
{
int _runCount = 0;
int _maxRunCount = 2;
const string Success = "Success";
protected override void Init()
{
Appearing += OnAppearing;
}
private void OnAppearing(object o, EventArgs eventArgs)
{
Application.Current.MainPage = CreatePage();
}
ContentPage CreatePage()
{
var page = new ContentPage
{
Content = new Label { Text = Success },
Title = $"CreatePage Iteration: {_runCount}"
};
page.Appearing += (sender, args) =>
{
_runCount += 1;
if (_runCount <= _maxRunCount)
{
Application.Current.MainPage = new NavigationPage(CreatePage());
}
};
return page;
}
#if UITEST
[Test]
public void SwitchMainPageOnAppearing()
{
// Without the fix, this would crash. If we're here at all, the test passed.
RunningApp.WaitForElement(Success);
}
#endif
}
}