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
|
using System;
using Xamarin.Forms.CustomAttributes;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls
{
[Preserve (AllMembers = true)]
[Issue (IssueTracker.Bugzilla, 30324, "Detail view of MasterDetailPage does not get appearance events on Android when whole MasterDetailPage disappears/reappears")]
public class Bugzilla30324 : TestNavigationPage
{
Label _lbl;
int _count;
protected override void Init ()
{
MasterDetailPage page = new MasterDetailPage();
page.Master = new Page () { Title = "Master", BackgroundColor = Color.Red };
_lbl = new Label ();
var otherPage = new ContentPage () {
Title = "Other",
Content = new StackLayout { Children = {
new Button () {
Text = "navigate back",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Command = new Command (() => Navigation.PopAsync())
}
}
}
};
page.Detail = new ContentPage () {
Title = "Detail",
Content = new StackLayout { Children = {
_lbl,
new Button () {
Text = "navigate",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center,
Command = new Command (() => Navigation.PushAsync (otherPage))
}
}
}
};
page.Appearing += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("Appear MDP");
};
page.Disappearing += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("Disappear MDP");
};
page.Detail.Appearing += (sender, args) =>
{
if(_count ==2)
_lbl.Text = "Appear detail";
System.Diagnostics.Debug.WriteLine("Appear detail");
};
page.Detail.Disappearing += (sender, args) => {
System.Diagnostics.Debug.WriteLine ("Disappear detail");
_lbl.Text = "Disappear detail";
page.Detail.BackgroundColor = Color.Green;
_count++;
};
page.Master.Appearing += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("Appear master");
};
Navigation.PushAsync (page);
}
#if UITEST
[Test]
public void Bugzilla30324Test ()
{
RunningApp.Tap (q => q.Marked ("navigate"));
RunningApp.Tap (q => q.Marked ("navigate back"));
RunningApp.WaitForElement (q => q.Marked ("Disappear detail"));
RunningApp.Tap (q => q.Marked ("navigate"));
RunningApp.Tap (q => q.Marked ("navigate back"));
RunningApp.WaitForElement (q => q.Marked ("Appear detail"));
}
#endif
}
}
|