summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla36955.cs
blob: 9649bfbdf09839c5e865b6aa316b2cbba436ace4 (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
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 36955, "[iOS] ViewCellRenderer.UpdateIsEnabled referencing null object", PlatformAffected.iOS)]
	public class Bugzilla36955 : TestContentPage
	{
		protected override void Init()
		{
			var ts = new TableSection();
			var tr = new TableRoot { ts };
			var tv = new TableView(tr);

			var sc = new SwitchCell
			{
				Text = "Toggle switch; nothing should crash"
			};

			var button = new Button();
			button.SetBinding(Button.TextProperty, new Binding("On", source: sc));

			var vc = new ViewCell
			{
				View = button
			};
			vc.SetBinding(IsEnabledProperty, new Binding("On", source: sc));

			ts.Add(sc);
			ts.Add(vc);

			Content = tv;
		}

#if UITEST && __IOS__
		[Ignore("Test failing due to unrelated issue, disable for moment")]
		[Test]
		public void Bugzilla36955Test()
		{
			AppResult[] buttonFalse = RunningApp.Query(q => q.Button().Text("False"));
			Assert.AreEqual(buttonFalse.Length == 1, true);
			RunningApp.Tap(q => q.Class("Switch"));
			AppResult[] buttonTrue = RunningApp.Query(q => q.Button().Text("True"));
			Assert.AreEqual(buttonTrue.Length == 1, true);
		}
#endif
	}
}