From 2ddf6e96978f048323cc6af538a88d0b233c0294 Mon Sep 17 00:00:00 2001 From: "guowei.wang" Date: Thu, 6 Aug 2020 17:51:42 +0800 Subject: [PATCH] [NUI][ACR-331] Add TCs for Notification class. New Tizen.NUI.Component Notificaiton , So add TCs for related APIs. change files: tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs Change-Id: Ic2eb780bd96bf966d3018917e61bcabe1a22a5b4 --- .../testcase/TSNotification.cs | 402 +++++++++++++++++++++ .../Tizen.NUI.Components.Tests/tizen-manifest.xml | 1 + 2 files changed, 403 insertions(+) create mode 100755 tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs diff --git a/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs new file mode 100755 index 0000000..b70f8c7 --- /dev/null +++ b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs @@ -0,0 +1,402 @@ +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; +using System.Threading.Tasks; + +namespace Tizen.NUI.Components.Tests +{ + [TestFixture] + [Description("Tizen.NUI.Components.Notification Tests")] + public class NotificationTests + { + private const string TAG = "Components"; + + [SetUp] + public void Init() + { + Tizen.Log.Info(TAG, "Init() is called!"); + } + + [TearDown] + public void Destroy() + { + Tizen.Log.Info(TAG, "Destroy() is called!"); + } + + [Test] + [Category("P1")] + [Description("Create a Notificaiton object. Check whether Notificaiton is successfully created or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Notification C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Notification_INIT() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + } + + [Test] + [Category("P2")] + [Description("Create a Notificaiton object with illegal argument.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Notification C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTX")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Notification_INIT_WITH_NULL_ARGUMENT() + { + /* TEST CODE */ + try + { + View view = null; + var noti = new Notification(view); + Assert.Fail("Should throw the Exception: Input contentView should not be null !"); + } + catch (ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + } + + [Test] + [Category("P1")] + [Description("Test ContentView. Check whether ContentView works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.ContentView A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void ContentView_SET_GET_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification."); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + View view2 = noti.ContentView; + Assert.IsNotNull(view2, "should be not null."); + Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view. "); + } + + [Test] + [Category("P1")] + [Description("Test SetLevel. Check whether SetLevel works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetLevel M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetLevel_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + NotificationLevel level = NotificationLevel.Medium; + Notification noti2 = noti.SetLevel(level); + Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. "); + } + + [Test] + [Category("P1")] + [Description("Test SetLevel. Check illegal notification level.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetLevel M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetLevel_CHECK_RETURN_VALUE_Exception() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + NotificationLevel level = (NotificationLevel)6; // We can set NotificationLevel value between -999999999 to 999999999. + var noti2 = noti.SetLevel(level); + Assert.IsNotNull(noti2, "should be not null."); + Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. "); + } + + [Test] + [Category("P1")] + [Description("Test SetPositionSize. Check whether SetPositionSize works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetPositionSize M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetPositionSize_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification."); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + Rectangle size = new Rectangle(0, 0, 300, 400); + Notification noti2 = noti.SetPositionSize(size); + Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti."); + } + + [Test] + [Category("P2")] + [Description("Test SetLevel. Check illegal position size.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetPositionSize M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetPositionSize_CHECK_RETURN_VALUE_Exception() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + try + { + Rectangle size = null; + noti.SetPositionSize(size); + Assert.Fail("Should throw the Exception: Input positionSize should not be null. !"); + } + catch (ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + } + + [Test] + [Category("P1")] + [Description("Test Post. Check whether Post works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Post M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Post_CHECK_NO_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + NotificationLevel level = NotificationLevel.Medium; + try + { + uint duration = 3000; + noti.Post(duration); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Dismiss. Check whether Dismiss works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Dismiss M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Dismiss_CHECK_NO_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + noti.Post(0); // If duration is 0, you should call Dismiss() manually. + try + { + noti.Dismiss(); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Dismiss. Call Dismiss() when NotificationState is not Post.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Dismiss M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Dismiss_CHECK_NO_RETURN_VALUE_Exception() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + noti.Dismiss(); // If NotificationState is not Post, call dismiss will return directly. + Assert.IsNotNull(noti, "should be not null."); + View view2 = noti.ContentView; + Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view."); + } + + [Test] + [Category("P1")] + [Description("Test ForceQuit. Call ForceQuit() before onDismissAnimation finished, check whether ForceQuit works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public async Task ForceQuit_CHECK_NO_RETURN_VALUE_During_onDismissAnimation() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + Animation ani = new Animation(4000); + Assert.IsNotNull(ani, "Can't create success object Animation"); + noti.SetAnimationOnDismiss(ani); + uint duration = 2000; + noti.Post(duration); + await Task.Delay(3000); // ani is palying. + try + { + noti.ForceQuit(); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test ForceQuit. Call ForceQuit() after onDismissAnimation finished.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public async Task ForceQuit_CHECK_NO_RETURN_VALUE_onDismissAnimation_Finished() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + Animation ani = new Animation(3000); + Assert.IsNotNull(ani, "Can't create success object Animation"); + noti.SetAnimationOnDismiss(ani); + uint duration = 2000; + noti.Post(duration); // Dismiss the noti after given time. + await Task.Delay(5000); + try + { + noti.ForceQuit(); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test ForceQuit. Call ForceQuit() when NotificationState is not Post.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void ForceQuit_CHECK_NO_RETURN_VALUE_Exception() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + noti.ForceQuit(); // NotificationState is not Post and Dismiss, return directly. + Assert.IsNotNull(noti, "Should be not null"); + View view2 = noti.ContentView; + Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view."); + } + + [Test] + [Category("P1")] + [Description("Test SetAnimationOnPost. Check whether SetAnimationOnPost works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetAnimationOnPost M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetAnimationOnPost_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + Animation ani = new Animation(); + Assert.IsNotNull(ani, "Can't create success object Animation"); + var noti2 = noti.SetAnimationOnPost(ani); + Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. "); + } + + [Test] + [Category("P1")] + [Description("Test SetAnimationOnDismiss. Check whether SetAnimationOnDismiss works or not. ")] + [Property("SPEC", "Tizen.NUI.Components.Notification.SetAnimationOnDismiss M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void SetAnimationOnDismiss_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + Animation ani = new Animation(); + Assert.IsNotNull(ani, "Can't create success object Animation"); + var noti2 = noti.SetAnimationOnDismiss(ani); + Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. "); + } + + [Test] + [Category("P1")] + [Description("Test Dispose, try to dispose the Notification.")] + [Property("SPEC", "Tizen.NUI.Components.Notification.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")] + public void Dispose_CHECK() + { + /* TEST CODE */ + try + { + View view = new View(); + Assert.IsNotNull(view, "Can't create success object View"); + var noti = new Notification(view); + Assert.IsNotNull(noti, "Can't create success object Notification"); + Assert.IsInstanceOf(noti, "Should be an instance of Notification type"); + noti.Post(); + noti.Dispose(); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + } +} diff --git a/tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml index 336240e..a6446b8 100755 --- a/tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml +++ b/tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml @@ -7,6 +7,7 @@ http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/window.priority.set -- 2.7.4