summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ScrollViewObjectDisposed.cs
blob: 8cd4bcbceb9e743ba8026a6cfe01efa6889b76f3 (plain)
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
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
	}
}