[NUI][NUI.Devel] Update nui line coverage TCs.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / BaseComponents / Style / TSTextLabelStyle.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("public/BaseComponents/Style/TextLabelStyle")]
13     public class PublicBaseComponentsStyleTextLabelStyleTest
14     {
15         private const string tag = "NUITEST";
16
17         [SetUp]
18         public void Init()
19         {
20             tlog.Info(tag, "Init() is called!");
21         }
22
23         [TearDown]
24         public void Destroy()
25         {
26             tlog.Info(tag, "Destroy() is called!");
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("TextLabelStyle TextLabelStyle.")]
32         [Property("SPEC", "Tizen.NUI.BaseComponents.Style.TextLabelStyle M")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "PRW")]
35         [Property("AUTHOR", "guowei.wang@samsung.com")]
36         public void BaseComponentsStyleTextLabelStyle()
37         {
38             tlog.Debug(tag, $"BaseComponentsStyleTextLabelStyle START");
39                         
40             var testingTarget = new TextLabelStyle();
41                         Assert.IsNotNull(testingTarget, "should be not null");
42                         Assert.IsInstanceOf<TextLabelStyle>(testingTarget, "should be an instance of TextLabelStyle class!");
43
44                         try
45                         {
46                                 testingTarget.TranslatableText = new Selector<string>()
47                                 {
48                                         All = "SamsungOneUI400",
49                 };
50                 Assert.AreEqual("SamsungOneUI400", testingTarget.TranslatableText.All, "Should be equal!");
51
52                 testingTarget.FontFamily = new Selector<string>()
53                 {
54                                         All = "SamsungOneUI400",
55                                         Normal = "BreezeSans",
56                                 };
57                                 Assert.AreEqual("BreezeSans", testingTarget.FontFamily.Normal, "Should be equal!");
58
59                                 testingTarget.MultiLine = true ;
60                                 Assert.IsTrue(testingTarget.MultiLine);
61
62                                 testingTarget.HorizontalAlignment = HorizontalAlignment.Center;
63                                 Assert.AreEqual(HorizontalAlignment.Center, testingTarget.HorizontalAlignment, "Should be equal!");
64
65                                 testingTarget.VerticalAlignment = VerticalAlignment.Center;
66                                 Assert.AreEqual(VerticalAlignment.Center, testingTarget.VerticalAlignment, "Should be equal!");
67
68                                 testingTarget.EnableMarkup = false ;
69                                 Assert.IsTrue(!testingTarget.EnableMarkup);     
70
71                                 testingTarget.EnableAutoScroll = true ;
72                                 Assert.IsTrue(testingTarget.EnableAutoScroll);  
73
74                                 testingTarget.AutoScrollSpeed = 80 ;
75                                 Assert.AreEqual(80, testingTarget.AutoScrollSpeed, "Should be equal!");
76
77                                 testingTarget.AutoScrollLoopCount = 2 ;
78                                 Assert.AreEqual(2, testingTarget.AutoScrollLoopCount, "Should be equal!");
79
80                                 testingTarget.AutoScrollGap = 50.0f ;
81                                 Assert.AreEqual(50.0f, testingTarget.AutoScrollGap, "Should be equal!");
82
83                                 testingTarget.LineSpacing = 2.0f ;
84                                 Assert.AreEqual(2.0f, testingTarget.LineSpacing, "Should be equal!");   
85
86                                 testingTarget.RelativeLineHeight = 5.0f ;
87                                 Assert.AreEqual(5.0f, testingTarget.RelativeLineHeight, "Should be equal!");
88
89                                 testingTarget.Emboss = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png";
90                                 tlog.Debug(tag, "Emboss : " + testingTarget.Emboss);
91
92                                 testingTarget.PixelSize = 24.0f;
93                                 Assert.AreEqual(24.0f, testingTarget.PixelSize, "Should be equal!");
94
95                                 testingTarget.Ellipsis = true ;
96                                 Assert.IsTrue(testingTarget.Ellipsis);
97
98                                 testingTarget.AutoScrollLoopDelay = 2.0f ;
99                                 Assert.AreEqual(2.0f, testingTarget.AutoScrollLoopDelay, "Should be equal!");
100
101                                 testingTarget.AutoScrollStopMode = AutoScrollStopMode.Immediate;
102                                 Assert.AreEqual(AutoScrollStopMode.Immediate, testingTarget.AutoScrollStopMode, "Should be equal!");
103
104                                 testingTarget.LineWrapMode = LineWrapMode.Character;
105                                 Assert.AreEqual(LineWrapMode.Character, testingTarget.LineWrapMode, "Should be equal!");
106
107                                 testingTarget.VerticalLineAlignment = VerticalLineAlignment.Center;
108                                 Assert.AreEqual(VerticalLineAlignment.Center, testingTarget.VerticalLineAlignment, "Should be equal!"); 
109
110                                 testingTarget.EllipsisPosition = EllipsisPosition.Start;
111                                 Assert.AreEqual(EllipsisPosition.Start, testingTarget.EllipsisPosition, "Should be equal!");
112
113                                 testingTarget.CharacterSpacing = 0;
114                                 Assert.AreEqual(0, testingTarget.CharacterSpacing, "Should be equal!");
115
116                                 testingTarget.MatchSystemLanguageDirection = false;
117                                 Assert.IsTrue(!testingTarget.MatchSystemLanguageDirection);
118                                 
119                                 testingTarget.TextColor = new Selector<Color>()
120                 {
121                     Normal = new Color(0.2196f, 0.6131f, 0.9882f, 1),
122                     Disabled = new Color(1, 1, 1, 0.35f),
123                 };
124                                 Assert.AreEqual(0.35f, testingTarget.TextColor.Disabled.A, "Should be equal!");
125
126                                 testingTarget.PointSize = new Selector<float?>()
127                                 {
128                                         All = 16.0f,
129                                 };
130                                 Assert.AreEqual(16.0f, testingTarget.PointSize.All, "Should be equal!");
131
132                                 using (TextLabel textLabel = new TextLabel())
133                                 {
134                                         textLabel.Text = "TextShadowConstructor";
135                                         textLabel.Color = Color.Red;
136                                         textLabel.PointSize = 15.0f;
137
138                                         using (PropertyMap temp = new PropertyMap())
139                     {
140                                                 Tizen.NUI.Object.GetProperty((global::System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.SHADOW).Get(temp);
141
142                                                 TextShadow shadow = new TextShadow(temp);
143
144                                                 testingTarget.TextShadow = new Selector<TextShadow>()
145                                                 {
146                                                         All = shadow,
147                                                 };
148                                                 Assert.AreEqual(1.0f, testingTarget.TextShadow.All.Color.A, "Should be equal!");
149                                         }
150                                 }
151
152                                 testingTarget.FontStyle = new PropertyMap().Add("weight", new PropertyValue("regular"));
153                                 testingTarget.FontStyle.Find(-1, "weight").Get(out string style);
154                                 Assert.AreEqual("regular", style, "Should be equal!");
155                         }
156             catch (Exception e)
157             {
158                 tlog.Debug(tag, e.Message.ToString());
159                 Assert.Fail("Caught Exception: Failed!");
160             }                   
161
162                         testingTarget.Dispose();
163             tlog.Debug(tag, $"BaseComponentsStyleTextLabelStyle END (OK)");
164         }
165     }
166 }