string charc_value = "1234";
string desc_value = "1";
bool isBluetoothGattClientSupported = false;
- BluetoothLeDevice leDevice = null;
BluetoothGattClient client = null;
+ bool isConnected = false;
[SetUp]
public void Init()
public void Destroy()
{
LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
+ if (isConnected == true)
+ {
+ client.DisconnectAsync();
+ isConnected = false;
+ }
+
+ if (client != null)
+ {
+ client.Dispose();
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test CreateClient method of BluetoothGattClient")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.CreateClient M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+ [Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
+ [Step(1, "Tap the Run button.")]
+ [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
+ public async Task CreateClient_RETURN_VALUE()
+ {
+ try
+ {
+ /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][CreateClient_RETURN_VALUE] Failed");
+ Assert.IsNotNull(client, "Client instance should not be null");
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test ConnectAsync method of BluetoothGattClient with auto connection enabled")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+ [Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
+ [Step(1, "Tap the Run button.")]
+ [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
+ public async Task ConnectAsync_RETURN_VALUE_TRUE()
+ {
+ try
+ {
+ /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][ConnectAsync_RETURN_VALUE] Failed");
+ Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+
+ await client.ConnectAsync(true);
+ isConnected = true;
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test ConnectAsync method of BluetoothGattClient with auto connection disabled")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+ [Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
+ [Step(1, "Tap the Run button.")]
+ [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
+ public async Task ConnectAsync_RETURN_VALUE_FALSE()
+ {
+ try
+ {
+ /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][ConnectAsync_RETURN_VALUE] Failed");
+ Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+
+ await client.ConnectAsync(false);
+ isConnected = true;
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test DisconnectAsync method of BluetoothGattClient")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.DisconnectAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+ [Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
+ [Step(1, "Tap the Run button.")]
+ [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
+ public async Task DisconnectAsync_RETURN_VALUE()
+ {
+ try
+ {
+ /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][DisconnectAsync_RETURN_VALUE] Failed");
+ Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+
+ await client.ConnectAsync(true);
+ isConnected = true;
+
+ await client.DisconnectAsync();
+ isConnected = false;
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test ConnectionStateChanged event of BluetoothGattClient")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectionStateChanged E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+ [Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
+ [Step(1, "Tap the Run button.")]
+ [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
+ public async Task ConnectionStateChanged_CHECK_EVENT()
+ {
+ try
+ {
+ /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed");
+ Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+
+ EventHandler<GattConnectionStateChangedEventArgs> OnConnectionStateChanged = (sender, e) =>
+ {
+ Assert.IsInstanceOf<bool>(e.IsConnected, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed");
+ Assert.IsTrue(e.IsConnected == true, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed");
+ ManualTest.Confirm();
+ };
+ client.ConnectionStateChanged += OnConnectionStateChanged;
+
+ await client.ConnectAsync(true);
+ isConnected = true;
+ await ManualTest.WaitForConfirm();
+
+ client.ConnectionStateChanged -= OnConnectionStateChanged;
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothGattClientSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
}
[Test]
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][RemoteAddress_PROPERTY_READ_ONLY] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
Assert.IsNotNull(client.RemoteAddress, "RemoteAddress shold not be null");
Assert.AreEqual(client.RemoteAddress, PreconditionUtils.GetBleAddress());
}
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][GetService_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
BluetoothGattService srv = client.GetService(svcUuid);
Assert.IsNotNull(srv, "Service returned should not be null");
Assert.AreEqual(srv.Uuid, svcUuid, "Fetched Service UUID is not matching");
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][GetServices_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
IEnumerable<BluetoothGattService> srv_list;
srv_list = client.GetServices();
Assert.IsNotNull(srv_list, "Service list should not be null");
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][ReadValueAsync_Characteristic_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
BluetoothGattService srv = client.GetService(svcUuid);
BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid);
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][ReadValueAsync_Descriptor_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
BluetoothGattService srv = client.GetService(svcUuid);
BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid);
BluetoothGattDescriptor desc = charc.GetDescriptor(descUuid);
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][WriteValueAsync_Characteristic_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
- BluetoothGattService srv = BluetoothSetup.client.GetService(svcUuid);
+ await client.ConnectAsync(true);
+ isConnected = true;
+
+ BluetoothGattService srv = client.GetService(svcUuid);
BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid);
charc.SetValue(charc_value);
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][WriteValueAsync_Descriptor_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
- BluetoothGattService srv = BluetoothSetup.client.GetService(svcUuid);
+ await client.ConnectAsync(true);
+ isConnected = true;
+
+ BluetoothGattService srv = client.GetService(svcUuid);
BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid);
BluetoothGattDescriptor desc = charc.GetDescriptor(descUuid);
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
- finally
- {
- if (client != null)
- await BluetoothSetup.gatt_client_exit();
- }
}
[Test]
[Property("CRITERIA", "MCST")]
[Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")]
[Precondition(1, "Bluetooth should be turned on.")]
+ [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")]
[Step(1, "Tap the Run button.")]
[Step(2, "TC should pass automatically.")]
[Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
/* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */
if (isBluetoothGattClientSupported == false)
{
- BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY");
+ BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE");
await ManualTest.WaitForConfirm();
return;
}
- client = await BluetoothSetup.gatt_client_init();
+ client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress());
+ Assert.IsInstanceOf<BluetoothGattClient>(client, "[TestCase][DestroyClient_RETURN_VALUE] Failed");
Assert.IsNotNull(client, "Precondition failed: client instance should not be null");
- bool status = await BluetoothSetup.gatt_client_exit();
- Assert.IsTrue(status, "Status should be true");
+ await client.ConnectAsync(true);
+ isConnected = true;
+
+ await client.DisconnectAsync();
+ isConnected = false;
+
+ client.Dispose();
}
catch (NotSupportedException)
{