[Bluetooth][TCSACR-301] Add SendData(byte) TC 10/225310/4
authorWootak Jung <wootak.jung@samsung.com>
Wed, 19 Feb 2020 04:16:31 +0000 (13:16 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 2 Mar 2020 07:29:40 +0000 (16:29 +0900)
Change-Id: I910e84daeac4deaac7310eabadbe9f4d0b211c4b

tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index a52a38b..aaa294d
@@ -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")]
old mode 100755 (executable)
new mode 100644 (file)
index 1aa4a00..18454a2
@@ -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<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)
             {
@@ -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<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")]
@@ -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<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();
@@ -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();
                 }
             }