Add Window Test file
authorWonsik Jung <sidein@samsung.com>
Mon, 9 Aug 2021 08:06:42 +0000 (17:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 27 Aug 2021 05:29:50 +0000 (14:29 +0900)
add new window test file and fix build error for UTC.

test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs [new file with mode: 0644]
test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/Window/TSWindow.cs

diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/WindowTest.cs
new file mode 100644 (file)
index 0000000..d567d79
--- /dev/null
@@ -0,0 +1,110 @@
+
+using global::System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.System;
+using NUnit.Framework;
+
+namespace Tizen.NUI.Samples
+{
+    using log = Tizen.Log;
+    public class WindowTest : IExample
+    {
+        string tag = "NUITEST";
+        Window mainWin;
+        int screenWidth;
+        int screenHeight;
+
+        int addingInput;
+
+        void Initialize()
+        {
+            mainWin = NUIApplication.GetDefaultWindow();
+            mainWin.KeyEvent += OnKeyEvent;
+            mainWin.TouchEvent += WinTouchEvent;
+            mainWin.BackgroundColor = Color.Cyan;
+
+            Information.TryGetValue<int>("http://tizen.org/feature/screen.width", out screenWidth);
+            Information.TryGetValue<int>("http://tizen.org/feature/screen.height", out screenHeight);
+            log.Fatal(tag, $"Initialize= screenWidth {screenWidth}, screenHeight {screenHeight} ");
+            Rectangle inputRegion = new Rectangle(0,0,screenWidth,screenHeight/2);
+            mainWin.AddInputRegion(inputRegion);
+
+            addingInput = 0;
+
+            TextLabel text = new TextLabel("NUI Window Test");
+            text.HorizontalAlignment = HorizontalAlignment.Center;
+            text.VerticalAlignment = VerticalAlignment.Center;
+            text.TextColor = Color.Blue;
+            text.PointSize = 12.0f;
+            text.HeightResizePolicy = ResizePolicyType.FillToParent;
+            text.WidthResizePolicy = ResizePolicyType.FillToParent;
+            mainWin.Add(text);
+
+            Animation animation = new Animation(2000);
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
+            animation.Looping = true;
+            animation.Play();
+        }
+
+        private void WinTouchEvent(object sender, Window.TouchEventArgs e)
+        {
+            if (e.Touch.GetState(0) == PointStateType.Down)
+            {
+                Vector2 touchpoint = e.Touch.GetScreenPosition(0);
+                log.Fatal(tag, $"WinTouchEvent={touchpoint.X}, {touchpoint.Y}");
+                int xPosition = 0;
+                if(addingInput == 0)
+                {
+                    if(touchpoint.Y > (screenHeight/2 - 50))
+                    {
+                        int yPostion = screenHeight/2 + 1;
+                        int height = screenHeight/2;
+                        log.Fatal(tag, $"WinTouchEvent= Add {xPosition},{yPostion} {screenWidth}x{height} ");
+                        mainWin.AddInputRegion(new Rectangle(xPosition,yPostion,screenWidth,height));
+                        addingInput = 1;
+                    }
+                }
+                else
+                {
+                    if(touchpoint.Y > (screenHeight - 50))
+                    {
+                        int yPostion = screenHeight/2 + 1;
+                        int height = screenHeight/2;
+                        log.Fatal(tag, $"WinTouchEvent= Subtract {xPosition},{yPostion} {screenWidth}x{height} ");
+                        mainWin.SubtractInputRegion(new Rectangle(xPosition, yPostion, screenWidth, height));
+                        addingInput = 0;
+                    }
+                }
+            }
+        }
+
+        public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+        {
+            if (e.Key.State == Key.StateType.Down)
+            {
+                log.Fatal(tag, $"key down! key={e.Key.KeyPressedName}");
+
+                switch (e.Key.KeyPressedName)
+                {
+                    case "XF86Back":
+                    case "Escape":
+                        //Exit();
+                        break;
+
+                    case "1":
+                        log.Fatal(tag, $"pressed 1!");
+                        break;
+
+                    default:
+                        log.Fatal(tag, $"no test!");
+                        break;
+                }
+            }
+        }
+
+        public void Activate() { Initialize(); }
+        public void Deactivate() { }
+    }
+}
index da9e336..3c43270 100755 (executable)
@@ -639,18 +639,16 @@ namespace Tizen.NUI.Devel.Tests
         [Property("CRITERIA", "MR")]
         public void AddInputRegionTest()
         {
-            tlog.Debug(tag, $"AddInputRegionTest START");
             try
             {
+                var window = Window.Instance;
                 Rectangle inputRegion = new Rectangle(0, 0, 720, 640);
-                myWin.AddInputRegionTest(inputRegion);
+                window.AddInputRegion(inputRegion);
             }
             catch (Exception e)
             {
-                tlog.Debug(tag, e.Message.ToString());
                 Assert.Fail("Caught Exception : Failed!");
             }
-            tlog.Debug(tag, $"AddInputRegionTest END (OK)");
         }
 
 
@@ -662,18 +660,17 @@ namespace Tizen.NUI.Devel.Tests
         [Property("CRITERIA", "MR")]
         public void SubtractInputRegionTest()
         {
-            tlog.Debug(tag, $"SubtractInputRegionTest START");
             try
             {
+                var window = Window.Instance;
                 Rectangle addInputRegion = new Rectangle(0, 0, 720, 1280);
-                myWin.AddInputRegionTest(addInputRegion);
+                window.AddInputRegion(addInputRegion);
 
                 Rectangle subtractInputRegion = new Rectangle(0, 641, 720, 640);
-                myWin.AddInputRegionTest(subtractInputRegion);
+                window.SubtractInputRegion(subtractInputRegion);
             }
             catch (Exception e)
             {
-                tlog.Debug(tag, e.Message.ToString());
                 Assert.Fail("Caught Exception : Failed!");
             }