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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 42599, "LineBreakMode does not work on UWP", PlatformAffected.WinRT)]
	public class Bugzilla42599 : TestContentPage
	{
		protected override void Init()
		{
			var scrollView = new ScrollView();
			var layout = new StackLayout();

			foreach (var lineBreakMode in Enum.GetValues(typeof(LineBreakMode)).Cast<LineBreakMode>())
			{
				layout.Children.Add(GetLayout(lineBreakMode));
			}
			scrollView.Content = layout;
			Content = scrollView;
		}

		static StackLayout GetLayout(LineBreakMode lineBreakMode)
		{
			var text = "";

			switch (lineBreakMode)
			{
				default:
				case LineBreakMode.NoWrap:
					text = "This is a long sentence that should NOT wrap. If this sentence has wrapped, then this test has failed.";
					break;
				case LineBreakMode.WordWrap:
					text = "This is a long sentence that should word wrap. If this sentence has NOT wrapped, then this test has failed.";
					break;
				case LineBreakMode.CharacterWrap:
					text = "This is a long sentence that should character wrap. If this sentence has NOT wrapped, then this test has failed.";
					break;
				case LineBreakMode.HeadTruncation:
					text = "This is a long sentence that should truncate at the beginning. If this sentence has NOT truncated, then this test has failed.";
					break;
				case LineBreakMode.TailTruncation:
					text = "This is a long sentence that should truncate at the end. If this sentence has NOT truncated, then this test has failed.";
					break;
				case LineBreakMode.MiddleTruncation:
					text = "This is a long sentence that should truncate at the middle. If this sentence has NOT truncated, then this test has failed.";
					break;
			}

			var label = new Label
			{
				LineBreakMode = lineBreakMode,
				Text = text,
			};

			var layout = new StackLayout
			{
				Children = { label },
				Orientation = StackOrientation.Horizontal
			};

			return layout;
		}
	}
}