-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Bugzilla59172.cs
118 lines (95 loc) · 2.86 KB
/
Bugzilla59172.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Bugzilla)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla,
59172, "[iOS] Popped page does not appear on top of current navigation stack, please file a bug.",
PlatformAffected.iOS)]
public class Bugzilla59172 : TestNavigationPage
{
protected override void Init()
{
var firstPage = new TestPage();
Navigation.PushAsync(firstPage);
}
[Preserve(AllMembers = true)]
public class TestPage : ContentPage
{
TestPage parent;
Label navigationErrorLabel = new Label();
public TestPage(TestPage parentPage = null)
{
this.parent = parentPage;
var layout = new StackLayout();
var forwardButton = new Button { Text = "Forward", AutomationId = "GoForward" };
layout.Children.Add(forwardButton);
forwardButton.Clicked += Forward_OnClicked;
if (parentPage != null)
{
var backButton = new Button { Text = "Back (Delayed)", AutomationId = "GoBackDelayed" };
layout.Children.Add(backButton);
backButton.Clicked += (a, b) => BackButtonPress(false);
var backButtonSafe = new Button { Text = "Back (Delayed; Safe)", AutomationId = "GoBackDelayedSafe" };
layout.Children.Add(backButtonSafe);
backButtonSafe.Clicked += (a, b) => BackButtonPress(true);
}
layout.Children.Add(navigationErrorLabel);
Content = layout;
}
void Forward_OnClicked(object sender, EventArgs e)
{
Navigation.PushAsync(new TestPage(this));
}
async void BackButtonPress(bool safe)
{
try
{
// Assume some workload that delays the back navigation
await Task.Delay(2500);
await Navigation.PopAsync();
}
catch (Exception ex)
{
if (!safe)
{ throw; }
parent.navigationErrorLabel.Text = ex.Message;
}
}
}
#if UITEST
// Test scenario: Tapping the GoBack link triggers a PopAsync 2500ms after the tap event.
// Right before PopAsync is triggered, manually navigate back pressing the back arrow in the navigation bar
[Test]
public async Task Issue59172Test()
{
RunningApp.Tap(q => q.Marked("GoForward"));
RunningApp.Tap(q => q.Marked("GoBackDelayed"));
RunningApp.Back();
await Task.Delay(1000);
// App should not have crashed
RunningApp.WaitForElement(q => q.Marked("GoForward"));
}
[Test]
public async Task Issue59172RecoveryTest()
{
RunningApp.Tap(q => q.Marked("GoForward"));
RunningApp.Tap(q => q.Marked("GoBackDelayedSafe"));
RunningApp.Back();
await Task.Delay(1000);
RunningApp.Tap(q => q.Marked("GoForward"));
// App should navigate
RunningApp.WaitForElement(q => q.Marked("GoBackDelayedSafe"));
}
#endif
}
}