public static void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
+ BluetoothSetup.DestroyServerSocketUtil();
}
[Test]
[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
await BluetoothSetup.AcceptSocketUtil();
Assert.IsNotNull(BluetoothSetup.AcceptConnection, "[TestCase][Connection_READ_ONLY][Socket] Fail");
- BluetoothSetup.DestroyServerSocketUtil();
BluetoothSetup.AcceptConnection = null;
}
catch (NotSupportedException)
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Connection_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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
{
Assert.Fail("[TestCase][Result_READ_ONLY][Socket] Fail");
}
-
- BluetoothSetup.DestroyServerSocketUtil();
}
catch (NotSupportedException)
{
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Result_READ_ONLY");
await ManualTest.WaitForConfirm();
}
{
Assert.Fail("[TestCase][State_READ_ONLY][Socket] Fail");
}
-
- BluetoothSetup.DestroyServerSocketUtil();
}
catch (NotSupportedException)
{
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("State_READ_ONLY");
await ManualTest.WaitForConfirm();
}
//TEST CODE
await BluetoothSetup.AcceptSocketUtil();
Assert.IsNotNull(BluetoothSetup.Server, "[TestCase][Server_READ_ONLY][Socket] Fail");
-
- BluetoothSetup.DestroyServerSocketUtil();
- BluetoothSetup.Server = null;
}
catch (NotSupportedException)
{
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Server_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
}
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();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ if (client != null)
+ await BluetoothSetup.gatt_client_exit();
+ }
}
[Test]
catch (TypeInitializationException e)
{
if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
public static void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
+ BluetoothSetup.DestroyServerSocketUtil();
}
[Test]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Listen_ACCEPT_CLIENT_CONNECTION_TEST");
await ManualTest.WaitForConfirm();
}
[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)
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("AcceptStateChanged_EVENT");
await ManualTest.WaitForConfirm();
}
[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;
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();
+ BluetoothSetup.DestroyClientSocketUtil();
}
}
[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)
{
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());
- BluetoothSetup.DestroyClientSocketUtil();
+ }
+ finally
+ {
+ BluetoothSetup.DestroyServerSocketUtil();
}
}
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();
+ BluetoothSetup.DestroyClientSocketUtil();
}
}
[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
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)
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();
+ }
+ finally
+ {
+ BluetoothSetup.DestroyServerSocketUtil();
}
}
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();
+ BluetoothSetup.DestroyClientSocketUtil();
}
}
}
await WaitServerDataReceivedFlag();
Assert.IsTrue(flagServerDataReceived, "[TestCase][Data_READ_ONLY_SERVER][Socket] Failed");
BluetoothSetup.Socket.DataReceived -= DataReceivedServerEventHandler;
- BluetoothSetup.DestroyServerSocketUtil();
- }
+ }
catch (NotSupportedException)
{
if (isBluetoothSupported == false)
catch (TypeInitializationException e)
{
if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER");
await ManualTest.WaitForConfirm();
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ BluetoothSetup.DestroyServerSocketUtil();
+ }
}
}
}