-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue3000.cs
126 lines (105 loc) · 2.83 KB
/
Issue3000.cs
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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 3000, "Horizontal ScrollView breaks scrolling when flowdirection is set to rtl")]
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
[NUnit.Framework.Category(UITestCategories.ScrollView)]
#endif
public class Issue3000 : TestContentPage
{
const string kSuccess = "Success";
protected override void Init()
{
ScrollView view = new ScrollView();
StackLayout parent = new StackLayout();
Label instructions = new Label() { Text = "Scroll X should not be zero Scroll Y should be zero" };
Label scrollPositions = new Label();
Label outcome = new Label();
parent.Children.Add(instructions);
parent.Children.Add(scrollPositions);
parent.Children.Add(outcome);
view.Scrolled += (_, __) =>
{
if (outcome.Text == kSuccess)
{
return;
}
scrollPositions.Text = $"ScrollX: {view.ScrollX} ScrollY: {view.ScrollY}";
if (view.ScrollY == 0 && view.ScrollX > 0)
{
outcome.Text = kSuccess;
}
else
{
outcome.Text = "Fail";
}
};
view.Orientation = ScrollOrientation.Both;
StackLayout layout = new StackLayout();
layout.Orientation = StackOrientation.Horizontal;
layout.Children.Add(new Label() { Text = "LEFT" });
for (int i = 0; i < 80; i++)
layout.Children.Add(new Image() { BackgroundColor = Color.Pink, Source = "coffee.png" });
layout.Children.Add(new Label() { Text = "RIGHT" });
StackLayout layoutDown = new StackLayout();
for (int i = 0; i < 80; i++)
layoutDown.Children.Add(new Image() { BackgroundColor = Color.Pink, Source = "coffee.png" });
view.FlowDirection = FlowDirection.RightToLeft;
parent.Children.Insert(0, new Button()
{
Text = "click me please",
Command = new Command(() =>
{
if (view.FlowDirection == FlowDirection.LeftToRight)
{
view.FlowDirection = FlowDirection.RightToLeft;
}
else
{
view.FlowDirection = FlowDirection.LeftToRight;
}
})
});
parent.Children.Insert(0, new Button()
{
Text = "reset this view",
Command = new Command(() =>
{
Application.Current.MainPage = new Issue3000();
})
});
parent.Children.Insert(0, new Label()
{
Text = "right to left text",
});
parent.Children.Insert(0, new Label()
{
Text = "left to right text"
});
view.Content = new StackLayout()
{
Children =
{
layout, layoutDown
}
};
parent.Children.Add(view);
Content = parent;
}
#if UITEST
[Test]
public void RtlScrollViewStartsScrollToRight()
{
RunningApp.WaitForElement(kSuccess);
}
#endif
}
}