[NUI][ACR-331] Add TCs for Notification class. 54/240454/19
authorguowei.wang <guowei.wang@samsung.com>
Thu, 6 Aug 2020 09:51:42 +0000 (17:51 +0800)
committerTan Nguyen <nguyen.vtan@samsung.com>
Thu, 15 Oct 2020 04:05:02 +0000 (04:05 +0000)
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

tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSNotification.cs [new file with mode: 0755]
tct-suite-vs/Tizen.NUI.Components.Tests/tizen-manifest.xml

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 (executable)
index 0000000..b70f8c7
--- /dev/null
@@ -0,0 +1,402 @@
+using NUnit.Framework;\r
+using NUnit.Framework.TUnit;\r
+using System;\r
+using Tizen.NUI.BaseComponents;\r
+using Tizen.NUI;\r
+using System.Threading.Tasks;\r
+\r
+namespace Tizen.NUI.Components.Tests\r
+{\r
+    [TestFixture]\r
+    [Description("Tizen.NUI.Components.Notification Tests")]\r
+    public class NotificationTests\r
+    {\r
+        private const string TAG = "Components";\r
+\r
+        [SetUp]\r
+        public void Init()\r
+        {\r
+            Tizen.Log.Info(TAG, "Init() is called!");\r
+        }\r
+\r
+        [TearDown]\r
+        public void Destroy()\r
+        {\r
+            Tizen.Log.Info(TAG, "Destroy() is called!");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Create a Notificaiton object. Check whether Notificaiton is successfully created or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Notification C")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "CONSTR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Notification_INIT()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P2")]\r
+        [Description("Create a Notificaiton object with illegal argument.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Notification C")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "CONSTX")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Notification_INIT_WITH_NULL_ARGUMENT()\r
+        {\r
+            /* TEST CODE */\r
+            try\r
+            {\r
+                View view = null;\r
+                var noti = new Notification(view);\r
+                Assert.Fail("Should throw the Exception: Input contentView should not be null !");\r
+            }\r
+            catch (ArgumentException)\r
+            {\r
+                Assert.Pass("ArgumentException: passed!");\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test ContentView. Check whether ContentView works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.ContentView A")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "PRW")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void ContentView_SET_GET_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification.");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            View view2 = noti.ContentView;\r
+            Assert.IsNotNull(view2, "should be not null.");\r
+            Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view. ");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test SetLevel. Check whether SetLevel works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetLevel M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetLevel_CHECK_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            NotificationLevel level = NotificationLevel.Medium;\r
+            Notification noti2 = noti.SetLevel(level);\r
+            Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. ");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test SetLevel. Check illegal notification level.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetLevel M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetLevel_CHECK_RETURN_VALUE_Exception()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            NotificationLevel level = (NotificationLevel)6;    // We can set NotificationLevel value between -999999999 to 999999999.\r
+            var noti2 = noti.SetLevel(level);\r
+            Assert.IsNotNull(noti2, "should be not null.");\r
+            Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. ");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test SetPositionSize. Check whether SetPositionSize works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetPositionSize M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetPositionSize_CHECK_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification.");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            Rectangle size = new Rectangle(0, 0, 300, 400);\r
+            Notification noti2 = noti.SetPositionSize(size);\r
+            Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti.");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P2")]\r
+        [Description("Test SetLevel. Check illegal position size.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetPositionSize M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MEX")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetPositionSize_CHECK_RETURN_VALUE_Exception()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            try\r
+            {\r
+                Rectangle size = null;\r
+                noti.SetPositionSize(size);\r
+                Assert.Fail("Should throw the Exception: Input positionSize should not be null. !");\r
+            }\r
+            catch (ArgumentException)\r
+            {\r
+                Assert.Pass("ArgumentException: passed!");\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test Post. Check whether Post works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Post M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Post_CHECK_NO_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            NotificationLevel level = NotificationLevel.Medium;\r
+            try\r
+            {\r
+                uint duration = 3000;\r
+                noti.Post(duration);\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Assert.Fail("Caught Exception" + e.ToString());\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test Dismiss. Check whether Dismiss works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Dismiss M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Dismiss_CHECK_NO_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            noti.Post(0);   // If duration is 0, you should call Dismiss() manually.\r
+            try\r
+            {\r
+                noti.Dismiss();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Assert.Fail("Caught Exception" + e.ToString());\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test Dismiss. Call Dismiss() when NotificationState is not Post.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Dismiss M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Dismiss_CHECK_NO_RETURN_VALUE_Exception()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            noti.Dismiss();   // If NotificationState is not Post, call dismiss will return directly.\r
+            Assert.IsNotNull(noti, "should be not null.");\r
+            View view2 = noti.ContentView;\r
+            Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view.");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test ForceQuit. Call ForceQuit() before onDismissAnimation finished, check whether ForceQuit works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public async Task ForceQuit_CHECK_NO_RETURN_VALUE_During_onDismissAnimation()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            Animation ani = new Animation(4000);\r
+            Assert.IsNotNull(ani, "Can't create success object Animation");\r
+            noti.SetAnimationOnDismiss(ani);\r
+            uint duration = 2000;\r
+            noti.Post(duration);\r
+            await Task.Delay(3000); // ani is palying.\r
+            try\r
+            {\r
+                noti.ForceQuit();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Assert.Fail("Caught Exception" + e.ToString());\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test ForceQuit. Call ForceQuit() after onDismissAnimation finished.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MEX")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public async Task ForceQuit_CHECK_NO_RETURN_VALUE_onDismissAnimation_Finished()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            Animation ani = new Animation(3000);\r
+            Assert.IsNotNull(ani, "Can't create success object Animation");\r
+            noti.SetAnimationOnDismiss(ani);\r
+            uint duration = 2000;\r
+            noti.Post(duration);    // Dismiss the noti after given time.\r
+            await Task.Delay(5000);\r
+            try\r
+            {\r
+                noti.ForceQuit();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Assert.Fail("Caught Exception" + e.ToString());\r
+            }\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test ForceQuit. Call ForceQuit() when NotificationState is not Post.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.ForceQuit M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void ForceQuit_CHECK_NO_RETURN_VALUE_Exception()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            noti.ForceQuit();   // NotificationState is not Post and Dismiss, return directly.\r
+            Assert.IsNotNull(noti, "Should be not null");\r
+            View view2 = noti.ContentView;\r
+            Assert.AreEqual(view, view2, "Retrieved view2 should be equal to view.");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test SetAnimationOnPost. Check whether SetAnimationOnPost works or not.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetAnimationOnPost M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetAnimationOnPost_CHECK_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            Animation ani = new Animation();\r
+            Assert.IsNotNull(ani, "Can't create success object Animation");\r
+            var noti2 = noti.SetAnimationOnPost(ani);\r
+            Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. ");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test SetAnimationOnDismiss. Check whether SetAnimationOnDismiss works or not. ")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.SetAnimationOnDismiss M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MR")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void SetAnimationOnDismiss_CHECK_RETURN_VALUE()\r
+        {\r
+            /* TEST CODE */\r
+            View view = new View();\r
+            Assert.IsNotNull(view, "Can't create success object View");\r
+            var noti = new Notification(view);\r
+            Assert.IsNotNull(noti, "Can't create success object Notification");\r
+            Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+            Animation ani = new Animation();\r
+            Assert.IsNotNull(ani, "Can't create success object Animation");\r
+            var noti2 = noti.SetAnimationOnDismiss(ani);\r
+            Assert.AreEqual(noti, noti2, "Retrieved noti2 should be equal to noti. ");\r
+        }\r
+\r
+        [Test]\r
+        [Category("P1")]\r
+        [Description("Test Dispose, try to dispose the Notification.")]\r
+        [Property("SPEC", "Tizen.NUI.Components.Notification.Dispose M")]\r
+        [Property("SPEC_URL", "-")]\r
+        [Property("CRITERIA", "MCST")]\r
+        [Property("AUTHOR", "Guowei Wang, guowei.wang@samsung.com")]\r
+        public void Dispose_CHECK()\r
+        {\r
+            /* TEST CODE */\r
+            try\r
+            {\r
+                View view = new View();\r
+                Assert.IsNotNull(view, "Can't create success object View");\r
+                var noti = new Notification(view);\r
+                Assert.IsNotNull(noti, "Can't create success object Notification");\r
+                Assert.IsInstanceOf<Notification>(noti, "Should be an instance of Notification type");\r
+                noti.Post();\r
+                noti.Dispose();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());\r
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());\r
+                Assert.Fail("Caught Exception" + e.ToString());\r
+            }\r
+        }\r
+    }\r
+}\r
index 336240e..a6446b8 100755 (executable)
@@ -7,6 +7,7 @@
     </ui-application>
     <privileges>
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+        <privilege>http://tizen.org/privilege/window.priority.set</privilege>
     </privileges>
     <provides-appdefined-privileges />
 </manifest>