summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25662.cs
blob: 0ec8540c4764369ba643d282403847d1fbd7a475 (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
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, 25662, "Setting IsEnabled does not disable SwitchCell")]
    public class Bugzilla25662 : TestContentPage
    {
		[Preserve(AllMembers = true)]
		class MySwitch : SwitchCell
		{
			public MySwitch ()
			{
				IsEnabled = false;
				SetBinding(SwitchCell.TextProperty, new Binding("."));
				OnChanged += (sender, e) => Text = "FAIL";
			}
		}

		protected override void Init ()
		{
			var list = new ListView {
				ItemsSource = new[] {
					"One", "Two", "Three"
				},
				ItemTemplate = new DataTemplate (typeof (MySwitch))
			};

			Content = list;
		}

#if UITEST
		[Test]
		public void Bugzilla25662Test ()
		{
            RunningApp.WaitForElement (q => q.Marked ("One"));
			RunningApp.Tap(q => q.Marked("One"));
			RunningApp.WaitForNoElement(q => q.Marked("FAIL"));
		}
#endif
	}
}