From: DoHyun Pyun Date: Fri, 15 Jan 2021 05:22:24 +0000 (+0900) Subject: [Bluetooth][Manual][Non-ACR] Make combine TC for Socket X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d30c285ddf9eeea8bf53241e8d90191b501876e;p=test%2Ftct%2Fcsharp%2Fapi.git [Bluetooth][Manual][Non-ACR] Make combine TC for Socket Change-Id: Ie8b35eeea015d61ac49eb2d0bd947175bf853b06 Signed-off-by: DoHyun Pyun --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAcceptStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAcceptStateChangedEventArgs.cs deleted file mode 100755 index 3b73cbe..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAcceptStateChangedEventArgs.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System; -using System.Threading.Tasks; -using Xamarin.Forms; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using BluetoothNetworkUtils; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("AcceptStateChangedEventArgs Tests")] - public class AcceptStateChangedEventArgsTests - { - static bool isBluetoothSupported = false; - - [SetUp] - public static void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported); - } - [TearDown] - public static void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.DestroyServerSocketUtil(); - } - - [Test] - [Category("P1")] - [Description("Test Connection property of AcceptStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Connection 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 test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - public static async Task Connection_READ_ONLY() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - //TEST CODE - await BluetoothSetup.AcceptSocketUtil(); - Assert.IsNotNull(BluetoothSetup.AcceptConnection, "[TestCase][Connection_READ_ONLY][Socket] Fail"); - - BluetoothSetup.AcceptConnection = null; - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Connection_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Connection_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test Result property of AcceptStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Result 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 test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - public static async Task Result_READ_ONLY() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - //TEST CODE - await BluetoothSetup.AcceptSocketUtil(); - if (BluetoothSetup.AcceptResult != BluetoothError.None) - { - Assert.Fail("[TestCase][Result_READ_ONLY][Socket] Fail"); - } - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test State property of AcceptStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.State 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 test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - [Postcondition(1, "Unpair the client device")] - public static async Task State_READ_ONLY() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - //TEST CODE - await BluetoothSetup.AcceptSocketUtil(); - if (BluetoothSocketState.Connected != BluetoothSetup.AcceptState) - { - Assert.Fail("[TestCase][State_READ_ONLY][Socket] Fail"); - } - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("State_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("State_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test Server property of AcceptStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Server 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 test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - [Postcondition(1, "Unpair the client device")] - public static async Task Server_READ_ONLY() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - //TEST CODE - await BluetoothSetup.AcceptSocketUtil(); - Assert.IsNotNull(BluetoothSetup.Server, "[TestCase][Server_READ_ONLY][Socket] Fail"); - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine10_SocketClient.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine10_SocketClient.cs new file mode 100644 index 0000000..cea6564 --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine10_SocketClient.cs @@ -0,0 +1,728 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using BluetoothNetworkUtils; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.System; +using Xamarin.Forms; + +namespace Tizen.Network.Bluetooth.Tests +{ + [TestFixture] + [Description("BluetoothClientSocket Tests")] + public class BluetoothClientSocketTests + { + static bool flagDiscovery = false; + static bool flagBondCreated = false; + static bool flagConnected = false; + static BluetoothDevice bondedDevice = null; + static BluetoothDevice foundDevice = null; + static bool isBluetoothSupported = false; + static string remoteAddress = PreconditionUtils.GetBtAddress(); + + /* PASS flag Variaibles for TCs */ + static bool pass_Connect_SOCKET_CONNECTION_TEST = false; + static bool pass_SocketFd_SocketConnection_READ_ONLY = false; + static bool pass_Address_SocketConnection_READ_ONLY = false; + static bool pass_ServiceUuid_SocketConnection_READ_ONLY = false; + static bool pass_Client_SocketConnection_READ_ONLY = false; + static bool pass_Connection_SocketConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_Result_SocketConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_State_SocketConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT = false; + static bool pass_SocketFd_SocketData_READ_ONLY = false; + static bool pass_DataSize_SocketData_READ_ONLY = false; + static bool pass_Data_SocketData_READ_ONLY = false; + static bool pass_ByteData_SocketData_READ_ONLY = false; + static bool pass_Disconnect_SOCKET_DISCONNECTION_TEST = false; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for IBluetoothClientSocket TEST"); + Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + } + + public static async Task WaitForBondflag() + { + int count = 0; + while(true) + { + await Task.Delay(200); + count++; + if (flagBondCreated) + break; + if (count == 100) + break; + } + } + + public static async Task WaitForDiscoveryflag() + { + int count = 0; + while(true) + { + await Task.Delay(200); + count++; + if (flagDiscovery) + break; + if (count == 40) + break; + } + } + + public static async Task WaitConnectedFlag() + { + int count = 0; + while (true) + { + await Task.Delay(1000); + count++; + if (flagConnected) + break; + if (count == 10) + break; + } + } + + public static void BondingSetupBondCreated(object sender, BondCreatedEventArgs e) + { + if (e.Device != null && e.Result == 0) + { + flagBondCreated = true; + bondedDevice = e.Device; + } + } + + public static void EventHandlerDiscoveryChanged(object sender, DiscoveryStateChangedEventArgs e) + { + if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found) + { + if (flagDiscovery == true) + return; + + if (e.DeviceFound.Address.Equals(remoteAddress)) + { + foundDevice = e.DeviceFound; + + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Found the matching device: " + foundDevice.Address); + flagDiscovery = true; + } + } + } + + public static async Task DiscoverySetup() + { + BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryChanged; + + if (BluetoothAdapter.IsDiscoveryInProgress) + { + BluetoothAdapter.StopDiscovery(); + await Task.Delay(1000); + } + + BluetoothAdapter.StartDiscovery(); + await WaitForDiscoveryflag(); + + if (BluetoothAdapter.IsDiscoveryInProgress) + { + BluetoothAdapter.StopDiscovery(); + await Task.Delay(1000); + } + BluetoothAdapter.DiscoveryStateChanged -= EventHandlerDiscoveryChanged; + } + + public static async Task BondingSetup() + { + foundDevice.BondCreated += BondingSetupBondCreated; + foundDevice.CreateBond(); + await WaitForBondflag(); + + foundDevice.BondCreated -= BondingSetupBondCreated; + } + + public async Task SocketClientCombine_TEST() + { + IBluetoothClientSocket socketClient = null; + IBluetoothServerSocket socketInterface = null; + + try + { + bondedDevice = BluetoothAdapter.GetBondedDevice(remoteAddress); + } + catch (Exception ex) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Device is not bonded : " + ex.ToString()); + } + + try + { + string serviceUuid = "00001101-0000-1000-8000-00805F9B7777"; + string dataFromServer = "Test from server"; + byte[] byteDataFromServer = { 0xAB, 0xCD, 0xEF }; + byte[] byteDataToServer = { 0xAB, 0xCD, 0xEF }; + int connection_fd = 0; + int writtenLength = 0; + + /* Prepare the destroy bond procedure */ + if (bondedDevice == null) + { + await DiscoverySetup(); + Assert.IsNotNull (foundDevice, "found device should not be null"); + + await BondingSetup(); + flagBondCreated = false; + + /* Wait for ACL disconnect */ + await Task.Delay(6000); + } + + Assert.IsNotNull(bondedDevice, "bondedDevice should not be null"); + + socketClient = bondedDevice.CreateSocket(serviceUuid); + Assert.IsNotNull(socketClient, "socketClient should not be null"); + + EventHandler EventHandlerConnectionStateChanged = null; + + EventHandlerConnectionStateChanged = (sender, e) => { + Log.Info(Globals.LogTag, "ConnectionStateChanged invoked!! Result: " + e.Result + ", State: " + e.State); + + socketClient.ConnectionStateChanged -= EventHandlerConnectionStateChanged; + + /* PASS condition for Result_SocketConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Result, "Result is not type of int"); + Assert.AreEqual(e.Result, BluetoothError.None, "Result is not Error.None"); + pass_Result_SocketConnectionStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for State_SocketConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.State, "State is not type of BluetoothSocketState"); + Assert.AreEqual(e.State, BluetoothSocketState.Connected, "State is not Connected"); + pass_State_SocketConnectionStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for Connection_SocketConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.Connection, "Connection is null"); + Assert.IsInstanceOf(e.Connection, "Connection is not type of SocketConnection"); + pass_Connection_SocketConnectionStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for SocketFd_SocketConnection_READ_ONLY */ + Assert.IsInstanceOf(e.Connection.SocketFd, "Connection.SocketFd is not proper"); + pass_SocketFd_SocketConnection_READ_ONLY = true; + + /* PASS condition for Address_SocketConnection_READ_ONLY */ + Assert.IsNotNull(e.Connection.Address, "Connection.Address is null"); + Assert.IsInstanceOf(e.Connection.Address, "Connection.Address is not proper"); + pass_Address_SocketConnection_READ_ONLY = true; + + /* PASS condition for ServiceUuid_SocketConnection_READ_ONLY */ + Assert.IsNotNull(e.Connection.ServiceUuid, "Connection.ServiceUuid is null"); + Assert.IsInstanceOf(e.Connection.ServiceUuid, "Connection.ServiceUuid is not proper"); + pass_ServiceUuid_SocketConnection_READ_ONLY = true; + + /* PASS condition for Client_SocketConnection_READ_ONLY */ + Assert.IsNotNull(e.Connection.Client, "Connection.Client is null"); + Assert.IsInstanceOf(e.Connection.Client, "Connection.Client is not proper"); + pass_Client_SocketConnection_READ_ONLY = true; + + socketInterface = e.Connection.Client; + connection_fd = e.Connection.SocketFd; + flagConnected = true; + }; + + socketClient.ConnectionStateChanged += EventHandlerConnectionStateChanged; + + /* PASS condition for Connect_SOCKET_CONNECTION_TEST */ + socketClient.Connect(); + + await WaitConnectedFlag(); + + Assert.IsTrue(flagConnected, "Socket was not connected "); + Assert.IsNotNull(socketInterface, "socketInterface is null"); + pass_Connect_SOCKET_CONNECTION_TEST = true; + + writtenLength = socketInterface.SendData(byteDataToServer); + + /* Wait for process data */ + await Task.Delay(1000); + + EventHandler EventHandlerDataReceived = null; + + EventHandlerDataReceived = (sender, e) => { + /* PASS condition for Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT */ + Assert.IsNotNull(e.Data, "Received data should not be null"); + Assert.IsInstanceOf(e.Data, "SocketData is not valid"); + pass_Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT = true; + + /* PASS condition for SocketFd_SocketData_READ_ONLY */ + Assert.IsInstanceOf(e.Data.SocketFd, "Data.SocketFd is not valid"); + Assert.AreEqual(connection_fd, e.Data.SocketFd, "Connected SocketFd and data received SocketFd are not same"); + pass_SocketFd_SocketData_READ_ONLY = true; + + /* PASS condition for DataSize_SocketData_READ_ONLY */ + Assert.IsInstanceOf(e.Data.DataSize, "DataSize is not valid"); + pass_DataSize_SocketData_READ_ONLY = true; + + /* PASS condition for Data_SocketData_READ_ONLY */ + if (e.Data.Data != null) + { + Assert.IsInstanceOf(e.Data.Data, "Received Data is not valid"); + pass_Data_SocketData_READ_ONLY = true; + + BluetoothHelper.DisplayCustomLabel("Data is received from Socket Server"); + } + + /* PASS condition for ByteData_SocketData_READ_ONLY */ + if (e.Data.ByteData != null) + { + Assert.IsInstanceOf(e.Data.ByteData, "Received ByteData is not valid"); + pass_ByteData_SocketData_READ_ONLY = true; + + Log.Info(Globals.LogTag, "Received ByteData: " + string.Format("0X{0:X2} ", e.Data.ByteData[0]) + + string.Format("0X{0:X2} ", e.Data.ByteData[1]) + string.Format("0X{0:X2} ", e.Data.ByteData[2])); + + BluetoothHelper.DisplayCustomLabel("ByteData is received from Socket Server"); + } + + if (pass_Data_SocketData_READ_ONLY == true && + pass_ByteData_SocketData_READ_ONLY == true) + { + socketInterface.DataReceived -= EventHandlerDataReceived; + + try + { + /* PASS condition for pass_Disconnect_SOCKET_DISCONNECTION_TEST */ + socketClient.Disconnect(); + pass_Disconnect_SOCKET_DISCONNECTION_TEST = true; + + BluetoothHelper.DisplayPassLabel("SocketClientCombine_TEST"); + } + catch (Exception ex) + { + Assert.Fail("[TestCase][OppClientCombine_TEST][CancelPush] FAIL " + ex.Message); + } + } + }; + + socketInterface.DataReceived += EventHandlerDataReceived; + + await ManualTest.WaitForConfirm(); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Connects to a remote device, establishing socket connection and acts as a client.")] + [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Connect M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Connect_SOCKET_CONNECTION_TEST() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Connect_SOCKET_CONNECTION_TEST == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Connect_SOCKET_CONNECTION_TEST, "[TestCase][Connect_SOCKET_CONNECTION_TEST] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Result property of SocketConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.Result 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Result_SocketConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Result_SocketConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Result_SocketConnectionStateChangedEventArgs_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Result_SocketConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][Result_SocketConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test State property of SocketConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.State 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task State_SocketConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("State_SocketConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_State_SocketConnectionStateChangedEventArgs_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_State_SocketConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][State_SocketConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Connection property of SocketConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.Connection 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Connection_SocketConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Connection_SocketConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Connection_SocketConnectionStateChangedEventArgs_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Connection_SocketConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][Connection_SocketConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test SocketFd. Check whether SocketFd is readable")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task SocketFd_SocketConnection_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("SocketFd_SocketConnection_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_SocketFd_SocketConnection_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_SocketFd_SocketConnection_READ_ONLY, "[TestCase][SocketFd_SocketConnection_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Address. Check whether Address is readable and writable")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.Address 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Address_SocketConnection_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Address_SocketConnection_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Address_SocketConnection_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Address_SocketConnection_READ_ONLY, "[TestCase][Address_SocketConnection_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ServiceUuid. Check whether ServiceUuid is readable and writable")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.ServiceUuid 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task ServiceUuid_SocketConnection_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("ServiceUuid_SocketConnection_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ServiceUuid_SocketConnection_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_ServiceUuid_SocketConnection_READ_ONLY, "[TestCase][ServiceUuid_SocketConnection_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Client. Check whether Client is valid")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.Client 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 test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Client_SocketConnection_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Client_SocketConnection_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Client_SocketConnection_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Client_SocketConnection_READ_ONLY, "[TestCase][Client_SocketConnection_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Data property of SocketDataReceivedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketDataReceivedEventArgs.Data 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.")] + public async Task Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT, "[TestCase][Data_SocketDataReceivedEventArgs_READ_ONLY_CLIENT] Fail"); + } + + [Test] + [Category("P1")] + [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.")] + public async Task SocketFd_SocketData_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("SocketFd_SocketData_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_SocketFd_SocketData_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_SocketFd_SocketData_READ_ONLY, "[TestCase][SocketFd_SocketData_READ_ONLY] Fail"); + } + + [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")] + [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.")] + public async Task DataSize_SocketData_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("DataSize_SocketData_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_DataSize_SocketData_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_DataSize_SocketData_READ_ONLY, "[TestCase][DataSize_SocketData_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Data. Check whether Data is readable")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketData.Data 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.")] + public async Task Data_SocketData_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Data_SocketData_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Data_SocketData_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Data_SocketData_READ_ONLY, "[TestCase][Data_SocketData_READ_ONLY] Fail"); + } + + [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.")] + public async Task ByteData_SocketData_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("ByteData_SocketData_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ByteData_SocketData_READ_ONLY == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_ByteData_SocketData_READ_ONLY, "[TestCase][ByteData_SocketData_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Disconnects the socket connection.")] + [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Disconnect M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task Disconnect_SOCKET_DISCONNECTION_TEST() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Disconnect_SOCKET_DISCONNECTION_TEST == false) + await SocketClientCombine_TEST(); + + Assert.True(pass_Disconnect_SOCKET_DISCONNECTION_TEST, "[TestCase][Disconnect_SOCKET_DISCONNECTION_TEST] Fail"); + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine11_SocketServer.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine11_SocketServer.cs new file mode 100644 index 0000000..d68b2a3 --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine11_SocketServer.cs @@ -0,0 +1,585 @@ +using System; +using System.Threading.Tasks; +using BluetoothNetworkUtils; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.System; +using Xamarin.Forms; + +namespace Tizen.Network.Bluetooth.Tests +{ + [TestFixture] + [Description("BluetoothServerSocket Tests")] + public class BluetoothServerSocketTests + { + static bool flagAccept =false; + static bool flagServerDataReceived = false; + static bool isBluetoothSupported = false; + + /* PASS flag Variaibles for TCs */ + static bool pass_Listen_ACCEPT_CLIENT_CONNECTION_TEST = false; + static bool pass_AcceptStateChanged_EVENT = false; + static bool pass_Connection_AcceptStateChangedEventArgs_READ_ONLY = false; + static bool pass_Result_AcceptStateChangedEventArgs_READ_ONLY = false; + static bool pass_State_AcceptStateChangedEventArgs_READ_ONLY = false; + static bool pass_Server_AcceptStateChangedEventArgs_READ_ONLY = false; + static bool pass_ConnectionStateChanged_EVENT = false; + static bool pass_SendData_SEND_DATA_TEST_SERVER = false; + static bool pass_SendData_SEND_DATA_BYTE_TEST_SERVER = false; + static bool pass_SendData_CHECK_EXCEPTION = false; + static bool pass_DataReceived_SERVER_EVENT = false; + static bool pass_Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER = false; + static bool pass_Dispose_CHECK_NO_EXCEPTION = false; + + [SetUp] + public static void Init() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for BluetoothServerSocket TEST"); + Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported); + } + + [TearDown] + public static void Destroy() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + BluetoothSetup.DestroyServerSocketUtil(); + } + + public static async Task WaitAcceptFlag() + { + int count = 0; + while (true) + { + await Task.Delay(1000); + count++; + if (flagAccept) + break; + if (count == 30) + break; + } + } + + public async Task WaitServerDataReceivedFlag() + { + int count = 0; + while(true) + { + await Task.Delay(1000); + count++; + if (flagServerDataReceived) + break; + if (count == 30) + break; + } + } + + public async Task SocketServerCombine_TEST() + { + BluetoothServerSocket socketServer = null; + IBluetoothServerSocket socketInterface = null; + + try + { + int writtenLength = 0; + string serviceUuid = "00001101-0000-1000-8000-00805F9B7777"; + string dataFromServer = "Test from server"; + byte[] sendData = { 0xAB, 0xCD, 0xEF }; + byte[] sendNullData = null; + + socketServer = BluetoothAdapter.CreateServerSocket(serviceUuid); + Assert.IsNotNull(socketServer, "socketServer should not be null"); + + EventHandler EventHandlerConnectionStateChanged = null; + + EventHandlerConnectionStateChanged = (sender, e) => { + socketInterface.ConnectionStateChanged -= EventHandlerConnectionStateChanged; + + /* PASS condition for ConnectionStateChanged_EVENT */ + Assert.IsInstanceOf(e.Result, "Result is not type of int"); + Assert.AreEqual(e.Result, BluetoothError.None, "Result is not Error.None"); + + Assert.IsInstanceOf(e.State, "State is not type of BluetoothSocketState"); + pass_ConnectionStateChanged_EVENT = true; + + Log.Info(Globals.LogTag, "ConnectionStateChanged invoked!! Result: " + e.Result + ", State: " + e.State); + }; + + EventHandler EventHandlerDataReceived = null; + + EventHandlerDataReceived = (sender, e) => { + Log.Info(Globals.LogTag, "EventHandlerDataReceived invoked!!"); + + socketInterface.DataReceived -= EventHandlerDataReceived; + + /* PASS condition for DataReceived_SERVER_EVENT */ + pass_DataReceived_SERVER_EVENT = true; + + /* PASS condition for Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER */ + Assert.IsNotNull(e.Data, "Received data should not be null"); + Assert.IsInstanceOf(e.Data, "SocketData is not valid"); + pass_Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER = true; + + flagServerDataReceived = true; + + BluetoothHelper.DisplayCustomLabel("Data is received from Socket Client"); + }; + + EventHandler EventHandlerAcceptStateChanged = null; + + EventHandlerAcceptStateChanged = (sender, e) => { + socketServer.AcceptStateChanged -= EventHandlerAcceptStateChanged; + + Log.Info(Globals.LogTag, "AcceptStateChangedCallback invoked!! Result: " + e.Result + ", State: " + e.State); + + /* PASS condition for pass_AcceptStateChanged_EVENT */ + pass_AcceptStateChanged_EVENT = true; + + /* PASS condition for Result_AcceptStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Result, "Result is not type of int"); + Assert.AreEqual(e.Result, BluetoothError.None, "Result is not Error.None"); + pass_Result_AcceptStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for State_AcceptStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.State, "State is not type of BluetoothSocketState"); + Assert.AreEqual(e.State, BluetoothSocketState.Connected, "State is not Connected"); + pass_State_AcceptStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for Connection_AcceptStateChangedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.Connection, "Connection is null"); + Assert.IsInstanceOf(e.Connection, "Connection is not type of SocketConnection"); + pass_Connection_AcceptStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for Server_AcceptStateChangedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.Server, "Server is null"); + Assert.IsInstanceOf(e.Server, "Server is not type of IBluetoothServerSocket"); + pass_Server_AcceptStateChangedEventArgs_READ_ONLY = true; + + socketInterface = e.Connection.Client; + + socketInterface.ConnectionStateChanged += EventHandlerConnectionStateChanged; + socketInterface.DataReceived += EventHandlerDataReceived; + + flagAccept = true; + }; + + /* PASS condition for Listen_ACCEPT_CLIENT_CONNECTION_TEST */ + socketServer.AcceptStateChanged += EventHandlerAcceptStateChanged; + socketServer.Listen(); + pass_Listen_ACCEPT_CLIENT_CONNECTION_TEST = true; + + await WaitAcceptFlag(); + Assert.IsNotNull(socketInterface, "socketInterface should not be null"); + + await WaitServerDataReceivedFlag(); + + await Task.Delay(1000); + + /* PASS condition for SendData_SEND_DATA_TEST_SERVER */ + writtenLength = socketInterface.SendData(dataFromServer); + Assert.AreEqual(writtenLength, dataFromServer.Length); + pass_SendData_SEND_DATA_TEST_SERVER = true; + + /* PASS condition for SendData_SEND_DATA_BYTE_TEST_SERVER */ + writtenLength = socketInterface.SendData(sendData); + Assert.AreEqual(writtenLength, sendData.Length); + pass_SendData_SEND_DATA_BYTE_TEST_SERVER = true; + + /* PASS condition for SendData_CHECK_EXCEPTION */ + Assert.Throws(() => + { + writtenLength = socketInterface.SendData(sendNullData); + }, "SendData should throw NullReferenceException"); + pass_SendData_CHECK_EXCEPTION = true; + + BluetoothHelper.DisplayCustomLabel("SendData is success, wait for disconnet"); + + /* Wait for disconnection from client */ + await Task.Delay(5000); + + /* PASS condition for Dispose_CHECK_NO_EXCEPTION */ + socketServer.Dispose(); + pass_Dispose_CHECK_NO_EXCEPTION = true; + socketServer = null; + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + finally + { + if (socketServer != null) + { + socketServer.Dispose(); + socketServer = null; + } + } + } + + [Test] + [Category("P1")] + [Description("Starts listening for a connection from remote device and accept the connection.")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.Listen M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task Listen_ACCEPT_CLIENT_CONNECTION_TEST() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Listen_ACCEPT_CLIENT_CONNECTION_TEST == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Listen_ACCEPT_CLIENT_CONNECTION_TEST, "[TestCase][Listen_ACCEPT_CLIENT_CONNECTION_TEST] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check AcceptStateChanged event")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.AcceptStateChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task AcceptStateChanged_EVENT() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_AcceptStateChanged_EVENT == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_AcceptStateChanged_EVENT, "[TestCase][AcceptStateChanged_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Connection property of AcceptStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Connection 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 test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task Connection_AcceptStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Connection_AcceptStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Connection_AcceptStateChangedEventArgs_READ_ONLY == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Connection_AcceptStateChangedEventArgs_READ_ONLY, "[TestCase][Connection_AcceptStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Result property of AcceptStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Result 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 test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task Result_AcceptStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Result_AcceptStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Result_AcceptStateChangedEventArgs_READ_ONLY == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Result_AcceptStateChangedEventArgs_READ_ONLY, "[TestCase][Result_AcceptStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test State property of AcceptStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.State 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 test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task State_AcceptStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("State_AcceptStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_State_AcceptStateChangedEventArgs_READ_ONLY == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_State_AcceptStateChangedEventArgs_READ_ONLY, "[TestCase][State_AcceptStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Server property of AcceptStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.AcceptStateChangedEventArgs.Server 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 test device which acts as server")] + [Precondition(3, "Test device(server) should be paired only with the client device")] + [Step(1, "Tap the Run button")] + [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] + public async Task Server_AcceptStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Server_AcceptStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Server_AcceptStateChangedEventArgs_READ_ONLY == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Server_AcceptStateChangedEventArgs_READ_ONLY, "[TestCase][Server_AcceptStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check ConnectionStateChanged event")] + [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.ConnectionStateChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as client")] + [Precondition(3, "Test device(client) should be paired only with the server device")] + [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] + [Step(1, "Tap the Run button")] + [Step(2, "When permission request popup appears, tap accept on server device.")] + public async Task ConnectionStateChanged_EVENT() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ConnectionStateChanged_EVENT == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_ConnectionStateChanged_EVENT, "[TestCase][ConnectionStateChanged_EVENT] Fail"); + } + + [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 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_TEST_SERVER() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_SendData_SEND_DATA_TEST_SERVER == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_SendData_SEND_DATA_TEST_SERVER, "[TestCase][SendData_SEND_DATA_TEST_SERVER] Fail"); + } + + [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", "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() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("SendData_SEND_DATA_BYTE_TEST_SERVER"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_SendData_SEND_DATA_BYTE_TEST_SERVER == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_SendData_SEND_DATA_BYTE_TEST_SERVER, "[TestCase][SendData_SEND_DATA_BYTE_TEST_SERVER] Fail"); + } + + [Test] + [Category("P2")] + [Description("Check if SendData returns proper error")] + [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [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_CHECK_EXCEPTION() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("SendData_CHECK_EXCEPTION"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_SendData_CHECK_EXCEPTION == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_SendData_CHECK_EXCEPTION, "[TestCase][SendData_CHECK_EXCEPTION] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check DataReceived event")] + [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.DataReceived E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] + [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.SendData_SEND_DATA_TEST_CLIENT in the client device immediately")] + public async Task DataReceived_SERVER_EVENT() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_DataReceived_SERVER_EVENT == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_DataReceived_SERVER_EVENT, "[TestCase][DataReceived_SERVER_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Data property of SocketDataReceivedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.SocketDataReceivedEventArgs.Data 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 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.SendData_SEND_DATA_TEST_CLIENT in the client device immediately")] + [Postcondition(1, "Unpair the client device")] + public async Task Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER, "[TestCase][Data_SocketDataReceivedEventArgs_READ_ONLY_SERVER] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Dispose works without throwing exception")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Hyuk Lee, hyuk0512.lee@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Run this only on test device which acts as server")] + [Step(1, "Tap the Run button")] + public async Task Dispose_CHECK_NO_EXCEPTION() + { + /* We can't occupy the precondition, if Bluetooth feature is not supported in Manual TC */ + if (isBluetoothSupported == false) + { + BluetoothHelper.DisplayLabel("Dispose_CHECK_NO_EXCEPTION"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Dispose_CHECK_NO_EXCEPTION == false) + await SocketServerCombine_TEST(); + + Assert.True(pass_Dispose_CHECK_NO_EXCEPTION, "[TestCase][Dispose_CHECK_NO_EXCEPTION] Fail"); + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs deleted file mode 100644 index 2ab1309..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothServerSocket Tests")] - public class BluetoothServerSocketTests - { - static bool isBluetoothSupported = false; - - [SetUp] - public static void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for BluetoothServerSocket TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported); - } - - [TearDown] - public static void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.DestroyServerSocketUtil(); - } - - [Test] - [Category("P1")] - [Description("Starts listening for a connection from remote device and accept the connection.")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.Listen ME")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEVENT")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - public static async Task Listen_ACCEPT_CLIENT_CONNECTION_TEST() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - await BluetoothSetup.AcceptSocketUtil(); - - if (BluetoothSetup.FlagAcceptStateChanged) - { - Log.Debug(Globals.LogTag, "[TestCase][Listen][Socket] Pass"); - BluetoothHelper.DisplayPassLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); - } - - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] //pass, fail - [Category("P1")] - [Description("Check AcceptStateChanged event")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.AcceptStateChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as server")] - [Precondition(3, "Test device(server) should be paired only with the client device")] - [Step(1, "Tap the Run button")] - [Step(2, "Run Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - public static async Task AcceptStateChanged_EVENT() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - - await BluetoothSetup.AcceptSocketUtil(); - // Donot use Assert.IsTrue() below. The Client deivce has to disconnect the socket first. - - if (BluetoothSetup.FlagAcceptStateChanged) - { - Log.Debug(Globals.LogTag, "[TestCase][AcceptStateChanged][Socket] Pass"); - BluetoothHelper.DisplayPassLabel("AcceptStateChanged_EVENT"); - } - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Dispose works without throwing exception")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothServerSocket.Dispose M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Hyuk Lee, hyuk0512.lee@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as server")] - [Step(1, "Tap the Run button")] - public async Task Dispose_CHECK_NO_EXCEPTION() - { - BluetoothServerSocket Server = null; - string ServiceUuid = "00001101-0000-1000-8000-00805F9B7777"; - try - { - Server = BluetoothAdapter.CreateServerSocket(ServiceUuid); - Assert.IsNotNull(Server, "PRECONDITION: Failed to get server socket for testing"); - Server.Dispose(); - } - catch (NotSupportedException) - { - if (isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothClientSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothClientSocket.cs deleted file mode 100755 index 33c0ef9..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothClientSocket.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("IBluetoothClientSocket Tests")] - public class IBluetoothClientSocketTests - { - private bool _isBluetoothSupported = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for IBluetoothClientSocket TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - [Test] - [Category("P1")] - [Description("Connects to a remote device, establishing socket connection and acts as a client.")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Connect M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task Connect_SOCKET_CONNECTION_TEST() - { - try { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST"); - 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(); - - await Task.Delay(1000); - - Assert.IsTrue(BluetoothSetup.FlagConnected, "[TestCase][Connect][Socket] Failed"); - - BluetoothHelper.DisplayPassLabel("Connect_SOCKET_CONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); - } - } - - [Test] - [Category("P1")] - [Description("Disconnects the socket connection.")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Disconnect M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task Disconnect_SOCKET_DISCONNECTION_TEST() - { - try { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST"); - 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(); - - await Task.Delay(1000); - - await BluetoothSetup.DisconnectSocketUtil(); - - await Task.Delay(1000); - - Assert.IsTrue(BluetoothSetup.FlagDisconnected, "[TestCase][Disconnect][Socket] Failed"); - - BluetoothHelper.DisplayPassLabel("Disconnect_SOCKET_DISCONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs deleted file mode 100644 index 3eb166f..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs +++ /dev/null @@ -1,472 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("IBluetoothServerSocket Tests")] - public class IBluetoothServerSocketTests - { - private string _dataFromClient = "Test from client"; - private bool _isBluetoothSupported = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for IBluetoothServerSocket TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - [Test] - [Category("P1")] - [Description("Check ConnectionStateChanged event")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.ConnectionStateChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Run this only on test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task ConnectionStateChanged_EVENT() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT"); - 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(); - Assert.IsTrue(BluetoothSetup.FlagConnected, "[TestCase][ConnectionStateChanged][Socket] Failed"); - - BluetoothHelper.DisplayPassLabel("ConnectionStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); - } - } - - [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 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_TEST_SERVER() - { - try - { - int writtenLength; - - /* 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(BluetoothSetup.dataFromServer); - Assert.AreEqual(writtenLength, BluetoothSetup.dataFromServer.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", "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("P2")] - [Description("Check if SendData returns proper error")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MEX")] - [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_CHECK_EXCEPTION() - { - try - { - int writtenLength; - byte[] sendData = null; - - /* 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); - Assert.Throws(() => - { - writtenLength = BluetoothSetup.Socket.SendData(sendData); - }, "SendData should throw NullReferenceException"); - } - catch (Exception ex) - { - if (ex is NotSupportedException) - { - Assert.IsTrue(_isBluetoothSupported == false, "Invalid NotSupportedException"); - } - else - { - Assert.Fail("Throwing exception " + 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")] - [Precondition(4, "Should run this only after the TC IBluetoothServerSocketTests.DataReceived_SERVER_EVENT is started in the server device")] - [Step(1, "Tap the Run button in client device")] - [Step(2, "Check if log in server device shows \"DataReceived in server: Test from client\".")] - [Postcondition(1, "Unpair the server device")] - public async Task SendData_SEND_DATA_TEST_CLIENT() - { - try - { - int writtenLength; - - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT"); - 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(); - await Task.Delay(2000); - writtenLength = BluetoothSetup.Client.SendData(_dataFromClient); - Assert.AreEqual(writtenLength, _dataFromClient.Length); - - BluetoothHelper.DisplayPassLabel("SendData_SEND_DATA_TEST_CLIENT"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); - } - } - - [Test] - [Category("P1")] - [Description("Check DataReceived event")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.DataReceived E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")] - [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.SendData_SEND_DATA_TEST_CLIENT in the client device immediately")] - public async Task DataReceived_SERVER_EVENT() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); - await ManualTest.WaitForConfirm(); - return; - } - - BluetoothSetup.CreateServerSocketUtil(); - await BluetoothSetup.AcceptSocketUtil(); - BluetoothSetup.Socket.DataReceived += (sender, args) => - { - Log.Info(Globals.LogTag, "DataReceived in server: "+args.Data.Data); - BluetoothHelper.DisplayPassLabel("DataReceived_SERVER_EVENT"); - }; - - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - BluetoothSetup.DestroyServerSocketUtil(); - } - } - - [Test] - [Category("P1")] - [Description("Check DataReceived event")] - [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.DataReceived E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [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")] - [Precondition(4, "Open terminal in client device to view logs")] - [Precondition(5, "Enter command \"sdb dlog -c\" to clear logs")] - [Precondition(6, "Enter command \"sdb dlog | grep TCT\" to terminal")] - [Step(1, "Tap the Run button in client device")] - [Step(2, "Check if log in client device shows \"DataReceived in client: Test from server\".")] - [Postcondition(1, "Close the terminal")] - [Postcondition(2, "Unpair the server device")] - public async Task DataReceived_CLIENT_EVENT() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("DataReceived_CLIENT_EVENT"); - 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 += (sender, args) => - { - Log.Info(Globals.LogTag, "DataReceived in client: "+args.Data.Data); - BluetoothHelper.DisplayPassLabel("DataReceived_SERVER_EVENT"); - }; - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnection.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnection.cs deleted file mode 100644 index 1a507c5..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnection.cs +++ /dev/null @@ -1,305 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("SocketConnection Tests")] - public class SocketConnectionTests - { - private bool _isBluetoothSupported = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - } - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.DestroyClientSocketUtil(); - } - - [Test] - [Category("P1")] - [Description("Test SocketFd. Check whether SocketFd is readable")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task SocketFd_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("SocketFd_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(); - if (BluetoothSetup.ClientConnection == null) - { - Assert.Fail("Connection data is null"); - return; - } - Assert.IsInstanceOf(BluetoothSetup.ClientConnection.SocketFd, "SocketFd is not proper"); - - BluetoothHelper.DisplayPassLabel("SocketFd_READ_ONLY"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test Address. Check whether Address is readable and writable")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.Address 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task Address_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Address_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(); - if (BluetoothSetup.ClientConnection == null) - { - Assert.Fail("Connection data is null"); - return; - } - Assert.IsNotNull(BluetoothSetup.ClientConnection.Address, "Remote device address is null"); - Assert.IsInstanceOf(BluetoothSetup.ClientConnection.Address, "Address is not proper"); - - BluetoothHelper.DisplayPassLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ServiceUuid. Check whether ServiceUuid is readable and writable")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.ServiceUuid 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task ServiceUuid_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("ServiceUuid_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(); - if (BluetoothSetup.ClientConnection == null) - { - Assert.Fail("Connection data is null"); - return; - } - Assert.IsNotNull(BluetoothSetup.ClientConnection.ServiceUuid, "ServiceUuid is null"); - Assert.IsInstanceOf(BluetoothSetup.ClientConnection.ServiceUuid, "ServiceUuid is not proper"); - - BluetoothHelper.DisplayPassLabel("ServiceUuid_READ_ONLY"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("ServiceUuid_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ServiceUuid_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test Client. Check whether Client is valid")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnection.Client 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task Client_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Client_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(); - Assert.IsNotNull(BluetoothSetup.ClientConnection, "Connection data is null"); - Assert.IsNotNull(BluetoothSetup.ClientConnection.Client, "Client is null"); - Assert.IsInstanceOf(BluetoothSetup.ClientConnection.Client, "Client is not proper"); - - BluetoothHelper.DisplayPassLabel("Client_READ_ONLY"); - await ManualTest.WaitForConfirm(); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Client_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Client_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnectionStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnectionStateChangedEventArgs.cs deleted file mode 100755 index 3acd30c..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketConnectionStateChangedEventArgs.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("SocketConnectionStateChangedEventArgs Tests")] - public class SocketConnectionStateChangedEventArgsTests - { - private bool _isBluetoothSupported = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - } - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.DestroyClientSocketUtil(); - } - - [Test] - [Category("P1")] - [Description("Test Connection property of SocketConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.Connection 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task Connection_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Connection_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(); - Assert.IsNotNull(BluetoothSetup.ClientConnection, "ClientConnection is null"); - Assert.IsInstanceOf(BluetoothSetup.ClientConnection, "ClientConnection is not type of SocketConnection"); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Connection_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Connection_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test Result property of SocketConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.Result 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Step(3, "Check if log shows \"[TestCase][Result_READ_ONLY][Socket] Pass\".")] - [Postcondition(1, "Unpair the server device")] - public async Task Result_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Result_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(); - Assert.IsInstanceOf(BluetoothSetup.ClientResult, "ClientResult is not type of int"); - Assert.AreEqual(BluetoothSetup.ClientResult, BluetoothError.None, "ClientResult is not Error.None"); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test State property of SocketConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketConnectionStateChangedEventArgs.State 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 test device which acts as client")] - [Precondition(3, "Test device(client) should be paired only with the server device")] - [Precondition(4, "Should run this only after the TC BluetoothServerSocketTests.Listen_ACCEPT_CLIENT_CONNECTION_TEST is started")] - [Step(1, "Tap the Run button")] - [Step(2, "When permission request popup appears, tap accept on server device.")] - [Postcondition(1, "Unpair the server device")] - public async Task State_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("State_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(); - Assert.IsInstanceOf(BluetoothSetup.ClientState, "ClientState is not type of BluetoothSocketState"); - Assert.AreEqual(BluetoothSetup.ClientState, BluetoothSocketState.Connected, "ClientState is not Connected"); - - await BluetoothSetup.DisconnectSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("State_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("State_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs deleted file mode 100644 index 18454a2..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketData.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using System.Linq; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("SocketData Tests")] - public class SocketDataTests - { - private bool _flagDataReceived = false; - private bool _isBluetoothSupported = false; - private static bool _isPassed = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - _flagDataReceived = false; - } - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.DestroyClientSocketUtil(); - BluetoothSetup.Data = null; - _flagDataReceived = false; - } - - public void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args) - { - BluetoothSetup.Data = args.Data; - _flagDataReceived = true; - } - - public async Task WaitClientDataReceivedFlag() - { - int count = 0; - while(true) - { - await Task.Delay(2000); - count++; - if (_flagDataReceived) - break; - if (count == 15) - break; - } - } - - 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) - { - BluetoothHelper.DisplayLabel("SocketFd_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(); - - /* 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"); - - /* 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) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [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")] - [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 DataSize_READ_ONLY() - { - await SocketDataTest(); - } - - [Test] - [Category("P1")] - [Description("Test Data. Check whether Data is readable")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketData.Data 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 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("ByteData_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.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."); - - 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(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("ByteData_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ByteData_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs deleted file mode 100755 index 68de987..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("SocketDataReceivedEventArgs Tests")] - public class SocketDataReceivedEventArgsTests - { - private bool _flagClientDataReceived = false; - private bool _flagServerDataReceived = false; - private bool _isBluetoothSupported = false; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported); - _flagClientDataReceived = false; - _flagServerDataReceived = false; - } - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - public async Task WaitClientDataReceivedFlag() - { - int count = 0; - while(true) - { - await Task.Delay(2000); - count++; - if (_flagClientDataReceived) - break; - if (count == 15) - break; - } - } - - public void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args) - { - BluetoothSetup.Data = args.Data; - Log.Info(Globals.LogTag, "DataReceived in client: "+args.Data.Data); - _flagClientDataReceived = true; - } - - [Test] - [Category("P1")] - [Description("Test Data property of SocketDataReceivedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketDataReceivedEventArgs.Data 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")] - [Postcondition(1, "Unpair the server device")] - public async Task Data_READ_ONLY_CLIENT() - { - try - { - /* We can't occupy the precondition, if BT feature is not supported in Manual TC */ - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Data_READ_ONLY_CLIENT"); - 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.IsTrue(_flagClientDataReceived, "[TestCase][Data_READ_ONLY_CLIENT][Socket] Failed"); - - BluetoothHelper.DisplayPassLabel("Data_READ_ONLY_CLIENT"); - await ManualTest.WaitForConfirm(); - - BluetoothSetup.Client.DataReceived -= DataReceivedClientEventHandler; - await BluetoothSetup.DisconnectSocketUtil(); - BluetoothSetup.DestroyClientSocketUtil(); - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Data_READ_ONLY_CLIENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Data_READ_ONLY_CLIENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - public async Task WaitServerDataReceivedFlag() - { - int count = 0; - while(true) - { - await Task.Delay(2000); - count++; - if (_flagServerDataReceived) - break; - if (count == 15) - break; - } - } - - public void DataReceivedServerEventHandler(object sender, SocketDataReceivedEventArgs args) - { - BluetoothSetup.Data = args.Data; - Log.Info(Globals.LogTag, "DataReceived in client: "+args.Data.Data); - _flagServerDataReceived = true; - } - - [Test] - [Category("P1")] - [Description("Test Data property of SocketDataReceivedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.SocketDataReceivedEventArgs.Data 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 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.SendData_SEND_DATA_TEST_CLIENT in the client device immediately")] - [Postcondition(1, "Unpair the client device")] - public async Task Data_READ_ONLY_SERVER() - { - try - { - BluetoothSetup.CreateServerSocketUtil(); - await BluetoothSetup.AcceptSocketUtil(); - BluetoothSetup.Socket.DataReceived += DataReceivedServerEventHandler; - await WaitServerDataReceivedFlag(); - Assert.IsTrue(_flagServerDataReceived, "[TestCase][Data_READ_ONLY_SERVER][Socket] Failed"); - BluetoothSetup.Socket.DataReceived -= DataReceivedServerEventHandler; - } - catch (NotSupportedException) - { - if (_isBluetoothSupported == false) - { - BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - BluetoothSetup.DestroyServerSocketUtil(); - } - } - } -}