From: Wootak Jung Date: Wed, 19 Feb 2020 04:16:31 +0000 (+0900) Subject: [Bluetooth][TCSACR-301] Add SendData(byte) TC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2cedba8b27acbf8427dbc99794ddc63e6a914fe3;p=test%2Ftct%2Fcsharp%2Fapi.git [Bluetooth][TCSACR-301] Add SendData(byte) TC Change-Id: I910e84daeac4deaac7310eabadbe9f4d0b211c4b --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs old mode 100755 new mode 100644 index a52a38b..aaa294d --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs @@ -101,6 +101,7 @@ namespace Tizen.Network.Bluetooth.Tests [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")] @@ -159,6 +160,67 @@ namespace Tizen.Network.Bluetooth.Tests [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")] diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs old mode 100755 new mode 100644 index 1aa4a00..18454a2 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs @@ -4,6 +4,7 @@ using BluetoothNetworkUtils; using NUnit.Framework; using NUnit.Framework.TUnit; using Tizen.System; +using System.Linq; using Xamarin.Forms; namespace Tizen.Network.Bluetooth.Tests @@ -14,6 +15,7 @@ namespace Tizen.Network.Bluetooth.Tests { private bool _flagDataReceived = false; private bool _isBluetoothSupported = false; + private static bool _isPassed = false; [SetUp] public void Init() @@ -51,24 +53,16 @@ namespace Tizen.Network.Bluetooth.Tests } } - [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) { @@ -88,14 +82,24 @@ namespace Tizen.Network.Bluetooth.Tests await BluetoothSetup.ConnectSocketUtil(); BluetoothSetup.Client.DataReceived += DataReceivedClientEventHandler; await WaitClientDataReceivedFlag(); + + /* Verify SocketFd */ Assert.IsInstanceOf(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(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(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) { @@ -121,7 +125,26 @@ namespace Tizen.Network.Bluetooth.Tests [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")] @@ -135,60 +158,12 @@ namespace Tizen.Network.Bluetooth.Tests [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(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")] @@ -202,12 +177,33 @@ namespace Tizen.Network.Bluetooth.Tests [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; } @@ -223,12 +219,12 @@ namespace Tizen.Network.Bluetooth.Tests await BluetoothSetup.ConnectSocketUtil(); BluetoothSetup.Client.DataReceived += DataReceivedClientEventHandler; await WaitClientDataReceivedFlag(); - Assert.IsNotNull(BluetoothSetup.Data.Data, "Received data should not be null"); - Assert.IsInstanceOf(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(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(); @@ -237,7 +233,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (_isBluetoothSupported == false) { - BluetoothHelper.DisplayLabel("Data_READ_ONLY"); + BluetoothHelper.DisplayLabel("ByteData_READ_ONLY"); await ManualTest.WaitForConfirm(); } } @@ -245,7 +241,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("Data_READ_ONLY"); + BluetoothHelper.DisplayLabel("ByteData_READ_ONLY"); await ManualTest.WaitForConfirm(); } }