Add Window Test file
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Window / TSWindow.cs
index 7274bf4..3c43270 100755 (executable)
@@ -12,23 +12,28 @@ namespace Tizen.NUI.Devel.Tests
     internal class PublicWindowTest
     {
         private const string tag = "NUITEST";
-        private static Window myWin;
+        private Window win = null;
+        private Rectangle rec = null;
+
         [SetUp]
         public void Init()
         {
-            Rectangle r1 = new Rectangle(0, 0, 20, 20);
-            myWin = new Window(r1);
             tlog.Info(tag, "Init() is called!");
+
+            rec = new Rectangle(0, 0, 2, 2);
+            win = new Window(rec);
         }
 
         [TearDown]
         public void Destroy()
         {
-            if (myWin != null)
+            rec.Dispose();
+            if (win != null)
             {
-                myWin.Destroy();
-                myWin = null;
+                win.Destroy();
+                win = null;
             }
+
             tlog.Info(tag, "Destroy() is called!");
         }
 
@@ -44,7 +49,11 @@ namespace Tizen.NUI.Devel.Tests
 
             try
             {
-                myWin.WindowPositionSize = new Rectangle(1, 2, 3, 4);
+                using (Rectangle size = new Rectangle(1, 2, 3, 4))
+                {
+                    win.WindowPositionSize = size;
+                    tlog.Debug(tag, "WindowPositionSize : " + win.WindowPositionSize);
+                }
             }
             catch (Exception e)
             {
@@ -113,7 +122,7 @@ namespace Tizen.NUI.Devel.Tests
             
             try
             {
-                myWin.GetLayer(0);
+                win.GetLayer(0);
             }
             catch (Exception e)
             {
@@ -135,7 +144,7 @@ namespace Tizen.NUI.Devel.Tests
             
             try
             {
-                myWin.GetCurrentOrientation();
+                win.GetCurrentOrientation();
             }
             catch (Exception e)
             {
@@ -146,36 +155,86 @@ namespace Tizen.NUI.Devel.Tests
             tlog.Debug(tag, $"WindowGetCurrentOrientation END (OK)");
         }
 
-        //[Test]
-        //[Category("P1")]
-        //[Description("Window SetAvailableOrientations")]
-        //[Property("SPEC", "Tizen.NUI.Window.SetAvailableOrientations M")]
-        //[Property("SPEC_URL", "-")]
-        //[Property("CRITERIA", "MR")]
-        //public void WindowSetAvailableOrientations()
-        //{
-        //    tlog.Debug(tag, $"WindowSetAvailableOrientations START");
-        //    try
-        //    {
-        //        List<Window.WindowOrientation> l1 = new List<Window.WindowOrientation>();
+        [Test]
+        [Category("P1")]
+        [Description("Window SetAvailableOrientations")]
+        [Property("SPEC", "Tizen.NUI.Window.SetAvailableOrientations M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowSetAvailableOrientations()
+        {
+            tlog.Debug(tag, $"WindowSetAvailableOrientations START");
+            try
+            {
+                List<Window.WindowOrientation> list = new List<Window.WindowOrientation>();
 
-        //        l1.Add(Window.WindowOrientation.Landscape);
-        //        l1.Add(Window.WindowOrientation.LandscapeInverse);
-        //        l1.Add(Window.WindowOrientation.NoOrientationPreference);
-        //        l1.Add(Window.WindowOrientation.Portrait);
-        //        l1.Add(Window.WindowOrientation.PortraitInverse);
+                list.Add(Window.WindowOrientation.Landscape);
+                list.Add(Window.WindowOrientation.LandscapeInverse);
+                list.Add(Window.WindowOrientation.NoOrientationPreference);
+                list.Add(Window.WindowOrientation.Portrait);
+                list.Add(Window.WindowOrientation.PortraitInverse);
 
-        //        myWin.SetAvailableOrientations(l1);
-        //    }
-        //    catch (Exception e)
-        //    {
-        //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
-        //        Assert.Fail("Caught Exception" + e.ToString());
-        //    }
+                win.SetAvailableOrientations(list);
+            }
+            catch (Exception e)
+            {
+                Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
+                Assert.Fail("Caught Exception" + e.ToString());
+            }
 
-        //    tlog.Debug(tag, $"WindowSetAvailableOrientations END (OK)");
-        //    Assert.Pass("WindowSetAvailableOrientations");
-        //}
+            tlog.Debug(tag, $"WindowSetAvailableOrientations END (OK)");
+            Assert.Pass("WindowSetAvailableOrientations");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Window SetAvailableOrientations")]
+        [Property("SPEC", "Tizen.NUI.Window.SetAvailableOrientations M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowSetAvailableOrientationsWithNullList()
+        {
+            tlog.Debug(tag, $"WindowSetAvailableOrientationsWithNullList START");
+
+            List<Window.WindowOrientation> list = null;
+
+            try
+            {
+                win.SetAvailableOrientations(list);
+            }
+            catch (ArgumentNullException e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                tlog.Debug(tag, $"WindowSetAvailableOrientationsWithNullList END (OK)");
+                Assert.Pass("Caught ArgumentNullException : Passed!");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window SetPositionSizeWithOrientation")]
+        [Property("SPEC", "Tizen.NUI.Window.SetPositionSizeWithOrientation M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowSetPositionSizeWithOrientation()
+        {
+            tlog.Debug(tag, $"WindowSetPositionSizeWithOrientation START");
+
+            try
+            {
+                using (Rectangle positionSize = new Rectangle(1, 2, 3, 4))
+                {
+                    win.SetPositionSizeWithOrientation(positionSize, Window.WindowOrientation.Landscape);
+                }
+            }
+            catch (Exception e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Fail("Caught Exception : Failed!");
+            }
+
+            tlog.Debug(tag, $"WindowSetPositionSizeWithOrientation END (OK)");
+        }
 
         [Test]
         [Category("P1")]
@@ -189,7 +248,7 @@ namespace Tizen.NUI.Devel.Tests
             
             try
             {
-                myWin.GetNativeId();
+                win.GetNativeId();
             }
             catch (Exception e)
             {
@@ -212,7 +271,7 @@ namespace Tizen.NUI.Devel.Tests
             
             try
             {
-                myWin.GetNativeHandle();
+                win.GetNativeHandle();
             }
             catch (Exception e)
             {
@@ -236,7 +295,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 Layer layer = null;
-                myWin.Add(layer);
+                win.Add(layer);
             }
             catch (ArgumentNullException e)
             {
@@ -259,7 +318,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 Layer layer = null;
-                myWin.Remove(layer);
+                win.Remove(layer);
             }
             catch (ArgumentNullException e)
             {
@@ -280,7 +339,7 @@ namespace Tizen.NUI.Devel.Tests
             tlog.Debug(tag, $"WindowGetRenderTaskList START");
             try
             {
-                myWin.GetRenderTaskList();
+                win.GetRenderTaskList();
             }
             catch (Exception e)
             {
@@ -302,7 +361,7 @@ namespace Tizen.NUI.Devel.Tests
         //    tlog.Debug(tag, $"WindowGetObjectRegistry START");
         //    try
         //    {
-        //        myWin.GetObjectRegistry();
+        //        win.GetObjectRegistry();
         //    }
         //    catch (Exception e)
         //    {
@@ -327,7 +386,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 Size2D s1 = null;
-                myWin.SetWindowSize(s1);
+                win.SetWindowSize(s1);
             }
             catch (ArgumentNullException e)
             {
@@ -350,7 +409,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 Position2D p1 = null;
-                myWin.SetPosition(p1);
+                win.SetPosition(p1);
             }
             catch (ArgumentNullException e)
             {
@@ -372,7 +431,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 Rectangle r1 = new Rectangle(0, 0, 20, 20);
-                myWin.SetPositionSize(r1);
+                win.SetPositionSize(r1);
             }
             catch (Exception e)
             {
@@ -394,7 +453,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 FrameUpdateCallbackInterface f1 = new FrameUpdateCallbackInterface();
-                myWin.AddFrameUpdateCallback(f1);
+                win.AddFrameUpdateCallback(f1);
             }
             catch (Exception e)
             {
@@ -417,7 +476,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 FrameUpdateCallbackInterface f1 = new FrameUpdateCallbackInterface();
-                myWin.RemoveFrameUpdateCallback(f1);
+                win.RemoveFrameUpdateCallback(f1);
             }
             catch (Exception e)
             {
@@ -441,7 +500,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 FrameCallbackType f1 = null;
-                myWin.AddFrameRenderedCallback(f1, 1);
+                win.AddFrameRenderedCallback(f1, 1);
             }
             catch (ArgumentNullException e)
             {
@@ -464,7 +523,7 @@ namespace Tizen.NUI.Devel.Tests
             try
             {
                 FrameCallbackType f1 = null;
-                myWin.AddFramePresentedCallback(f1, 1);
+                win.AddFramePresentedCallback(f1, 1);
             }
             catch (ArgumentNullException e)
             {
@@ -473,5 +532,149 @@ namespace Tizen.NUI.Devel.Tests
                 Assert.Pass("Caught ArgumentNullException : Passed!");
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window Get")]
+        [Property("SPEC", "Tizen.NUI.Window.Get M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowGet()
+        {
+            tlog.Debug(tag, $"WindowGet START");
+
+            using (NUI.BaseComponents.View view = new NUI.BaseComponents.View() { Color = Color.Cyan })
+            {
+                NUIApplication.GetDefaultWindow().Add(view);
+                
+                try
+                {
+                    var result = Window.Get(view);
+                }
+                catch (Exception e)
+                {
+                    tlog.Debug(tag, e.Message.ToString());
+                    Assert.Fail("Caught Exception : Failed!");
+                }
+
+                NUIApplication.GetDefaultWindow().Remove(view);
+            }
+
+            tlog.Debug(tag, $"WindowGet END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window EnableFloatingMode")]
+        [Property("SPEC", "Tizen.NUI.Window.EnableFloatingMode M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowEnableFloatingMode()
+        {
+            tlog.Debug(tag, $"WindowEnableFloatingMode START");
+
+            try
+            {
+                Window.Instance.EnableFloatingMode(true);
+
+            }
+            catch (Exception e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Fail("Caught Exception : Failed!");
+            }
+            tlog.Debug(tag, $"AddInputRegionTest END (OK)");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window RequestMoveToServer")]
+        [Property("SPEC", "Tizen.NUI.Window.RequestMoveToServer M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowRequestMoveToServer()
+        {
+            tlog.Debug(tag, $"WindowRequestMoveToServer START");
+
+            try
+            {
+                Window.Instance.RequestMoveToServer();
+            }
+            catch (Exception e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Fail("Caught Exception : Failed!");
+            }
+            tlog.Debug(tag, $"WindowRequestMoveToServer END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window RequestResizeToServer")]
+        [Property("SPEC", "Tizen.NUI.Window.RequestResizeToServer M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void WindowRequestResizeToServer()
+        {
+            tlog.Debug(tag, $"WindowRequestResizeToServer START");
+
+            try
+            {
+                Window.Instance.RequestResizeToServer(ResizeDirection.Top);
+            }
+            catch (Exception e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Fail("Caught Exception : Failed!");
+            }
+            tlog.Debug(tag, $"WindowRequestMoveToServer END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Window AddInputRegion Test")]
+        [Property("SPEC", "Tizen.NUI.Window.AddInputRegion M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void AddInputRegionTest()
+        {
+            try
+            {
+                var window = Window.Instance;
+                Rectangle inputRegion = new Rectangle(0, 0, 720, 640);
+                window.AddInputRegion(inputRegion);
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("Caught Exception : Failed!");
+            }
+        }
+
+
+        [Test]
+        [Category("P1")]
+        [Description("Window SubtractInputRegion Test")]
+        [Property("SPEC", "Tizen.NUI.Window.SubtractInputRegion M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        public void SubtractInputRegionTest()
+        {
+            try
+            {
+                var window = Window.Instance;
+                Rectangle addInputRegion = new Rectangle(0, 0, 720, 1280);
+                window.AddInputRegion(addInputRegion);
+
+                Rectangle subtractInputRegion = new Rectangle(0, 641, 720, 640);
+                window.SubtractInputRegion(subtractInputRegion);
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("Caught Exception : Failed!");
+            }
+
+            tlog.Debug(tag, $"SubtractInputRegionTest END (OK)");
+        }
     }
-}
\ No newline at end of file
+}