diff options
author | Samantha Houts <samhouts@users.noreply.github.com> | 2017-07-24 13:38:34 -0700 |
---|---|---|
committer | Stephane Delcroix <stephane@delcroix.org> | 2017-07-24 16:38:34 -0400 |
commit | 60db754eb7171d5b691fe7ae85ef25c4dcef464f (patch) | |
tree | c8a118e232ae1a21f579a3f5c50719b14c171903 /Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared | |
parent | b12f0b3bb71dfa22ac91d0d07463a7da7646e049 (diff) | |
download | xamarin-forms-60db754eb7171d5b691fe7ae85ef25c4dcef464f.tar.gz xamarin-forms-60db754eb7171d5b691fe7ae85ef25c4dcef464f.tar.bz2 xamarin-forms-60db754eb7171d5b691fe7ae85ef25c4dcef464f.zip |
[Android] Prevent ObjectDisposed exceptions on Fast Renderers (#1033)
* Add repro for object disposed exception
* [Android] Clear Renderer property from Element on dispose
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared')
2 files changed, 66 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ScrollViewObjectDisposed.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ScrollViewObjectDisposed.cs new file mode 100644 index 00000000..8cd4bcbc --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ScrollViewObjectDisposed.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +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.None, 0, "Object Disposed Exception in ScrollViewContainer", PlatformAffected.Android)] + public class ScrollViewObjectDisposed : TestContentPage + { + const string Instructions = "Tap the button. If the app does not crash and the red label displays \"Success\", this test has passed."; + const string Success = "Success"; + const string TestButtonId = "TestButtonId"; + + Label _status = new Label() { Text = "Test is running...", BackgroundColor = Color.Red, TextColor = Color.White }; + + ScrollView _scroll = new ScrollView(); + + protected override void Init() + { + _scroll.Content = _status; + + InitTest(); + } + + void InitTest() + { + + Button nextButton = new Button { Text = "Next", AutomationId = TestButtonId }; + nextButton.Clicked += NextButton_Clicked; + + StackLayout stack = new StackLayout + { + Children = { new Label { Text = Instructions }, _scroll, nextButton } + }; + + Content = stack; + } + + void NextButton_Clicked(object sender, EventArgs e) + { + _status.Text = ""; + + InitTest(); + + _status.Text = Success; + } + +#if UITEST + [Test] + public void ScrollViewObjectDisposedTest () + { + RunningApp.Tap(q => q.Marked(TestButtonId)); + RunningApp.WaitForElement(q => q.Marked(Success)); + } +#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 04954748..ae6e9fcd 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 @@ -309,6 +309,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla56896.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla40161.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzila57749.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)ScrollViewObjectDisposed.cs" /> <Compile Include="$(MSBuildThisFileDirectory)_Template.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" /> |