public static BluetoothAudio BtAudio = null;
public static BluetoothAvrcp BtAvrcp = null;
public static BluetoothHid BtHid = null;
+ public static BluetoothOppClient BtOppClient = null;
public static BluetoothServerSocket Server = null;
public static IBluetoothServerSocket Socket = null;
public static IBluetoothClientSocket Client = null;
StateChanged_flag = false;
role = "";
}
+
+ public static BluetoothOppClient GetBluetoothOppClientUtil()
+ {
+ if (BtOppClient != null)
+ return BtOppClient;
+
+ pairedDevice = BluetoothAdapter.GetBondedDevice(remote_addr);
+
+ if (pairedDevice != null)
+ {
+ BtOppClient = pairedDevice.GetProfile<BluetoothOppClient>();
+ }
+ else
+ {
+ LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "No matched paired device");
+ }
+
+ return BtOppClient;
+ }
+
+ public static BluetoothDevice GetPairedDevice()
+ {
+ return pairedDevice;
+ }
}
}
{
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 ()
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;
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;
}
using NUnit.Framework.TUnit;
using BluetoothNetworkUtils;
using Tizen.System;
-using Xamarin.Forms;
+using System.IO;
+using Tizen.Applications;
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]
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<BluetoothOppClient>();
- _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")]
[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<PushFinishedEventArgs> 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<InvalidOperationException>(() =>
- {
- _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();
}
}
{
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();
}
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test AddFile, check if AddFile method works properly")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.AddFile M")]
[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<PushFinishedEventArgs> 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<InvalidOperationException>(() =>
- {
- _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();
}
}
{
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();
}
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test ClearFiles, check if ClearFiles method works properly")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.ClearFiles M")]
[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<PushFinishedEventArgs> 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)
{
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test CancelPush, check if CancelPush method works properly")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.CancelPush M")]
[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<PushProgressEventArgs> 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<InvalidOperationException>(() =>
- {
- _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();
}
}
{
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();
}
}
}
}
- // [Test]
+ [Test]
[Category("P1")]
[Description("Test PushResponded, check if PushResponded event is proper")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushResponded E")]
[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<PushRespondedEventArgs> 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)
{
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test PushProgress, check if PushProgress event is proper")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushProgress E")]
[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<PushProgressEventArgs> 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)
{
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test PushFinished, check if PushFinished event is proper")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothOppClient.PushFinished E")]
[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<PushFinishedEventArgs> 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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("PushFinished_CHECK_EVENT");
await ManualTest.WaitForConfirm();
}
using NUnit.Framework.TUnit;
using BluetoothNetworkUtils;
using Tizen.System;
-using Xamarin.Forms;
+using System.IO;
+using Tizen.Applications;
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]
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<BluetoothOppClient>();
- _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")]
[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<PushFinishedEventArgs> EventHandlerPushFinished = null;
+
+ EventHandlerPushFinished = (sender, e) => {
+ _oppClient.PushFinished -= EventHandlerPushFinished;
+ Assert.IsNotNull(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed");
+ Assert.IsInstanceOf<string>(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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[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<PushFinishedEventArgs> 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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
using NUnit.Framework.TUnit;
using BluetoothNetworkUtils;
using Tizen.System;
-using Xamarin.Forms;
+using System.IO;
+using Tizen.Applications;
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;
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<BluetoothOppClient>();
- _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")]
[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<PushProgressEventArgs> EventHandlerPushProgress = null;
+
+ EventHandlerPushProgress = (sender, e) => {
+ Assert.IsNotNull(e.File, "[TestCase][File_PROPERTY_READ_ONLY] Failed");
+ Assert.IsInstanceOf<string>(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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("File_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test Size, check if Size has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.PushProgressEventArgs.Size A")]
[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<PushProgressEventArgs> EventHandlerPushProgress = null;
+
+ EventHandlerPushProgress = (sender, e) => {
+ _oppClient.PushProgress -= EventHandlerPushProgress;
+ Assert.IsInstanceOf<long>(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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Size_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Test Percent, check if Percent has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.PushProgressEventArgs.Percent A")]
[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<PushProgressEventArgs> EventHandlerPushProgress = null;
+
+ EventHandlerPushProgress = (sender, e) => {
+ _oppClient.PushProgress -= EventHandlerPushProgress;
+ Assert.IsInstanceOf<int>(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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Percent_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
using NUnit.Framework.TUnit;
using BluetoothNetworkUtils;
using Tizen.System;
-using Xamarin.Forms;
+using System.IO;
+using Tizen.Applications;
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;
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<BluetoothOppClient>();
- _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")]
[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<PushRespondedEventArgs> EventHandlerPushResponsed = null;
+
+ EventHandlerPushResponsed = (sender, e) => {
+ _oppClient.PushResponded -= EventHandlerPushResponsed;
+ Assert.IsNotNull(e.Address, "[TestCase][Address_PROPERTY_READ_ONLY] Failed");
+ Assert.IsInstanceOf<string>(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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Address_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[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<PushRespondedEventArgs> 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)
{
catch (TypeInitializationException e)
{
if (isBluetoothOppSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}