public static bool FlagAcceptStateChanged = false;
public static bool FlagConnected = false;
public static bool FlagDisconnected = false;
- public static bool FlagDeviceFound = false;
public static string ServiceUuid = "00001101-0000-1000-8000-00805F9B7777";
public static SocketConnection AcceptConnection = null;
public static BluetoothError AcceptResult;
public static string A2dpSnkUuid = "0000110B-0000-1000-8000-00805F9B34FB";
private static bool flagCreateSocketDone = false;
- private static bool flagCreateClientDone = false;
private static bool flagAcceptSocketDone = false;
private static bool flagConnectSocketDone = false;
private static bool flagDisconnectSocketDone = false;
}
}
- public static void DiscoveryStateChangedEventHandler(object sender, DiscoveryStateChangedEventArgs args)
+ public static void CreateClientSocketUtil()
{
- Log.Info(Globals.LogTag, "DiscoverySateChanged callback "+ args.DiscoveryState);
- if (args.DiscoveryState == BluetoothDeviceDiscoveryState.Found && args.DeviceFound.IsPaired)
- {
- if (FlagDeviceFound == true)
- return;
-
- if (remote_addr.Equals(default_remote_addr))
- {
- LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Use the first found device");
- }
- else if (args.DeviceFound.Address.Equals(remote_addr))
- {
- LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Found the matching device: " + args.DeviceFound.Address);
- }
- else
- {
- LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Exception: " + args.DeviceFound.Address);
- return;
- }
-
- Log.Info(Globals.LogTag, "DiscoverySateChanged callback device found: "+ args.DeviceFound.Name);
- Client = args.DeviceFound.CreateSocket(ServiceUuid);
-
- if (Client != null)
- {
- FlagDeviceFound = true;
- BluetoothAdapter.StopDiscovery();
- }
- }
- }
-
- public static async Task WaitDiscoveryFlag()
- {
- int count = 0;
- while(true)
- {
- await Task.Delay(2000);
- count++;
- if (FlagDeviceFound)
- break;
- if (count == 15)
- break;
- }
- }
-
- public static async Task CreateClientSocketUtil()
- {
- pairedDevice = BluetoothAdapter.GetBondedDevice(remote_addr);
-
- if (pairedDevice == null)
+ try
{
- BluetoothAdapter.DiscoveryStateChanged += DiscoveryStateChangedEventHandler;
- BluetoothAdapter.StartDiscovery ();
- await WaitDiscoveryFlag ();
-
- if (BluetoothAdapter.IsDiscoveryInProgress)
- BluetoothAdapter.StopDiscovery ();
-
- BluetoothAdapter.DiscoveryStateChanged -= DiscoveryStateChangedEventHandler;
-
- if (FlagDeviceFound)
- flagCreateClientDone = true;
+ pairedDevice = BluetoothAdapter.GetBondedDevice(remote_addr);
+ Client = pairedDevice.CreateSocket(ServiceUuid);
}
- else
+ catch (Exception e)
{
- Client = pairedDevice.CreateSocket(ServiceUuid);
-
- if (Client != null)
- {
- FlagDeviceFound = true;
- flagCreateClientDone = true;
- }
+ Log.Error(Globals.LogTag, "Failed to get bonded device(" + remote_addr + "), Exception: " + e.ToString());
}
}
{
Client = null;
ClientConnection = null;
- flagCreateClientDone = false;
- FlagDeviceFound = false;
}
public static async Task WaitAcceptFlag()
{
int count = 0;
- while(true)
+ while (true)
{
await Task.Delay(2000);
count++;
FlagDisconnected = true;
flagDisconnectSocketDone = true;
}
- //ManualTest.Confirm();
+ ManualTest.Confirm();
}
public static async Task WaitConnectedFlag()
{
int count = 0;
- while(true)
+ while (true)
{
await Task.Delay(1000);
count++;
if (flagConnectSocketDone == false)
{
Client.ConnectionStateChanged += ConnectionStateChangedEventHandler;
- Client.Connect ();
+ Client.Connect();
- await WaitConnectedFlag ();
- //await ManualTest.WaitForConfirm();
+ //await WaitConnectedFlag ();
+ await ManualTest.WaitForConfirm();
//Client.ConnectionStateChanged -= ConnectionStateChangedEventHandler;
if (FlagConnected)
{
public static async Task WaitDisconnectedFlag()
{
int count = 0;
- while(true)
+ while (true)
{
await Task.Delay(1000);
count++;
{
//Client.ConnectionStateChanged += ConnectionStateChangedEventHandler;
Client.Disconnect();
- await WaitDisconnectedFlag();
+
+ //await WaitDisconnectedFlag();
+ await ManualTest.WaitForConfirm();
if (FlagDisconnected)
{
Client.ConnectionStateChanged -= ConnectionStateChangedEventHandler;
{
BluetoothDevice bondedDevice = e.Device;
- if(bondedDevice != null && bondedDevice.IsPaired)
+ if (bondedDevice != null && bondedDevice.IsPaired)
{
pairedDevice = bondedDevice;
}
public static void EventHandlerDiscoveryStateChanged(object sender, DiscoveryStateChangedEventArgs e)
{
- if(e.DiscoveryState == BluetoothDeviceDiscoveryState.Found)
+ if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found)
{
BluetoothDevice resultDevice = e.DeviceFound;
BluetoothClass btClass = resultDevice.Class;
public static void EventHandlerHidDiscoveryStateChanged(object sender, DiscoveryStateChangedEventArgs e)
{
- if(hidDevice != null)
+ if (hidDevice != null)
{
LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "hidDevice instance already exist");
return;
}
- if(e.DiscoveryState == BluetoothDeviceDiscoveryState.Found)
+ if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found)
{
BluetoothDevice resultDevice = e.DeviceFound;
BluetoothClass btClass = resultDevice.Class;
[Description("IBluetoothClientSocket Tests")]
public class IBluetoothClientSocketTests
{
- static bool isBluetoothSupported = false;
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ public void Init()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for IBluetoothClientSocket TEST");
- Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported);
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
}
[TearDown]
- public static void Destroy()
+ 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 ME")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Connect M")]
[Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MEVENT")]
+ [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")]
[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 static async Task Connect_SOCKET_CONNECTION_TEST()
+ public async Task Connect_SOCKET_CONNECTION_TEST()
{
try {
- await BluetoothSetup.CreateClientSocketUtil();
+ 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);
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Connect_SOCKET_CONNECTION_TEST");
await ManualTest.WaitForConfirm();
[Test]
[Category("P1")]
[Description("Disconnects the socket connection.")]
- [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Disconnect ME")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothClientSocket.Disconnect M")]
[Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MEVENT")]
+ [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")]
[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 static async Task Disconnect_SOCKET_DISCONNECTION_TEST()
+ public async Task Disconnect_SOCKET_DISCONNECTION_TEST()
{
try {
- await BluetoothSetup.CreateClientSocketUtil();
+ 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);
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Disconnect_SOCKET_DISCONNECTION_TEST");
await ManualTest.WaitForConfirm();
[Description("IBluetoothServerSocket Tests")]
public class IBluetoothServerSocketTests
{
- private static string dataFromClient = "Test from client";
- static bool isBluetoothSupported = false;
+ private string _dataFromClient = "Test from client";
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ public void Init()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for IBluetoothServerSocket TEST");
- Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported);
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
}
[TearDown]
- public static void Destroy()
+ public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
}
- [Test] //pass, fail
+ [Test]
[Category("P1")]
[Description("Check ConnectionStateChanged event")]
[Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.ConnectionStateChanged E")]
[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 static async Task ConnectionStateChanged_EVENT()
+ public async Task ConnectionStateChanged_EVENT()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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");
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("ConnectionStateChanged_EVENT");
await ManualTest.WaitForConfirm();
[Test]
[Category("P1")]
[Description("Sends data to the connected device")]
- [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData ME")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData M")]
[Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MEVENT")]
+ [Property("CRITERIA", "MR")]
[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.DataReceived_CLIENT_EVENT in the client device immediately")]
- public static async Task SendData_SEND_DATA_TEST_SERVER()
+ public async Task SendData_SEND_DATA_TEST_SERVER()
{
try
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_SERVER");
await ManualTest.WaitForConfirm();
[Test]
[Category("P1")]
[Description("Sends data to the connected device")]
- [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData ME")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.SendData M")]
[Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MEVENT")]
+ [Property("CRITERIA", "MR")]
[Property("AUTHOR", "Adhavan, adhavan.m@samsung.com")]
[Precondition(1, "Turn on the bluetooth")]
[Precondition(2, "Run this only on client 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 static async Task SendData_SEND_DATA_TEST_CLIENT()
+ public async Task SendData_SEND_DATA_TEST_CLIENT()
{
try
{
int writtenLength;
- await BluetoothSetup.CreateClientSocketUtil();
+ 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);
+ writtenLength = BluetoothSetup.Client.SendData(_dataFromClient);
+ Assert.AreEqual(writtenLength, _dataFromClient.Length);
BluetoothHelper.DisplayPassLabel("SendData_SEND_DATA_TEST_CLIENT");
await ManualTest.WaitForConfirm();
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("SendData_SEND_DATA_TEST_CLIENT");
await ManualTest.WaitForConfirm();
}
}
- [Test] //pass, fail
+ [Test]
[Category("P1")]
[Description("Check DataReceived event")]
[Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.DataReceived E")]
[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 static async Task DataReceived_SERVER_EVENT()
+ public async Task DataReceived_SERVER_EVENT()
{
try
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT");
await ManualTest.WaitForConfirm();
}
}
- [Test] //pass, fail
+ [Test]
[Category("P1")]
[Description("Check DataReceived event")]
[Property("SPEC", "Tizen.Network.Bluetooth.IBluetoothServerSocket.DataReceived E")]
[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 static async Task DataReceived_CLIENT_EVENT()
+ public async Task DataReceived_CLIENT_EVENT()
{
try
{
- //TEST CODE
- await BluetoothSetup.CreateClientSocketUtil();
+ 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) =>
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("DataReceived_SERVER_EVENT");
await ManualTest.WaitForConfirm();
[Description("NotificationSentEventArg Tests")]
public class NotificationSentEventArgTests
{
- bool isBluetoothGattServerSupported = false;
- BluetoothGattServer server = null;
- string svcUuid = "181D";
- string charUuid = "2A20";
- string valueChanged = "valueChanged";
+ private bool _isBluetoothGattServerSupported = false;
+ private BluetoothGattServer _server = null;
+ private string _svcUuid = "181D";
+ private string _charUuid = "2A20";
+ private string _valueChanged = "valueChanged";
[SetUp]
public void Init()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST");
- Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.server", out isBluetoothGattServerSupported);
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.server", out _isBluetoothGattServerSupported);
}
[TearDown]
string origin_val = null;
/* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
return;
}
- server = await BluetoothSetup.gatt_server_init();
- Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+ _server = await BluetoothSetup.gatt_server_init();
+ Assert.IsNotNull(_server, "Precondition failed: server instance should not be null");
EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
Server_NotificationSent = (sender, e) => {
- server.NotificationSent -= Server_NotificationSent;
+ _server.NotificationSent -= Server_NotificationSent;
Assert.IsNotNull(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed");
Assert.IsInstanceOf<string>(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed");
BluetoothHelper.DisplayPassLabel("ClientAddress_PROPERTY_READ_ONLY");
try
{
Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
- server.NotificationSent += Server_NotificationSent;
+ _server.NotificationSent += Server_NotificationSent;
origin_val = charc.GetValue(0);
- charc.SetValue(valueChanged);
- server.SendIndicationAsync(charc, null);
+ charc.SetValue(_valueChanged);
+ _server.SendIndicationAsync(charc, null);
charc.SetValue(origin_val);
}
}
};
- srv = server.GetService(svcUuid);
- charc = srv.GetCharacteristic(charUuid);
+ srv = _server.GetService(_svcUuid);
+ charc = srv.GetCharacteristic(_charUuid);
charc.NotificationStateChanged += Charc_NotificationStateChanged;
}
catch (NotSupportedException)
{
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
string origin_val = null;
/* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
return;
}
- server = await BluetoothSetup.gatt_server_init();
- Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+ _server = await BluetoothSetup.gatt_server_init();
+ Assert.IsNotNull(_server, "Precondition failed: server instance should not be null");
EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
Server_NotificationSent = (sender, e) => {
- server.NotificationSent -= Server_NotificationSent;
- Assert.IsTrue(e.Completed == true, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed");
+ _server.NotificationSent -= Server_NotificationSent;
Assert.IsInstanceOf<bool>(e.Completed, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed");
+ Assert.IsTrue(e.Completed == true, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed");
BluetoothHelper.DisplayPassLabel("Completed_PROPERTY_READ_ONLY");
};
try
{
Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
- server.NotificationSent += Server_NotificationSent;
+ _server.NotificationSent += Server_NotificationSent;
origin_val = charc.GetValue(0);
- charc.SetValue(valueChanged);
- server.SendIndicationAsync(charc, null);
+ charc.SetValue(_valueChanged);
+ _server.SendIndicationAsync(charc, null);
charc.SetValue(origin_val);
}
catch (Exception ex)
{
- Assert.Fail("[TestCase][ClientAddress_PROPERTY_READ_ONLY] FAIL " + ex.Message);
+ Assert.Fail("[TestCase][Completed_PROPERTY_READ_ONLY] FAIL " + ex.Message);
}
};
- srv = server.GetService(svcUuid);
- charc = srv.GetCharacteristic(charUuid);
+ srv = _server.GetService(_svcUuid);
+ charc = srv.GetCharacteristic(_charUuid);
charc.NotificationStateChanged += Charc_NotificationStateChanged;
}
catch (NotSupportedException)
{
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
string origin_val = null;
/* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
return;
}
- server = await BluetoothSetup.gatt_server_init();
- Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+ _server = await BluetoothSetup.gatt_server_init();
+ Assert.IsNotNull(_server, "Precondition failed: server instance should not be null");
EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
Server_NotificationSent = (sender, e) => {
- server.NotificationSent -= Server_NotificationSent;
+ _server.NotificationSent -= Server_NotificationSent;
Assert.IsInstanceOf<int>(e.Result, "[TestCase][Result_PROPERTY_READ_ONLY] Failed");
Assert.IsTrue((int)e.Result == 0, "[TestCase][Result_PROPERTY_READ_ONLY] Failed");
BluetoothHelper.DisplayPassLabel("Result_PROPERTY_READ_ONLY");
try
{
Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
- server.NotificationSent += Server_NotificationSent;
+ _server.NotificationSent += Server_NotificationSent;
origin_val = charc.GetValue(0);
- charc.SetValue(valueChanged);
- server.SendIndicationAsync(charc, null);
+ charc.SetValue(_valueChanged);
+ _server.SendIndicationAsync(charc, null);
charc.SetValue(origin_val);
}
}
};
- srv = server.GetService(svcUuid);
- charc = srv.GetCharacteristic(charUuid);
+ srv = _server.GetService(_svcUuid);
+ charc = srv.GetCharacteristic(_charUuid);
charc.NotificationStateChanged += Charc_NotificationStateChanged;
}
catch (NotSupportedException)
{
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
string origin_val = null;
/* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
return;
}
- server = await BluetoothSetup.gatt_server_init();
- Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+ _server = await BluetoothSetup.gatt_server_init();
+ Assert.IsNotNull(_server, "Precondition failed: server instance should not be null");
EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
Server_NotificationSent = (sender, e) => {
- server.NotificationSent -= Server_NotificationSent;
+ _server.NotificationSent -= Server_NotificationSent;
Assert.IsNotNull(e.Server, "[TestCase][Server_PROPERTY_READ_ONLY] Failed");
Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "[TestCase][Server_PROPERTY_READ_ONLY] Failed");
- Assert.AreSame(server, e.Server);
+ Assert.AreSame(_server, e.Server);
BluetoothHelper.DisplayPassLabel("Server_PROPERTY_READ_ONLY");
};
try
{
Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
- server.NotificationSent += Server_NotificationSent;
+ _server.NotificationSent += Server_NotificationSent;
origin_val = charc.GetValue(0);
- charc.SetValue(valueChanged);
- server.SendIndicationAsync(charc, null);
+ charc.SetValue(_valueChanged);
+ _server.SendIndicationAsync(charc, null);
charc.SetValue(origin_val);
}
}
};
- srv = server.GetService(svcUuid);
- charc = srv.GetCharacteristic(charUuid);
+ srv = _server.GetService(_svcUuid);
+ charc = srv.GetCharacteristic(_charUuid);
charc.NotificationStateChanged += Charc_NotificationStateChanged;
}
catch (NotSupportedException)
{
- if (isBluetoothGattServerSupported == false)
+ if (_isBluetoothGattServerSupported == false)
{
BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
[Description("SocketConnection Tests")]
public class SocketConnectionTests
{
- static bool isBluetoothSupported = false;
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ public void Init()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST");
- Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported);
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
}
[TearDown]
- public static void Destroy()
+ public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
BluetoothSetup.DestroyClientSocketUtil();
[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 static async Task SocketFd_READ_ONLY()
+ public async Task SocketFd_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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)
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task Address_READ_ONLY()
+ public async Task Address_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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)
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Address_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("Address_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task ServiceUuid_READ_ONLY()
+ public async Task ServiceUuid_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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)
{
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("ServiceUuid_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("ServiceUuid_READ_ONLY");
await ManualTest.WaitForConfirm();
}
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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");
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Client_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Client_READ_ONLY");
await ManualTest.WaitForConfirm();
[Description("SocketConnectionStateChangedEventArgs Tests")]
public class SocketConnectionStateChangedEventArgsTests
{
- static bool isBluetoothSupported = false;
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ public void Init()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST");
- Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported);
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
}
[TearDown]
- public static void Destroy()
+ public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
BluetoothSetup.DestroyClientSocketUtil();
[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 static async Task Connection_READ_ONLY()
+ public async Task Connection_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
- await BluetoothSetup.ConnectSocketUtil();
- Assert.IsNotNull(BluetoothSetup.ClientConnection, "[TestCase][Connection_READ_ONLY][Socket] Failed");
+ BluetoothSetup.CreateClientSocketUtil();
+ if (BluetoothSetup.Client == null)
+ {
+ ManualTest.DisplayCustomLabel("Precondition failed: Test device should be paired to the remote device.");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
- BluetoothHelper.DisplayPassLabel("Connection_READ_ONLY");
- await ManualTest.WaitForConfirm();
+ await BluetoothSetup.ConnectSocketUtil();
+ Assert.IsNotNull(BluetoothSetup.ClientConnection, "ClientConnection is null");
+ Assert.IsInstanceOf<SocketConnection>(BluetoothSetup.ClientConnection, "ClientConnection is not type of SocketConnection");
await BluetoothSetup.DisconnectSocketUtil();
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Connection_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("Connection_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task Result_READ_ONLY()
+ public async Task Result_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
- await BluetoothSetup.ConnectSocketUtil();
- if (BluetoothSetup.ClientResult == BluetoothError.None)
+ BluetoothSetup.CreateClientSocketUtil();
+ if (BluetoothSetup.Client == null)
{
- Log.Debug(Globals.LogTag, "[TestCase][Result_READ_ONLY][Socket] Pass");
- BluetoothHelper.DisplayPassLabel("Result_READ_ONLY");
+ ManualTest.DisplayCustomLabel("Precondition failed: Test device should be paired to the remote device.");
await ManualTest.WaitForConfirm();
+ return;
}
- else
- {
- Assert.Fail("[TestCase][Result_READ_ONLY][Socket] Failed");
- }
+
+ await BluetoothSetup.ConnectSocketUtil();
+ Assert.IsInstanceOf<BluetoothError>(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)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Result_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("Result_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task State_READ_ONLY()
+ public async Task State_READ_ONLY()
{
try
{
- //TEST CODE
- await BluetoothSetup.CreateClientSocketUtil();
- await BluetoothSetup.ConnectSocketUtil();
- if (BluetoothSocketState.Connected == BluetoothSetup.ClientState)
+ BluetoothSetup.CreateClientSocketUtil();
+ if (BluetoothSetup.Client == null)
{
- Log.Debug(Globals.LogTag, "[TestCase][State_READ_ONLY][Socket] Pass");
- BluetoothHelper.DisplayPassLabel("State_READ_ONLY");
+ ManualTest.DisplayCustomLabel("Precondition failed: Test device should be paired to the remote device.");
await ManualTest.WaitForConfirm();
+ return;
}
- else
- {
- Assert.Fail("[TestCase][State_READ_ONLY][Socket] Failed");
- }
+
+ await BluetoothSetup.ConnectSocketUtil();
+ Assert.IsInstanceOf<BluetoothSocketState>(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)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("State_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("State_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[Description("SocketData Tests")]
public class SocketDataTests
{
- private static bool flagDataReceived = false;
- static bool isBluetoothSupported = false;
+ private bool _flagDataReceived = false;
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ 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;
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
+ _flagDataReceived = false;
}
[TearDown]
- public static void Destroy()
+ public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
BluetoothSetup.DestroyClientSocketUtil();
BluetoothSetup.Data = null;
- flagDataReceived = false;
+ _flagDataReceived = false;
}
- public static void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args)
+ public void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args)
{
BluetoothSetup.Data = args.Data;
- flagDataReceived = true;
+ _flagDataReceived = true;
}
- public static async Task WaitClientDataReceivedFlag()
+ public async Task WaitClientDataReceivedFlag()
{
int count = 0;
while(true)
{
await Task.Delay(2000);
count++;
- if (flagDataReceived)
+ if (_flagDataReceived)
break;
if (count == 15)
break;
[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 static async Task SocketFd_READ_ONLY()
+ public async Task SocketFd_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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();
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("SocketFd_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task DataSize_READ_ONLY()
+ public async Task DataSize_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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();
BluetoothSetup.Client.DataReceived -= DataReceivedClientEventHandler;
await BluetoothSetup.DisconnectSocketUtil();
- }
+ }
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("DataSize_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("DataSize_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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 static async Task Data_READ_ONLY()
+ public async Task Data_READ_ONLY()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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();
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Data_READ_ONLY");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("Data_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[Description("SocketDataReceivedEventArgs Tests")]
public class SocketDataReceivedEventArgsTests
{
- private static bool flagClientDataReceived = false;
- private static bool flagServerDataReceived = false;
- static bool isBluetoothSupported = false;
+ private bool _flagClientDataReceived = false;
+ private bool _flagServerDataReceived = false;
+ private bool _isBluetoothSupported = false;
[SetUp]
- public static void Init()
+ 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;
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
+ _flagClientDataReceived = false;
+ _flagServerDataReceived = false;
}
[TearDown]
- public static void Destroy()
+ public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
}
- public static async Task WaitClientDataReceivedFlag()
+ public async Task WaitClientDataReceivedFlag()
{
int count = 0;
while(true)
{
await Task.Delay(2000);
count++;
- if (flagClientDataReceived)
+ if (_flagClientDataReceived)
break;
if (count == 15)
break;
}
}
- public static void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args)
+ public void DataReceivedClientEventHandler(object sender, SocketDataReceivedEventArgs args)
{
BluetoothSetup.Data = args.Data;
Log.Info(Globals.LogTag, "DataReceived in client: "+args.Data.Data);
- flagClientDataReceived = true;
+ _flagClientDataReceived = true;
}
[Test]
[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 static async Task Data_READ_ONLY_CLIENT()
+ public async Task Data_READ_ONLY_CLIENT()
{
try
{
- await BluetoothSetup.CreateClientSocketUtil();
+ 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");
+ Assert.IsTrue(_flagClientDataReceived, "[TestCase][Data_READ_ONLY_CLIENT][Socket] Failed");
BluetoothHelper.DisplayPassLabel("Data_READ_ONLY_CLIENT");
await ManualTest.WaitForConfirm();
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Data_READ_ONLY_CLIENT");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
BluetoothHelper.DisplayLabel("Data_READ_ONLY_CLIENT");
await ManualTest.WaitForConfirm();
}
}
}
- public static async Task WaitServerDataReceivedFlag()
+ public async Task WaitServerDataReceivedFlag()
{
int count = 0;
while(true)
{
await Task.Delay(2000);
count++;
- if (flagServerDataReceived)
+ if (_flagServerDataReceived)
break;
if (count == 15)
break;
}
}
- public static void DataReceivedServerEventHandler(object sender, SocketDataReceivedEventArgs args)
+ public void DataReceivedServerEventHandler(object sender, SocketDataReceivedEventArgs args)
{
BluetoothSetup.Data = args.Data;
Log.Info(Globals.LogTag, "DataReceived in client: "+args.Data.Data);
- flagServerDataReceived = true;
+ _flagServerDataReceived = true;
}
[Test]
[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 static async Task Data_READ_ONLY_SERVER()
+ public async Task Data_READ_ONLY_SERVER()
{
try
{
await BluetoothSetup.AcceptSocketUtil();
BluetoothSetup.Socket.DataReceived += DataReceivedServerEventHandler;
await WaitServerDataReceivedFlag();
- Assert.IsTrue(flagServerDataReceived, "[TestCase][Data_READ_ONLY_SERVER][Socket] Failed");
+ Assert.IsTrue(_flagServerDataReceived, "[TestCase][Data_READ_ONLY_SERVER][Socket] Failed");
BluetoothSetup.Socket.DataReceived -= DataReceivedServerEventHandler;
}
catch (NotSupportedException)
{
- if (isBluetoothSupported == false)
+ if (_isBluetoothSupported == false)
{
BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER");
await ManualTest.WaitForConfirm();
}
catch (TypeInitializationException e)
{
- if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ if (_isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
{
BluetoothHelper.DisplayLabel("Data_READ_ONLY_SERVER");
await ManualTest.WaitForConfirm();