[TCSACR-221][Bluetooth][Manual][Add new BluetoothGattClient TCs] 30/201430/9
authorWootak Jung <wootak.jung@samsung.com>
Thu, 14 Mar 2019 04:37:27 +0000 (13:37 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 18 Mar 2019 06:53:21 +0000 (15:53 +0900)
Change-Id: I29b877e8814c58750ec9a377f26d02ee7a23464d

tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs

index 8b930d7b7bccf1417a4f7cf8f096bf1514e242a9..84eb7ad66be8bd36450e6de47d8e8605d002d5fd 100644 (file)
@@ -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<BluetoothGattClient>(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<ValueChangedEventArgs> 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<byte[]>(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();
-            }
         }
     }
 }
index 2ed55c503a4c8ba30363e700bcbeb8cb132730ce..41205cdb6e8ed77dddf25696c193e7c77a258051 100644 (file)
@@ -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<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]
@@ -59,9 +340,13 @@ namespace Tizen.Network.Bluetooth.Tests
                     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());
             }
@@ -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<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");
@@ -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<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");
@@ -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<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);
 
@@ -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<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);
@@ -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<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);
 
@@ -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<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);
 
@@ -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<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)
             {
index a4742da1096a25ca29b8f98a29d92902281ac53c..1711f374ed3d494ba5d70afaec632f5c48f71af9 100755 (executable)
@@ -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<BluetoothGattClient>(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();
-            }
         }
     }
 }
index c4390f3f429cfdc0cc3c89661b51ebd41ad98b52..119994d4008eae57fcdf993641ebb21a6640e5a1 100644 (file)
@@ -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<BluetoothGattClient>(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<ValueChangedEventArgs> 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<byte[]>(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();
-            }
         }
     }
 }