[Non-ACR][NUI][Fix tct fails] 48/239948/2
authorDongsug Song <dongsug.song@samsung.com>
Fri, 31 Jul 2020 02:06:50 +0000 (11:06 +0900)
committerDongsug Song <dongsug.song@samsung.com>
Fri, 31 Jul 2020 02:10:21 +0000 (11:10 +0900)
- refactoring entry point (main) codes of NUI and NUI.Components
- NUIApplication.GetDefaultWindow() is recommended to use
- Window.GetDefaultLayer() is recommended to use

Change-Id: Ib97d30fe984e8cdcc5b9aa121cbf280208d1145b

tct-suite-vs/Tizen.NUI.Components.Tests/Program.cs
tct-suite-vs/Tizen.NUI.Tests/Program.cs

index ec63c711da415e0402476ed7c6f251fd74720705..5ca9d883b0dcb31d2d025b72828260babcd8abf6 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,110 +24,111 @@ using System.Threading.Tasks;
 
 namespace Tizen.NUI.Components.Test
 {
-
+    using tlog = Tizen.Log;
     public class App : Tizen.NUI.NUIApplication
     {
-        static TextLabel MainTitle;
-        static readonly string Title = "NUI.Components Auto TCT \n\n";
-        static readonly float TextSize = 30.0f;
-
-        private static Graphics.BackendType GraphicsBackend()
-        {
-            String DALI_VULKAN_BACKEND = Environment.GetEnvironmentVariable("DALI_VULKAN_BACKEND");
-            int numVal = 0;
-            Int32.TryParse(DALI_VULKAN_BACKEND, out numVal);
-
-            if ((Graphics.BackendType)numVal == Graphics.BackendType.Gles)
-            {
-                Log.Fatal("NUI.Components", "NUI Vulkan disabled~!");
-                return Graphics.BackendType.Gles;
-            }
-
-            Log.Fatal("NUI.Components", "NUI Vulkan enabled~!");
-            return Graphics.BackendType.Vulkan;
-        }
+        static string tag = "NUITEST";
 
-        public App() : base(GraphicsBackend(), WindowMode.Opaque, null, null, "")
+        public App() : base()
         {
-            // : base(GraphicsBackend(), WindowMode.Opaque, null, null, "")
-            Log.Fatal("NUI.Components", "Call App()");
+            tlog.Debug(tag, "Call App()");
         }
 
+        View root;
+        static TextLabel mainTitle;
+        static string title = "NUI Auto TCT \n\n";
+        float textSize = 30.0f;
+        Window window;
+        Layer layer;
         protected override void OnCreate()
         {
             base.OnCreate();
 
-            //Tizen.Log.Fatal("NUI", "### OnCreate() START!");
-            Random rand = new Random();
+            tlog.Debug(tag, "OnCreate() START!");
 
-            Window window = Window.Instance;
+            window = NUIApplication.GetDefaultWindow();
             window.BackgroundColor = Color.Green;
 
-            MainTitle = new TextLabel();
-            MainTitle.MultiLine = true;
-            MainTitle.Text = Title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n\n" + "Backend: ";
-            if (GraphicsBackend() == Graphics.BackendType.Gles)
+            root = new View()
+            {
+                Size = new Size(100, 100),
+                BackgroundColor = Color.White,
+                PositionUsesPivotPoint = true,
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+            };
+
+            layer = window.GetDefaultLayer();
+            layer.Add(root);
+
+            mainTitle = new TextLabel()
             {
-                MainTitle.Text+="GL\n";
+                MultiLine = true,
+                Text = title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n",
+                PixelSize = textSize,
+                BackgroundColor = Color.Cyan,
+                Size2D = new Size2D(window.WindowSize.Width / 2, window.WindowSize.Height / 2),
+                PositionUsesPivotPoint = true,
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+            };
+            root.Add(mainTitle);
+
+            tlog.Debug(tag, "OnCreate() END!");
+        }
+
+        static public async Task MainTitleChangeBackgroundColor(Color color)
+        {
+            if (color != null)
+            {
+                mainTitle.BackgroundColor = color;
+                await Task.Delay(900);
             }
-            else
+        }
+
+        static public async Task MainTitleChangeText(string tcTitle)
+        {
+            if (tcTitle != null)
             {
-                MainTitle.Text+="Vulkan\n";
+                var processId = Process.GetCurrentProcess().Id;
+                var threadId = Thread.CurrentThread.ManagedThreadId;
+
+                mainTitle.Text = $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}";
+                await Task.Delay(20);
+
+                tlog.Debug(tag, $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}");
             }
-            MainTitle.PixelSize = TextSize;
-            MainTitle.BackgroundColor = new Color(rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, 1.0f);
-            MainTitle.Size2D = new Size2D(window.WindowSize.Width / 2, window.WindowSize.Height / 2);
-            MainTitle.PositionUsesPivotPoint = true;
-            MainTitle.ParentOrigin = ParentOrigin.Center;
-            MainTitle.PivotPoint = PivotPoint.Center;
-            window.Add(MainTitle);
-
-            //TRunner t = new TRunner();
-            //t.LoadTestsuite();
-            //t.Execute();
-
-            //Tizen.Log.Fatal("NUI", "### OnCreate() END!");
         }
 
         protected override void OnResume()
         {
             base.OnResume();
 
-            //Tizen.Log.Fatal("NUI", $"### OnResume() START!");
+            tlog.Debug(tag, $"OnResume() START!");
 
             TRunner t = new TRunner();
             t.LoadTestsuite();
             t.Execute();
 
-            //Tizen.Log.Fatal("NUI", $"### OnResume() END!");
+            tlog.Debug(tag, $"OnResume() END!");
         }
 
         protected override void OnPause()
         {
             base.OnPause();
-
-            //Tizen.Log.Fatal("NUI", $"### OnPause() START!");
-            //TO DO!
-            //Tizen.Log.Fatal("NUI", $"### OnPause() END!");
         }
 
         protected override void OnTerminate()
         {
-            //Tizen.Log.Fatal("NUI", "### OnTerminate() START!");
-
-            Exit();
             base.OnTerminate();
-
-            //Tizen.Log.Fatal("NUI", "### OnTerminate() END!");
+            Exit();
         }
 
         static void Main(string[] args)
         {
-            Tizen.Log.Fatal("NUI.Components", "NUI RUN!");
+            tlog.Debug(tag, "NUI RUN!");
             App example = new App();
             example.Run(args);
         }
-
     };
-
 }
index eae134da2c6145afc651bcbff8fbec66cb2528c9..6f45903d76d4c17090d00a6272419e83e1757c49 100755 (executable)
@@ -24,130 +24,111 @@ using System.Threading.Tasks;
 
 namespace Tizen.NUI.Test
 {
-
+    using tlog = Tizen.Log;
     public class App : Tizen.NUI.NUIApplication
     {
-        static TextLabel MainTitle;
-        static readonly string Title = "NUI Auto TCT \n\n";
-        static readonly float TextSize = 30.0f;
+        static string tag = "NUITEST";
 
-        private static Graphics.BackendType GraphicsBackend()
+        public App() : base()
         {
-            String DALI_VULKAN_BACKEND = Environment.GetEnvironmentVariable("DALI_VULKAN_BACKEND");
-            int numVal = 0;
-            Int32.TryParse(DALI_VULKAN_BACKEND, out numVal);
-
-            if ((Graphics.BackendType)numVal == Graphics.BackendType.Gles)
-            {
-                Log.Fatal("NUI", "NUI Vulkan disabled~!");
-                return Graphics.BackendType.Gles;
-            }
-
-            Log.Fatal("NUI", "NUI Vulkan enabled~!");
-            return Graphics.BackendType.Vulkan;
-        }
-
-        public App() : base(GraphicsBackend(), WindowMode.Opaque, null, null, "")
-        {
-            // : base(GraphicsBackend(), WindowMode.Opaque, null, null, "")
-            Log.Fatal("NUI", "Call App()");
+            tlog.Debug(tag, "Call App()");
         }
 
+        View root;
+        static TextLabel mainTitle;\r
+        static string title = "NUI Auto TCT \n\n";
+        float textSize = 30.0f;
+        Window window;
+        Layer layer;
         protected override void OnCreate()
         {
             base.OnCreate();
 
-            //Tizen.Log.Fatal("NUI", "### OnCreate() START!");
-            Random rand = new Random();
+            tlog.Debug(tag, "OnCreate() START!");
 
-            Window window = Window.Instance;
+            window = NUIApplication.GetDefaultWindow();
             window.BackgroundColor = Color.Green;
 
-            MainTitle = new TextLabel();
-            MainTitle.MultiLine = true;
-            MainTitle.Text = Title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n\n" + "Backend: ";
-            if (GraphicsBackend() == Graphics.BackendType.Gles)
-            {
-                MainTitle.Text+="GL\n";
-            }
-            else
+            root = new View()\r
+            {\r
+                Size = new Size(100, 100),\r
+                BackgroundColor = Color.White,\r
+                PositionUsesPivotPoint = true,\r
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+            };\r
+\r
+            layer = window.GetDefaultLayer();
+            layer.Add(root);\r
+\r
+            mainTitle = new TextLabel()
             {
-                MainTitle.Text+="Vulkan\n";
-            }
-            MainTitle.PixelSize = TextSize;
-            MainTitle.BackgroundColor = new Color(rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, 1.0f);
-            MainTitle.Size2D = new Size2D(window.WindowSize.Width / 2, window.WindowSize.Height / 2);
-            MainTitle.PositionUsesPivotPoint = true;
-            MainTitle.ParentOrigin = ParentOrigin.Center;
-            MainTitle.PivotPoint = PivotPoint.Center;
-            window.Add(MainTitle);
-
-            //TRunner t = new TRunner();
-            //t.LoadTestsuite();
-            //t.Execute();
-
-            //Tizen.Log.Fatal("NUI", "### OnCreate() END!");
+                MultiLine = true,
+                Text = title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n",
+                PixelSize = textSize,
+                BackgroundColor = Color.Cyan,
+                Size2D = new Size2D(window.WindowSize.Width / 2, window.WindowSize.Height / 2),
+                PositionUsesPivotPoint = true,
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+            };
+            root.Add(mainTitle);
+
+            tlog.Debug(tag, "OnCreate() END!");
         }
 
         static public async Task MainTitleChangeBackgroundColor(Color color)
         {
-            //if (color == null)
-            //{
-            //    Random rand = new Random();
-            //    color = new Color(rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, rand.Next(250) / 255.0f, 1.0f);
-            //}
-            //MainTitle.BackgroundColor = color;
-            //await Task.Delay(1000);
+            if (color != null)
+            {\r
+                mainTitle.BackgroundColor = color;\r
+                await Task.Delay(900);\r
+            }\r
         }
 
-        static public async Task MainTitleChangeText(string title)
+        static public async Task MainTitleChangeText(string tcTitle)
         {
-            //MainTitle.Text = Title + title;
-            //MainTitle.PixelSize = TextSize;
-            //await Task.Delay(1000);
-
-            //Tizen.Log.Fatal("NUI", $"{title} Process ID: {Process.GetCurrentProcess().Id} Thread ID: {Thread.CurrentThread.ManagedThreadId}");
+            if (tcTitle != null)\r
+            {\r
+                var processId = Process.GetCurrentProcess().Id;\r
+                var threadId = Thread.CurrentThread.ManagedThreadId;\r
+\r
+                mainTitle.Text = $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}";\r
+                await Task.Delay(20);\r
+\r
+                tlog.Debug(tag, $"{title}\nProcess ID: {processId}\nThread ID: {threadId}\n TC: {tcTitle}");
+            }
         }
 
         protected override void OnResume()
         {
             base.OnResume();
 
-            //Tizen.Log.Fatal("NUI", $"### OnResume() START!");
+            tlog.Debug(tag, $"OnResume() START!");
 
             TRunner t = new TRunner();
             t.LoadTestsuite();
             t.Execute();
 
-            //Tizen.Log.Fatal("NUI", $"### OnResume() END!");
+            tlog.Debug(tag, $"OnResume() END!");
         }
 
         protected override void OnPause()
         {
             base.OnPause();
-
-            //Tizen.Log.Fatal("NUI", $"### OnPause() START!");
-            //TO DO!
-            //Tizen.Log.Fatal("NUI", $"### OnPause() END!");
         }
 
         protected override void OnTerminate()
         {
-            //Tizen.Log.Fatal("NUI", "### OnTerminate() START!");
-
-            Exit();
-            base.OnTerminate();
-
-            //Tizen.Log.Fatal("NUI", "### OnTerminate() END!");
+            base.OnTerminate();\r
+            Exit();\r
         }
 
         static void Main(string[] args)
         {
-            Tizen.Log.Fatal("NUI", "NUI RUN!");
+            tlog.Debug(tag, "NUI RUN!");
             App example = new App();
             example.Run(args);
         }
-
     };
-
 }