From: DoHyun Pyun Date: Mon, 14 Jan 2019 07:18:35 +0000 (+0900) Subject: [Non-ACR][Bluetooth][Manual][Enable Bluetooth OPP Server TCs] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab0f390ab6c17799e7cdf04b6b89732f9fc07518;p=test%2Ftct%2Fcsharp%2Fapi.git [Non-ACR][Bluetooth][Manual][Enable Bluetooth OPP Server TCs] Change-Id: If4923aada6c771b1c84449b0095f6022e6b5c079 Signed-off-by: DoHyun Pyun --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppServer.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppServer.cs old mode 100755 new mode 100644 index 6daf46a61..287e3376f --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppServer.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppServer.cs @@ -6,7 +6,6 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System.Collections.Generic; using Tizen.System; -using Xamarin.Forms; namespace Tizen.Network.Bluetooth.Tests { @@ -14,14 +13,9 @@ namespace Tizen.Network.Bluetooth.Tests [Description("BluetoothOppServer Tests")] public class BluetoothOppServerTests { - static bool _acceptPush = false; - static bool _canceltransfer = false; - static bool _flagTransferFinished = false; - static bool _flagConnectionRequested = false; static BluetoothOppServer _oppServer = null; - const string filePath = "/opt/usr/home/owner/media/"; - static string _fileName = "test1"; - static string _nullfileName = null; + static string filePath = StorageManager.Storages.Where(s => s.StorageType == StorageArea.Internal).FirstOrDefault().RootDirectory + "/Downloads"; + static string fileName = "test1.jpg"; static int _transferId; static bool isBluetoothOppSupported = false; @@ -35,307 +29,66 @@ namespace Tizen.Network.Bluetooth.Tests [TearDown] public static void Destroy() { - _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; - _oppServer.TransferProgress -= EventHandlerTransferProgress; - _oppServer.TransferFinished -= EventHandlerTransferFinished; - _oppServer.StopServer(); - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - public static void EventHandlerTransferProgress(object sender, TransferProgressEventArgs e) - { - if (e.Size > 0) - { - Log.Info(Globals.LogTag, "EventHandlerTransferProgress"); - if (_canceltransfer) - { - _oppServer.CancelTransfer(_transferId); - ManualTest.Confirm(); - } - } - } - - public static void EventHandlerTransferFinished(object sender, TransferFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - Log.Info(Globals.LogTag, "EventHandlerTransferFinished"); - _flagTransferFinished = true; - ManualTest.Confirm(); - } - } - - public static void EventHandlerConnectionRequested(object sender, ConnectionRequestedEventArgs e) - { - - if (e.Address != null) + if (_oppServer != null) { - try - { - Log.Info(Globals.LogTag, "EventHandlerConnectionRequested"); - _oppServer.TransferProgress += EventHandlerTransferProgress; - _oppServer.TransferFinished += EventHandlerTransferFinished; - if (_acceptPush) - { - _oppServer.SetDestinationPath(filePath); - _transferId = _oppServer.AcceptPush(_fileName); - } - else - { - _oppServer.RejectPush(); - ManualTest.Confirm(); - } - } - catch (Exception ex) - { - Assert.Fail("[TestCase][BluetoothOppServer] FAIL " + ex.Message); - } - _flagConnectionRequested = true; - } - } - - public static void EventHandlerConnectionRequested1(object sender, ConnectionRequestedEventArgs e) - { - if (e.Address != null) - { - try - { - Log.Info(Globals.LogTag, "EventHandlerConnectionRequested"); - _oppServer.TransferProgress += EventHandlerTransferProgress; - _oppServer.TransferFinished += EventHandlerTransferFinished; - _oppServer.SetDestinationPath(filePath); - _transferId = _oppServer.AcceptPush(_nullfileName); - ManualTest.Confirm(); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][BluetoothOppServer] FAIL " + ex.Message); - } + _oppServer.StopServer(); + _oppServer = null; } + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - //[Test] + [Test] [Category("P1")] - [Description("Test StartServer, check if StartServer method works properly")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.StartServer M")] + [Description("Test AcceptPush, check if AcceptPush method works properly")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.AcceptPush M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MR")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as Server")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button" )] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] - public static void StartServer_CHECK_FOR_OPPSERVER_START_SERVER() + public static async Task AcceptPush_CHECK_FOR_ACCEPT_PUSH() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE - _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - } - catch (NotSupportedException) - { - if (isBluetoothOppSupported == false) - { - BluetoothHelper.DisplayLabel("StartServer_CHECK_FOR_OPPSERVER_START_SERVER"); - ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("StartServer_CHECK_FOR_OPPSERVER_START_SERVER"); - ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Create a BluetoothOppServer Object")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.BluetoothOppServer C")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "CONSTR")] - [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as Server")] - [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static void BluetoothOppServer_INIT() - { - try - { - _oppServer = BluetoothOppServer.StartServer(filePath); + EventHandler EventHandlerConnectionRequested = null; - //TEST CODE - Assert.IsInstanceOf(_oppServer, "Should return BluetoothOppServer instance."); - Assert.IsNotNull(_oppServer, "BluetoothOppServer instance should not be null"); - } - catch (NotSupportedException) - { - if (isBluetoothOppSupported == false) - { - BluetoothHelper.DisplayLabel("BluetoothOppServer_INIT"); - ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("BluetoothOppServer_INIT"); - ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; - //[Test] - [Category("P1")] - [Description("Test StopServer, check if StopServer method works properly")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.StopServer M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as Server")] - [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static void StopServer_CHECK_FOR_OPPSERVER_STOP_SERVER() - { - try - { - _oppServer = BluetoothOppServer.StartServer(filePath); + _transferId = _oppServer.AcceptPush(fileName); - //TEST CODE - _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _oppServer.StopServer(); - } - catch (NotSupportedException) - { - if (isBluetoothOppSupported == false) - { - BluetoothHelper.DisplayLabel("StopServer_CHECK_FOR_OPPSERVER_STOP_SERVER"); - ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("StopServer_CHECK_FOR_OPPSERVER_STOP_SERVER"); - ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } + BluetoothHelper.DisplayPassLabel("AcceptPush_CHECK_FOR_ACCEPT_PUSH"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][AcceptPush_CHECK_FOR_ACCEPT_PUSH] FAIL " + ex.Message); + } + }; - //[Test] - [Category("P1")] - [Description("Test AcceptPush, check if AcceptPush method works properly")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.AcceptPush M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task AcceptPush_CHECK_FOR_OPPSERVER_ACCEPT_PUSH() - { - try - { - _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _acceptPush = true; - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothOppSupported == false) - { - BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_OPPSERVER_ACCEPT_PUSH"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_OPPSERVER_ACCEPT_PUSH"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Test AcceptPush, check if AcceptPush method throws InvalidOperationException")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.AcceptPush M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEX")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task AcceptPush_CHECK_FOR_EXCEPTION() - { - try - { - _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE - _oppServer.ConnectionRequested += EventHandlerConnectionRequested1; await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_EXCEPTION"); + BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_ACCEPT_PUSH"); await ManualTest.WaitForConfirm(); } } catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_EXCEPTION"); + { + BluetoothHelper.DisplayLabel("AcceptPush_CHECK_FOR_ACCEPT_PUSH"); await ManualTest.WaitForConfirm(); } } @@ -345,7 +98,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test RejectPush, check if RejectPush method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.RejectPush M")] @@ -354,33 +107,49 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] - public static async Task RejectPush_CHECK_FOR_OPPSERVER_REJECT_PUSH() + public static async Task RejectPush_CHECK_FOR_REJECT_PUSH() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _oppServer.RejectPush(); + + BluetoothHelper.DisplayPassLabel("RejectPush_CHECK_FOR_REJECT_PUSH"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][RejectPush_CHECK_FOR_REJECT_PUSH] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("RejectPush_CHECK_FOR_OPPSERVER_REJECT_PUSH"); + BluetoothHelper.DisplayLabel("RejectPush_CHECK_FOR_REJECT_PUSH"); await ManualTest.WaitForConfirm(); } } catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("RejectPush_CHECK_FOR_OPPSERVER_REJECT_PUSH"); + { + BluetoothHelper.DisplayLabel("RejectPush_CHECK_FOR_REJECT_PUSH"); await ManualTest.WaitForConfirm(); } } @@ -390,7 +159,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test CancelTransfer, check if CancelTransfer method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.CancelTransfer M")] @@ -399,80 +168,54 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] - public static async Task CancelTransfer_CHECK_FOR_OPPSERVER_CANCEL_TRANSFER() + public static async Task CancelTransfer_CHECK_FOR_CANCEL_TRANSFER() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE - _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _canceltransfer = true; - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothOppSupported == false) - { - BluetoothHelper.DisplayLabel("CancelTransfer_CHECK_FOR_OPPSERVER_CANCEL_TRANSFER"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("CancelTransfer_CHECK_FOR_OPPSERVER_CANCEL_TRANSFER"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Test SetDestinationPath, check if SetDestinationPath method works properly")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.SetDestinationPath M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task SetDestinationPath_CHECK_FOR_OPPSERVER_SET_DESTINATION() - { - try - { - _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + EventHandler EventHandlerConnectionRequested = null; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + /* Wait to start the current transfer */ + Task.Delay(100).Wait(); + + _oppServer.CancelTransfer(_transferId); + + BluetoothHelper.DisplayPassLabel("CancelTransfer_CHECK_FOR_CANCEL_TRANSFER"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][CancelTransfer_CHECK_FOR_CANCEL_TRANSFER] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _acceptPush = true; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("SetDestinationPath_CHECK_FOR_OPPSERVER_SET_DESTINATION"); + BluetoothHelper.DisplayLabel("CancelTransfer_CHECK_FOR_CANCEL_TRANSFER"); await ManualTest.WaitForConfirm(); } } catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("SetDestinationPath_CHECK_FOR_OPPSERVER_SET_DESTINATION"); + { + BluetoothHelper.DisplayLabel("CancelTransfer_CHECK_FOR_CANCEL_TRANSFER"); await ManualTest.WaitForConfirm(); } } @@ -482,7 +225,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test ConnectionRequested, check if ConnectionRequested event is proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.ConnectionRequested E")] @@ -491,21 +234,35 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task ConnectionRequested_CHECK_EVENT() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + BluetoothHelper.DisplayPassLabel("ConnectionRequested_CHECK_EVENT"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][ConnectionRequested_CHECK_EVENT] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _acceptPush = true; + await ManualTest.WaitForConfirm(); - Assert.IsTrue(_flagConnectionRequested, "[TestCase][BluetoothOppServer][ConnectionRequested_CHECK_EVENT] FAIL "); } catch (NotSupportedException) { @@ -518,7 +275,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("ConnectionRequested_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } @@ -527,10 +284,9 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - } - //[Test] + [Test] [Category("P1")] [Description("Test TransferProgress, check if TransferProgressis proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.TransferProgress E")] @@ -539,21 +295,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task TransferProgress_CHECK_EVENT() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE - _acceptPush = true; + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferProgress = null; + + EventHandlerTransferProgress = (sender, e) => { + if (e.Percent >= 0) + { + _oppServer.TransferProgress -= EventHandlerTransferProgress; + BluetoothHelper.DisplayPassLabel("TransferProgress_CHECK_EVENT"); + } + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferProgress += EventHandlerTransferProgress; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][TransferProgress_CHECK_EVENT] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); - Assert.IsTrue(_flagTransferFinished, "[TestCase][BluetoothOppServer][TransferProgress] FAIL"); } catch (NotSupportedException) { @@ -566,7 +345,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("TransferProgress_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } @@ -577,7 +356,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test TransferFinished, check if TransferFinished event is proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppServer.TransferFinished E")] @@ -586,21 +365,45 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task TransferFinished_CHECK_EVENT() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferFinished = null; + + EventHandlerTransferFinished = (sender, e) => { + if (e.Result == 0) + { + _oppServer.TransferFinished -= EventHandlerTransferFinished; + + BluetoothHelper.DisplayPassLabel("TransferFinished_CHECK_EVENT"); + } + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferFinished += EventHandlerTransferFinished; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][TransferFinished_CHECK_EVENT] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; - _acceptPush = true; + await ManualTest.WaitForConfirm(); - Assert.IsTrue(_flagTransferFinished, "[TestCase][BluetoothOppServer][TransferFinished_CHECK_EVENT] FAIL"); } catch (NotSupportedException) { @@ -613,7 +416,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("TransferFinished_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSConnectionRequestedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSConnectionRequestedEventArgs.cs index 384abcb58..a33bbb2c6 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSConnectionRequestedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSConnectionRequestedEventArgs.cs @@ -6,7 +6,6 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System.Collections.Generic; using Tizen.System; -using Xamarin.Forms; namespace Tizen.Network.Bluetooth.Tests { @@ -15,8 +14,9 @@ namespace Tizen.Network.Bluetooth.Tests public class ConnectionRequestedEventArgsTests { static BluetoothOppServer _oppServer = null; - const string filePath = "/opt/usr/home/owner/share/"; - const string fileName = "test1"; + static string filePath = StorageManager.Storages.Where(s => s.StorageType == StorageArea.Internal).FirstOrDefault().RootDirectory + "/Downloads"; + const string fileName = "test1.jpg"; + static int _transferId; static bool isBluetoothOppSupported = false; [SetUp] @@ -29,44 +29,15 @@ namespace Tizen.Network.Bluetooth.Tests [TearDown] public static void Destroy() { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - _oppServer.StopServer(); - } - - public static void EventHandlerTransferProgress(object sender, TransferProgressEventArgs e) - { - if (e.Size > 0) - { - Log.Info(Globals.LogTag, "EventHandlerTransferProgress"); - } - } - - public static void EventHandlerTransferFinished(object sender, TransferFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - Log.Info(Globals.LogTag, "EventHandlerTransferFinished"); - ManualTest.Confirm(); - } - } - - public static void EventHandlerConnectionRequested(object sender, ConnectionRequestedEventArgs e) - { - Assert.IsNotNull(e.Address, "[TestCase][BluetoothOppServerConnectionRequested][Address_PROPERTY_READ_ONLY] FAIL"); - try + if (_oppServer != null) { - _oppServer.TransferProgress += EventHandlerTransferProgress; - _oppServer.TransferFinished += EventHandlerTransferFinished; - _oppServer.AcceptPush(fileName); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][BluetoothOppServerConnectionRequested] FAIL " + ex.Message); + _oppServer.StopServer(); + _oppServer = null; } + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - //[Test] + [Test] [Category("P1")] [Description("Test Address, check if Address has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.ConnectionRequestedEventArgs.Address A")] @@ -75,18 +46,37 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task Address_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + Assert.IsNotNull(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + + _transferId = _oppServer.AcceptPush(fileName); + + BluetoothHelper.DisplayPassLabel("Address_PROPERTY_READ_ONLY"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][Address_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferFinishedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferFinishedEventArgs.cs index 2950ab5f7..9f8d5eb3d 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferFinishedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferFinishedEventArgs.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; using Tizen.System; -using Xamarin.Forms; +using System.Linq; namespace Tizen.Network.Bluetooth.Tests { @@ -12,10 +12,10 @@ namespace Tizen.Network.Bluetooth.Tests [Description("TransferFinishedEventArgs Tests")] public class TransferFinishedEventArgsTests { - static bool _flagTransferFinished = false; static BluetoothOppServer _oppServer = null; - const string filePath = "/opt/usr/home/owner/media/"; - const string fileName = "test1"; + static string filePath = StorageManager.Storages.Where(s => s.StorageType == StorageArea.Internal).FirstOrDefault().RootDirectory + "/Downloads"; + const string fileName = "test1.jpg"; + static int _transferId; static bool isBluetoothOppSupported = false; [SetUp] @@ -28,55 +28,15 @@ namespace Tizen.Network.Bluetooth.Tests [TearDown] public static void Destroy() { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; - _oppServer.TransferProgress -= EventHandlerTransferProgress; - _oppServer.TransferFinished -= EventHandlerTransferFinished; - _oppServer.StopServer(); - } - - public static void EventHandlerTransferProgress(object sender, TransferProgressEventArgs e) - { - if (e.Size > 0 && e.File != null && e.Percent > 0) - { - Log.Info(Globals.LogTag, "EventHandlerTransferProgress"); - } - } - - public static void EventHandlerTransferFinished(object sender, TransferFinishedEventArgs e) - { - if (e.Result == 0 && e.File != null && e.Size > 0) - { - Log.Info(Globals.LogTag, "BluetoothOppServerTransferFinishedEventArgs"); - _flagTransferFinished = true; - ManualTest.Confirm(); - } - else + if (_oppServer != null) { - Assert.IsTrue(_flagTransferFinished, "[TestCase][TransferFinishedEventArgs] FAIL"); - } - } - - public static void EventHandlerConnectionRequested(object sender, ConnectionRequestedEventArgs e) - { - - if (e.Address != null) - { - try - { - Log.Info(Globals.LogTag, "EventHandlerConnectionRequested"); - _oppServer.TransferProgress += EventHandlerTransferProgress; - _oppServer.TransferFinished += EventHandlerTransferFinished; - _oppServer.AcceptPush(fileName); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][BluetoothOppServerTransferFinishedEventArgs] FAIL " + ex.Message); - } + _oppServer.StopServer(); + _oppServer = null; } + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - //[Test] + [Test] [Category("P1")] [Description("Test File, check if File has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferFinishedEventArgs.File A")] @@ -85,18 +45,45 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task File_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferFinished = null; + + EventHandlerTransferFinished = (sender, e) => { + _oppServer.TransferFinished -= EventHandlerTransferFinished; + + Assert.IsNotNull(e.File, "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.File, "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + Assert.True(String.Equals(e.File, fileName), "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("File_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferFinished += EventHandlerTransferFinished; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][File_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) @@ -110,7 +97,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -121,7 +108,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Size, check if Size has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferFinishedEventArgs.Size A")] @@ -130,33 +117,59 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task Size_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferFinished = null; + + EventHandlerTransferFinished = (sender, e) => { + _oppServer.TransferFinished -= EventHandlerTransferFinished; + + Assert.IsInstanceOf(e.Size, "[TestCase][Size_PROPERTY_READ_ONLY] Failed"); + Assert.IsTrue(e.Size >= 0, "[TestCase][Size_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("File_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferFinished += EventHandlerTransferFinished; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][File_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("Size_PROPERTY_READ_ONLY"); + BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } } catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Size_PROPERTY_READ_ONLY"); + { + BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } } @@ -166,7 +179,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Result, check if Result has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferFinishedEventArgs.Result A")] @@ -175,18 +188,43 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task Result_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferFinished = null; + + EventHandlerTransferFinished = (sender, e) => { + _oppServer.TransferFinished -= EventHandlerTransferFinished; + + Assert.IsTrue((int)e.Result == 0, "[TestCase][Result_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("Result_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferFinished += EventHandlerTransferFinished; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][Result_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) @@ -200,7 +238,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferProgressEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferProgressEventArgs.cs index ee65c9e1b..74d661086 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferProgressEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSTransferProgressEventArgs.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; using Tizen.System; -using Xamarin.Forms; +using System.Linq; namespace Tizen.Network.Bluetooth.Tests { @@ -12,10 +12,10 @@ namespace Tizen.Network.Bluetooth.Tests [Description("TransferProgressEventArgs Tests")] public class TransferProgressEventArgsTests { - static bool _flagTransferProgress = false; static BluetoothOppServer _oppServer = null; - const string filePath = "/opt/usr/home/owner/media/"; - const string fileName = "test1"; + static string filePath = StorageManager.Storages.Where(s => s.StorageType == StorageArea.Internal).FirstOrDefault().RootDirectory + "/Downloads"; + const string fileName = "test1.jpg"; + static int _transferId; static bool isBluetoothOppSupported = false; [SetUp] @@ -27,57 +27,15 @@ namespace Tizen.Network.Bluetooth.Tests [TearDown] public static void Destroy() { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; - _oppServer.TransferProgress -= EventHandlerTransferProgress; - _oppServer.TransferFinished -= EventHandlerTransferFinished; - _oppServer.StopServer(); - - } - - public static void EventHandlerTransferProgress(object sender, TransferProgressEventArgs e) - { - if (e.Size > 0 && e.File != null && e.Percent > 0) - { - _flagTransferProgress = true; - } - else + if (_oppServer != null) { - _flagTransferProgress = false; - } - } - - public static void EventHandlerTransferFinished(object sender, TransferFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - Log.Info(Globals.LogTag, "TransferProgressEventArgs"); - Assert.IsTrue(_flagTransferProgress, "[TestCase][TransferProgressEventArgs] FAIL"); - ManualTest.Confirm(); - } - } - - public static void EventHandlerConnectionRequested(object sender, ConnectionRequestedEventArgs e) - { - - if (e.Address != null) - { - try - { - Log.Info(Globals.LogTag, "EventHandlerConnectionRequested"); - _oppServer.TransferProgress += EventHandlerTransferProgress; - _oppServer.TransferFinished += EventHandlerTransferFinished; - _oppServer.AcceptPush(fileName); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][TransferProgressEventArgs] FAIL " + ex.Message); - } + _oppServer.StopServer(); + _oppServer = null; } + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - //[Test] + [Test] [Category("P1")] [Description("Test File, check if File has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferProgressEventArgs.File A")] @@ -86,18 +44,45 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task File_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferProgress = null; + + EventHandlerTransferProgress = (sender, e) => { + _oppServer.TransferProgress -= EventHandlerTransferProgress; + + Assert.IsNotNull(e.File, "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.File, "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + Assert.True(String.Equals(e.File, fileName), "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("File_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferProgress += EventHandlerTransferProgress; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][File_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) @@ -111,7 +96,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -122,7 +107,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Size, check if Size has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferProgressEventArgs.Size A")] @@ -131,18 +116,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task Size_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferProgress = null; + + EventHandlerTransferProgress = (sender, e) => { + _oppServer.TransferProgress -= EventHandlerTransferProgress; + + Assert.IsInstanceOf(e.Size, "[TestCase][Size_PROPERTY_READ_ONLY] Failed"); + Assert.IsTrue(e.Size >= 0, "[TestCase][Size_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("Size_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferProgress += EventHandlerTransferProgress; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][Size_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) @@ -156,7 +167,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Size_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -167,7 +178,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Percent, check if Percent has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.TransferProgressEventArgs.Percent A")] @@ -176,18 +187,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] [Step(1, "Tap the Run button")] - [Step(2, "Open the bluetooth setting on server device, which makes the device visible")] - [Step(3, "Share a file from Opp Client device over bluetooth")] - [Step(4, "When permission request popup appears, tap accept on server device.")] - [Step(5, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] + [Step(2, "Share a file from Opp Client device over bluetooth")] + [Step(3, "When permission request popup appears, tap accept on server device.")] [Postcondition(1, "NA")] public static async Task Percent_PROPERTY_READ_ONLY() { try { _oppServer = BluetoothOppServer.StartServer(filePath); - //TEST CODE + + EventHandler EventHandlerConnectionRequested = null; + EventHandler EventHandlerTransferProgress = null; + + EventHandlerTransferProgress = (sender, e) => { + _oppServer.TransferProgress -= EventHandlerTransferProgress; + + Assert.IsInstanceOf(e.Percent, "[TestCase][Percent_PROPERTY_READ_ONLY] Failed"); + Assert.IsTrue(e.Percent >= 0, "[TestCase][Percent_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("Percent_PROPERTY_READ_ONLY"); + }; + + EventHandlerConnectionRequested = (sender, e) => { + try + { + _oppServer.ConnectionRequested -= EventHandlerConnectionRequested; + + _transferId = _oppServer.AcceptPush(fileName); + + _oppServer.TransferProgress += EventHandlerTransferProgress; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][Percent_PROPERTY_READ_ONLY] FAIL " + ex.Message); + } + }; + _oppServer.ConnectionRequested += EventHandlerConnectionRequested; + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) @@ -201,7 +238,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Percent_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); }