From 3f4d5aec73bac79d91e6b46e0f30fd0b0f397bd1 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Wed, 9 Jan 2019 10:55:16 +0900 Subject: [PATCH] [Non-ACR][Bluetooth][Manual]Enable Bluetooth OPP Client TCs] Change-Id: I1973f38b642c5d5f408161eee0ae1f2b6c47a3e0 Signed-off-by: DoHyun Pyun --- .../shared/res/test1.jpg | Bin 0 -> 10839 bytes .../testcase/BluetoothSetup.cs | 25 + .../testcase/PreconditionUtils.cs | 14 + .../testcase/TSBluetoothOppClient.cs | 558 +++++++----------- .../testcase/TSPushFinishedEventArgs.cs | 179 +++--- .../testcase/TSPushProgressEventArgs.cs | 207 +++---- .../testcase/TSPushRespondedEventArgs.cs | 177 +++--- 7 files changed, 496 insertions(+), 664 deletions(-) create mode 100755 tct-suite-vs/Tizen.Bluetooth.Manual.Tests/shared/res/test1.jpg mode change 100755 => 100644 tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushFinishedEventArgs.cs diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/shared/res/test1.jpg b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/shared/res/test1.jpg new file mode 100755 index 0000000000000000000000000000000000000000..c090428a43294a99108094b5a3d3f6e59d894eb2 GIT binary patch literal 10839 zcmeHM&5zqe6n{>DW>;mkX^VuQ5>_}YLUO#>D1unYu1c4b0zp+-i5@%gj2(CVC3~WH z_rwWq95`?xf*ay5;DQ7k5Pt(75^6bC74R2e-q_AZvqkK-RfXtGWasDi-n{wE&rk77 zlKz<9g!MOjmwTX;6u6ErNPma53p5xopnyY3Z>@jxdg53B{XV>mmI|yXYfwV80&wa# z~R6bCipW%;`m*z30vvYi@S74lV>2iThfDavbqR8{fi zCX)=Sh`*S8mf>~8e@#Bm@Uw`2xP2Z@0X+35&iM)tIDZ>Y703wxiXM@84X+d7ltU^Y z6_5%@1*8K169x8Q2nQ}EQeG;Dj*e*3P=T{0*|8t=^d!< zj?Dc7Y#GFNe{3GoTdTbx=b@qNeq1Nw$Bw!gczQxYy;0xPp|g{O#N20G9WdMRyBmLe z{q2V8(C)^2t^Q^|yvT;m8;22l_wb!P^Kjp6(~X_&r&l|Pk$9oUI8hVN^cSL$4A0!S0spY-gP{v2)4rItQ2;%VuR| zda*xw%jqw)DT5TO(W~5^9^3W7CoPSpXKN}V!q)L z-|p5Dt!Vpe`L6N%#L~8Lz3H~+L=e$=RsR==-9-oK#iPLuX7Wc^6pM>K)C$mx0>lp@ zM6-`AyesM>7;=#li7e%ka-B$l69voaI-Xqfo{;(22#&GiOMiijpd5dc=A%3tB1w^= zq$n7H$IN+LkbVc%igL5`ep#tPsj8H#O8PxKgXET4{#7)eTVJ+(); + } + else + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "No matched paired device"); + } + + return BtOppClient; + } + + public static BluetoothDevice GetPairedDevice() + { + return pairedDevice; + } } } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/PreconditionUtils.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/PreconditionUtils.cs index 53f58b3da..f4c3e2d92 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/PreconditionUtils.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/PreconditionUtils.cs @@ -24,6 +24,7 @@ namespace BluetoothNetworkUtils { public static string BT_REMOTE_BLE_DEVICE_ADDRESS = null; public static string BT_REMOTE_HID_DEVICE_ADDRESS = null; + public static string BT_REMOTE_OPP_DEVICE_ADDRESS = null; public static string default_remote_addr = "AA:AA:AA:AA:AA:AA"; public static string GetBleAddress () @@ -42,6 +43,14 @@ namespace BluetoothNetworkUtils return BT_REMOTE_HID_DEVICE_ADDRESS; } + public static string GetOppAddress () + { + if (BT_REMOTE_OPP_DEVICE_ADDRESS == null) + SetPrecondition(); + + return BT_REMOTE_OPP_DEVICE_ADDRESS; + } + public static string GetDefaultAddress () { return default_remote_addr; @@ -73,6 +82,11 @@ namespace BluetoothNetworkUtils resultArray[index + 1] = resultArray[index + 1].Replace("\\", ""); BT_REMOTE_HID_DEVICE_ADDRESS = resultArray[index + 1]; break; + case "BT_REMOTE_OPP_DEVICE_ADDRESS": + // Remove backslash + resultArray[index + 1] = resultArray[index + 1].Replace("\\", ""); + BT_REMOTE_OPP_DEVICE_ADDRESS = resultArray[index + 1]; + break; default: break; } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppClient.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppClient.cs index 9434d8544..5cc666b4b 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppClient.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothOppClient.cs @@ -4,7 +4,8 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using BluetoothNetworkUtils; using Tizen.System; -using Xamarin.Forms; +using System.IO; +using Tizen.Applications; namespace Tizen.Network.Bluetooth.Tests { @@ -12,16 +13,9 @@ namespace Tizen.Network.Bluetooth.Tests [Description("BluetoothOppClient Tests")] public class BluetoothOppClientTests { - static bool _flagDiscovery = false; - static bool _flagPushResponded = false; - static bool _flagPushProgress = false; - static bool _flagPushFinished = false; - static bool _flagCancelPush = false; static BluetoothDevice _device = null; static BluetoothOppClient _oppClient = null; - const string filePath = "/opt/usr/home/owner/share/image1.jpg"; - const string invalidfilePath = "/opt/usr/home/owner/share/image2.jpg"; - public static string _remoteAddress = PreconditionUtils.GetBleAddress(); + private static string filePath = Path.Combine(Application.Current.DirectoryInfo.SharedResource, "test1.jpg"); static bool isBluetoothOppSupported = false; [SetUp] @@ -37,87 +31,7 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - public static async Task DiscoverySetup() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Setup DiscoverySetup"); - BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryChanged; - BluetoothAdapter.StartDiscovery(); - await WaitForDiscoveryflag(); - BluetoothAdapter.StopDiscovery(); - await Task.Delay(8000); - BluetoothAdapter.DiscoveryStateChanged -= EventHandlerDiscoveryChanged; - } - - public static async Task WaitForDiscoveryflag() - { - int count = 0; - while (true) - { - await Task.Delay(1000); - count++; - if (_flagDiscovery) - break; - if (count == 8) - break; - } - } - - public static void EventHandlerDiscoveryChanged(object sender, DiscoveryStateChangedEventArgs e) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Remote Address: " + _remoteAddress); - - if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found && e.DeviceFound.Address.Equals(_remoteAddress)) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerDiscoveryChanged: " + e.DeviceFound.Address); - _device = e.DeviceFound; - _oppClient = _device.GetProfile(); - _flagDiscovery = true; - } - } - - public static void EventHandlerPushProgress(object sender, PushProgressEventArgs e) - { - if (e.Size > 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushProgress"); - _flagPushProgress = true; - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "File : " + e.File + " Size : " + e.Size + " Percent : " + e.Percent + "%"); - if (_flagCancelPush) - { - try - { - _oppClient.CancelPush(); - ManualTest.Confirm(); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][BluetoothOppClient][EventHandlerPushProgress] FAIL " + ex.Message); - } - } - } - } - - public static void EventHandlerPushFinished(object sender, PushFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushFinished"); - _flagPushFinished = true; - ManualTest.Confirm(); - } - } - - public static void EventHandlerPushResponded(object sender, PushRespondedEventArgs e) - { - if (e.Address != null) - { - _flagPushResponded = true; - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushResponded"); - } - } - - //[Test] + [Test] [Category("P1")] [Description("Test PushFile, check if PushFile method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushFile M")] @@ -125,87 +39,53 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; - _oppClient.AddFile(filePath); - _oppClient.PushFile(_device.Address); - await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][BluetoothOppClient][PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE] Failed"); - } - catch (NotSupportedException) - { + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ if (isBluetoothOppSupported == false) { BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE"); await ManualTest.WaitForConfirm(); + return; } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Test PushFile, check if PushFile throws InvalidOperationException")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushFile M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEX")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task PushFile_CHECK_FOR_EXCEPTIONAsync() - { - //TEST CODE - try - { - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + if (e.Result == 0) + { + BluetoothHelper.DisplayPassLabel("PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE"); + _oppClient.PushFinished -= EventHandlerPushFinished; + } + }; + _oppClient.PushFinished += EventHandlerPushFinished; - Assert.Throws(() => - { - _oppClient.PushFile(_device.Address); - }, "PushFile should throw InvalidOperationException"); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; + + _oppClient.AddFile(filePath); + + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_EXCEPTIONAsync"); + BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE"); await ManualTest.WaitForConfirm(); } } @@ -213,7 +93,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_EXCEPTIONAsync"); + BluetoothHelper.DisplayLabel("PushFile_CHECK_FOR_OPPCLIENT_PUSH_FILE"); await ManualTest.WaitForConfirm(); } } @@ -223,7 +103,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test AddFile, check if AddFile method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.AddFile M")] @@ -231,87 +111,53 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; - _oppClient.AddFile(filePath); - _oppClient.PushFile(_device.Address); - await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][BluetoothOppClient][AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE] Failed"); - } - catch (NotSupportedException) - { + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ if (isBluetoothOppSupported == false) { BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE"); await ManualTest.WaitForConfirm(); + return; } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Test AddFile, check if AddFile method throws InvalidOperationException")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.AddFile M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEX")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task AddFile_CHECK_FOR_EXECPTIONAsync() - { - try - { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + if (e.Result == 0) + { + BluetoothHelper.DisplayPassLabel("AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE"); + _oppClient.PushFinished -= EventHandlerPushFinished; + } + }; + _oppClient.PushFinished += EventHandlerPushFinished; - Assert.Throws(() => - { - _oppClient.AddFile(invalidfilePath); - }, "AddFile should throw InvalidOperationException"); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; + + _oppClient.AddFile(filePath); + + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_EXECPTIONAsync"); + BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE"); await ManualTest.WaitForConfirm(); } } @@ -319,7 +165,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_EXECPTIONAsync"); + BluetoothHelper.DisplayLabel("AddFile_CHECK_FOR_OPPCLIENT_ADD_FILE"); await ManualTest.WaitForConfirm(); } } @@ -329,7 +175,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test ClearFiles, check if ClearFiles method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.ClearFiles M")] @@ -337,26 +183,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] - public static async Task ClearFiles_CHECK_FOR_OPPCLIENT_CLEAR_FILESAsync() + public static async Task ClearFiles_CHECK_FOR_OPPCLIENT_CLEAR_FILES() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("ClearFiles_CHECK_FOR_OPPCLIENT_CLEAR_FILESAsync"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + if (e.Result == 0) + { + BluetoothHelper.DisplayPassLabel("ClearFiles_CHECK_FOR_OPPCLIENT_CLEAR_FILESAsync"); + _oppClient.PushFinished -= EventHandlerPushFinished; + } + }; + _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + + _oppClient.PushFile(_device.Address); + _oppClient.ClearFiles(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { @@ -380,7 +247,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test CancelPush, check if CancelPush method works properly")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.CancelPush M")] @@ -388,88 +255,58 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; - _oppClient.AddFile(filePath); - _flagCancelPush = true; - _oppClient.PushFile(_device.Address); - await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][BluetoothOppClient][CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH] Failed"); - } - catch (NotSupportedException) - { + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ if (isBluetoothOppSupported == false) { BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH"); await ManualTest.WaitForConfirm(); + return; } - } - catch (TypeInitializationException e) - { - if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - //[Test] - [Category("P1")] - [Description("Test CancelPush, check if CancelPush method throws InvalidOperationException")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.CancelPush M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEX")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] - [Postcondition(1, "NA")] - public static async Task CancelPush_CHECK_FOR_EXCEPTIONAsync() - { - try - { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushProgress = null; + + EventHandlerPushProgress = (sender, e) => { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "File : " + e.File + " Size : " + e.Size + " Percent : " + e.Percent + "%"); + try + { + _oppClient.CancelPush(); + BluetoothHelper.DisplayPassLabel("CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][BluetoothOppClient][CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH] FAIL " + ex.Message); + } + }; + _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; - Assert.Throws(() => - { - _oppClient.CancelPush(); - }, "CancelPush should throw InvalidOperationException"); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; + + _oppClient.AddFile(filePath); + + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { if (isBluetoothOppSupported == false) { - BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_EXCEPTIONAsync"); + BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH"); await ManualTest.WaitForConfirm(); } } @@ -477,7 +314,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_EXCEPTIONAsync"); + BluetoothHelper.DisplayLabel("CancelPush_CHECK_FOR_OPPCLIENT_CANCEL_PUSH"); await ManualTest.WaitForConfirm(); } } @@ -487,7 +324,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - // [Test] + [Test] [Category("P1")] [Description("Test PushResponded, check if PushResponded event is proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushResponded E")] @@ -495,28 +332,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task PushResponded_CHECK_EVENT() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("PushResponded_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushResponsed = null; + + EventHandlerPushResponsed = (sender, e) => { + if (e.Result == 0) + { + BluetoothHelper.DisplayPassLabel("PushResponded_CHECK_EVENT"); + _oppClient.PushResponded -= EventHandlerPushResponsed; + } + }; + + _oppClient.PushResponded += EventHandlerPushResponsed; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][BluetoothOppClient][PushResponded_CHECK_EVENT] Failed"); } catch (NotSupportedException) { @@ -540,7 +396,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test PushProgress, check if PushProgress event is proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushProgress E")] @@ -548,28 +404,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task PushProgress_CHECK_EVENT() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("PushProgress_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushProgress = null; + + EventHandlerPushProgress = (sender, e) => { + if (e.Percent >= 0) + { + BluetoothHelper.DisplayPassLabel("PushProgress_CHECK_EVENT"); + _oppClient.PushProgress -= EventHandlerPushProgress; + } + }; + _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushProgress, "[TestCase][BluetoothOppClient][PushProgress_CHECK_EVENT] Failed"); } catch (NotSupportedException) { @@ -593,7 +468,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test PushFinished, check if PushFinished event is proper")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushFinished E")] @@ -601,28 +476,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task PushFinished_CHECK_EVENT() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("PushProgress_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + if (e.Result == 0) + { + BluetoothHelper.DisplayPassLabel("PushProgress_CHECK_EVENT"); + _oppClient.PushFinished -= EventHandlerPushFinished; + } + }; + _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushFinished, "[TestCase][BluetoothOppClient][PushFinished_CHECK_EVENT] Failed"); } catch (NotSupportedException) { @@ -635,7 +529,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("PushFinished_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushFinishedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushFinishedEventArgs.cs old mode 100755 new mode 100644 index 7f75bc359..b2bc89a7b --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushFinishedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushFinishedEventArgs.cs @@ -4,7 +4,8 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using BluetoothNetworkUtils; using Tizen.System; -using Xamarin.Forms; +using System.IO; +using Tizen.Applications; namespace Tizen.Network.Bluetooth.Tests { @@ -12,15 +13,9 @@ namespace Tizen.Network.Bluetooth.Tests [Description("PushFinishedEventArgs Tests")] public class PushFinishedEventArgsTests { - static bool _flagDiscovery = false; - static bool _flagPushResponded = false; - static bool _flagPushProgress = false; - static bool _flagPushFinished = false; - static bool _flagCancelPush = false; static BluetoothDevice _device = null; static BluetoothOppClient _oppClient = null; - const string filePath = "/opt/usr/home/owner/share/image1.jpg"; - public static string _remoteAddress = PreconditionUtils.GetBleAddress(); + private static string filePath = Path.Combine(Application.Current.DirectoryInfo.SharedResource, "test1.jpg"); static bool isBluetoothOppSupported = false; [SetUp] @@ -36,85 +31,7 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - public static async Task DiscoverySetup() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Setup DiscoverySetup"); - BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryChanged; - BluetoothAdapter.StartDiscovery(); - await WaitForDiscoveryflag(); - BluetoothAdapter.StopDiscovery(); - await Task.Delay(8000); - BluetoothAdapter.DiscoveryStateChanged -= EventHandlerDiscoveryChanged; - } - - public static async Task WaitForDiscoveryflag() - { - int count = 0; - while (true) - { - await Task.Delay(1000); - count++; - if (_flagDiscovery) - break; - if (count == 8) - break; - } - } - - public static void EventHandlerDiscoveryChanged(object sender, DiscoveryStateChangedEventArgs e) - { - if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found && e.DeviceFound.Address.Equals(_remoteAddress)) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerDiscoveryChanged"); - _device = e.DeviceFound; - _oppClient = _device.GetProfile(); - _flagDiscovery = true; - } - } - - public static void EventHandlerPushProgress(object sender, PushProgressEventArgs e) - { - if (e.Size > 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushProgress"); - _flagPushProgress = true; - if (_flagCancelPush) - { - try - { - _oppClient.CancelPush(); - ManualTest.Confirm(); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][PushFinishedEventArgs][EventHandlerPushProgress] FAIL " + ex.Message); - } - } - } - } - - public static void EventHandlerPushFinished(object sender, PushFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushFinished"); - _flagPushFinished = true; - ManualTest.Confirm(); - } - } - - public static void EventHandlerPushResponded(object sender, PushRespondedEventArgs e) - { - if (e.Address != null && e.Result == 0) - { - _flagPushResponded = true; - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushResponded"); - //ManualTest.Confirm(); - } - } - - //[Test] + [Test] [Category("P1")] [Description("Test Address, check if Address has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushFinishedEventArgs.Address A")] @@ -122,28 +39,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Address_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + _oppClient.PushFinished -= EventHandlerPushFinished; + Assert.IsNotNull(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + Assert.True(String.Equals(e.Address, _device.Address), "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("Address_PROPERTY_READ_ONLY"); + }; + _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushFinished, "[TestCase][PushFinishedEventArgs][Address_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -156,7 +92,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -167,36 +103,53 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] - [Description("Test Address, check if Address has proper value")] + [Description("Test Result, check if Result has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushFinishedEventArgs.Result A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Result_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushFinished = null; + + EventHandlerPushFinished = (sender, e) => { + _oppClient.PushFinished -= EventHandlerPushFinished; + Assert.IsTrue((int)e.Result == 0, "[TestCase][Result_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("Result_PROPERTY_READ_ONLY"); + }; + _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushFinished, "[TestCase][PushFinishedEventArgs][Result_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -209,7 +162,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/TSPushProgressEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushProgressEventArgs.cs index 2abf6d4ba..fd4c6ff53 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushProgressEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushProgressEventArgs.cs @@ -4,7 +4,8 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using BluetoothNetworkUtils; using Tizen.System; -using Xamarin.Forms; +using System.IO; +using Tizen.Applications; namespace Tizen.Network.Bluetooth.Tests { @@ -12,14 +13,9 @@ namespace Tizen.Network.Bluetooth.Tests [Description("PushProgressEventArgs Tests")] public class PushProgressEventArgsTests { - static bool _flagDiscovery = false; - static bool _flagPushResponded = false; - static bool _flagPushProgress = false; - static bool _flagPushFinished = false; - static bool _flagCancelPush = false; static BluetoothDevice _device = null; static BluetoothOppClient _oppClient = null; - const string filePath = "/opt/usr/home/owner/share/image1.jpg"; + private static string filePath = Path.Combine(Application.Current.DirectoryInfo.SharedResource, "test1.jpg"); public static string _remoteAddress = PreconditionUtils.GetBleAddress(); static bool isBluetoothOppSupported = false; @@ -36,71 +32,7 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - public static async Task DiscoverySetup() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Setup DiscoverySetup"); - BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryChanged; - BluetoothAdapter.StartDiscovery(); - await WaitForDiscoveryflag(); - BluetoothAdapter.StopDiscovery(); - await Task.Delay(8000); - BluetoothAdapter.DiscoveryStateChanged -= EventHandlerDiscoveryChanged; - } - - public static async Task WaitForDiscoveryflag() - { - int count = 0; - while (true) - { - await Task.Delay(1000); - count++; - if (_flagDiscovery) - break; - if (count == 8) - break; - } - } - - public static void EventHandlerDiscoveryChanged(object sender, DiscoveryStateChangedEventArgs e) - { - if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found && e.DeviceFound.Address.Equals(_remoteAddress)) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerDiscoveryChanged"); - _device = e.DeviceFound; - _oppClient = _device.GetProfile(); - _flagDiscovery = true; - } - } - - public static void EventHandlerPushProgress(object sender, PushProgressEventArgs e) - { - if (e.Size > 0 && e.File != null && e.Percent > 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushProgress"); - _flagPushProgress = true; - } - } - - public static void EventHandlerPushFinished(object sender, PushFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushFinished"); - ManualTest.Confirm(); - } - } - - public static void EventHandlerPushResponded(object sender, PushRespondedEventArgs e) - { - if (e.Address != null && e.Result == 0) - { - _flagPushResponded = true; - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushResponded"); - } - } - - //[Test] + [Test] [Category("P1")] [Description("Test File, check if File has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushProgressEventArgs.File A")] @@ -108,28 +40,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task File_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushProgress = null; + + EventHandlerPushProgress = (sender, e) => { + 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, filePath), "[TestCase][File_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("File_PROPERTY_READ_ONLY"); + _oppClient.PushProgress -= EventHandlerPushProgress; + }; + _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushProgress, "[TestCase][PushProgressEventArgs][File_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -142,7 +93,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(); } @@ -153,7 +104,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Size, check if Size has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushProgressEventArgs.Size A")] @@ -161,28 +112,46 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Size_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Size_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushProgress = null; + + EventHandlerPushProgress = (sender, e) => { + _oppClient.PushProgress -= EventHandlerPushProgress; + 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"); + }; + _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushProgress, "[TestCase][PushProgressEventArgs][Size_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -195,7 +164,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(); } @@ -206,7 +175,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test Percent, check if Percent has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushProgressEventArgs.Percent A")] @@ -214,28 +183,46 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Percent_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Percent_PushProgressEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushProgress = null; + + EventHandlerPushProgress = (sender, e) => { + _oppClient.PushProgress -= EventHandlerPushProgress; + 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"); + }; + _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushProgress, "[TestCase][PushProgressEventArgs][Percent_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -248,7 +235,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(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushRespondedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushRespondedEventArgs.cs index eb9b934bd..41acf0860 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushRespondedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSPushRespondedEventArgs.cs @@ -4,7 +4,8 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using BluetoothNetworkUtils; using Tizen.System; -using Xamarin.Forms; +using System.IO; +using Tizen.Applications; namespace Tizen.Network.Bluetooth.Tests { @@ -12,12 +13,9 @@ namespace Tizen.Network.Bluetooth.Tests [Description("PushRespondedEventArgs Tests")] public class PushRespondedEventArgsTests { - static bool _flagDiscovery = false; - static bool _flagPushResponded = false; - static bool _flagCancelPush = false; static BluetoothDevice _device = null; static BluetoothOppClient _oppClient = null; - const string filePath = "/opt/usr/home/owner/share/image1.jpg"; + private static string filePath = Path.Combine(Application.Current.DirectoryInfo.SharedResource, "test1.jpg"); public static string _remoteAddress = PreconditionUtils.GetBleAddress(); static bool isBluetoothOppSupported = false; @@ -34,82 +32,7 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - public static async Task DiscoverySetup() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Setup DiscoverySetup"); - BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryChanged; - BluetoothAdapter.StartDiscovery(); - await WaitForDiscoveryflag(); - BluetoothAdapter.StopDiscovery(); - await Task.Delay(8000); - BluetoothAdapter.DiscoveryStateChanged -= EventHandlerDiscoveryChanged; - } - - public static async Task WaitForDiscoveryflag() - { - int count = 0; - while (true) - { - await Task.Delay(1000); - count++; - if (_flagDiscovery) - break; - if (count == 8) - break; - } - } - - public static void EventHandlerDiscoveryChanged(object sender, DiscoveryStateChangedEventArgs e) - { - if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found && e.DeviceFound.Address.Equals(_remoteAddress)) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerDiscoveryChanged"); - _device = e.DeviceFound; - _oppClient = _device.GetProfile(); - _flagDiscovery = true; - } - } - - public static void EventHandlerPushProgress(object sender, PushProgressEventArgs e) - { - if (e.Size > 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushProgress"); - if (_flagCancelPush) - { - try - { - _oppClient.CancelPush(); - ManualTest.Confirm(); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][PushRespondedEventArgs][EventHandlerPushProgress] FAIL " + ex.Message); - } - } - } - } - - public static void EventHandlerPushFinished(object sender, PushFinishedEventArgs e) - { - int _result = e.Result; - if (_result == 0) - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushFinished"); - ManualTest.Confirm(); - } - } - - public static void EventHandlerPushResponded(object sender, PushRespondedEventArgs e) - { - if (e.Address != null && e.Result == 0) - { - _flagPushResponded = true; - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "EventHandlerPushResponded"); - } - } - - //[Test] + [Test] [Category("P1")] [Description("Test Address, check if Address has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushRespondedEventArgs.Address A")] @@ -117,28 +40,47 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Address_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushResponsed = null; + + EventHandlerPushResponsed = (sender, e) => { + _oppClient.PushResponded -= EventHandlerPushResponsed; + Assert.IsNotNull(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + Assert.True(String.Equals(e.Address, _device.Address), "[TestCase][Address_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("Address_PROPERTY_READ_ONLY"); + }; + + _oppClient.PushResponded += EventHandlerPushResponsed; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][PushRespondedEventArgs][Address_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -151,7 +93,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -162,36 +104,53 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] - [Description("Test Address, check if Address has proper value")] + [Description("Test Result, check if Result has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.PushRespondedEventArgs.Result A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Sandeep H, h.sandeep@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Create, copy and put an image file (image1.jpg) in location /opt/usr/home/owner/share/")] - [Precondition(3, "Keep Bluetooth settings open on Server device, which makes it visible")] + [Precondition(2, "Paired with the remote OPP server device")] [Step(1, "Tap the Run button")] [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "If testcase is working properly, TCT is passed automatically. Otherwise, please press fail button")] [Postcondition(1, "NA")] public static async Task Result_PROPERTY_READ_ONLY() { try { - //TEST CODE - await DiscoverySetup(); - _oppClient.PushResponded += EventHandlerPushResponded; - _oppClient.PushProgress += EventHandlerPushProgress; - _oppClient.PushFinished += EventHandlerPushFinished; + /* We can't occupy the precondition, if OPP feature is not supported in Manual TC */ + if (isBluetoothOppSupported == false) + { + BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + _oppClient = BluetoothSetup.GetBluetoothOppClientUtil(); + + Assert.IsNotNull(_oppClient, "_oppClient shold not be null"); + + _device = BluetoothSetup.GetPairedDevice(); + + EventHandler EventHandlerPushResponsed = null; + + EventHandlerPushResponsed = (sender, e) => { + _oppClient.PushResponded -= EventHandlerPushResponsed; + Assert.IsTrue((int)e.Result == 0, "[TestCase][Result_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("Result_PROPERTY_READ_ONLY"); + }; + + _oppClient.PushResponded += EventHandlerPushResponsed; + _oppClient.AddFile(filePath); + _oppClient.PushFile(_device.Address); + + _oppClient.ClearFiles(); + await ManualTest.WaitForConfirm(); - _oppClient.PushResponded -= EventHandlerPushResponded; - _oppClient.PushProgress -= EventHandlerPushProgress; - _oppClient.PushFinished -= EventHandlerPushFinished; - Assert.IsTrue(_flagPushResponded, "[TestCase][PushRespondedEventArgs][Result_PROPERTY_READ_ONLY] Failed"); } catch (NotSupportedException) { @@ -204,7 +163,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(); } -- 2.34.1