From c225fc67dd7ca4e6eb6e042fe3c4016a0bd31979 Mon Sep 17 00:00:00 2001 From: SukhyungKang Date: Wed, 18 Oct 2023 09:07:44 +0900 Subject: [PATCH] [WidgetControl][Non-ACR] fix tct fail when the widget feature is disabled Change-Id: I923d83dfe197600fd2b36bae39209395e2843592 Signed-off-by: SukhyungKang --- .../testcase/TSWidgetControl.Scale.cs | 120 +++++++++---- .../testcase/TSWidgetControl.cs | 188 +++++++++++++++++---- .../testcase/TSWidgetLifecycleEventArgs.cs | 16 ++ 3 files changed, 259 insertions(+), 65 deletions(-) mode change 100644 => 100755 tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs diff --git a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.Scale.cs b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.Scale.cs index f399a4e..3e7c6a2 100755 --- a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.Scale.cs +++ b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.Scale.cs @@ -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 + { + 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'"); + } + 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'"); + } + 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 + { + 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'"); + } + 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 + { + 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'"); + } + 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'"); } } } diff --git a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.cs b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.cs index cd95b2e..fc7f1a8 100755 --- a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.cs +++ b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetControl.cs @@ -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 + { + var MyWidgetControl = new Tizen.Applications.WidgetControl(MyWidgetId1); + Assert.IsNotNull(MyWidgetControl, "Object should not be null after initialization"); + MyWidgetControl.Dispose(); + } + 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(_widgetControl.Id); - Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal"); + try + { + Assert.IsInstanceOf(_widgetControl.Id); + Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal"); + } + 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(_widgetControl.IsNoDisplay); - Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false"); + try + { + Assert.IsInstanceOf(_widgetControl.IsNoDisplay); + Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false"); + } + 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 MyWidgetScale = _widgetControl.GetScales(); - Assert.IsNotNull(MyWidgetScale, "Object should not be null"); + try + { + IEnumerable MyWidgetScale = _widgetControl.GetScales(); + Assert.IsNotNull(MyWidgetScale, "Object should not be null"); + } + 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 + { + Tizen.Applications.WidgetControl[] controlArr = Tizen.Applications.WidgetControl.CreateAll(MyWidgetId); + Assert.IsNotNull(controlArr, "Object should not be null"); + Assert.IsInstanceOf(controlArr, "The object should be of WidgetControl array"); + } + 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(iconPath); + try + { + string iconPath = _widgetControl.GetIconPath(Lang); + Assert.IsNotNull(iconPath, "Object should not be null"); + Assert.IsInstanceOf(iconPath); + } + 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(name); + try + { + string name = _widgetControl.GetName(Lang); + Assert.IsNotNull(name, "Object should not be null"); + Assert.IsInstanceOf(name); + } + 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(idArr); + try + { + string[] idArr = Tizen.Applications.WidgetControl.GetWidgetIds(MyWidgetId); + Assert.IsNotNull(idArr, "Object should not be null"); + Assert.IsInstanceOf(idArr); + } + 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; + + } + 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(_widgetControl.MainAppId); - Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample"); + try + { + Assert.IsInstanceOf(_widgetControl.MainAppId); + Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample"); + } + 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(_widgetControl.PackageId); - Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen"); + try + { + Assert.IsInstanceOf(_widgetControl.PackageId); + Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen"); + } + 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(delegate - { - string id = _widgetControl3.SetupAppId; - }); + string id = _widgetControl3.SetupAppId; + } + catch (InvalidOperationException) + { + Assert.Pass("InvalidOperationException passed"); } catch (NotSupportedException) { diff --git a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs old mode 100644 new mode 100755 index e8cf397..6cf3fe5 --- a/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs +++ b/tct-suite-vs/Tizen.WidgetControl.Tests/testcase/TSWidgetLifecycleEventArgs.cs @@ -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(); + } + 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(); + } + 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(); + } + catch (NotSupportedException) + { + Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException"); } catch (Exception e) { -- 2.7.4