[NUI] Update NUI.Devel to fix block and crash issues.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Window / TSWindowVisibilityChangedEvent.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
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Window/WindowVisibilityChangedEvent")]
14     public class InternalWindowVisibilityChangedEventTest
15     {
16         private const string tag = "NUITEST";
17
18         private delegate bool dummyCallback(IntPtr signal);
19         private bool OnDummyCallback(IntPtr data)
20         {
21             return false;
22         }
23
24         [SetUp]
25         public void Init()
26         {
27             tlog.Info(tag, "Init() is called!");
28         }
29
30         [TearDown]
31         public void Destroy()
32         {
33             tlog.Info(tag, "Destroy() is called!");
34         }
35
36         [Test]
37         [Category("P1")]
38         [Description("WindowVisibilityChangedEvent constructor")]
39         [Property("SPEC", "Tizen.NUI.WindowVisibilityChangedEvent.WindowVisibilityChangedEvent C")]
40         [Property("SPEC_URL", "-")]
41         [Property("CRITERIA", "CONSTR")]
42         [Property("AUTHOR", "guowei.wang@samsung.com")]
43         public void WindowVisibilityChangedEventConstructor()
44         {
45             tlog.Debug(tag, $"WindowVisibilityChangedEventConstructor START");
46
47             var testingTarget = new WindowVisibilityChangedEvent(Window.Instance);
48             Assert.IsNotNull(testingTarget, "should be not null");
49             Assert.IsInstanceOf<WindowVisibilityChangedEvent>(testingTarget, "should be an instance of WindowVisibilityChangedEvent class!");
50
51             testingTarget.Dispose();
52             tlog.Debug(tag, $"WindowVisibilityChangedEventConstructor END (OK)");
53         }
54
55         [Test]
56         [Category("P1")]
57         [Description("WindowVisibilityChangedEvent Empty.")]
58         [Property("SPEC", "Tizen.NUI.WindowVisibilityChangedEvent.Empty M")]
59         [Property("SPEC_URL", "-")]
60         [Property("CRITERIA", "MR")]
61         [Property("AUTHOR", "guowei.wang@samsung.com")]
62         public void WindowVisibilityChangedEventEmpty()
63         {
64             tlog.Debug(tag, $"WindowVisibilityChangedEventEmpty START");
65
66             var testingTarget = new WindowVisibilityChangedEvent(Window.Instance);
67             Assert.IsNotNull(testingTarget, "Should be not null!");
68             Assert.IsInstanceOf<WindowVisibilityChangedEvent>(testingTarget, "Should be an Instance of WindowVisibilityChangedEvent!");
69
70             try
71             {
72                 testingTarget.Empty();
73             }
74             catch (Exception e)
75             {
76                 tlog.Debug(tag, e.Message.ToString());
77                 Assert.Fail("Caught Exception: Failed!");
78             }
79
80             testingTarget.Dispose();
81             tlog.Debug(tag, $"WindowVisibilityChangedEventEmpty END (OK)");
82         }
83
84         [Test]
85         [Category("P1")]
86         [Description("WindowVisibilityChangedEvent GetConnectionCount.")]
87         [Property("SPEC", "Tizen.NUI.WindowVisibilityChangedEvent.GetConnectionCount M")]
88         [Property("SPEC_URL", "-")]
89         [Property("CRITERIA", "MR")]
90         [Property("AUTHOR", "guowei.wang@samsung.com")]
91         public void WindowVisibilityChangedEventGetConnectionCount()
92         {
93             tlog.Debug(tag, $"WindowVisibilityChangedEventGetConnectionCount START");
94
95             var testingTarget = new WindowVisibilityChangedEvent(Window.Instance);
96             Assert.IsNotNull(testingTarget, "Should be not null!");
97             Assert.IsInstanceOf<WindowVisibilityChangedEvent>(testingTarget, "Should be an Instance of WindowVisibilityChangedEvent!");
98
99             try
100             {
101                 testingTarget.GetConnectionCount();
102             }
103             catch (Exception e)
104             {
105                 tlog.Debug(tag, e.Message.ToString());
106                 Assert.Fail("Caught Exception: Failed!");
107             }
108
109             testingTarget.Dispose();
110
111             tlog.Debug(tag, $"WindowVisibilityChangedEventGetConnectionCount END (OK)");
112         }
113
114         [Test]
115         [Category("P1")]
116         [Description("WindowVisibilityChangedEvent Connect.")]
117         [Property("SPEC", "Tizen.NUI.WindowVisibilityChangedEvent.Connect M")]
118         [Property("SPEC_URL", "-")]
119         [Property("CRITERIA", "MR")]
120         [Property("AUTHOR", "guowei.wang@samsung.com")]
121         public void WindowVisibilityChangedEventConnect()
122         {
123             tlog.Debug(tag, $"WindowVisibilityChangedEventConnect START");
124
125             var testingTarget = new WindowVisibilityChangedEvent(Window.Instance);
126             Assert.IsNotNull(testingTarget, "Should be not null!");
127             Assert.IsInstanceOf<WindowVisibilityChangedEvent>(testingTarget, "Should be an Instance of WindowVisibilityChangedEvent!");
128
129             try
130             {
131                 dummyCallback callback = OnDummyCallback;
132                 testingTarget.Connect(callback);
133                 testingTarget.Disconnect(callback);
134             }
135             catch (Exception e)
136             {
137                 tlog.Debug(tag, e.Message.ToString());
138                 Assert.Fail("Caught Exception: Failed!");
139             }
140
141             testingTarget.Dispose();
142
143             tlog.Debug(tag, $"WindowVisibilityChangedEventConnect END (OK)");
144         }
145
146         [Test]
147         [Category("P1")]
148         [Description("WindowVisibilityChangedEvent Emit.")]
149         [Property("SPEC", "Tizen.NUI.WindowVisibilityChangedEvent.Emit M")]
150         [Property("SPEC_URL", "-")]
151         [Property("CRITERIA", "MR")]
152         [Property("AUTHOR", "guowei.wang@samsung.com")]
153         public void WindowVisibilityChangedEventEmit()
154         {
155             tlog.Debug(tag, $"WindowVisibilityChangedEventEmit START");
156             var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
157             var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
158
159             tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
160
161             using (Window window = new Window(new Rectangle(0, 0, 2, 2), false))
162             {
163                 var testingTarget = new WindowVisibilityChangedEvent(Window.Instance);
164                 Assert.IsNotNull(testingTarget, "Should be not null!");
165                 Assert.IsInstanceOf<WindowVisibilityChangedEvent>(testingTarget, "Should be an Instance of WindowVisibilityChangedEvent!");
166
167                 try
168                 {
169                     testingTarget.Emit(window, false);
170                 }
171                 catch (Exception e)
172                 {
173                     tlog.Debug(tag, e.Message.ToString());
174                     Assert.Fail("Caught Exception: Failed!");
175                 }
176
177                 testingTarget.Dispose();
178             }
179
180             tlog.Debug(tag, $"WindowVisibilityChangedEventEmit END (OK)");
181         }
182     }
183 }