diff options
author | Kevin Petit <kevin.petit@outlook.com> | 2017-01-19 10:12:51 +0100 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-01-19 11:40:36 -0800 |
commit | a48f2d28e4e70985714d7dc7ff1c37d3ee536e79 (patch) | |
tree | 21ad0722cd2b631b19f070e60f3b82af33444ade /Xamarin.Forms.Controls.Issues | |
parent | 27206618d732d026de4d254aad0865515bc8a7fb (diff) | |
download | xamarin-forms-a48f2d28e4e70985714d7dc7ff1c37d3ee536e79.tar.gz xamarin-forms-a48f2d28e4e70985714d7dc7ff1c37d3ee536e79.tar.bz2 xamarin-forms-a48f2d28e4e70985714d7dc7ff1c37d3ee536e79.zip |
Fix NullReferenceException in VisualElement finalize. (#701)
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
2 files changed, 81 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs new file mode 100644 index 00000000..e9cdebc9 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla51503.cs @@ -0,0 +1,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 + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index e040a049..ba7de6cb 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -222,6 +222,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla28650.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla37431.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44777.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51503.cs" /> <Compile Include="$(MSBuildThisFileDirectory)_Template.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" /> |