[NUI][TCSACR-279][Add a new testcase for Window] 03/214503/7
authorSunghyun kim <scholb.kim@samsung.com>
Mon, 23 Sep 2019 09:43:35 +0000 (18:43 +0900)
committerSunghyun kim <scholb.kim@samsung.com>
Mon, 14 Oct 2019 08:14:04 +0000 (17:14 +0900)
Change-Id: I5f2acbf3856c676e7560818290656a09b12082a9

tct-suite-vs/Tizen.NUI.Tests/testcase/TSWindow.cs

index ca091e0..f2b15bc 100755 (executable)
@@ -28,22 +28,62 @@ namespace Tizen.NUI.Tests
         public void Destroy()
         {
             Tizen.Log.Info(TAG, "Destroy() is called!");
-        }\r
-\r
-        private void OnFocusChanged(object obj, EventArgs e)\r
+        }
+
+        private void OnFocusChanged(object obj, EventArgs e)
         { }
 
-        private void OnKeyEvent(object obj, EventArgs e)\r
+        private void OnKeyEvent(object obj, EventArgs e)
         { }
 
-        private void OnTouchEvent(object obj, EventArgs e)\r
+        private void OnTouchEvent(object obj, EventArgs e)
         { }
 
-        private void OnWheelEvent(object obj, EventArgs e)\r
+        private void OnWheelEvent(object obj, EventArgs e)
         { }
 
         [Test]
         [Category("P1")]
+        [Description("Create a new Window. Check whether window is successfully created or not.")]
+        [Property("SPEC", "Tizen.NUI.Window.Window C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("COVPARAM", "Rectangle, bool")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void Window_INIT()
+        {
+            /* TEST CODE */
+            var window = new Window(new Rectangle(0,0,1920,1080), false );
+            Assert.IsNotNull(window, "The instance should be not null");
+            Assert.IsInstanceOf<Window>(window, "Should return View instance.");
+
+            var twindow = new Window(new Rectangle(0,0,1920,1080), true );
+            Assert.IsNotNull(twindow, "The instance should be not null");
+            Assert.IsInstanceOf<Window>(twindow, "Should return View instance.");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Create a new Window include name. Check whether window is successfully created or not.")]
+        [Property("SPEC", "Tizen.NUI.Window.Window C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("COVPARAM", "string, Rectangle, bool")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void Window_INIT_NAME()
+        {
+            /* TEST CODE */
+            var window = new Window("Test Window", new Rectangle(0,0,1920,1080), false );
+            Assert.IsNotNull(window, "The instance should be not null");
+            Assert.IsInstanceOf<Window>(window, "Should return View instance.");
+
+            var twindow = new Window("Test Window", new Rectangle(0,0,1920,1080), true );
+            Assert.IsNotNull(twindow, "The instance should be not null");
+            Assert.IsInstanceOf<Window>(twindow, "Should return View instance.");
+        }
+
+        [Test]
+        [Category("P1")]
         [Description("dali window Raise test, try to raise the window")]
         [Property("SPEC", "Tizen.NUI.Window.Raise M")]
         [Property("SPEC_URL", "-")]
@@ -398,24 +438,24 @@ namespace Tizen.NUI.Tests
             /* TEST CODE */
             Window stage = Window.Instance;
             Layer layer = stage.GetDefaultLayer();
-            uint cnt = stage.LayerCount;\r
-            Tizen.Log.Debug("NUITEST", $"num of layers={cnt}");\r
-\r
-            // default layer's depth can be changed by sibling order or rendering order\r
-            uint defaultLayerdepth = 0;\r
-            for (uint i = 0; i < cnt; i++)\r
-            {\r
-                var iterLayer = stage.GetLayer(i);\r
-                if (iterLayer == null)\r
-                {\r
-                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is NULL!");\r
-                }\r
-                else if (iterLayer == layer)\r
-                {\r
-                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is same as default layer!");\r
-                    defaultLayerdepth = i;\r
-                    break;\r
-                }\r
+            uint cnt = stage.LayerCount;
+            Tizen.Log.Debug("NUITEST", $"num of layers={cnt}");
+
+            // default layer's depth can be changed by sibling order or rendering order
+            uint defaultLayerdepth = 0;
+            for (uint i = 0; i < cnt; i++)
+            {
+                var iterLayer = stage.GetLayer(i);
+                if (iterLayer == null)
+                {
+                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is NULL!");
+                }
+                else if (iterLayer == layer)
+                {
+                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is same as default layer!");
+                    defaultLayerdepth = i;
+                    break;
+                }
             }
             Assert.IsTrue((stage.GetLayer(defaultLayerdepth) == layer), "Should be equal!");
         }
@@ -844,26 +884,26 @@ namespace Tizen.NUI.Tests
         public void GetLayer_CHECK_RETURN_VALUE()
         {
             /* TEST CODE */
-            Layer layer = Window.Instance.GetDefaultLayer();\r
-\r
-            uint cnt = Window.Instance.LayerCount;\r
-            Tizen.Log.Debug("NUITEST", $"num of layers={cnt}");\r
-\r
-            // default layer's depth can be changed by sibling order or rendering order\r
-            uint defaultLayerdepth = 0;\r
-            for (uint i = 0; i < cnt; i++)\r
-            {\r
-                var iterLayer = Window.Instance.GetLayer(i);\r
-                if (iterLayer == null)\r
-                {\r
-                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is NULL!");\r
-                }\r
-                else if (iterLayer == layer)\r
-                {\r
-                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is same as default layer!");\r
-                    defaultLayerdepth = i;\r
-                    break;\r
-                }\r
+            Layer layer = Window.Instance.GetDefaultLayer();
+
+            uint cnt = Window.Instance.LayerCount;
+            Tizen.Log.Debug("NUITEST", $"num of layers={cnt}");
+
+            // default layer's depth can be changed by sibling order or rendering order
+            uint defaultLayerdepth = 0;
+            for (uint i = 0; i < cnt; i++)
+            {
+                var iterLayer = Window.Instance.GetLayer(i);
+                if (iterLayer == null)
+                {
+                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is NULL!");
+                }
+                else if (iterLayer == layer)
+                {
+                    Tizen.Log.Debug("NUITEST", $"iterLayer[{i}] is same as default layer!");
+                    defaultLayerdepth = i;
+                    break;
+                }
             }
 
             Assert.IsTrue((Window.Instance.GetLayer(defaultLayerdepth) == layer), "Should be equal!");
@@ -1173,5 +1213,176 @@ namespace Tizen.NUI.Tests
                 Assert.Fail("Caught Exception" + e.ToString());
             }
         }
-    }\r
+
+        [Test]
+        [Category("P1")]
+        [Description("AddAvailableOrientation test. After AddAvailableOrientation, Windows rotation is possible in that direction.")]
+        [Property("SPEC", "Tizen.NUI.Window.AddAvailableOrientation M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void AddAvailableOrientation_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            var window = Window.Instance;
+            try
+            {
+                window.AddAvailableOrientation( Window.WindowOrientation.Portrait );
+                window.AddAvailableOrientation( Window.WindowOrientation.Landscape );
+                window.AddAvailableOrientation( Window.WindowOrientation.PortraitInverse );
+                window.AddAvailableOrientation( Window.WindowOrientation.LandscapeInverse );
+                window.AddAvailableOrientation((Window.WindowOrientation)100);
+                window.AddAvailableOrientation((Window.WindowOrientation)200 );
+                window.AddAvailableOrientation((Window.WindowOrientation)300 );
+            }
+            catch( Exception e )
+            {
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("checks for Window::RemoveAvailableOrientation() functionality")]
+        [Property("SPEC", "Tizen.NUI.Window.RemoveAvailableOrientation M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void RemoveAvailableOrientation_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            var window = Window.Instance;
+            try
+            {
+                window.AddAvailableOrientation(Window.WindowOrientation.Portrait);
+                window.AddAvailableOrientation(Window.WindowOrientation.Landscape);
+                window.AddAvailableOrientation(Window.WindowOrientation.PortraitInverse);
+                window.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse);
+                window.RemoveAvailableOrientation( Window.WindowOrientation.Landscape );
+                window.RemoveAvailableOrientation( Window.WindowOrientation.Landscape);
+                window.RemoveAvailableOrientation( Window.WindowOrientation.Landscape);
+                window.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse);
+                window.AddAvailableOrientation((Window.WindowOrientation)100 );
+                window.RemoveAvailableOrientation(Window.WindowOrientation.Landscape);
+                window.AddAvailableOrientation((Window.WindowOrientation)200 );
+                window.AddAvailableOrientation((Window.WindowOrientation)300 );
+            }
+            catch( Exception e )
+            {
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("SetPreferredOrientation test. After SetPreferredOrientation, window is forcibly rotated in that direction.")]
+        [Property("SPEC", "Tizen.NUI.Window.SetPreferredOrientation M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void SetPreferredOrientation_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            var window = Window.Instance;
+            window.SetPreferredOrientation(Window.WindowOrientation.Landscape);
+            Assert.AreEqual(Window.WindowOrientation.Landscape , window.GetPreferredOrientation(), "SetPreferredOrientation does not work.");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("GetPreferredOrientation test. GetPreferredOrientation() have to return the currently set orientation value.")]
+        [Property("SPEC", "Tizen.NUI.Window.GetPreferredOrientation M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void GetPreferredOrientation_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            var window = Window.Instance;
+            window.SetPreferredOrientation(Window.WindowOrientation.Portrait);
+            Assert.AreEqual(Window.WindowOrientation.Portrait, window.GetPreferredOrientation(), "GetPreferredOrientation does not work.");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test SetParent. Check whether setting the parent window for the current window works fine or not")]
+        [Property("SPEC", "Tizen.NUI.Window.SetParent M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void SetParent_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            try
+            {
+                var window = Window.Instance;
+                var pwindow = new Window();
+                Assert.IsNotNull(pwindow, "The instance should be not null");
+                window.SetParent(pwindow);
+            }
+            catch (Exception e)
+            {
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test Unparent. Check whether unsetting the parent window for the current window works fine or not")]
+        [Property("SPEC", "Tizen.NUI.Window.Unparent M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void Unparent_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            try
+            {
+                var window = Window.Instance;
+                var pwindow = new Window();
+                Assert.IsNotNull(pwindow, "The instance should be not null");
+                window.SetParent(pwindow);
+                window.Unparent();
+                Assert.AreNotEqual(pwindow, window.GetParent(), "Unparent does not work");
+            }
+            catch (Exception e)
+            {
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test GetParent. GetParent() have to return the currently set parent window.")]
+        [Property("SPEC", "Tizen.NUI.Window.GetParent M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Sunghyun kim, scholb.kim@samsung.com")]
+        public void GetParent_CHECK_RETURN_VALUE()
+        {
+            /* TEST CODE */
+            try
+            {
+                var window = Window.Instance;
+                var pwindow = new Window();
+                Assert.IsNotNull(pwindow, "The instance should be not null");
+                window.SetParent(pwindow);
+                Assert.AreEqual(pwindow, window.GetParent(), "GetParent does not work");
+            }
+            catch (Exception e)
+            {
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
+        }
+    }
 }