e92fa37f4281bdf52a3b2614f38fbd8c92451482
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Utility / TSTextPageUtil.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 using System.Collections.Generic;
7 using System.Threading.Tasks;
8 using Tizen.NUI.Utility;
9
10 namespace Tizen.NUI.Devel.Tests
11 {
12     using tlog = Tizen.Log;
13
14     [TestFixture]
15     [Description("public/Utility/TextPageUtil")]
16     class PublicTextPageUtilTest
17     {
18         private const string tag = "NUITEST";
19
20         [SetUp]
21         public void Init()
22         {
23             tlog.Info(tag, "Init() is called!");
24         }
25
26         [TearDown]
27         public void Destroy()
28         {
29             tlog.Info(tag, "Destroy() is called!");
30         }
31
32         [Test]
33         [Category("P1")]
34         [Description("TextPageUtil SetText.")]
35         [Property("SPEC", "Tizen.NUI.TextPageUtil.SetText M")]
36         [Property("SPEC_URL", "-")]
37         [Property("CRITERIA", "MR")]
38         [Property("AUTHOR", "guowei.wang@samsung.com")]
39         public void TextPageUtilSetText()
40         {
41             tlog.Debug(tag, $"TextPageUtilSetText START");
42
43             TextPageUtil testingTarget = new TextPageUtil();
44             Assert.IsNotNull(testingTarget, "Can't create success object TextPageUtil");
45             Assert.IsInstanceOf<TextPageUtil>(testingTarget, "Should be an instance of TextPageUtil type.");
46
47             using (TextLabel label = new TextLabel())
48             {
49                 label.EnableMarkup = true;
50                 label.Text = "PublicPageUtilTest";
51                 var result = testingTarget.SetText(label, "My PageUtil");
52                 Assert.IsNotNull(result);
53             }
54
55             // label.EnableMarkup = false
56             using (TextLabel label = new TextLabel())
57             {
58                 label.EnableMarkup = false;
59                 label.Text = "PublicPageUtilTest";
60                 var result = testingTarget.SetText(label, "MyPageUtil");
61                 Assert.IsNotNull(result);
62             }
63
64             testingTarget.Dispose();
65             tlog.Debug(tag, $"TextPageUtilSetText END (OK)");
66         }
67
68         [Test]
69         [Category("P1")]
70         [Description("TextPageUtil GetText.")]
71         [Property("SPEC", "Tizen.NUI.TextPageUtil.GetText M")]
72         [Property("SPEC_URL", "-")]
73         [Property("CRITERIA", "MR")]
74         [Property("AUTHOR", "guowei.wang@samsung.com")]
75         public void TextPageUtilGetText()
76         {
77             tlog.Debug(tag, $"TextPageUtilGetText START");
78
79             TextPageUtil testingTarget = new TextPageUtil();
80             Assert.IsNotNull(testingTarget, "Can't create success object TextPageUtil");
81             Assert.IsInstanceOf<TextPageUtil>(testingTarget, "Should be an instance of TextPageUtil type.");
82
83             using (TextLabel label = new TextLabel())
84             {
85                 label.EnableMarkup = true;
86                 label.Text = "PublicPageUtilTest";
87                 var result = testingTarget.SetText(label, "MyPageUtil");
88                 Assert.IsNotNull(result);
89
90                 /** if param is 0 will return */
91                 try
92                 {
93                     testingTarget.GetText(0);
94                 }
95                 catch (Exception e)
96                 {
97                     tlog.Debug(tag, e.Message.ToString());
98                     Assert.Fail("Caught Exception: Failed!");
99                 }
100
101                 try
102                 {
103                     testingTarget.GetText(1);
104                 }
105                 catch (Exception e)
106                 {
107                     tlog.Debug(tag, e.Message.ToString());
108                     Assert.Fail("Caught Exception: Failed!");
109                 }
110             }
111
112             testingTarget.Dispose();
113             tlog.Debug(tag, $"TextPageUtilGetText END (OK)");
114         }
115
116         [Test]
117         [Category("P1")]
118         [Description("TextPageUtil GetText situation.")]
119         [Property("SPEC", "Tizen.NUI.TextPageUtil.GetText situation M")]
120         [Property("SPEC_URL", "-")]
121         [Property("CRITERIA", "MR")]
122         [Property("AUTHOR", "guowei.wang@samsung.com")]
123         public void TextPageUtilGetTextsituation()
124         {
125             tlog.Debug(tag, $"TextPageUtilGetTextsituation START");
126
127             TextPageUtil testingTarget = new TextPageUtil();
128             Assert.IsNotNull(testingTarget, "Can't create success object TextPageUtil");
129             Assert.IsInstanceOf<TextPageUtil>(testingTarget, "Should be an instance of TextPageUtil type.");
130
131             using (TextLabel label = new TextLabel())
132             {
133                 label.EnableMarkup = true;
134                 label.Text = "PublicPageUtilTest";
135                 
136                 var result = testingTarget.SetText(label, "MyPageUtil");
137                 Assert.IsNotNull(result);
138
139                 /** if param is 0 will return */
140                 try
141                 {
142                     testingTarget.GetText(-1);
143                 }
144                 catch (Exception e)
145                 {
146                     tlog.Debug(tag, e.Message.ToString());
147                     Assert.Fail("Caught Exception: Failed!");
148                 }
149             }
150
151             testingTarget.Dispose();
152             tlog.Debug(tag, $"TextPageUtilGetTextsituation END (OK)");
153         }
154
155         [Test]
156         [Category("P1")]
157         [Description("TextPageUtil PageData.")]
158         [Property("SPEC", "Tizen.NUI.TextPageUtil.PageData A")]
159         [Property("SPEC_URL", "-")]
160         [Property("CRITERIA", "PRW")]
161         [Property("AUTHOR", "guowei.wang@samsung.com")]
162         public void TextPageUtilPageData()
163         {
164             tlog.Debug(tag, $"TextPageUtilPageData START");
165
166             var testingTarget = new PageData();
167
168             testingTarget.PreviousTag = "previous";
169             tlog.Debug(tag, "PreviousTag : " + testingTarget.PreviousTag);
170
171             testingTarget.EndTag = "end";
172             tlog.Debug(tag, "EndTag : " + testingTarget.EndTag);
173
174             testingTarget.StartOffset = 0;
175             tlog.Debug(tag, "StartOffset : " + testingTarget.StartOffset);
176
177             testingTarget.EndOffset = 2;
178             tlog.Debug(tag, "EndOffset : " + testingTarget.EndOffset);
179
180             tlog.Debug(tag, $"TextPageUtilPageData END (OK)");
181         }
182
183         [Test]
184         [Category("P1")]
185         [Description("TextPageUtil TagData.")]
186         [Property("SPEC", "Tizen.NUI.TextPageUtil.TagData A")]
187         [Property("SPEC_URL", "-")]
188         [Property("CRITERIA", "PRW")]
189         [Property("AUTHOR", "guowei.wang@samsung.com")]
190         public void TextPageUtilTagData()
191         {
192             tlog.Debug(tag, $"TextPageUtilTagData START");
193
194             var testingTarget = new TagData();
195
196             testingTarget.TagName = "tag";
197             tlog.Debug(tag, "TagName : " + testingTarget.TagName);
198
199             testingTarget.AttributeName = "size";
200             tlog.Debug(tag, "AttributName : " + testingTarget.AttributeName);
201
202             testingTarget.IsEndTag = true;
203             tlog.Debug(tag, "IsEndTag" + testingTarget.IsEndTag);
204
205             tlog.Debug(tag, $"TextPageUtilTagData END (OK)");
206         }
207     }
208 }