7baaa4c9c9e1e840ce855bc4dc170fa629023716
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / TSToast.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI;
5 using Tizen.NUI.Components;
6 using Tizen.NUI.BaseComponents;
7
8 namespace Tizen.NUI.Components.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("Control/Toast")]
14     public class ControlToastTest
15     {
16         private const string tag = "NUITEST";
17
18         [Obsolete]
19         internal class MyToast : Toast
20         {
21             public MyToast() : base()
22             { }
23
24             public override void OnInitialize()
25             {
26                 base.OnInitialize();
27             }
28
29             public void OnCreateViewStyle()
30             {
31                 base.CreateViewStyle();
32             }
33         }
34
35         [SetUp]
36         public void Init()
37         {
38             tlog.Info(tag, "Init() is called!");
39         }
40
41         [TearDown]
42         public void Destroy()
43         {
44             tlog.Info(tag, "Destroy() is called!");
45         }
46
47         [Test]
48         [Category("P1")]
49         [Description("Toast constructor.")]
50         [Property("SPEC", "Tizen.NUI.Components.Toast.Toast C")]
51         [Property("SPEC_URL", "-")]
52         [Property("CRITERIA", "CONSTR")]
53         [Property("COVPARAM", "")]
54         [Property("AUTHOR", "guowei.wang@samsung.com")]
55         [Obsolete]
56         public void ToastConstructor()
57         {
58             tlog.Debug(tag, $"ToastConstructor START");
59
60             ToastStyle style = new ToastStyle()
61             { 
62                 BackgroundColor = Color.Cyan,
63             };
64
65             var testingTarget = new Toast(style);
66             Assert.IsNotNull(testingTarget, "null handle");
67             Assert.IsInstanceOf<Toast>(testingTarget, "Should return Toast instance.");
68
69             testingTarget.Dispose();
70             tlog.Debug(tag, $"ToastConstructor END (OK)");
71         }
72
73         [Test]
74         [Category("P1")]
75         [Description("Toast FromText.")]
76         [Property("SPEC", "Tizen.NUI.Components.Toast.FromText M")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "MR")]
79         [Property("COVPARAM", "")]
80         [Property("AUTHOR", "guowei.wang@samsung.com")]
81         [Obsolete]
82         public void ToastFromText()
83         {
84             tlog.Debug(tag, $"ToastFromText START");
85
86             var testingTarget = Toast.FromText("Null parameter construction", 1000);
87             Assert.IsNotNull(testingTarget, "null handle");
88             Assert.IsInstanceOf<Toast>(testingTarget, "Should return Toast instance.");
89
90             testingTarget.Dispose();
91             tlog.Debug(tag, $"ToastFromText END (OK)");
92         }
93
94         [Test]
95         [Category("P1")]
96         [Description("Toast Duration.")]
97         [Property("SPEC", "Tizen.NUI.Components.Toast.Duration A")]
98         [Property("SPEC_URL", "-")]
99         [Property("CRITERIA", "PRW")]
100         [Property("COVPARAM", "")]
101         [Property("AUTHOR", "guowei.wang@samsung.com")]
102         [Obsolete]
103         public void ToastDuration()
104         {
105             tlog.Debug(tag, $"ToastDuration START");
106
107             var testingTarget = new MyToast();
108             Assert.IsNotNull(testingTarget, "null handle");
109             Assert.IsInstanceOf<Toast>(testingTarget, "Should return Toast instance.");
110
111             testingTarget.OnInitialize();
112
113             testingTarget.Duration = 10;
114             tlog.Debug(tag, "Duration : " + testingTarget.Duration);
115
116             testingTarget.TextLineSpace = 8;
117             tlog.Debug(tag, "testingTarget : " + testingTarget.TextLineSpace);
118
119             testingTarget.TextLineHeight = 15;
120             tlog.Debug(tag, "TextLineHeight : " + testingTarget.TextLineHeight);
121
122             testingTarget.TextPadding = new Extents(2, 2, 2, 2);
123             tlog.Debug(tag, "TextPadding : " + testingTarget.TextPadding);
124
125             testingTarget.Message = "Toast";
126             tlog.Debug(tag, "Message : " + testingTarget.Message);
127
128             testingTarget.TextAlignment = HorizontalAlignment.Center;
129             tlog.Debug(tag, "TextAlignment :" + testingTarget.TextAlignment);
130
131             testingTarget.TextArray = new string[2] { "microsoft", "perfomance" };
132             tlog.Debug(tag, "TextArray : " + testingTarget.TextArray);
133
134             testingTarget.PointSize = 15.0f;
135             tlog.Debug(tag, "PointSize : " + testingTarget.PointSize);
136
137             testingTarget.FontFamily = "BreezeSans";
138             tlog.Debug(tag, "FontFamily : " + testingTarget.FontFamily);
139
140             testingTarget.TextColor = Color.Yellow;
141             tlog.Debug(tag, "TextColor : " + testingTarget.TextColor);
142
143             try
144             {
145                 testingTarget.Post(Window.Instance);
146             }
147             catch (Exception e)
148             {
149                 tlog.Debug(tag, e.Message.ToString());
150                 Assert.Fail("Caught Exception : Failed!");
151             }
152
153             testingTarget.Dispose();
154             tlog.Debug(tag, $"ToastDuration END (OK)");
155         }
156
157         [Test]
158         [Category("P1")]
159         [Description("Toast CreateViewStyle.")]
160         [Property("SPEC", "Tizen.NUI.Components.Toast.CreateViewStyle M")]
161         [Property("SPEC_URL", "-")]
162         [Property("CRITERIA", "MR")]
163         [Property("COVPARAM", "")]
164         [Property("AUTHOR", "guowei.wang@samsung.com")]
165         [Obsolete]
166         public void ToastCreateViewStyle()
167         {
168             tlog.Debug(tag, $"ToastCreateViewStyle START");
169
170             var testingTarget = new MyToast();
171             Assert.IsNotNull(testingTarget, "null handle");
172             Assert.IsInstanceOf<Toast>(testingTarget, "Should return Toast instance.");
173
174             try
175             {
176                 testingTarget.OnCreateViewStyle();
177             }
178             catch (Exception e)
179             {
180                 tlog.Debug(tag, e.Message.ToString());
181                 Assert.Fail("Caught Exception : Failed!");
182             }
183
184             testingTarget.Dispose();
185             tlog.Debug(tag, $"ToastCreateViewStyle END (OK)");
186         }
187
188         [Test]
189         [Category("P1")]
190         [Description("Toast ApplyStyle.")]
191         [Property("SPEC", "Tizen.NUI.Components.Toast.ApplyStyle M")]
192         [Property("SPEC_URL", "-")]
193         [Property("CRITERIA", "MR")]
194         [Property("COVPARAM", "")]
195         [Property("AUTHOR", "guowei.wang@samsung.com")]
196         [Obsolete]
197         public void ToastApplyStyle()
198         {
199             tlog.Debug(tag, $"ToastApplyStyle START");
200
201             var testingTarget = new Toast();
202             Assert.IsNotNull(testingTarget, "null handle");
203             Assert.IsInstanceOf<Toast>(testingTarget, "Should return Toast instance.");
204
205             ToastStyle style = new ToastStyle()
206             {
207                 Text = new TextLabelStyle()
208                 { 
209                     Size = new Size(80, 30)
210                 }
211             };
212
213             try
214             {
215                 testingTarget.ApplyStyle(style);
216             }
217             catch (Exception e)
218             {
219                 tlog.Debug(tag, e.Message.ToString());
220                 Assert.Fail("Caught Exception : Failed!");
221             }
222
223             testingTarget.Dispose();
224             tlog.Debug(tag, $"ToastApplyStyle END (OK)");
225         }
226     }
227 }