[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
+ [Property("COVPARAM", "string")]
[Precondition(1, "Turn on the bluetooth")]
[Precondition(2, "Run this only on server device")]
[Precondition(3, "Test device(server) should be paired only with client device")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "MR")]
[Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
+ [Property("COVPARAM", "byte[]")]
+ [Precondition(1, "Turn on the bluetooth")]
+ [Precondition(2, "Run this only on server device")]
+ [Precondition(3, "Test device(server) should be paired only with client device")]
+ [Step(1, "Tap the Run button in server device")]
+ [Step(2, "Run IBluetoothServerSocketTests.DataReceived_CLIENT_EVENT in the client device immediately")]
+ public async Task SendData_SEND_DATA_BYTE_TEST_SERVER()
+ {
+ try
+ {
+ int writtenLength;
+ byte[] sendData = { 0xAB, 0xCD, 0xEF };
+
+ /* We can't occupy the precondition, if BT feature is not supported in Manual TC */
+ if (_isBluetoothSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ BluetoothSetup.CreateServerSocketUtil();
+ await BluetoothSetup.AcceptSocketUtil();
+ await Task.Delay(2000);
+ writtenLength = BluetoothSetup.Socket.SendData(sendData);
+ Assert.AreEqual(writtenLength, sendData.Length);
+ }
+ catch (NotSupportedException)
+ {
+ if (_isBluetoothSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ finally
+ {
+ BluetoothSetup.DestroyServerSocketUtil();
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sends data to the connected device")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
+ [Property("COVPARAM", "string")]
[Precondition(1, "Turn on the bluetooth")]
[Precondition(2, "Run this only on client device")]
[Precondition(3, "Test device(client) should be paired only with server device")]
using NUnit.Framework;
using NUnit.Framework.TUnit;
using Tizen.System;
+using System.Linq;
using Xamarin.Forms;
namespace Tizen.Network.Bluetooth.Tests
{
private bool _flagDataReceived = false;
private bool _isBluetoothSupported = false;
+ private static bool _isPassed = false;
[SetUp]
public void Init()
}
}
- [Test]
- [Category("P1")]
- [Description("Test SocketFd. Check whether SocketFd is readable and writable")]
- [Property("SPEC", "Tizen.Network.Bluetooth.SocketData.SocketFd A")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "PRO")]
- [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
- [Precondition(1, "Turn on the bluetooth")]
- [Precondition(2, "Run this only on client device")]
- [Precondition(3, "Test device(client) should be paired only with server device")]
- [Precondition(4, "Should run this only after the TC IBluetoothServerSocketTests.SendData_SEND_DATA_TEST_SERVER is started in the server device")]
- [Step(1, "Tap the Run button in client device")]
- [Step(2, "When permission request popup appears, tap accept on server device.")]
- [Postcondition(1, "Unpair the server device")]
- public async Task SocketFd_READ_ONLY()
+ private async Task SocketDataTest()
{
try
{
+ if (_isPassed == true)
+ {
+ Log.Info(Globals.LogTag, "This operation already passed.");
+ return;
+ }
+
/* We can't occupy the precondition, if BT feature is not supported in Manual TC */
if (_isBluetoothSupported == false)
{
await BluetoothSetup.ConnectSocketUtil();
BluetoothSetup.Client.DataReceived += DataReceivedClientEventHandler;
await WaitClientDataReceivedFlag();
+
+ /* Verify SocketFd */
Assert.IsInstanceOf<int>(BluetoothSetup.Data.SocketFd, "SocketFd is not valid");
Assert.AreEqual(BluetoothSetup.ClientConnection.SocketFd, BluetoothSetup.Data.SocketFd, "Connected SocketFd and data received SocketFd are not same");
- BluetoothHelper.DisplayPassLabel("SocketFd_READ_ONLY");
- await ManualTest.WaitForConfirm();
+ /* Verify DataSize */
+ Assert.IsInstanceOf<int>(BluetoothSetup.Data.DataSize, "DataSize is not valid");
+ Assert.AreEqual(BluetoothSetup.dataFromServer.Length, BluetoothSetup.Data.DataSize, "DataSize is not same as sent from the server");
+
+ /* Verify Data */
+ Assert.IsNotNull(BluetoothSetup.Data.Data, "Received data should not be null");
+ Assert.IsInstanceOf<string>(BluetoothSetup.Data.Data, "Received Data is not valid");
+ Assert.AreEqual(BluetoothSetup.dataFromServer, BluetoothSetup.Data.Data, "Received data is not same as sent from the server");
BluetoothSetup.Client.DataReceived -= DataReceivedClientEventHandler;
await BluetoothSetup.DisconnectSocketUtil();
+
+ _isPassed = true;
}
catch (NotSupportedException)
{
[Test]
[Category("P1")]
- [Description("Test DataSize. Check whether DataSize is readable and writable")]
+ [Description("Test SocketFd. Check whether SocketFd is readable")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.SocketData.SocketFd A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
+ [Precondition(1, "Turn on the bluetooth")]
+ [Precondition(2, "Run this only on client device")]
+ [Precondition(3, "Test device(client) should be paired only with server device")]
+ [Precondition(4, "Should run this only after the TC IBluetoothServerSocketTests.SendData_SEND_DATA_TEST_SERVER is started in the server device")]
+ [Step(1, "Tap the Run button in client device")]
+ [Step(2, "When permission request popup appears, tap accept on server device.")]
+ [Postcondition(1, "Unpair the server device")]
+ public async Task SocketFd_READ_ONLY()
+ {
+ await SocketDataTest();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test DataSize. Check whether DataSize is readable")]
[Property("SPEC", "Tizen.Network.Bluetooth.SocketData.DataSize A")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "PRO")]
[Postcondition(1, "Unpair the server device")]
public async Task DataSize_READ_ONLY()
{
- try
- {
- /* We can't occupy the precondition, if BT feature is not supported in Manual TC */
- if (_isBluetoothSupported == false)
- {
- BluetoothHelper.DisplayLabel("DataSize_READ_ONLY");
- await ManualTest.WaitForConfirm();
- return;
- }
-
- BluetoothSetup.CreateClientSocketUtil();
- if (BluetoothSetup.Client == null)
- {
- ManualTest.DisplayCustomLabel("Precondition failed: Test device should be paired to the remote device.");
- await ManualTest.WaitForConfirm();
- return;
- }
-
- await BluetoothSetup.ConnectSocketUtil();
- BluetoothSetup.Client.DataReceived += DataReceivedClientEventHandler;
- await WaitClientDataReceivedFlag();
- Assert.IsInstanceOf<int>(BluetoothSetup.Data.DataSize, "DataSize is not valid");
-
- BluetoothHelper.DisplayPassLabel("DataSize_READ_ONLY");
- await ManualTest.WaitForConfirm();
-
- BluetoothSetup.Client.DataReceived -= DataReceivedClientEventHandler;
- await BluetoothSetup.DisconnectSocketUtil();
- }
- catch (NotSupportedException)
- {
- if (_isBluetoothSupported == false)
- {
- BluetoothHelper.DisplayLabel("DataSize_READ_ONLY");
- await ManualTest.WaitForConfirm();
- }
- }
- catch (TypeInitializationException e)
- {
- if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
- BluetoothHelper.DisplayLabel("DataSize_READ_ONLY");
- await ManualTest.WaitForConfirm();
- }
- }
- catch (Exception ex)
- {
- Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
- }
+ await SocketDataTest();
}
[Test]
[Category("P1")]
- [Description("Test Data. Check whether Data is readable and writable")]
+ [Description("Test Data. Check whether Data is readable")]
[Property("SPEC", "Tizen.Network.Bluetooth.SocketData.Data A")]
[Property("SPEC_URL", "-")]
[Property("CRITERIA", "PRO")]
[Postcondition(1, "Unpair the server device")]
public async Task Data_READ_ONLY()
{
+ await SocketDataTest();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test Data. Check whether ByteData is readable")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.SocketData.ByteData A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
+ [Precondition(1, "Turn on the bluetooth")]
+ [Precondition(2, "Run this only on client device")]
+ [Precondition(3, "Test device(client) should be paired only with server device")]
+ [Precondition(4, "Should run this only after the TC IBluetoothServerSocketTests.SendData_SEND_DATA_BYTE_TEST_SERVER is started in the server device")]
+ [Step(1, "Tap the Run button in client device")]
+ [Step(2, "When permission request popup appears, tap accept on server device.")]
+ [Postcondition(1, "Unpair the server device")]
+ public async Task ByteData_READ_ONLY()
+ {
try
{
+ byte[] _sendData = { 0xAB, 0xCD, 0xEF };
+
/* We can't occupy the precondition, if BT feature is not supported in Manual TC */
if (_isBluetoothSupported == false)
{
- BluetoothHelper.DisplayLabel("Data_READ_ONLY");
+ BluetoothHelper.DisplayLabel("ByteData_READ_ONLY");
await ManualTest.WaitForConfirm();
return;
}
await BluetoothSetup.ConnectSocketUtil();
BluetoothSetup.Client.DataReceived += DataReceivedClientEventHandler;
await WaitClientDataReceivedFlag();
- Assert.IsNotNull(BluetoothSetup.Data.Data, "Received data should not be null");
- Assert.IsInstanceOf<string>(BluetoothSetup.Data.Data, "Received Data is not valid");
- Assert.AreEqual(BluetoothSetup.dataFromServer, BluetoothSetup.Data.Data, "Received data is not same as sent from the server");
+ Assert.IsNotNull(BluetoothSetup.Data.ByteData, "Received ByteData should not be null");
+ Assert.IsInstanceOf<byte[]>(BluetoothSetup.Data.ByteData, "Received ByteData is not valid");
+ Assert.True(_sendData.SequenceEqual(BluetoothSetup.Data.ByteData), "Received ByteData is NOT same as sent from the server.");
- BluetoothHelper.DisplayPassLabel("Data_READ_ONLY");
- await ManualTest.WaitForConfirm();
+ Log.Info(Globals.LogTag, "Received ByteData: " + string.Format("0X{0:X2} ", BluetoothSetup.Data.ByteData[0])
+ + string.Format("0X{0:X2} ", BluetoothSetup.Data.ByteData[1]) + string.Format("0X{0:X2} ", BluetoothSetup.Data.ByteData[2]));
BluetoothSetup.Client.DataReceived -= DataReceivedClientEventHandler;
await BluetoothSetup.DisconnectSocketUtil();
{
if (_isBluetoothSupported == false)
{
- BluetoothHelper.DisplayLabel("Data_READ_ONLY");
+ BluetoothHelper.DisplayLabel("ByteData_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
{
if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
- BluetoothHelper.DisplayLabel("Data_READ_ONLY");
+ BluetoothHelper.DisplayLabel("ByteData_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}