From 598ce5cacf19cccbfb8b6dec06fd6b549a95c711 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 14 Mar 2019 13:37:27 +0900 Subject: [PATCH] [TCSACR-221][Bluetooth][Manual][Add new BluetoothGattClient TCs] Change-Id: I29b877e8814c58750ec9a377f26d02ee7a23464d --- .../testcase/TSBluetoothGattCharacteristic.cs | 27 +- .../testcase/TSBluetoothGattClient.cs | 391 +++++++++++++++--- .../testcase/TSBluetoothGattService.cs | 35 +- .../testcase/TSValueChangedEventArgs.cs | 31 +- 4 files changed, 397 insertions(+), 87 deletions(-) diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs index 8b930d7b7..84eb7ad66 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs @@ -20,6 +20,7 @@ namespace Tizen.Network.Bluetooth.Tests BluetoothGattServer server = null; string svcUuid = "181D"; string charUuid = "2A20"; + bool isClientConnected = false; [SetUp] public void Init() @@ -33,6 +34,16 @@ namespace Tizen.Network.Bluetooth.Tests public void Destroy() { LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + if (isClientConnected == true) + { + client.DisconnectAsync(); + isClientConnected = false; + } + + if (client != null) + { + client.Dispose(); + } } [Test] @@ -130,10 +141,14 @@ namespace Tizen.Network.Bluetooth.Tests return; } - client = await BluetoothSetup.gatt_client_init(); + client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); + Assert.IsInstanceOf(client, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - BluetoothGattService srv = BluetoothSetup.client.GetService(svcUuid); + await client.ConnectAsync(true); + isClientConnected = true; + + BluetoothGattService srv = client.GetService(svcUuid); BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); EventHandler Charc_ValueChanged = null; @@ -141,8 +156,7 @@ namespace Tizen.Network.Bluetooth.Tests Charc_ValueChanged = (sender, e) => { Assert.IsNotNull(e.Value, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); Assert.IsInstanceOf(e.Value, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); - - BluetoothHelper.DisplayPassLabel("ValueChanged_CHECK_EVENT"); + ManualTest.Confirm(); }; charc.ValueChanged += Charc_ValueChanged; @@ -171,11 +185,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } } } 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 2ed55c503..41205cdb6 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs @@ -20,8 +20,8 @@ namespace Tizen.Network.Bluetooth.Tests string charc_value = "1234"; string desc_value = "1"; bool isBluetoothGattClientSupported = false; - BluetoothLeDevice leDevice = null; BluetoothGattClient client = null; + bool isConnected = false; [SetUp] public void Init() @@ -34,6 +34,287 @@ namespace Tizen.Network.Bluetooth.Tests 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(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(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(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(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(client, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed"); + Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); + + EventHandler OnConnectionStateChanged = (sender, e) => + { + Assert.IsInstanceOf(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] @@ -59,9 +340,13 @@ namespace Tizen.Network.Bluetooth.Tests return; } - client = await BluetoothSetup.gatt_client_init(); + client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); + Assert.IsInstanceOf(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()); } @@ -85,11 +370,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -110,14 +390,18 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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"); @@ -142,11 +426,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -167,14 +446,18 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(client, "[TestCase][GetServices_RETURN_VALUE] Failed"); Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); + await client.ConnectAsync(true); + isConnected = true; + IEnumerable srv_list; srv_list = client.GetServices(); Assert.IsNotNull(srv_list, "Service list should not be null"); @@ -199,11 +482,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -225,14 +503,18 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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); @@ -259,11 +541,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -285,14 +562,18 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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); @@ -320,11 +601,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -347,15 +623,19 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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); @@ -385,11 +665,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -412,15 +687,19 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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); @@ -452,11 +731,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } [Test] @@ -467,6 +741,7 @@ namespace Tizen.Network.Bluetooth.Tests [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.")] @@ -477,16 +752,22 @@ namespace Tizen.Network.Bluetooth.Tests /* 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(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) { diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs index a4742da10..1711f374e 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs @@ -24,7 +24,8 @@ namespace Tizen.Network.Bluetooth.Tests { string svcUuid = "181D"; bool _isBluetoothGattClientSupported = false; - BluetoothGattClient _client = null; + BluetoothGattClient client = null; + bool isConnected = false; [SetUp] public void Init() @@ -37,6 +38,16 @@ namespace Tizen.Network.Bluetooth.Tests 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] @@ -59,28 +70,32 @@ namespace Tizen.Network.Bluetooth.Tests /* 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("GetGattClient_RETURN_VALUE"); await ManualTest.WaitForConfirm(); return; } - _client = await BluetoothSetup.gatt_client_init(); - Assert.IsNotNull(_client, "Precondition failed: _client instance should not be null"); + client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); + Assert.IsInstanceOf(client, "[TestCase][GetGattClient_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); + 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"); svc_client = srv.GetGattClient(); Assert.IsNotNull(svc_client, "svc_client returned should not be null"); - Assert.AreSame(_client, svc_client); + Assert.AreSame(client, svc_client); } catch (NotSupportedException) { if (_isBluetoothGattClientSupported == false) { - BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); + BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } } @@ -88,7 +103,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (_isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); + BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } } @@ -96,10 +111,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - await BluetoothSetup.gatt_client_exit(); - } } } } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs index c4390f3f4..119994d40 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs @@ -18,6 +18,7 @@ namespace Tizen.Network.Bluetooth.Tests BluetoothGattClient client = null; string svcUuid = "181D"; string charUuid = "2A20"; + bool isConnected = false; [SetUp] public void Init() @@ -30,6 +31,16 @@ namespace Tizen.Network.Bluetooth.Tests 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] @@ -55,10 +66,14 @@ namespace Tizen.Network.Bluetooth.Tests return; } - client = await BluetoothSetup.gatt_client_init(); + client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); + Assert.IsInstanceOf(client, "[TestCase][Value_READ_ONLY] 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); EventHandler Charc_ValueChanged = null; @@ -66,8 +81,7 @@ namespace Tizen.Network.Bluetooth.Tests Charc_ValueChanged = (sender, e) => { Assert.IsNotNull(e.Value, "[TestCase][Value_READ_ONLY] Failed"); Assert.IsInstanceOf(e.Value, "[TestCase][Value_READ_ONLY] Failed"); - - BluetoothHelper.DisplayPassLabel("Value_READ_ONLY"); + ManualTest.Confirm(); }; charc.ValueChanged += Charc_ValueChanged; @@ -80,7 +94,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (isBluetoothGattClientSupported == false) { - BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); + BluetoothHelper.DisplayLabel("Value_READ_ONLY"); await ManualTest.WaitForConfirm(); } } @@ -88,7 +102,7 @@ namespace Tizen.Network.Bluetooth.Tests { if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) { - BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); + BluetoothHelper.DisplayLabel("Value_READ_ONLY"); await ManualTest.WaitForConfirm(); } } @@ -96,11 +110,6 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } - finally - { - if (client != null) - await BluetoothSetup.gatt_client_exit(); - } } } } -- 2.34.1