8d43d0e8a016a7157a4e874c48d78d57fe8a63f0
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Window / TSWindow.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections.Generic;
4 using static Tizen.NUI.Window;
5
6 namespace Tizen.NUI.Devel.Tests
7 {
8     using tlog = Tizen.Log;
9
10     [TestFixture]
11     [Description("public/Window/Window")]
12     internal class PublicWindowTest
13     {
14         private const string tag = "NUITEST";
15         private Window win = null;
16         private Rectangle rec = null;
17
18         [SetUp]
19         public void Init()
20         {
21             tlog.Info(tag, "Init() is called!");
22
23             rec = new Rectangle(0, 0, 2, 2);
24             win = new Window(rec);
25         }
26
27         [TearDown]
28         public void Destroy()
29         {
30             rec.Dispose();
31             if (win != null)
32             {
33                 win.Destroy();
34                 win = null;
35             }
36
37             tlog.Info(tag, "Destroy() is called!");
38         }
39
40         [Test]
41         [Category("P1")]
42         [Description("Window WindowPositionSize")]
43         [Property("SPEC", "Tizen.NUI.Window.WindowPositionSize A")]
44         [Property("SPEC_URL", "-")]
45         [Property("CRITERIA", "PRW")]
46         public void WindowWindowPositionSize()
47         {
48             tlog.Debug(tag, $"WindowWindowPositionSize START");
49
50             try
51             {
52                 using (Rectangle size = new Rectangle(1, 2, 3, 4))
53                 {
54                     win.WindowPositionSize = size;
55                     tlog.Debug(tag, "WindowPositionSize : " + win.WindowPositionSize);
56                 }
57             }
58             catch (Exception e)
59             {
60                 tlog.Debug(tag, e.Message.ToString());
61                 Assert.Fail("Caught Exception : Failed!");
62             }
63
64             tlog.Debug(tag, $"WindowWindowPositionSize END (OK)");
65         }
66
67         //[Test]
68         //[Category("P1")]
69         //[Description("Window DEFAULT_BACKGROUND_COLOR")]
70         //[Property("SPEC", "Tizen.NUI.Window.DEFAULT_BACKGROUND_COLOR A")]
71         //[Property("SPEC_URL", "-")]
72         //[Property("CRITERIA", "PRW")]
73         //public void WindowDEFAULT_BACKGROUND_COLOR()
74         //{
75         //    tlog.Debug(tag, $"WindowDEFAULT_BACKGROUND_COLOR START");
76         //    try
77         //    {
78         //        Vector4 v1 = Window.DEFAULT_BACKGROUND_COLOR;
79         //    }
80         //    catch (Exception e)
81         //    {
82         //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
83
84         //        Assert.Fail("Caught Exception" + e.ToString());
85         //    }
86         //    tlog.Debug(tag, $"WindowDEFAULT_BACKGROUND_COLOR END (OK)");
87         //    Assert.Pass("WindowDEFAULT_BACKGROUND_COLOR");
88         //}
89
90         //[Test]
91         //[Category("P1")]
92         //[Description("Window DEBUG_BACKGROUND_COLOR")]
93         //[Property("SPEC", "Tizen.NUI.Window.DEBUG_BACKGROUND_COLOR A")]
94         //[Property("SPEC_URL", "-")]
95         //[Property("CRITERIA", "PRW")]
96         //public void WindowDEBUG_BACKGROUND_COLOR()
97         //{
98         //    tlog.Debug(tag, $"WindowDEBUG_BACKGROUND_COLOR START");
99         //    try
100         //    {
101         //        Vector4 v1 = Window.DEBUG_BACKGROUND_COLOR;
102         //    }
103         //    catch (Exception e)
104         //    {
105         //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
106
107         //        Assert.Fail("Caught Exception" + e.ToString());
108         //    }
109         //    tlog.Debug(tag, $"WindowDEBUG_BACKGROUND_COLOR END (OK)");
110         //    Assert.Pass("WindowDEBUG_BACKGROUND_COLOR");
111         //}
112
113         [Test]
114         [Category("P1")]
115         [Description("Window GetLayer")]
116         [Property("SPEC", "Tizen.NUI.Window.GetLayer M")]
117         [Property("SPEC_URL", "-")]
118         [Property("CRITERIA", "MR")]
119         public void WindowGetLayer()
120         {
121             tlog.Debug(tag, $"WindowGetLayer START");
122             
123             try
124             {
125                 win.GetLayer(0);
126             }
127             catch (Exception e)
128             {
129                 tlog.Debug(tag, e.Message.ToString());
130                 Assert.Fail("Caught Exception : Failed!");
131             }
132             tlog.Debug(tag, $"WindowGetLayer END (OK)");
133         }
134
135         [Test]
136         [Category("P1")]
137         [Description("Window GetCurrentOrientation")]
138         [Property("SPEC", "Tizen.NUI.Window.GetCurrentOrientation M")]
139         [Property("SPEC_URL", "-")]
140         [Property("CRITERIA", "MR")]
141         public void WindowGetCurrentOrientation()
142         {
143             tlog.Debug(tag, $"WindowGetCurrentOrientation START");
144             
145             try
146             {
147                 win.GetCurrentOrientation();
148             }
149             catch (Exception e)
150             {
151                 tlog.Debug(tag, e.Message.ToString());
152                 Assert.Fail("Caught Exception : Failed!");
153             }
154
155             tlog.Debug(tag, $"WindowGetCurrentOrientation END (OK)");
156         }
157
158         [Test]
159         [Category("P1")]
160         [Description("Window SetAvailableOrientations")]
161         [Property("SPEC", "Tizen.NUI.Window.SetAvailableOrientations M")]
162         [Property("SPEC_URL", "-")]
163         [Property("CRITERIA", "MR")]
164         public void WindowSetAvailableOrientations()
165         {
166             tlog.Debug(tag, $"WindowSetAvailableOrientations START");
167             try
168             {
169                 List<Window.WindowOrientation> list = new List<Window.WindowOrientation>();
170
171                 list.Add(Window.WindowOrientation.Landscape);
172                 list.Add(Window.WindowOrientation.LandscapeInverse);
173                 list.Add(Window.WindowOrientation.NoOrientationPreference);
174                 list.Add(Window.WindowOrientation.Portrait);
175                 list.Add(Window.WindowOrientation.PortraitInverse);
176
177                 win.SetAvailableOrientations(list);
178             }
179             catch (Exception e)
180             {
181                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
182                 Assert.Fail("Caught Exception" + e.ToString());
183             }
184
185             tlog.Debug(tag, $"WindowSetAvailableOrientations END (OK)");
186             Assert.Pass("WindowSetAvailableOrientations");
187         }
188
189         [Test]
190         [Category("P2")]
191         [Description("Window SetAvailableOrientations")]
192         [Property("SPEC", "Tizen.NUI.Window.SetAvailableOrientations M")]
193         [Property("SPEC_URL", "-")]
194         [Property("CRITERIA", "MR")]
195         public void WindowSetAvailableOrientationsWithNullList()
196         {
197             tlog.Debug(tag, $"WindowSetAvailableOrientationsWithNullList START");
198
199             List<Window.WindowOrientation> list = null;
200
201             try
202             {
203                 win.SetAvailableOrientations(list);
204             }
205             catch (ArgumentNullException e)
206             {
207                 tlog.Debug(tag, e.Message.ToString());
208                 tlog.Debug(tag, $"WindowSetAvailableOrientationsWithNullList END (OK)");
209                 Assert.Pass("Caught ArgumentNullException : Passed!");
210             }
211         }
212
213         [Test]
214         [Category("P1")]
215         [Description("Window SetPositionSizeWithOrientation")]
216         [Property("SPEC", "Tizen.NUI.Window.SetPositionSizeWithOrientation M")]
217         [Property("SPEC_URL", "-")]
218         [Property("CRITERIA", "MR")]
219         public void WindowSetPositionSizeWithOrientation()
220         {
221             tlog.Debug(tag, $"WindowSetPositionSizeWithOrientation START");
222
223             try
224             {
225                 using (Rectangle positionSize = new Rectangle(1, 2, 3, 4))
226                 {
227                     win.SetPositionSizeWithOrientation(positionSize, Window.WindowOrientation.Landscape);
228                 }
229             }
230             catch (Exception e)
231             {
232                 tlog.Debug(tag, e.Message.ToString());
233                 Assert.Fail("Caught Exception : Failed!");
234             }
235
236             tlog.Debug(tag, $"WindowSetPositionSizeWithOrientation END (OK)");
237         }
238
239         [Test]
240         [Category("P1")]
241         [Description("Window GetNativeId")]
242         [Property("SPEC", "Tizen.NUI.Window.GetNativeId M")]
243         [Property("SPEC_URL", "-")]
244         [Property("CRITERIA", "MR")]
245         public void WindowGetNativeId()
246         {
247             tlog.Debug(tag, $"WindowGetNativeId START");
248             
249             try
250             {
251                 win.GetNativeId();
252             }
253             catch (Exception e)
254             {
255                 tlog.Debug(tag, e.Message.ToString());
256                 Assert.Fail("Caught Exception : Failed!");
257             }
258
259             tlog.Debug(tag, $"WindowGetNativeId END (OK)");
260         }
261
262         [Test]
263         [Category("P1")]
264         [Description("Window GetNativeHandle")]
265         [Property("SPEC", "Tizen.NUI.Window.GetNativeHandle M")]
266         [Property("SPEC_URL", "-")]
267         [Property("CRITERIA", "MR")]
268         public void WindowGetNativeHandle()
269         {
270             tlog.Debug(tag, $"WindowGetNativeHandle START");
271             
272             try
273             {
274                 win.GetNativeHandle();
275             }
276             catch (Exception e)
277             {
278                 tlog.Debug(tag, e.Message.ToString());
279                 Assert.Fail("Caught Exception : Failed!");
280             }
281
282             tlog.Debug(tag, $"WindowGetNativeHandle END (OK)");
283         }
284
285         [Test]
286         [Category("P1")]
287         [Description("Window Add")]
288         [Property("SPEC", "Tizen.NUI.Window.Add M")]
289         [Property("SPEC_URL", "-")]
290         [Property("CRITERIA", "MR")]
291         public void WindowAdd()
292         {
293             tlog.Debug(tag, $"WindowAdd START");
294
295             try
296             {
297                 Layer layer = null;
298                 win.Add(layer);
299             }
300             catch (ArgumentNullException e)
301             {
302                 tlog.Debug(tag, e.Message.ToString());
303                 tlog.Debug(tag, $"WindowAdd END (OK)");
304                 Assert.Pass("Caught ArgumentNullException : Passed!");
305             }
306         }
307
308         [Test]
309         [Category("P1")]
310         [Description("Window Remove")]
311         [Property("SPEC", "Tizen.NUI.Window.Remove M")]
312         [Property("SPEC_URL", "-")]
313         [Property("CRITERIA", "MR")]
314         public void WindowRemove()
315         {
316             tlog.Debug(tag, $"WindowRemove START");
317
318             try
319             {
320                 Layer layer = null;
321                 win.Remove(layer);
322             }
323             catch (ArgumentNullException e)
324             {
325                 tlog.Debug(tag, e.Message.ToString());
326                 tlog.Debug(tag, $"WindowRemove END (OK)");
327                 Assert.Pass("Caught ArgumentNullException : Passed!");
328             }
329         }
330
331         [Test]
332         [Category("P1")]
333         [Description("Window GetRenderTaskList")]
334         [Property("SPEC", "Tizen.NUI.Window.GetRenderTaskList M")]
335         [Property("SPEC_URL", "-")]
336         [Property("CRITERIA", "MR")]
337         public void WindowGetRenderTaskList()
338         {
339             tlog.Debug(tag, $"WindowGetRenderTaskList START");
340             try
341             {
342                 win.GetRenderTaskList();
343             }
344             catch (Exception e)
345             {
346                 tlog.Debug(tag, e.Message.ToString());
347                 Assert.Fail("Caught Exception : Failed!");
348             }
349
350             tlog.Debug(tag, $"WindowGetRenderTaskList END (OK)");
351         }
352
353         //[Test]
354         //[Category("P1")]
355         //[Description("Window GetObjectRegistry")]
356         //[Property("SPEC", "Tizen.NUI.Window.GetObjectRegistry M")]
357         //[Property("SPEC_URL", "-")]
358         //[Property("CRITERIA", "MR")]
359         //public void WindowGetObjectRegistry()
360         //{
361         //    tlog.Debug(tag, $"WindowGetObjectRegistry START");
362         //    try
363         //    {
364         //        win.GetObjectRegistry();
365         //    }
366         //    catch (Exception e)
367         //    {
368         //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
369
370         //        Assert.Fail("Caught Exception" + e.ToString());
371         //    }
372         //    tlog.Debug(tag, $"WindowGetObjectRegistry END (OK)");
373         //    Assert.Pass("WindowGetObjectRegistry");
374         //}
375
376         [Test]
377         [Category("P1")]
378         [Description("Window SetWindowSize")]
379         [Property("SPEC", "Tizen.NUI.Window.SetWindowSize M")]
380         [Property("SPEC_URL", "-")]
381         [Property("CRITERIA", "MR")]
382         public void WindowSetWindowSize()
383         {
384             tlog.Debug(tag, $"WindowSetWindowSize START");
385
386             try
387             {
388                 Size2D s1 = null;
389                 win.SetWindowSize(s1);
390             }
391             catch (ArgumentNullException e)
392             {
393                 tlog.Debug(tag, e.Message.ToString());
394                 tlog.Debug(tag, $"WindowSetWindowSize END (OK)");
395                 Assert.Pass("Caught ArgumentNullException : Passed!");
396             }
397         }
398
399         [Test]
400         [Category("P1")]
401         [Description("Window SetPosition")]
402         [Property("SPEC", "Tizen.NUI.Window.SetPosition M")]
403         [Property("SPEC_URL", "-")]
404         [Property("CRITERIA", "MR")]
405         public void WindowSetPosition()
406         {
407             tlog.Debug(tag, $"WindowSetPosition START");
408
409             try
410             {
411                 Position2D p1 = null;
412                 win.SetPosition(p1);
413             }
414             catch (ArgumentNullException e)
415             {
416                 tlog.Debug(tag, e.Message.ToString());
417                 tlog.Debug(tag, $"WindowSetPosition END (OK)");
418                 Assert.Pass("Caught ArgumentNullException : Passed!");
419             }
420         }
421
422         [Test]
423         [Category("P1")]
424         [Description("Window SetPositionSize")]
425         [Property("SPEC", "Tizen.NUI.Window.SetPositionSize M")]
426         [Property("SPEC_URL", "-")]
427         [Property("CRITERIA", "MR")]
428         public void WindowSetPositionSize()
429         {
430             tlog.Debug(tag, $"WindowSetPositionSize START");
431             try
432             {
433                 Rectangle r1 = new Rectangle(0, 0, 20, 20);
434                 win.SetPositionSize(r1);
435             }
436             catch (Exception e)
437             {
438                 tlog.Debug(tag, e.Message.ToString());
439                 Assert.Fail("Caught Exception : Failed!");
440             }
441             tlog.Debug(tag, $"WindowSetPositionSize END (OK)");
442         }
443
444         [Test]
445         [Category("P1")]
446         [Description("Window AddFrameUpdateCallback")]
447         [Property("SPEC", "Tizen.NUI.Window.AddFrameUpdateCallback M")]
448         [Property("SPEC_URL", "-")]
449         [Property("CRITERIA", "MR")]
450         public void WindowAddFrameUpdateCallback()
451         {
452             tlog.Debug(tag, $"WindowAddFrameUpdateCallback START");
453             try
454             {
455                 FrameUpdateCallbackInterface f1 = new FrameUpdateCallbackInterface();
456                 win.AddFrameUpdateCallback(f1);
457             }
458             catch (Exception e)
459             {
460                 tlog.Debug(tag, e.Message.ToString());
461                 Assert.Fail("Caught Exception : Failed!");
462             }
463
464             tlog.Debug(tag, $"WindowAddFrameUpdateCallback END (OK)");
465         }
466
467         [Test]
468         [Category("P1")]
469         [Description("Window RemoveFrameUpdateCallback")]
470         [Property("SPEC", "Tizen.NUI.Window.RemoveFrameUpdateCallback M")]
471         [Property("SPEC_URL", "-")]
472         [Property("CRITERIA", "MR")]
473         public void WindowRemoveFrameUpdateCallback()
474         {
475             tlog.Debug(tag, $"WindowRemoveFrameUpdateCallback START");
476             try
477             {
478                 FrameUpdateCallbackInterface f1 = new FrameUpdateCallbackInterface();
479                 win.RemoveFrameUpdateCallback(f1);
480             }
481             catch (Exception e)
482             {
483                 tlog.Debug(tag, e.Message.ToString());
484                 Assert.Fail("Caught Exception : Failed!");
485             }
486
487             tlog.Debug(tag, $"WindowRemoveFrameUpdateCallback END (OK)");
488         }
489
490         [Test]
491         [Category("P1")]
492         [Description("Window AddFrameRenderedCallback")]
493         [Property("SPEC", "Tizen.NUI.Window.AddFrameRenderedCallback M")]
494         [Property("SPEC_URL", "-")]
495         [Property("CRITERIA", "MR")]
496         public void WindowAddFrameRenderedCallback()
497         {
498             tlog.Debug(tag, $"WindowAddFrameRenderedCallback START");
499             
500             try
501             {
502                 FrameCallbackType f1 = null;
503                 win.AddFrameRenderedCallback(f1, 1);
504             }
505             catch (ArgumentNullException e)
506             {
507                 tlog.Debug(tag, e.Message.ToString());
508                 tlog.Debug(tag, $"WindowAddFrameRenderedCallback END (OK)");
509                 Assert.Pass("Caught ArgumentNullException : Passed!");
510             }
511         }
512
513         [Test]
514         [Category("P1")]
515         [Description("Window AddFramePresentedCallback")]
516         [Property("SPEC", "Tizen.NUI.Window.AddFramePresentedCallback M")]
517         [Property("SPEC_URL", "-")]
518         [Property("CRITERIA", "MR")]
519         public void WindowAddFramePresentedCallback()
520         {
521             tlog.Debug(tag, $"WindowAddFramePresentedCallback START");
522             
523             try
524             {
525                 FrameCallbackType f1 = null;
526                 win.AddFramePresentedCallback(f1, 1);
527             }
528             catch (ArgumentNullException e)
529             {
530                 tlog.Debug(tag, e.Message.ToString());
531                 tlog.Debug(tag, $"WindowAddFramePresentedCallback END (OK)");
532                 Assert.Pass("Caught ArgumentNullException : Passed!");
533             }
534         }
535
536         [Test]
537         [Category("P1")]
538         [Description("Window Get")]
539         [Property("SPEC", "Tizen.NUI.Window.Get M")]
540         [Property("SPEC_URL", "-")]
541         [Property("CRITERIA", "MR")]
542         public void WindowGet()
543         {
544             tlog.Debug(tag, $"WindowGet START");
545
546             using (NUI.BaseComponents.View view = new NUI.BaseComponents.View() { Color = Color.Cyan })
547             {
548                 NUIApplication.GetDefaultWindow().Add(view);
549                 
550                 try
551                 {
552                     var result = Window.Get(view);
553                 }
554                 catch (Exception e)
555                 {
556                     tlog.Debug(tag, e.Message.ToString());
557                     Assert.Fail("Caught Exception : Failed!");
558                 }
559
560                 NUIApplication.GetDefaultWindow().Remove(view);
561             }
562
563             tlog.Debug(tag, $"WindowGet END (OK)");
564         }
565
566         [Test]
567         [Category("P1")]
568         [Description("Window EnableFloatingMode")]
569         [Property("SPEC", "Tizen.NUI.Window.EnableFloatingMode M")]
570         [Property("SPEC_URL", "-")]
571         [Property("CRITERIA", "MR")]
572         public void WindowEnableFloatingMode()
573         {
574             tlog.Debug(tag, $"WindowEnableFloatingMode START");
575
576             try
577             {
578                 Window.Instance.EnableFloatingMode(true);
579             }
580             catch (Exception e)
581             {
582                 tlog.Debug(tag, e.Message.ToString());
583                 Assert.Fail("Caught Exception : Failed!");
584             }
585             
586             tlog.Debug(tag, $"WindowEnableFloatingMode END (OK)");
587         }
588
589         [Test]
590         [Category("P1")]
591         [Description("Window RequestMoveToServer")]
592         [Property("SPEC", "Tizen.NUI.Window.RequestMoveToServer M")]
593         [Property("SPEC_URL", "-")]
594         [Property("CRITERIA", "MR")]
595         public void WindowRequestMoveToServer()
596         {
597             tlog.Debug(tag, $"WindowRequestMoveToServer START");
598
599             try
600             {
601                 Window.Instance.RequestMoveToServer();
602             }
603             catch (Exception e)
604             {
605                 tlog.Debug(tag, e.Message.ToString());
606                 Assert.Fail("Caught Exception : Failed!");
607             }
608
609             tlog.Debug(tag, $"WindowRequestMoveToServer END (OK)");
610         }
611
612         [Test]
613         [Category("P1")]
614         [Description("Window RequestResizeToServer")]
615         [Property("SPEC", "Tizen.NUI.Window.RequestResizeToServer M")]
616         [Property("SPEC_URL", "-")]
617         [Property("CRITERIA", "MR")]
618         public void WindowRequestResizeToServer()
619         {
620             tlog.Debug(tag, $"WindowRequestResizeToServer START");
621
622             try
623             {
624                 Window.Instance.RequestResizeToServer(ResizeDirection.Top);
625             }
626             catch (Exception e)
627             {
628                 tlog.Debug(tag, e.Message.ToString());
629                 Assert.Fail("Caught Exception : Failed!");
630             }
631
632             tlog.Debug(tag, $"WindowRequestResizeToServer END (OK)");
633         }
634     }
635 }