[WidgetControl][Non-ACR] fix tct fail when the widget feature is disabled 66/300166/2
authorSukhyungKang <shine.kang@samsung.com>
Wed, 18 Oct 2023 00:07:44 +0000 (09:07 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Wed, 18 Oct 2023 00:56:19 +0000 (09:56 +0900)
Change-Id: I923d83dfe197600fd2b36bae39209395e2843592
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.Scale.cs
tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.cs
tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs [changed mode: 0644->0755]

index f399a4e..3e7c6a2 100755 (executable)
@@ -1,6 +1,8 @@
 using Tizen.Applications;
 using NUnit.Framework.TUnit;
 using NUnit.Framework;
+using System;
+using Tizen.System;
 
 namespace Tizen.WidgetControl.Scale.Tests
 {
@@ -14,11 +16,15 @@ namespace Tizen.WidgetControl.Scale.Tests
         private const string MyWidgetId = "org.tizen.WidgetCtrlSample";
         private const string MyPreviewImage = "preview.png";
 
+        static bool isWidgetSupported = false;
+
         [SetUp]
         public void Init()
         {
             _widgetControl = new Tizen.Applications.WidgetControl(MyWidgetId);
             _appInfo = new ApplicationInfo(MyWidgetId);
+
+            Information.TryGetValue("http://tizen.org/feature/shell.appwidget", out isWidgetSupported);
             LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST");
         }
 
@@ -41,15 +47,26 @@ namespace Tizen.WidgetControl.Scale.Tests
         {
             bool flag = false;
 
-            foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
-            {
-                if (MyWidgetScale != null)
+            try
+            {\r
+                foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
                 {
-                    Assert.AreEqual(MyWidgetScale.Type, Applications.WidgetControl.Scale.SizeType.Basic4x4, "Expects given values to be equal");
-                    flag = true;
+                    if (MyWidgetScale != null)
+                    {
+                        Assert.AreEqual(MyWidgetScale.Type, Applications.WidgetControl.Scale.SizeType.Basic4x4, "Expects given values to be equal");
+                        flag = true;
+                    }
                 }
+                Assert.AreNotEqual(flag, false, "The flag should be 'true'");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
             }
-            Assert.AreNotEqual(flag, false, "The flag should be 'true'");
         }
 
         [Test]
@@ -63,15 +80,26 @@ namespace Tizen.WidgetControl.Scale.Tests
         {
             bool flag = false;
 
-            foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
+            try
             {
-                if (MyWidgetScale != null)
+                foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
                 {
-                    Assert.AreEqual(MyWidgetScale.PreviewImagePath, _appInfo.SharedResourcePath + MyPreviewImage, "The value should be equal");
-                    flag = true;
+                    if (MyWidgetScale != null)
+                    {
+                        Assert.AreEqual(MyWidgetScale.PreviewImagePath, _appInfo.SharedResourcePath + MyPreviewImage, "The value should be equal");
+                        flag = true;
+                    }
                 }
+                Assert.AreNotEqual(flag, false, "The falg should be 'true'");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
             }
-            Assert.AreNotEqual(flag, false, "The falg should be 'true'");
         }
 
         [Test]
@@ -85,23 +113,34 @@ namespace Tizen.WidgetControl.Scale.Tests
         {
             bool flag = false;
 
-            foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
-            {
-                if (MyWidgetScale != null)
+            try
+            {\r
+                foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
                 {
-                    if (MyWidgetScale.Height >= 0)
+                    if (MyWidgetScale != null)
                     {
-                        Assert.Pass();
-                    }
-                    else
-                    {
-                        Assert.Fail("The value should be greater than 0");
-                    }
+                        if (MyWidgetScale.Height >= 0)
+                        {
+                            Assert.Pass();
+                        }
+                        else
+                        {
+                            Assert.Fail("The value should be greater than 0");
+                        }
 
-                    flag = true;
+                        flag = true;
+                    }
                 }
+                Assert.AreNotEqual(flag, false, "The falg should be 'true'");\r
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
             }
-            Assert.AreNotEqual(flag, false, "The falg should be 'true'");
         }
 
         [Test]
@@ -115,23 +154,34 @@ namespace Tizen.WidgetControl.Scale.Tests
         {
             bool flag = false;
 
-            foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
-            {
-                if (MyWidgetScale != null)
+            try
+            {\r
+                foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
                 {
-                    if (MyWidgetScale.Width >= 0)
+                    if (MyWidgetScale != null)
                     {
-                        Assert.Pass();
-                    }
-                    else
-                    {
-                        Assert.Fail("The value should be greater than 0");
-                    }
+                        if (MyWidgetScale.Width >= 0)
+                        {
+                            Assert.Pass();
+                        }
+                        else
+                        {
+                            Assert.Fail("The value should be greater than 0");
+                        }
 
-                    flag = true;
+                        flag = true;
+                    }
                 }
+                Assert.AreNotEqual(flag, false, "The flag should be 'true'");\r
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
             }
-            Assert.AreNotEqual(flag, false, "The flag should be 'true'");
         }
     }
 }
index cd95b2e..fc7f1a8 100755 (executable)
@@ -68,9 +68,20 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
         public void WidgetControl_INIT()
         {
-            var MyWidgetControl = new Tizen.Applications.WidgetControl(MyWidgetId1);
-            Assert.IsNotNull(MyWidgetControl, "Object should not be null after initialization");
-            MyWidgetControl.Dispose();
+            try
+            {\r
+                var MyWidgetControl = new Tizen.Applications.WidgetControl(MyWidgetId1);
+                Assert.IsNotNull(MyWidgetControl, "Object should not be null after initialization");
+                MyWidgetControl.Dispose();\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -82,8 +93,19 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
         public void Id_PROPERTY_GET()
         {
-            Assert.IsInstanceOf<string>(_widgetControl.Id);
-            Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal");
+            try
+            {\r
+                Assert.IsInstanceOf<string>(_widgetControl.Id);
+                Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -95,8 +117,19 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
         public void IsNoDisplay_PROPERTY_GET()
         {
-            Assert.IsInstanceOf<bool>(_widgetControl.IsNoDisplay);
-            Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false");
+            try
+            {\r
+                Assert.IsInstanceOf<bool>(_widgetControl.IsNoDisplay);
+                Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -108,8 +141,19 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
         public void GetScales_RETURN_VALUE()
         {
-            IEnumerable<Applications.WidgetControl.Scale> MyWidgetScale = _widgetControl.GetScales();
-            Assert.IsNotNull(MyWidgetScale, "Object should not be null");
+            try
+            {\r
+                IEnumerable<Applications.WidgetControl.Scale> MyWidgetScale = _widgetControl.GetScales();
+                Assert.IsNotNull(MyWidgetScale, "Object should not be null");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -121,9 +165,20 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
         public void CreateAll_RETURN_VALUE()
         {
-            Tizen.Applications.WidgetControl[] controlArr = Tizen.Applications.WidgetControl.CreateAll(MyWidgetId);
-            Assert.IsNotNull(controlArr, "Object should not be null");
-            Assert.IsInstanceOf< Tizen.Applications.WidgetControl[]>(controlArr, "The object should be of WidgetControl array");
+            try
+            {\r
+                Tizen.Applications.WidgetControl[] controlArr = Tizen.Applications.WidgetControl.CreateAll(MyWidgetId);
+                Assert.IsNotNull(controlArr, "Object should not be null");
+                Assert.IsInstanceOf<Tizen.Applications.WidgetControl[]>(controlArr, "The object should be of WidgetControl array");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -135,9 +190,20 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
         public void GetIconPath_RETURN_VALUE()
         {
-            string iconPath = _widgetControl.GetIconPath(Lang);
-            Assert.IsNotNull(iconPath, "Object should not be null");
-            Assert.IsInstanceOf<string>(iconPath);
+            try
+            {\r
+                string iconPath = _widgetControl.GetIconPath(Lang);
+                Assert.IsNotNull(iconPath, "Object should not be null");
+                Assert.IsInstanceOf<string>(iconPath);\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -149,9 +215,20 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
         public void GetName_RETURN_VALUE()
         {
-            string name = _widgetControl.GetName(Lang);
-            Assert.IsNotNull(name, "Object should not be null");
-            Assert.IsInstanceOf<string>(name);
+            try
+            {\r
+                string name = _widgetControl.GetName(Lang);
+                Assert.IsNotNull(name, "Object should not be null");
+                Assert.IsInstanceOf<string>(name);\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -163,9 +240,20 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
         public void GetWidgetIds_RETURN_VALUE()
         {
-            string[] idArr = Tizen.Applications.WidgetControl.GetWidgetIds(MyWidgetId);
-            Assert.IsNotNull(idArr, "Object should not be null");
-            Assert.IsInstanceOf<string[]>(idArr);
+            try
+            {\r
+                string[] idArr = Tizen.Applications.WidgetControl.GetWidgetIds(MyWidgetId);
+                Assert.IsNotNull(idArr, "Object should not be null");
+                Assert.IsInstanceOf<string[]>(idArr);\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -180,7 +268,12 @@ namespace Tizen.WidgetControl.Tests
             try
             {
                 _widgetControl.Created += OnCreated;
-                _widgetControl.Created -= OnCreated;
+                _widgetControl.Created -= OnCreated;\r
+\r
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
             }
             catch (Exception e)
             {
@@ -203,6 +296,10 @@ namespace Tizen.WidgetControl.Tests
                 _widgetControl.Destroyed += OnCreated;
                 _widgetControl.Destroyed -= OnCreated;
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Log.Debug(TAG, "Caught Exception" + e.ToString());
@@ -224,6 +321,10 @@ namespace Tizen.WidgetControl.Tests
                 _widgetControl.Paused += OnPaused;
                 _widgetControl.Paused -= OnPaused;
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Log.Debug(TAG, "Caught Exception" + e.ToString());
@@ -245,6 +346,10 @@ namespace Tizen.WidgetControl.Tests
                 _widgetControl.Resumed += OnResumed;
                 _widgetControl.Resumed -= OnResumed;
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Log.Debug(TAG, "Caught Exception" + e.ToString());
@@ -261,8 +366,19 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Junghoon Park, jh9216.park@samsung.com")]
         public void MainAppId_PROPERTY_GET()
         {
-            Assert.IsInstanceOf<string>(_widgetControl.MainAppId);
-            Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample");
+            try
+            {\r
+                Assert.IsInstanceOf<string>(_widgetControl.MainAppId);
+                Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample");\r
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -274,8 +390,19 @@ namespace Tizen.WidgetControl.Tests
         [Property("AUTHOR", "Junghoon Park, jh9216.park@samsung.com")]
         public void PackageId_PROPERTY_GET()
         {
-            Assert.IsInstanceOf<string>(_widgetControl.PackageId);
-            Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen");
+            try
+            {\r
+                Assert.IsInstanceOf<string>(_widgetControl.PackageId);
+                Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen");\r
+            }
+            catch(NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+            }
+            catch (Exception e)
+            {
+                Assert.Fail("There should be no exception " + e.ToString());
+            }
         }
 
         [Test]
@@ -313,10 +440,11 @@ namespace Tizen.WidgetControl.Tests
         {
             try
             {
-                Assert.Throws<InvalidOperationException>(delegate
-                {
-                    string id = _widgetControl3.SetupAppId;
-                });
+                string id = _widgetControl3.SetupAppId;
+            }
+            catch (InvalidOperationException)
+            {\r
+                Assert.Pass("InvalidOperationException passed");\r
             }
             catch (NotSupportedException)
             {
old mode 100644 (file)
new mode 100755 (executable)
index e8cf397..6cf3fe5
@@ -4,6 +4,7 @@ using NUnit.Framework;
 using ElmSharp;
 using System.Threading.Tasks;
 using System;
+using Tizen.System;
 
 namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
 {
@@ -23,6 +24,8 @@ namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
         private static string _argWidgetId = null;
         private static bool _eventTypeChecked = false;
 
+        static bool isWidgetSupported = false;
+
         private static void OnCreated(object sender, Tizen.Applications.WidgetLifecycleEventArgs args)
         {
 
@@ -75,6 +78,7 @@ namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
         [SetUp]
         public void Init()
         {
+            Information.TryGetValue("http://tizen.org/feature/shell.appwidget", out isWidgetSupported);
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
         }
 
@@ -114,6 +118,10 @@ namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
                 Assert.IsNotNull(_argInstanceId, "Object should not be null after initialization");
                 MyWidgetControl.Created -= OnCreated;
                 MyWidgetControl.Dispose();
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
             }
             catch (Exception e)
             {
@@ -148,6 +156,10 @@ namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
                 Assert.IsNotNull(_argWidgetId, "Object should not be null after initialization");
                 MyWidgetControl.Created -= OnCreated;
                 MyWidgetControl.Dispose();
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
             }
             catch (Exception e)
             {
@@ -181,6 +193,10 @@ namespace Tizen.WidgetControl.WidgetLifecycleEventArgs.Tests
                 Assert.IsTrue(_eventTypeChecked, "Event type should be checked after widget is created");
                 MyWidgetControl.Created -= OnCreated;
                 MyWidgetControl.Dispose();
+            }\r
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
             }
             catch (Exception e)
             {