summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs
new file mode 100644
index 00000000..378077e0
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31255.cs
@@ -0,0 +1,88 @@
+´╗┐using System;
+
+using Xamarin.Forms.CustomAttributes;
+using System.Threading.Tasks;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ [Issue (IssueTracker.Bugzilla, 31255, "Master's page Icon cause memory leak after MasterDetailPage is popped out by holding on page")]
+ public class Bugzilla31255 : TestContentPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init ()
+ {
+ var stack = new StackLayout () { VerticalOptions = LayoutOptions.Center };
+
+ stack.Children.Add (new Label () { VerticalOptions =
+ LayoutOptions.Center, XAlign = TextAlignment.Center, Text = "Page 1"
+ });
+
+ Content = stack;
+
+ }
+
+ WeakReference _page2Tracker;
+
+ protected override async void OnAppearing ()
+ {
+ base.OnAppearing ();
+
+ if (_page2Tracker == null) {
+ var page2 = new Page2 ();
+
+ _page2Tracker = new WeakReference (page2, false);
+
+ await Task.Delay (1000);
+ await Navigation.PushModalAsync (page2);
+
+ StartTrackPage2 ();
+ }
+ }
+
+ async void StartTrackPage2 ()
+ {
+ while (true) {
+ ((Label)((StackLayout)Content).Children [0]).Text =
+ string.Format ("Page1. But Page2 IsAlive = {0}", _page2Tracker.IsAlive);
+ await Task.Delay (1000);
+ GC.Collect ();
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ public class Page2 : MasterDetailPage
+ {
+ public Page2 ()
+ {
+ Master = new Page () { Title = "Master",
+ Icon = "Icon.png"
+ };
+ Detail = new Page () { Title = "Detail" };
+ }
+
+ protected override async void OnAppearing ()
+ {
+ base.OnAppearing ();
+
+ await Task.Delay (1000);
+ await Navigation.PopModalAsync ();
+ }
+ }
+
+ #if UITEST
+ [Test]
+ [Ignore("Fails intermittently on TestCloud")]
+ public async void Bugzilla31255Test ()
+ {
+ RunningApp.Screenshot ("I am at Bugzilla 31255");
+ await Task.Delay (5000);
+ RunningApp.WaitForElement (q => q.Marked ("Page1. But Page2 IsAlive = False"));
+ }
+ #endif
+ }
+}