[NUI][Non-ACR][Fix TCT Crash issue] 42/187742/7
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 28 Aug 2018 06:34:31 +0000 (15:34 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Thu, 30 Aug 2018 00:59:33 +0000 (09:59 +0900)
Change-Id: I06fcf7f4a826ac37e03489e37fa25d47f5da4dc7
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
tct-suite-vs/Tizen.NUI.Tests/testcase/TSContainer.cs
tct-suite-vs/Tizen.NUI.Tests/testcase/TSView.cs

index 0468c3a..55e207e 100755 (executable)
@@ -96,7 +96,7 @@ namespace Tizen.NUI.Tests
             Layer parentContainer = new Layer();
             View childView = new View();
             parentContainer.Add(childView);
-            Container parent = childView.Parent;
+            Container parent = childView.GetParent();
             Assert.IsNotNull(parent, "Should be not null!");
         }
 
index 2987a68..ff2ff6a 100755 (executable)
@@ -18,9 +18,10 @@ namespace Tizen.NUI.Tests
     public class ViewTests
     {
         private static string TAG = "NUI";
-        private static string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
+        private static bool _flag = false;
+        private static string _imagePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
 
-        private string VertexShader = " attribute mediump vec2 aPosition;\n" +
+        private string _vertexShader = " attribute mediump vec2 aPosition;\n" +
                     " uniform   mediump mat4 uMvpMatrix;\n" +
                     " \n" +
                     " void main()\n" +
@@ -28,7 +29,7 @@ namespace Tizen.NUI.Tests
                     "   mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n" +
                     "   gl_Position = uMvpMatrix * vertexPosition;\n" +
                     " }\n";
-        private string FragmentShader = " uniform mediump vec4 uColor;\n" +
+        private string _fragmentShader = " uniform mediump vec4 uColor;\n" +
                                         "  \n" +
                                         "  void main()\n" +
                                         "  {\n" +
@@ -39,6 +40,7 @@ namespace Tizen.NUI.Tests
         public static void Init()
         {
             Tizen.Log.Info(TAG, "Init() is called!");
+            _flag = false;
             App.MainTitleChangeText("ViewTests");
             App.MainTitleChangeBackgroundColor(null);
         }
@@ -49,6 +51,10 @@ namespace Tizen.NUI.Tests
             Tizen.Log.Info(TAG, "Destroy() is called!");
         }
 
+        private void viewEventCallback(object sender, EventArgs e)
+        {
+            _flag = true;
+        }
 
         [Test]
         [Category("P1")]
@@ -174,6 +180,7 @@ namespace Tizen.NUI.Tests
             Assert.AreEqual(-1, actor.HierarchyDepth, "The actor is not in the hierarchy");
             Window.Instance.GetDefaultLayer().Add(actor);
             Assert.AreEqual(1, actor.HierarchyDepth, "The actor is in the hierarchy");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
 
@@ -372,6 +379,7 @@ namespace Tizen.NUI.Tests
             Assert.AreEqual((position.X + parentPosition.X), actor.WorldPosition.X, "The WorldPosition.X of actor should be 7.0f now");
             Assert.AreEqual((position.Y + parentPosition.Y), actor.WorldPosition.Y, "The WorldPosition.Y of actor should be 8.0f now");
             Assert.AreEqual((position.Z + parentPosition.Z), actor.WorldPosition.Z, "The WorldPosition.Z of actor should be 9.0f now");
+            Window.Instance.GetDefaultLayer().Remove(parentActor);
         }
 
         [Test]
@@ -384,13 +392,11 @@ namespace Tizen.NUI.Tests
         public void AddedToWindow_CHECK_EVENT()
         {
             View view = new View();
-            bool flag = false;
-            view.AddedToWindow += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.AddedToWindow += viewEventCallback;
             Window.Instance.GetDefaultLayer().Add(view);
-            Assert.IsTrue(flag, "The AddedToWindow Event has been triggerred!");
+            Assert.IsTrue(_flag, "The AddedToWindow Event has been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.AddedToWindow -= viewEventCallback;
         }
 
         [Test]
@@ -575,6 +581,7 @@ namespace Tizen.NUI.Tests
             await Task.Delay(20);
             Assert.AreEqual(size.Width, actorSize.Width, "The Width of actor should be 100.0f now");
             Assert.AreEqual(size.Height, actorSize.Height, "The Height of actor should be 100.0f now");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
         [Test]
@@ -636,6 +643,7 @@ namespace Tizen.NUI.Tests
 
             Assert.Greater(actor.ScreenPosition.X, 0, "The X of the actor's ScreenPosition is not correct!");
             Assert.Greater(actor.ScreenPosition.Y, 0, "The Y of the actor's ScreenPosition is not correct!");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
         [Test]
@@ -697,6 +705,7 @@ namespace Tizen.NUI.Tests
             Assert.Greater(actor.WorldScale.X, 0, "The WorldScale.X of actor should be 2.0f now");
             Assert.Greater(actor.WorldScale.Y, 0, "The WorldScale.Y of actor should be 4.0f now");
             Assert.Greater(actor.WorldScale.Z, 0, "The WorldScale.Z of actor should be 2.0f now");
+            Window.Instance.GetDefaultLayer().Remove(parentActor);
         }
 
 
@@ -1059,6 +1068,9 @@ namespace Tizen.NUI.Tests
                 Window.Instance.GetDefaultLayer().Add(actorB);
                 Window.Instance.GetDefaultLayer().Add(actorC);
                 actorC.RaiseToTop();
+                Window.Instance.GetDefaultLayer().Remove(actorA);
+                Window.Instance.GetDefaultLayer().Remove(actorB);
+                Window.Instance.GetDefaultLayer().Remove(actorC);
             }
             catch (Exception e)
             {
@@ -1099,6 +1111,9 @@ namespace Tizen.NUI.Tests
                 Window.Instance.GetDefaultLayer().Add(actorB);
                 Window.Instance.GetDefaultLayer().Add(actorC);
                 actorA.LowerToBottom();
+                Window.Instance.GetDefaultLayer().Remove(actorA);
+                Window.Instance.GetDefaultLayer().Remove(actorB);
+                Window.Instance.GetDefaultLayer().Remove(actorC);
             }
             catch (Exception e)
             {
@@ -1164,6 +1179,7 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(actor);
             bool isOnStage = actor.IsOnWindow;
             Assert.IsTrue(isOnStage, "The actor is on window now.");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
         [Test]
@@ -1319,6 +1335,7 @@ namespace Tizen.NUI.Tests
             parentActor.Add(childActor);
             await Task.Delay(20);
             Assert.Less(Math.Abs(rotation.Length() - (parentActor.WorldOrientation).Length()), 0.00001, "The parentActor's Orientation is not correct");
+            Window.Instance.GetDefaultLayer().Remove(parentActor);
         }
 
         [Test]
@@ -1433,6 +1450,7 @@ namespace Tizen.NUI.Tests
 
             view.Flex = 2.0f;
             Assert.AreEqual(2.0f, view.Flex, "The Flex value of View is not correct!");
+            Window.Instance.GetDefaultLayer().Remove(flexContainer);
         }
 
         [Test]
@@ -1531,6 +1549,7 @@ namespace Tizen.NUI.Tests
             view3.CellVerticalAlignment = VerticalAlignmentType.Bottom;
             table.Add(view3);
             Assert.IsTrue(table.GetChildAt(new TableView.CellPosition(0, 0)) == view3, "The child at (0, 0) should be view3!");
+            Window.Instance.GetDefaultLayer().Remove(table);
 
         }
 
@@ -1709,6 +1728,8 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(leftView);
             view.LeftFocusableView = leftView;
             Assert.IsTrue((leftView == view.LeftFocusableView), "The value of view1's LeftFocusableView is not correct here");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            Window.Instance.GetDefaultLayer().Remove(leftView);
         }
 
         [Test]
@@ -1727,6 +1748,8 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(rightView);
             view.RightFocusableView = rightView;
             Assert.IsTrue((rightView == view.RightFocusableView), "The value of view1's RightFocusableView is not correct here");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            Window.Instance.GetDefaultLayer().Remove(rightView);
         }
 
         [Test]
@@ -1745,6 +1768,8 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(upView);
             view.UpFocusableView = upView;
             Assert.IsTrue((upView == view.UpFocusableView), "The value of view1's UpFocusableView is not correct here");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            Window.Instance.GetDefaultLayer().Remove(upView);
         }
 
         [Test]
@@ -1779,6 +1804,8 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(downView);
             view.DownFocusableView = downView;
             Assert.IsTrue((downView == view.DownFocusableView), "The value of view1's DownFocusableView is not correct here");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            Window.Instance.GetDefaultLayer().Remove(downView);
         }
 
         [Test]
@@ -1837,7 +1864,7 @@ namespace Tizen.NUI.Tests
         public void AddRenderer_CHECK_RETURN_VALUE()
         {
             /* TEST CODE */
-            Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+            Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
 
             //Create the geometry
             Geometry geometry = new Geometry();
@@ -1856,7 +1883,7 @@ namespace Tizen.NUI.Tests
         public void GetRendererAt_CHECK_RETURN_VALUE()
         {
             /* TEST CODE */
-            Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+            Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
 
             //Create the geometry
             Geometry geometry = new Geometry();
@@ -1885,7 +1912,7 @@ namespace Tizen.NUI.Tests
         public void RemoveRenderer_CHECK_RETURN_VALUE_WITH_INDEX()
         {
             /* TEST CODE */
-            Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+            Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
 
             //Create the geometry
             Geometry geometry = new Geometry();
@@ -1915,7 +1942,7 @@ namespace Tizen.NUI.Tests
         public void RemoveRenderer_CHECK_RETURN_VALUE()
         {
             /* TEST CODE */
-            Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+            Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
 
             //Create the geometry
             Geometry geometry = new Geometry();
@@ -1944,7 +1971,7 @@ namespace Tizen.NUI.Tests
         public void RendererCount_CHECK_RETURN_VALUE()
         {
             /* TEST CODE */
-            Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+            Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
 
             //Create the geometry
             Geometry geometry = new Geometry();
@@ -1995,6 +2022,7 @@ namespace Tizen.NUI.Tests
 
             Assert.IsNotNull(animation, "The animation should be not null!");
             Assert.IsInstanceOf<Animation>(animation, "Should return a instance of Animation class!");
+            Window.Instance.GetDefaultLayer().Remove(view);
         }
 
         [Test]
@@ -2014,6 +2042,7 @@ namespace Tizen.NUI.Tests
 
             await Task.Delay(20);
             Assert.AreEqual(100.0f, actor.GetRelayoutSize(DimensionType.Width), "The GetRelayoutSize does not work here!");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
         [Test]
@@ -2030,7 +2059,8 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(view);
             try
             {
-                view.Unparent();
+                view.Unparent();\r
+                Window.Instance.GetDefaultLayer().Remove(view);
             }
             catch (Exception e)
             {
@@ -2057,6 +2087,7 @@ namespace Tizen.NUI.Tests
 
             Window.Instance.GetDefaultLayer().Add(view);
             Assert.IsTrue(view.IsResourceReady(), "Should be true now!");
+            Window.Instance.GetDefaultLayer().Remove(view);
         }
 
         [Test]
@@ -2085,6 +2116,7 @@ namespace Tizen.NUI.Tests
 
                 Assert.Greater(localX, 0.0f, "The localX is not correct!");
                 Assert.IsTrue(ret, "ScreenToLocal() returns false!");
+                Window.Instance.GetDefaultLayer().Remove(actor);
             }
             catch (Exception e)
             {
@@ -2110,6 +2142,7 @@ namespace Tizen.NUI.Tests
             parentActor.Add(childActor);
             Window.Instance.GetDefaultLayer().Add(parentActor);
             Assert.AreEqual(1, parentActor.ChildCount, "The child count of parentActor should be 1");
+            Window.Instance.GetDefaultLayer().Remove(parentActor);
         }
 
         [Test]
@@ -2147,6 +2180,7 @@ namespace Tizen.NUI.Tests
             await Task.Delay(300);
             Assert.AreEqual(100, actor.CurrentSize.Width, "The Width of the actor's CurrentSize is not correct!");
             Assert.AreEqual(100, actor.CurrentSize.Height, "The Height of the actor's CurrentSize is not correct!");
+            Window.Instance.GetDefaultLayer().Remove(actor);
         }
 
         [Test]
@@ -2164,6 +2198,7 @@ namespace Tizen.NUI.Tests
             view.BackgroundColor = Color.Red;
             Window.Instance.GetDefaultLayer().Add(view);
             Assert.Greater(view.ID, 0, "Should be greater than zero!");
+            Window.Instance.GetDefaultLayer().Remove(view);
         }
 
         [Test]
@@ -2182,6 +2217,7 @@ namespace Tizen.NUI.Tests
             Window.Instance.GetDefaultLayer().Add(view);
             Layer layer = view.GetLayer();
             Assert.IsNotNull(layer, "The layer of under the view Should be not null!");
+            Window.Instance.GetDefaultLayer().Remove(view);
         }
 
         [Test]
@@ -2201,6 +2237,7 @@ namespace Tizen.NUI.Tests
             try
             {
                 view.DoAction(0, 0, new PropertyValue(0));
+                Window.Instance.GetDefaultLayer().Remove(view);
             }
             catch (Exception e)
             {
@@ -2243,6 +2280,7 @@ namespace Tizen.NUI.Tests
             Assert.Greater(actor.WorldPosition.X, 0, "ChildActor's WorldPosition.X is incorrect");
             Assert.Greater(actor.WorldPosition.Y, 0, "ChildActor's WorldPosition.Y is incorrect");
             Assert.Greater(actor.WorldPosition.Z, 0, "ChildActor's WorldPosition.Z is incorrect");
+            Window.Instance.GetDefaultLayer().Remove(parentActor);
         }
 
         [Test]
@@ -2258,15 +2296,13 @@ namespace Tizen.NUI.Tests
             view.BackgroundColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
             view.Size2D = new Size2D(100, 100);
             view.Hide();
-            bool flag = false;
-            view.VisibilityChanged += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.VisibilityChanged += viewEventCallback;
             Window.Instance.GetDefaultLayer().Add(view);
             view.Show();
             await Task.Delay(200);
-            Assert.IsTrue(flag, "The VisibilityChanged Event has been triggerred!");
+            Assert.IsTrue(_flag, "The VisibilityChanged Event has been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.VisibilityChanged -= viewEventCallback;
         }
 
         [Test]
@@ -2285,6 +2321,7 @@ namespace Tizen.NUI.Tests
             FocusManager.Instance.SetCurrentFocusView(view);
             await Task.Delay(200);
             Assert.IsTrue(view.HasFocus(), "The view should hold the focus now");
+            Window.Instance.GetDefaultLayer().Remove(view);
 
         }
 
@@ -2301,13 +2338,11 @@ namespace Tizen.NUI.Tests
             view.Focusable = true;
             Window.Instance.GetDefaultLayer().Add(view);
 
-            bool flag = false;
-            view.FocusGained += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.FocusGained += viewEventCallback;
             FocusManager.Instance.SetCurrentFocusView(view);
-            Assert.IsTrue(flag, "The FocusGained Event not been triggerred!");
+            Assert.IsTrue(_flag, "The FocusGained Event not been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.FocusGained -= viewEventCallback;
         }
 
         [Test]
@@ -2325,14 +2360,13 @@ namespace Tizen.NUI.Tests
             view2.Focusable = true;
             Window.Instance.GetDefaultLayer().Add(view);
             Window.Instance.GetDefaultLayer().Add(view2);
-            bool flag = false;
-            view.FocusLost += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.FocusLost += viewEventCallback;
             FocusManager.Instance.SetCurrentFocusView(view);
             FocusManager.Instance.SetCurrentFocusView(view2);
-            Assert.IsTrue(flag, "The FocusLost Event not been triggerred!");
+            Assert.IsTrue(_flag, "The FocusLost Event not been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            Window.Instance.GetDefaultLayer().Remove(view2);
+            view.FocusLost -= viewEventCallback;
         }
 
         [Test]
@@ -2350,16 +2384,13 @@ namespace Tizen.NUI.Tests
             View parentView = new View();
             parentView.Add(view);
             Window.Instance.GetDefaultLayer().Add(parentView);
-            parentView.Size = new Size(100.0f, 100.0f, 100.0f);
-            Window.Instance.GetDefaultLayer().Add(view);
-            bool flag = false;
-            view.Relayout += (obj, e) =>
-            {
-                flag = true;
-            };
-            parentView.Size = new Size(200.0f, 300.0f, 200.0f);
+            parentView.Size2D = new Size2D(100, 100);
+            view.Relayout += viewEventCallback;
+            parentView.Size2D = new Size2D(200, 300);
             await Task.Delay(200);
-            Assert.IsTrue(flag, "The OnRelayoutEvent Event has been triggerred!");
+            Assert.IsTrue(_flag, "The OnRelayoutEvent Event has been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(parentView);
+            view.Relayout -= viewEventCallback;
         }
 
         [Test]
@@ -2375,14 +2406,12 @@ namespace Tizen.NUI.Tests
             view.Size2D = new Size2D(200, 200);
             view.BackgroundColor = Color.Red;
             Window.Instance.GetDefaultLayer().Add(view);
-            bool flag = false;
-            view.RemovedFromWindow += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.RemovedFromWindow += viewEventCallback;
             Window.Instance.GetDefaultLayer().Remove(view);
             await Task.Delay(20);
-            Assert.IsTrue(flag, "The OffStageEvent Event has been triggerred!");
+            Assert.IsTrue(_flag, "The OffStageEvent Event has been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.RemovedFromWindow -= viewEventCallback;
         }
 
         [Test]
@@ -2395,18 +2424,16 @@ namespace Tizen.NUI.Tests
         public async Task ResourcesLoaded_CHECK_EVENT()
         {
             /* TEST CODE */
-            ImageView view = new ImageView(image_path);
-            bool flag = false;
-            view.ResourcesLoaded += (obj, e) =>
-            {
-                flag = true;
-            };
+            ImageView view = new ImageView(_imagePath);
+            view.ResourcesLoaded += viewEventCallback;
             view.Size2D = new Size2D(100, 100);
             //view.ResourceUrl = image_path;
             Window.Instance.GetDefaultLayer().Add(view);
-            Tizen.Log.Debug(TAG, "ResourceUrl=" + image_path);
+            Tizen.Log.Debug(TAG, "ResourceUrl=" + _imagePath);
             await Task.Delay(500);
-            Assert.IsTrue(flag, "ResourcesLoaded does not work!");
+            Assert.IsTrue(_flag, "ResourcesLoaded does not work!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.ResourcesLoaded -= viewEventCallback;
         }
 
         [Test]
@@ -2421,16 +2448,14 @@ namespace Tizen.NUI.Tests
             View view = new View();
             view.Name = "View";
             view.LayoutDirection = ViewLayoutDirectionType.RTL;
-            bool flag = false;
-            view.LayoutDirectionChanged += (obj, e) =>
-            {
-                flag = true;
-            };
+            view.LayoutDirectionChanged += viewEventCallback;
             Window.Instance.GetDefaultLayer().Add(view);
 
             view.LayoutDirection = ViewLayoutDirectionType.LTR;
             await Task.Delay(20);
-            Assert.IsTrue(flag, "The LayoutDirectionChanged Event has been triggerred!");
+            Assert.IsTrue(_flag, "The LayoutDirectionChanged Event has been triggerred!");
+            Window.Instance.GetDefaultLayer().Remove(view);
+            view.LayoutDirectionChanged -= viewEventCallback;
         }
     }