From b7440fc79d88f11709d9dda4f9152d055191c2bb Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Tue, 7 May 2019 08:46:49 +0900 Subject: [PATCH] [Applications.EventManager][Non-ACR] Add precondition for tests Change-Id: Ie61bf458a561d2c574f8de7a71c546e5da70f18f Signed-off-by: Inkyun Kil --- .../testcase/TSEventManager.EventReceiver.cs | 260 ++++++++++++--------- 1 file changed, 149 insertions(+), 111 deletions(-) diff --git a/tct-suite-vs/Tizen.Applications.EventManager.Manual.Tests/testcase/TSEventManager.EventReceiver.cs b/tct-suite-vs/Tizen.Applications.EventManager.Manual.Tests/testcase/TSEventManager.EventReceiver.cs index 009bddf..35e74d8 100755 --- a/tct-suite-vs/Tizen.Applications.EventManager.Manual.Tests/testcase/TSEventManager.EventReceiver.cs +++ b/tct-suite-vs/Tizen.Applications.EventManager.Manual.Tests/testcase/TSEventManager.EventReceiver.cs @@ -1,111 +1,149 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -using System.Threading.Tasks; -using NUnit.Framework; -using Tizen.Applications; -using Tizen.Applications.EventManager; -using Tizen.Applications.EventManager.SystemEvents; - -namespace Tizen.Applications.EventManager.Manual.Tests -{ - - [TestFixture] - [Description("Tizen.Applications.EventManager.EventManagerEventReceiver Tests")] - public class EventManagerEventReceiverTests - { - - private string TAG = "Tizen.Application.EventManager"; - private string _message; - EventReceiver receiver; - - [SetUp] - public void Init() - { - } - - [TearDown] - public void Destroy() - { - } - - void OnReceived(object sender, EventManagerEventArgs e) - { - if (e.Name == EarjackStatus.EventName) - { - Bundle eventData = e.Data; - object aValue = eventData.GetItem(EarjackStatus.StatusKey); - if (eventData.Is(EarjackStatus.StatusKey)) - { - string statusValue = (string)aValue; - - ToastMessage toast = new ToastMessage - { - Message = statusValue - }; - - toast.Post(); - } - } - - receiver.Received -= OnReceived; - } - - [Test] - [Category("P1")] - [Description("MANUAL TEST : EventReceiver add received event handler.")] - [Property("SPEC", "Tizen.Applications.EventManager.EventReceiver.Received E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "inkyun kil, inkyun.kil@samsung.com")] - [Precondition(1, "earjack is disconnected.")] - [Step(1, "Click run TC")] - [Step(2, "earjack is connected")] - [Step(3, "check if toast message show \"connected\".")] - public async Task Received_Add() - { - - receiver = new EventReceiver(EarjackStatus.EventName); - receiver.Received += OnReceived; - - // Waits for user confirmation. - await ManualTest.WaitForConfirm(); - } - - [Test] - [Category("P1")] - [Description("MANUAL TEST : EventReceiver remove received event handler.")] - [Property("SPEC", "Tizen.Applications.EventManager.EventReceiver.Received E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "inkyun kil, inkyun.kil@samsung.com")] - [Precondition(1, "earjack is disconnected.")] - [Step(1, "Click run TC")] - [Step(2, "earjack is connected")] - [Step(3, "check if toast message doesn't show \"connected\".")] - public async Task Received_Remove() - { - - receiver = new EventReceiver(EarjackStatus.EventName); - receiver.Received += OnReceived; - receiver.Received -= OnReceived; - - // Waits for user confirmation. - await ManualTest.WaitForConfirm(); - } - } -} - +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using Tizen.Applications; +using Tizen.Applications.EventManager; +using Tizen.Applications.EventManager.SystemEvents; +using Tizen.System; + +namespace Tizen.Applications.EventManager.Manual.Tests +{ + + [TestFixture] + [Description("Tizen.Applications.EventManager.EventManagerEventReceiver Tests")] + public class EventManagerEventReceiverTests + { + + private string TAG = "Tizen.Application.EventManager"; + private string _message; + EventReceiver receiver; + + [SetUp] + public void Init() + { + } + + [TearDown] + public void Destroy() + { + } + + void OnReceived(object sender, EventManagerEventArgs e) + { + if (e.Name == EarjackStatus.EventName) + { + Bundle eventData = e.Data; + object aValue = eventData.GetItem(EarjackStatus.StatusKey); + if (eventData.Is(EarjackStatus.StatusKey)) + { + string statusValue = (string)aValue; + + ToastMessage toast = new ToastMessage + { + Message = statusValue + }; + + toast.Post(); + } + } + + receiver.Received -= OnReceived; + } + + [Test] + [Category("P1")] + [Description("MANUAL TEST : EventReceiver add received event handler.")] + [Property("SPEC", "Tizen.Applications.EventManager.EventReceiver.Received E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "inkyun kil, inkyun.kil@samsung.com")] + [Precondition(1, "This test can be tested only in mobile device.")] + [Precondition(2, "earjack is disconnected.")] + [Step(1, "Click run TC")] + [Step(2, "earjack is connected")] + [Step(3, "check if toast message show \"connected\".")] + public async Task Received_Add() + { + string profile; + bool canBeTested; + + Information.TryGetValue("tizen.org/feature/profile", out profile); + + // This TC will be tested only "mobile". + if (String.Compare(profile, "mobile", true) == 0) + canBeTested = true; + else + canBeTested = false; + + if (canBeTested) + { + receiver = new EventReceiver(EarjackStatus.EventName); + receiver.Received += OnReceived; + + // Waits for user confirmation. + await ManualTest.WaitForConfirm(); + } + else + { + Assert.Pass("Not Supported profile"); + } + } + + [Test] + [Category("P1")] + [Description("MANUAL TEST : EventReceiver remove received event handler.")] + [Property("SPEC", "Tizen.Applications.EventManager.EventReceiver.Received E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "inkyun kil, inkyun.kil@samsung.com")] + [Precondition(1, "This test can be tested only in mobile device.")] + [Precondition(2, "earjack is disconnected.")] + [Step(1, "Click run TC")] + [Step(2, "earjack is connected")] + [Step(3, "check if toast message doesn't show \"connected\".")] + public async Task Received_Remove() + { + string profile; + bool canBeTested; + + Information.TryGetValue("tizen.org/feature/profile", out profile); + + // This TC will be tested only "mobile". + if (String.Compare(profile, "mobile", true) == 0) + canBeTested = true; + else + canBeTested = false; + + if (canBeTested) + { + receiver = new EventReceiver(EarjackStatus.EventName); + receiver.Received += OnReceived; + receiver.Received -= OnReceived; + + // Waits for user confirmation. + await ManualTest.WaitForConfirm(); + } + else + { + Assert.Pass("Not Supported profile"); + } + } + } +} + -- 2.7.4