From: DoHyun Pyun Date: Wed, 13 Feb 2019 04:28:13 +0000 (+0900) Subject: [Non-ACR][Bluetooth][Manual][Destroy sockets after running each TC] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c99601f43574762043f52387faeb37e85e6c3d3c;p=test%2Ftct%2Fcsharp%2Fapi.git [Non-ACR][Bluetooth][Manual][Destroy sockets after running each TC] Change-Id: I395fc6f62526ca32855eda861683433c9b21a050 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 index a1c6fc0..3b73cbe 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAcceptStateChangedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAcceptStateChangedEventArgs.cs @@ -24,6 +24,7 @@ namespace Tizen.Network.Bluetooth.Tests public static void Destroy() { LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + BluetoothSetup.DestroyServerSocketUtil(); } [Test] @@ -38,7 +39,6 @@ namespace Tizen.Network.Bluetooth.Tests [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 Connection_READ_ONLY() { try @@ -49,7 +49,6 @@ namespace Tizen.Network.Bluetooth.Tests await BluetoothSetup.AcceptSocketUtil(); Assert.IsNotNull(BluetoothSetup.AcceptConnection, "[TestCase][Connection_READ_ONLY][Socket] Fail"); - BluetoothSetup.DestroyServerSocketUtil(); BluetoothSetup.AcceptConnection = null; } catch (NotSupportedException) @@ -63,7 +62,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Connection_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -86,7 +85,6 @@ namespace Tizen.Network.Bluetooth.Tests [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 Result_READ_ONLY() { try @@ -99,8 +97,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.Fail("[TestCase][Result_READ_ONLY][Socket] Fail"); } - - BluetoothSetup.DestroyServerSocketUtil(); } catch (NotSupportedException) { @@ -113,7 +109,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Result_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -149,8 +145,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.Fail("[TestCase][State_READ_ONLY][Socket] Fail"); } - - BluetoothSetup.DestroyServerSocketUtil(); } catch (NotSupportedException) { @@ -163,7 +157,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("State_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -196,9 +190,6 @@ namespace Tizen.Network.Bluetooth.Tests //TEST CODE await BluetoothSetup.AcceptSocketUtil(); Assert.IsNotNull(BluetoothSetup.Server, "[TestCase][Server_READ_ONLY][Socket] Fail"); - - BluetoothSetup.DestroyServerSocketUtil(); - BluetoothSetup.Server = null; } catch (NotSupportedException) { @@ -211,7 +202,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Server_READ_ONLY"); await ManualTest.WaitForConfirm(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs index 18c4844..2ed55c5 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs @@ -76,7 +76,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); await ManualTest.WaitForConfirm(); } @@ -85,6 +85,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -128,7 +133,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -137,6 +142,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -180,7 +190,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -189,6 +199,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -235,7 +250,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -244,6 +259,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -291,7 +311,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -300,6 +320,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -350,8 +375,8 @@ namespace Tizen.Network.Bluetooth.Tests } catch (TypeInitializationException e) { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + { BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -360,6 +385,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -413,7 +443,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -422,6 +452,11 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (client != null) + await BluetoothSetup.gatt_client_exit(); + } } [Test] @@ -464,7 +499,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs index e638830..2ab1309 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothServerSocket.cs @@ -25,6 +25,7 @@ namespace Tizen.Network.Bluetooth.Tests public static void Destroy() { LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + BluetoothSetup.DestroyServerSocketUtil(); } [Test] @@ -37,32 +38,24 @@ namespace Tizen.Network.Bluetooth.Tests [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")] - [Precondition(4, "Open terminal to view logs")] - [Precondition(5, "Enter command \"sdb dlog -c\" to clear log")] - [Precondition(6, "Enter command \"sdb dlog | grep TCT\" to terminal")] [Step(1, "Tap the Run button")] [Step(2, "Run IBluetoothClientSocketTests.Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - [Step(3, "Check if log shows \"[TestCase][Listen][Socket] Pass\".")] - [Postcondition(1, "Unpair the client device")] - [Postcondition(2, "Close the terminal")] 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"); - } + BluetoothHelper.DisplayPassLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); + } await ManualTest.WaitForConfirm(); - - BluetoothSetup.DestroyServerSocketUtil(); - } + } catch (NotSupportedException) { if (isBluetoothSupported == false) @@ -74,7 +67,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST"); await ManualTest.WaitForConfirm(); } @@ -95,32 +88,24 @@ namespace Tizen.Network.Bluetooth.Tests [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")] - [Precondition(4, "Open terminal to view logs")] - [Precondition(5, "Enter command \"sdb dlog -c\" to clear log")] - [Precondition(6, "Enter command \"sdb dlog | grep TCT\" to terminal")] [Step(1, "Tap the Run button")] [Step(2, "Run Connect_SOCKET_CONNECTION_TEST in the client device immediately")] - [Step(3, "Check if log shows \"[TestCase][AcceptStateChanged][Socket] Pass\".")] - [Postcondition(1, "Unpair the client device")] - [Postcondition(2, "Close the terminal")] 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"); - } + BluetoothHelper.DisplayPassLabel("AcceptStateChanged_EVENT"); + } await ManualTest.WaitForConfirm(); - - BluetoothSetup.DestroyServerSocketUtil(); - } + } catch (NotSupportedException) { if (isBluetoothSupported == false) @@ -132,7 +117,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT"); await ManualTest.WaitForConfirm(); } @@ -153,7 +138,6 @@ namespace Tizen.Network.Bluetooth.Tests [Precondition(1, "Turn on the bluetooth")] [Precondition(2, "Run this only on test device which acts as server")] [Step(1, "Tap the Run button")] - [Postcondition(1, "Close the terminal")] public async Task Dispose_CHECK_NO_EXCEPTION() { BluetoothServerSocket Server = null; diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs index 912cf4a..1b8d578 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSIBluetoothServerSocket.cs @@ -67,7 +67,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT"); await ManualTest.WaitForConfirm(); } @@ -75,7 +75,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (Exception ex) { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); + BluetoothSetup.DestroyClientSocketUtil(); } } @@ -91,21 +91,17 @@ namespace Tizen.Network.Bluetooth.Tests [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")] - [Step(3, "Check if log in client device shows \"DataReceived in client: Test from server\".")] - [Postcondition(1, "Unpair the client device")] public static async Task SendData_SEND_DATA_TEST_SERVER() { try { - int writtenLength; + int writtenLength; BluetoothSetup.CreateServerSocketUtil(); await BluetoothSetup.AcceptSocketUtil(); await Task.Delay(2000); writtenLength = BluetoothSetup.Socket.SendData(BluetoothSetup.dataFromServer); - await ManualTest.WaitForConfirm(); Assert.AreEqual(writtenLength, BluetoothSetup.dataFromServer.Length); - BluetoothSetup.DestroyServerSocketUtil(); } catch (NotSupportedException) { @@ -118,7 +114,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER"); await ManualTest.WaitForConfirm(); } @@ -126,7 +122,10 @@ namespace Tizen.Network.Bluetooth.Tests catch (Exception ex) { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); + } + finally + { + BluetoothSetup.DestroyServerSocketUtil(); } } @@ -173,7 +172,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT"); await ManualTest.WaitForConfirm(); } @@ -181,7 +180,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (Exception ex) { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); + BluetoothSetup.DestroyClientSocketUtil(); } } @@ -195,14 +194,8 @@ namespace Tizen.Network.Bluetooth.Tests [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")] - [Precondition(4, "Open terminal in server 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 server device")] [Step(2, "Run IBluetoothServerSocketTests.SendData_SEND_DATA_TEST_CLIENT in the client device immediately")] - [Step(3, "Check if log in server device shows \"DataReceived in server: Test from client\".")] - [Postcondition(1, "Close the terminal")] - [Postcondition(2, "Unpair the client device")] public static async Task DataReceived_SERVER_EVENT() { try @@ -212,12 +205,11 @@ namespace Tizen.Network.Bluetooth.Tests BluetoothSetup.Socket.DataReceived += (sender, args) => { Log.Info(Globals.LogTag, "DataReceived in server: "+args.Data.Data); - BluetoothHelper.DisplayPassLabel("DataReceived_SERVER_EVENT"); + BluetoothHelper.DisplayPassLabel("DataReceived_SERVER_EVENT"); }; - + await ManualTest.WaitForConfirm(); - BluetoothSetup.DestroyServerSocketUtil(); - } + } catch (NotSupportedException) { if (isBluetoothSupported == false) @@ -229,7 +221,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); await ManualTest.WaitForConfirm(); } @@ -237,7 +229,10 @@ namespace Tizen.Network.Bluetooth.Tests catch (Exception ex) { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); + } + finally + { + BluetoothSetup.DestroyServerSocketUtil(); } } @@ -287,7 +282,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT"); await ManualTest.WaitForConfirm(); } @@ -295,7 +290,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (Exception ex) { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - BluetoothSetup.DestroyClientSocketUtil(); + BluetoothSetup.DestroyClientSocketUtil(); } } } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs index 6e34805..6f1b995 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSSocketDataReceivedEventArgs.cs @@ -147,8 +147,7 @@ namespace Tizen.Network.Bluetooth.Tests await WaitServerDataReceivedFlag(); Assert.IsTrue(flagServerDataReceived, "[TestCase][Data_READ_ONLY_SERVER][Socket] Failed"); BluetoothSetup.Socket.DataReceived -= DataReceivedServerEventHandler; - BluetoothSetup.DestroyServerSocketUtil(); - } + } catch (NotSupportedException) { if (isBluetoothSupported == false) @@ -160,7 +159,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER"); await ManualTest.WaitForConfirm(); } @@ -169,6 +168,10 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + BluetoothSetup.DestroyServerSocketUtil(); + } } } }