summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26501.cs
blob: 54c634bd903ae71c2f8403c5a23223da797707a2 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
using Xamarin.UITest;
#endif

namespace Xamarin.Forms.Controls.TestCasesPages
{
	[Preserve (AllMembers = true)]
	public class FamilyViewModel
	{
		public Guid ProfileId { get; set; }
		public string DisplayName { get; set; }
		public string ImageFilename { get; set; }
		public string BonusBalance { get; set; }
		public string MemberNo { get; set; }

		public FamilyViewModel ()
		{
			ProfileId = Guid.Empty;
			DisplayName = "";
			BonusBalance = "";
			MemberNo = "";
			ImageFilename = "";
		}
	}

	[Preserve (AllMembers = true)]
	public class FamilyCell : ViewCell
	{
		public Label FamilyLabel;

		public FamilyCell ()
		{
			FamilyLabel = new Label ();

			var l1 = new RelativeLayout ();

			l1.Children.Add (FamilyLabel,
			                 Constraint.Constant (50),
			                 Constraint.Constant (4),
			                 Constraint.RelativeToParent (p => p.Width - 10 - 50 - 85)
				);


			View = l1;

			FamilyLabel.SetBinding (Label.TextProperty, "DisplayName");

			// COMMENT LINE BELOW OUT TO MAKE IT WORK!
			AddContextActions ();
		}

		void AddContextActions ()
		{
			ContextActions.Add (new MenuItem () {
				Text = "Delete",
				IsDestructive = true,
				Command = new Command (Delete)
			});

			ContextActions.Add (new MenuItem () {
				Text = "More",
				IsDestructive = false,
				Command = new Command (More)
			});
		}

		void Delete ()
		{
		}

		void More ()
		{
		}
	}

	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Bugzilla, 26501, "BindingSource / Context action issue", PlatformAffected.iOS)]
	public class Bugzilla26501 : TestContentPage
	{
		protected override void Init ()
		{
			//TODO: Multilanguage
			Title = "Context Action Bug";

			_familyListView = new ListView () {
				RowHeight = 50,
				ItemTemplate = new DataTemplate (typeof (FamilyCell)),
				HasUnevenRows = true
			};

			//TODO: Multilanguage
			ToolbarItems.Add (new ToolbarItem ("Refresh", "", () => {
				_familyListView.ItemsSource = _demoDataSource2;
			}));


			_familyListView.ItemSelected += (sender, e) => _familyListView.SelectedItem = null;

			Content = _familyListView;

			UpdateData ();
		}

		readonly FamilyViewModel[] _demoDataSource = new FamilyViewModel[] {
			new FamilyViewModel {DisplayName = "ZOOMER robothund"},
			new FamilyViewModel {DisplayName = "FROST sengetųj"},
			new FamilyViewModel {DisplayName = "BEADOS Quick Dry designstation"},
			new FamilyViewModel {DisplayName = "Redningsstation i junglen"},
		};

		readonly FamilyViewModel[] _demoDataSource2 = new FamilyViewModel[] {
			new FamilyViewModel {DisplayName = "ZOOMER robothund"},
			new FamilyViewModel {DisplayName = "FROST sengetųj"},
			new FamilyViewModel {DisplayName = "BEADOS Quick Dry designstation"},
			new FamilyViewModel {DisplayName = "Redningsstation i junglen"},
			new FamilyViewModel {DisplayName = "CHAMPIONS LEAGUE 2014/15 boosterpakke"},
			new FamilyViewModel {DisplayName = "NEW BORN BABY luksusęske med dukke"},
			new FamilyViewModel {DisplayName = "FURBY Boom Festive Sweater elektronisk plysdyr"},
			new FamilyViewModel {DisplayName = "LEGO FRIENDS 41007 Heartlake hundesalon"},
			new FamilyViewModel {DisplayName = "LEGO CITY 4204 Minen"}
		};

		ListView _familyListView;

		List<FamilyViewModel> _itemSource;

		void UpdateData ()
		{
			Device.BeginInvokeOnMainThread (() => _familyListView.ItemsSource = _demoDataSource);
		}

#if UITEST
		[Test]
		public void TestCellsShowAfterRefresh ()
		{
			RunningApp.Tap (q => q.Marked ("Refresh"));

			// make sure the refresh has completed
			System.Threading.Thread.Sleep (1);

			RunningApp.WaitForElement (q => q.Marked ("ZOOMER robothund"));
		}
#endif
	}
}