[NUI] Make it works on net6.0
authorEunki Hong <eunkiki.hong@samsung.com>
Thu, 26 Oct 2023 16:48:39 +0000 (01:48 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Mon, 30 Oct 2023 12:38:47 +0000 (21:38 +0900)
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
14 files changed:
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/.vscode/launch.json
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/Program.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/Tizen.NUI.Devel.Tests/testcase/public/TSPropertyValue.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Api/NUnitTestAssemblyRunner.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/CompositeWorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/ParallelWorkItemDispatcher.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/SimpleWorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/SimpleWorkItemDispatcher.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/TestWorker.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/WorkItem.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/Internal/Execution/WorkShift.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunit.framework/TUnit/TAsyncThreadMgr.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunitlite/TUnit/TRunner.cs
test/Tizen.NUI.Devel.Tests.Ubuntu/nunitlite/TextRunner.cs

index 368e16f4396da7a612398dde91f131598152cda3..dc9b2c999d4c6572ead33aa058a1bea8baa1606c 100755 (executable)
@@ -9,7 +9,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/Tizen.NUI.Devel.Tests.dll",
+            "program": "${workspaceFolder}/bin/Debug/net6.0/Tizen.NUI.Devel.Tests.dll",
             "args": [],
             "env": {
                 "DESKTOP_PREFIX":"${env:HOME}/dali-env/opt",
index 60af9ff074a1c5c1b719a82b3f5fa88a69c4e0a2..f9543492d0e43c16948230ef143361af4e7e1ad4 100755 (executable)
@@ -52,6 +52,8 @@ namespace Tizen.NUI.Devel.Tests
         private ManualResetEvent methodExecutionResetEvent;
         private TAsyncThreadMgr asyncThreadMgr;
 
+        private bool testFinished = false;
+
         protected override void OnCreate()
         {
             base.OnCreate();
@@ -114,15 +116,18 @@ namespace Tizen.NUI.Devel.Tests
         {
             methodExecutionResetEvent.WaitOne();
 
-            if (asyncThreadMgr.RunTestMethod() == false)
+            if (eventThreadCallback == null || asyncThreadMgr.RunTestMethod() == false)
             {
                 mainTitle.Text = title + "Finished!\nWill be terminated after 5 seconds";
+                testFinished = true;
+
                 timer = new Timer(300);
                 timer.Tick += OnTick;
                 timer.Start();
                 return;
             }
-            eventThreadCallback.Trigger();
+
+            eventThreadCallback?.Trigger();
         }
 
         private bool OnTick(object obj, EventArgs e)
@@ -163,9 +168,9 @@ namespace Tizen.NUI.Devel.Tests
 
         protected override void OnResume()
         {
-            base.OnResume();
-
             tlog.Debug(tag, $"OnResume()");
+
+            base.OnResume();
         }
 
         protected override void OnPause()
@@ -175,9 +180,21 @@ namespace Tizen.NUI.Devel.Tests
 
         protected override void OnTerminate()
         {
-            timer.Dispose();
-            mainTitle.Unparent();
-            root.Unparent();
+            tlog.Debug(tag, "OnTerminate()");
+
+            // Clear program
+            timer?.Dispose();
+            mainTitle?.Unparent();
+            root?.Dispose();
+            eventThreadCallback?.Dispose();
+
+            // Stop test forcely.
+            if (!testFinished)
+            {
+                // TODO : Currently, it is not works well...
+                // trunner._textRunner.StopTest(true);
+            }
+
             base.OnTerminate();
             Exit();
         }
index aa18e3d6ef0b0ec103b02f18f4ad7f016ccaebd1..5a73629799351f62875f56c9dff286c2dbcc2e2f 100644 (file)
@@ -12,7 +12,6 @@ namespace Tizen.NUI.Devel.Tests
     public class PropertyValueTest
     {
         private const string tag = "NUITEST";
-        private string path;
 
         [SetUp]
         public void Init()
index 10220ce81982cb9974dd7a7a9e5c1d1fe650c6f6..94ffb3f26b8d14d94e29099b168cb432652bbdf8 100755 (executable)
@@ -261,7 +261,7 @@ namespace NUnit.Framework.Api
         /// </remarks>
         public void RunAsync(ITestListener listener, ITestFilter filter)
         {
-            log.Info("Running tests");
+            TLogger.Write("RunAsync Start!\n");
             if (LoadedTest == null)
                 throw new InvalidOperationException("The Run method was called but no test has been loaded");
 
@@ -288,6 +288,7 @@ namespace NUnit.Framework.Api
 
             StartRun(listener);
             WaitForCompletion(Timeout.Infinite);
+            TLogger.Write("RunAsync Finished!\n");
         }
 
         /// <summary>
@@ -297,6 +298,7 @@ namespace NUnit.Framework.Api
         /// <returns>True if the run completed, otherwise false</returns>
         public bool WaitForCompletion(int timeout)
         {
+            TLogger.Write("WaitForCompletion...\n");
 #if !SILVERLIGHT && !PORTABLE
             return _runComplete.WaitOne(timeout, false);
 #else
@@ -408,6 +410,7 @@ namespace NUnit.Framework.Api
         /// </summary>
         private void OnRunCompleted(object sender, EventArgs e)
         {
+            TLogger.Write("OnRunCompleted\n");
 #if PARALLEL
             if (_pump != null)
                 _pump.Dispose();
index b06a287aef857da8e814fce35c1ed1706a95809e..e044c25ed0a0d06a2a611971ec45fe9b8ce40040 100755 (executable)
@@ -518,6 +518,7 @@ namespace NUnit.Framework.Internal.Execution
         {
             lock (cancelLock)
             {
+                NUnit.Framework.TUnit.TLogger.Write($"CompositeWorkItem Cancel {force}\n");
                 if (_children == null)
                     return;
 
@@ -531,6 +532,7 @@ namespace NUnit.Framework.Internal.Execution
                         child.Cancel(force);
                 }
             }
+            base.Cancel(force);
         }
 
         private string GetCaseID(string TCID)
index 37344e6bb7d04f0ce29fbf5d3820e61e013e097d..8d3a3386d316864b90ea1ddfb59d83fb1e7daf1f 100755 (executable)
@@ -205,6 +205,7 @@ namespace NUnit.Framework.Internal.Execution
         /// </summary>
         public void CancelRun(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"CancelRun {force}\n");
             foreach (var shift in Shifts)
                 shift.Cancel(force);
         }
index 79fad1c4a724e02ab0942b7c8e0a098ce009dc03..fe18b795415a785f193886f28f20cd40e17b219e 100755 (executable)
@@ -75,5 +75,10 @@ namespace NUnit.Framework.Internal.Execution
             }
         }
 
+        public override void Cancel(bool force)
+        {
+            TLogger.Write($"Cancel SimpleWorkItem force:{force}\n");
+            base.Cancel(force);
+        }
     }
 }
index 3bab6f4b8a518e90fdff3b2345c5272697ebcddf..b0d7c85a265de15b2f2ee099aa627a229df018e2 100755 (executable)
@@ -99,6 +99,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the run should be aborted, false if it should allow its currently running test to complete</param>
         public void CancelRun(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"CancelRun {force}\n");
 #if !PORTABLE
             lock (cancelLock)
             {
index dc80a92d831358058b67124cedf5aa4e2dfaf3fa..951c3e274e6c30cd50584cb2bbd732c0be4da61f 100755 (executable)
@@ -30,6 +30,7 @@
 #if PARALLEL
 using System;
 using System.Threading;
+using NUnit.Framework.TUnit;
 
 namespace NUnit.Framework.Internal.Execution
 {
@@ -112,6 +113,7 @@ namespace NUnit.Framework.Internal.Execution
         private void TestWorkerThreadProc()
         {
             log.Info("{0} starting ", _workerThread.Name);
+            TLogger.Write($"{_workerThread.Name} Started\n");
 
             _running = true;
 
@@ -125,15 +127,20 @@ namespace NUnit.Framework.Internal.Execution
 
                     log.Info("{0} executing {1}", _workerThread.Name, _currentWorkItem.Test.Name);
 
+                    TLogger.Write($"{_workerThread.Name} busy\n");
+
                     if (Busy != null)
                         Busy(this, EventArgs.Empty);
-
+                        
+                    TLogger.Write($"{_workerThread.Name} executing {_currentWorkItem.Test.Name}\n");
                     _currentWorkItem.WorkerId = Name;
                     _currentWorkItem.Execute();
+                    TLogger.Write($"{_workerThread.Name} executing {_currentWorkItem.Test.Name} done\n");
 
                     if (Idle != null)
                         Idle(this, EventArgs.Empty);
 
+                    TLogger.Write($"{_workerThread.Name} idle\n");
                     ++_workItemCount;
                 }
             }
@@ -141,6 +148,7 @@ namespace NUnit.Framework.Internal.Execution
             {
                 log.Info("{0} stopping - {1} WorkItems processed.", _workerThread.Name, _workItemCount);
             }
+            TLogger.Write($"{_workerThread.Name} Finished\n");
         }
 
         /// <summary>
@@ -159,6 +167,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the thread should be aborted, false if it should allow the currently running test to complete</param>
         public void Cancel(bool force)
         {
+            TLogger.Write($"Cancel TestWorker force:{force}\n");
             if (force)
                 _running = false;
 
@@ -167,7 +176,9 @@ namespace NUnit.Framework.Internal.Execution
                 {
                     _currentWorkItem.Cancel(force);
                     if (force)
+                    {
                         _currentWorkItem = null;
+                    }
                 }
         }
     }
index 2242dade387d2d5ba34526a79774e4b0b225b3ee..1c12841ebedb361f1a1cb3bc679b26f8e8e56e3b 100755 (executable)
@@ -383,6 +383,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the WorkItem should be aborted, false if it should run to completion</param>
         public virtual void Cancel(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"Cancel WorkItem force:{force}\n");
             if (Context != null)
                 Context.ExecutionStatus = force ? TestExecutionStatus.AbortRequested : TestExecutionStatus.StopRequested;
 
index 79a7b4ae4e2465059d02fc8880e8c3ab2a3c5b0d..4b0dc59f0394879052674f5de6384958bb9fcea4 100755 (executable)
@@ -201,6 +201,7 @@ namespace NUnit.Framework.Internal.Execution
         /// <param name="force">true if the WorkShift should be aborted, false if it should allow its currently running tests to complete</param>
         public void Cancel(bool force)
         {
+            NUnit.Framework.TUnit.TLogger.Write($"Cancel shift {force}\n");
             if (force)
                 this.IsActive = false;
 
index 58eb76c8b2a51f7782344fd10a45044e8115c9d4..7191378f9ca2196e0d4823bcbe60be585cb4f676 100755 (executable)
@@ -44,6 +44,7 @@ namespace NUnit.Framework.TUnit
 
         public void SetData(TestCommand testCommand, TestMethod testMethod, object[] arguments, TestExecutionContext context, bool IsAsyncOperation)
         {
+            TLogger.Write($"TAsyn.SetData()\n");
             this.testCommand = testCommand;
             this.testMethod = testMethod;
             this.arguments = arguments;
@@ -126,6 +127,7 @@ namespace NUnit.Framework.TUnit
                     runTearDown();
                     Thread.Sleep(50);
                     #endregion
+                    
                     testCommand._testMethodRunComplete.Set();
                     _methodExecutionResetEvent.Reset();
                     _methodExecutionResetEvent.WaitOne();
@@ -163,6 +165,7 @@ namespace NUnit.Framework.TUnit
             #region nguyen.vtan add TearDown
             runTearDown();
             #endregion
+
             testCommand._testMethodRunComplete.Set();
             _methodExecutionResetEvent.Reset();
             _methodExecutionResetEvent.WaitOne();
index ae763eaaaada4d69d7835d44a3306ce0a6e50e59..440c257a8506416de3454466f3e90546ea6350d9 100755 (executable)
@@ -127,14 +127,15 @@ namespace NUnitLite.TUnit
 
             //TLogger.Write("Executing the application: " + pkgName + "...");
             Tizen.Log.Fatal("NUITEST", $"Executing the application: {pkgName}");
+            Tizen.Log.Fatal("NUITEST", $"dllPath: {dllPath}");
             string exeFilePathName = "";
-            if (dllPath.Contains("netcoreapp"))
+            if (dllPath.Contains("net6.0"))
             {
                 exeFilePathName = string.Format(dllPath + "Tizen.{0}Tests.dll", pkgName);
             }
             else
             {
-                exeFilePathName = string.Format(dllPath + "Debug/netcoreapp3.1/Tizen.{0}dll", pkgName);
+                exeFilePathName = string.Format(dllPath + "Debug/net6.0/Tizen.{0}dll", pkgName);
             }
             //TLogger.Write("exeFilePathName : " + exeFilePathName);
             Tizen.Log.Fatal("NUITEST", $"exeFilePathName : {exeFilePathName}");
index 18fe8d399a255d5b2121bf018f34106d6da3cdfa..4cb77f2fc08e8062d1869d07f0e481e13e29a462 100755 (executable)
@@ -420,6 +420,12 @@ namespace NUnitLite
                return Summary.FailureCount + Summary.ErrorCount + Summary.InvalidCount;
        }
 
+       public void StopTest(bool force)
+       {
+               TLogger.Write($"StopTest force:{force}\n");
+               _runner.StopRun(force);
+       }
+
        public void ReportResults(ITestResult result)
        {
                Summary = new ResultSummary(result);