6ae63d3d4b3c2d0562d98a263cfc7878feab1500
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Window / TSDefaultBorder.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.Runtime.InteropServices;
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("public/Window/ DefaultBorder.cs")]
15     internal class PublicDefaultBorderTest
16     {
17         private const string tag = "NUITEST";
18
19         internal class IBorderInterfaceImpl : IBorderInterface
20         {
21             public uint BorderLineThickness => 2;
22
23             public uint TouchThickness => 2;
24
25             public float BorderHeight => 3;
26
27             public Size2D MinSize => new Size2D(1, 1);
28
29             public Size2D MaxSize => new Size2D(5, 5);
30
31             public Window BorderWindow
32             {
33                 get
34                 {
35                     return Window.Instance;
36                 }
37                 set
38                 {
39                     this.BorderWindow = Window.Instance;
40                 }
41             }
42
43             public bool OverlayMode => true;
44
45             public Window.BorderResizePolicyType ResizePolicy => Window.BorderResizePolicyType.Free;
46
47             public void CreateBorderView(View borderView) { }
48
49             public bool CreateBottomBorderView(View bottomView) { return true; }
50
51             public bool CreateTopBorderView(View topView) { return true; }
52
53             public void Dispose() { }
54
55             public void OnCreated(View borderView) { }
56
57             public void OnMaximize(bool isMaximized) { }
58
59             public void OnMinimize(bool isMinimized) { }
60
61             public void OnOverlayMode(bool enabled) { }
62
63             public void OnRequestResize() { }
64
65             public void OnResized(int width, int height) { }
66
67             public void OnMoved(int x, int y) { }
68         }
69
70         [SetUp]
71         public void Init()
72         {
73             tlog.Info(tag, "Init() is called!");
74         }
75
76         [TearDown]
77         public void Destroy()
78         {
79             tlog.Info(tag, "Destroy() is called!");
80         }
81                 
82                 [Test]
83         [Category("P1")]
84         [Description("Create a DefaultBorder object.")]
85         [Property("SPEC", "Tizen.NUI.DefaultBorder.contructor C")]
86         [Property("SPEC_URL", "-")]
87         [Property("CRITERIA", "CONSTR")]
88         [Property("COVPARAM", "")]
89         public void DefaultBorderConstructor()
90         {
91             tlog.Debug(tag, $"DefaultBorderConstructor START");
92               
93                     var testingTarget = new DefaultBorder();
94             Assert.IsNotNull(testingTarget, "should be not null");
95             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
96
97             testingTarget.Dispose();
98                         
99             tlog.Debug(tag, $"DefaultBorderConstructor END (OK)");
100         }
101                 
102         [Test]
103         [Category("P1")]
104         [Description("DefaultBorder MaxSize  ")]
105         [Property("SPEC", "Tizen.NUI.DefaultBorder.MaxSize A")]
106         [Property("SPEC_URL", "-")]
107         [Property("CRITERIA", "PRW")]
108         [Property("AUTHOR", "guowei.wang@samsung.com")]
109         public void DefaultBorderMaxSize()
110         {
111             tlog.Debug(tag, $"DefaultBorderMaxSize START");
112
113             var testingTarget = new DefaultBorder();
114             Assert.IsNotNull(testingTarget, "null handle returned");
115             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "Should return DefaultBorder instance.");
116
117             testingTarget.MaxSize = new Size2D(100, 100);
118             Assert.AreEqual(100, testingTarget.MaxSize.Width, "Should be equal!");
119             Assert.AreEqual(100, testingTarget.MaxSize.Height, "Should be equal!");
120
121             testingTarget.Dispose();
122             tlog.Debug(tag, $"DefaultBorderMaxSize END (OK)");
123         }
124                 
125                 [Test]
126         [Category("P1")]
127         [Description("  DefaultBorder CreateTopBorderView.")]
128         [Property("SPEC", "Tizen.NUI.DefaultBorder.CreateTopBorderView M")]
129         [Property("SPEC_URL", "-")]
130         [Property("CRITERIA", "MR")]
131         [Property("COVPARAM", "")]
132         public void DefaultBorderCreateTopBorderViewtopView()
133         {
134             tlog.Debug(tag, $"DefaultBorderCreateTopBorderViewtopView START");
135                         
136                         using (View topView = new View() { Size = new Size(Window.Instance.WindowSize.Width, 10) } )
137             {
138                             var testingTarget = new DefaultBorder();
139                 Assert.IsNotNull(testingTarget, "should be not null");
140                 Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
141                 
142                                 var result = testingTarget.CreateTopBorderView(topView);
143                 tlog.Debug(tag, "CreateTopBorderView : " + result);
144
145                 testingTarget.Dispose();
146             }
147             
148             tlog.Debug(tag, $"DefaultBorderCreateTopBorderViewtopView END (OK)");
149         }
150                 
151                 [Test]
152         [Category("P1")]
153         [Description("  DefaultBorder  CreateBottomBorderView.")]
154         [Property("SPEC", "Tizen.NUI.DefaultBorder.CreateBottomBorderView M")]
155         [Property("SPEC_URL", "-")]
156         [Property("CRITERIA", "MR")]
157         [Property("COVPARAM", "")]
158         public void DefaultBorderCreateTopBorderViewbottomView()
159         {
160             tlog.Debug(tag, $"DefaultBorderCreateBottomBorderViewbottomView START");
161                 
162                         using (View bottomView = new View() { Size = new Size(Window.Instance.WindowSize.Width, 10) })
163             {
164                             var testingTarget = new DefaultBorder();
165                 Assert.IsNotNull(testingTarget, "should be not null");
166                 Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
167                 
168                                 var result = testingTarget.CreateBottomBorderView(bottomView);
169                 tlog.Debug(tag, "CreateBottomBorderView : " + result);
170
171                 testingTarget.Dispose();
172             }
173                                 
174             tlog.Debug(tag, $"DefaultBorderCreateBottomBorderViewbottomView END (OK)");
175         }
176                 
177                 [Test]
178         [Category("P1")]
179         [Description("  DefaultBorder  CreateBorderView.")]
180         [Property("SPEC", "Tizen.NUI.DefaultBorder.CreateBorderView M")]
181         [Property("SPEC_URL", "-")]
182         [Property("CRITERIA", "MR")]
183         [Property("COVPARAM", "")]
184         public void DefaultBorderCreateBorderView()
185         {
186             tlog.Debug(tag, $"DefaultBorderCreateBorderView START");
187                         
188                         using (View borderView  = new View() )
189             {
190                                 var testingTarget = new DefaultBorder();
191                 Assert.IsNotNull(testingTarget, "should be not null");
192                 Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
193
194                 try
195                 {
196                     testingTarget.CreateBorderView(borderView);
197                 }
198                 catch (Exception e)
199                 {
200                     tlog.Debug(tag, e.Message.ToString());
201                     Assert.Fail("Caught Exception : Failed!");
202                 }
203
204                 testingTarget.Dispose();
205             }
206                         
207             tlog.Debug(tag, $"DefaultBorderCreateBorderView END (OK)");
208         }
209                 
210                 [Test]
211         [Category("P1")]
212         [Description("  DefaultBorder  CreateBorderView1.")]
213         [Property("SPEC", "Tizen.NUI.DefaultBorder.CreateBorderView1 M")]
214         [Property("SPEC_URL", "-")]
215         [Property("CRITERIA", "MR")]
216         [Property("COVPARAM", "")]
217         public void DefaultBorderCreateBorderView1()
218         {
219             tlog.Debug(tag, $"DefaultBorderCreateBorderView1 START");
220                         
221                         var testingTarget = new DefaultBorder();
222             Assert.IsNotNull(testingTarget, "should be not null");
223             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
224
225             try
226             {
227                 testingTarget.CreateBorderView(null);
228             }
229             catch (Exception e)
230             {
231                 tlog.Debug(tag, e.Message.ToString());
232                 Assert.Fail("Caught Exception : Failed!");
233             }
234
235             testingTarget.Dispose();
236             tlog.Debug(tag, $"DefaultBorderCreateBorderView END (OK)");
237         }
238
239                 [Test]
240         [Category("P1")]
241         [Description("DefaultBorder  OnResized.")]
242         [Property("SPEC", "Tizen.NUI.DefaultBorder.OnResized M")]
243         [Property("SPEC_URL", "-")]
244         [Property("CRITERIA", "MR")]
245         [Property("COVPARAM", "")]
246         public void DefaultBorderOnResized()
247         {
248             tlog.Debug(tag, $"DefaultBorderOnResized START");
249                             
250                         var testingTarget = new DefaultBorder();
251             Assert.IsNotNull(testingTarget, "should be not null");
252             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
253
254             try
255             {
256                 testingTarget.OnResized(50, 50);
257             }
258             catch (Exception e)
259             {
260                 tlog.Debug(tag, e.Message.ToString());
261                 Assert.Fail("Caught Exception : Failed!");
262             }
263
264             testingTarget.Dispose();
265             tlog.Debug(tag, $"DefaultBorderOnResized END (OK)");
266         }
267                 
268                 [Test]
269         [Category("P1")]
270         [Description("DefaultBorder  OnMaximizeAndOnMinimize.")]
271         [Property("SPEC", "Tizen.NUI.DefaultBorder.OnMaximizeAndOnMinimize M")]
272         [Property("SPEC_URL", "-")]
273         [Property("CRITERIA", "MR")]
274         [Property("COVPARAM", "")]
275         public void DefaultBorderOnMaximize()
276         {
277            tlog.Debug(tag, $"DefaultBorderOnMaximizeAndOnMinimize START");
278     
279                         var testingTarget = new DefaultBorder();                        
280             Assert.IsNotNull(testingTarget, "should be not null");
281             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
282
283             try
284             {
285                 testingTarget.OnMaximize(true);
286                 testingTarget.OnMaximize(false);
287                 testingTarget.OnMinimize(true);
288                 testingTarget.OnMinimize(false);
289             }
290             catch (Exception e)
291             {
292                 tlog.Debug(tag, e.Message.ToString());
293                 Assert.Fail("Caught Exception : Failed!");
294             }
295
296             testingTarget.Dispose();
297             tlog.Debug(tag, $"DefaultBorderOnMaximizeAndOnMinimize END (OK)");
298         }
299                 
300                 [Test]
301         [Category("P1")]
302         [Description("DefaultBorder  OnOverlayMode.")]
303         [Property("SPEC", "Tizen.NUI.DefaultBorder.OnOverlayMode M")]
304         [Property("SPEC_URL", "-")]
305         [Property("CRITERIA", "MR")]
306         [Property("COVPARAM", "")]
307         public void DefaultBorderOnOverlayMode()
308         {
309             tlog.Debug(tag, $"DefaultBorderOnOverlayMode START");
310                         
311                         var testingTarget = new DefaultBorder();
312             Assert.IsNotNull(testingTarget, "should be not null");
313             Assert.IsInstanceOf<DefaultBorder>(testingTarget, "should be an instance of testing target class!");
314
315             using (View view = new View())
316             {
317                 testingTarget.CreateBorderView(view);
318                 testingTarget.OverlayMode = true;
319
320                 try
321                 {
322                     testingTarget.OnOverlayMode(true);
323                     testingTarget.OnOverlayMode(false);
324                 }
325                 catch (Exception e)
326                 {
327                     tlog.Debug(tag, e.Message.ToString());
328                     Assert.Fail("Caught Exception : Failed!");
329                 }
330             }
331
332             testingTarget.Dispose();
333             tlog.Debug(tag, $"DefaultBorderOnOverlayMode END (OK)");
334         }
335         }
336 }