summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla36802.cs
blob: 20b9b30788048731e791a1917d87e1f6d4abd4cf (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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Linq;
using System.Collections.ObjectModel;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{

    [Preserve(AllMembers = true)]
    [Issue(IssueTracker.Bugzilla, 36802, "[iOS] AccessoryView Partially Hidden When Using RecycleElement and GroupShortName", PlatformAffected.iOS)]
    public class Bugzilla36802 : TestContentPage
    {
        const string Instructions = "On iOS, all the list items below should have an AccessoryView visible. If any are not visible or are covered by the section index list then this test has failed.";
        ObservableCollection<GroupedItem> grouped { get; set; }
        ListView lstView;

        public class AccessoryViewCell : ViewCell
        {
            public AccessoryViewCell()
            {
                var label = new Label();
                label.SetBinding(Label.TextProperty, ".");
                View = label;
            }
        }

        public class GroupedItem : ObservableCollection<string>
        {
            public string LongName { get; set; }
            public string ShortName { get; set; }
        }

        protected override void Init()
        {
            var label = new Label { Text = Instructions };
            grouped = new ObservableCollection<GroupedItem>();
            lstView = new ListView(ListViewCachingStrategy.RecycleElement) {
                IsGroupingEnabled = true,
                ItemTemplate = new DataTemplate(typeof(AccessoryViewCell)),
                ItemsSource = grouped,
                GroupDisplayBinding = new Binding("LongName"),
                GroupShortNameBinding = new Binding("ShortName")
            };

            var grp1 = new GroupedItem() { LongName = "Group 1", ShortName = "1" };
            var grp2 = new GroupedItem() { LongName = "Group 2", ShortName = "2" };

            for (int i = 1; i < 4; i++)
            {
                grp1.Add($"Item #{i}");
                grp2.Add($"Item #{i}");
            }

            grouped.Add(grp1); 
            grouped.Add(grp2);

            Content = new StackLayout
            {
                Children = {
                    label,
                    lstView
                }
            };
        }

#if (UITEST && __IOS__)
        [Test]
		[Category(UITestCategories.ManualReview)]
        public void Bugzilla36802Test()
        {
            RunningApp.Screenshot("AccessoryView partially hidden test");
        }
#endif
    }
}