[Non-ACR][Bluetooth][Manual][Enable Bluetooth GATT Server TCs] 25/198825/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 30 Jan 2019 06:03:05 +0000 (15:03 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 30 Jan 2019 06:03:05 +0000 (15:03 +0900)
Change-Id: I45325f323e81f7fd0282960de5644838d09b6c06
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattAttribute.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattServer.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationSentEventArg.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationStateChangedEventArg.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSReadRequestedEventArgs.cs
tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSWriteRequestedEventArgs.cs

index 1a0bbb3..166bb52 100644 (file)
@@ -715,23 +715,6 @@ namespace BluetoothNetworkUtils
             return BtLeScanDevice;
         }
 
-
-        /* GATT Server*/
-        public static async Task WaitAdvertisingFlag()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitAdvertisingFlag");
-                await Task.Delay(1000);
-                count++;
-                if (advertisingFlag)
-                    break;
-                if (count == 8)
-                    break;
-            }
-        }
-
         public static void AdvertisingChangedEventHandler(object sender, AdvertisingStateChangedEventArgs e)
         {
             if ((int)e.State == (int)BluetoothLeAdvertisingState.BluetoothLeAdvertisingStarted)
@@ -740,97 +723,149 @@ namespace BluetoothNetworkUtils
                 advertisingFlag = false;
         }
 
-        public static async Task AdvertiseSetup()
+        public static bool StartAdvertising()
         {
-            // TEST CODE
-            if (!advertisingFlag)
+            string name = BluetoothAdapter.Name;
+
+            if (advertisingFlag == true)
             {
-                advertiser.StartAdvertising(advertiseData);
-                await WaitAdvertisingFlag();
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Already adverising...");
+                return true;
             }
-        }
 
-        public static async Task StartAdvertising()
-        {
-            if (advertiser == null)
-                advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();
-            if (advertiseData == null)
+            try
             {
-                advertiseData = new BluetoothLeAdvertiseData();
-                advertiseData.AdvertisingMode = BluetoothLeAdvertisingMode.BluetoothLeAdvertisingBalancedMode;
-                advertiseData.AdvertisingConnectable = true;
-                advertiseData.Appearance = 192;
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "StartAdvertising");
 
-                BluetoothLePacketType packetType = BluetoothLePacketType.BluetoothLeAdvertisingPacket;
-                string serviceUuid = "1805"; /*time_svc_uuid_16*/
-                advertiseData.AddAdvertisingServiceUuid(packetType, serviceUuid);
+                if (advertiser == null)
+                {
+                    advertiser = BluetoothAdapter.GetBluetoothLeAdvertiser();
+                    advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
+                }
 
-                string serviceSolicitationUuid = "180d"; /*heart_rate_svc_uuid_16*/
-                advertiseData.AddAdvertisingServiceSolicitationUuid(packetType, serviceSolicitationUuid);
+                if (advertiseData == null)
+                {
+                    /* Change the name, because the adversement data size is limited - 32 byte */
+                    BluetoothAdapter.Name = "T";
+
+                    advertiseData = new BluetoothLeAdvertiseData();
+                    advertiseData.AdvertisingMode = BluetoothLeAdvertisingMode.BluetoothLeAdvertisingBalancedMode;
+                    advertiseData.AdvertisingConnectable = true;
+                    advertiseData.Appearance = 192;
+
+                    BluetoothLePacketType packetType = BluetoothLePacketType.BluetoothLeAdvertisingPacket;
+                    string serviceUuid = "1805"; /*time_svc_uuid_16*/
+                    advertiseData.AddAdvertisingServiceUuid(packetType, serviceUuid);
+
+                    string serviceSolicitationUuid = "180d"; /*heart_rate_svc_uuid_16*/
+                    advertiseData.AddAdvertisingServiceSolicitationUuid(packetType, serviceSolicitationUuid);
+
+                    advertiseData.IncludeDeviceName = true;
+                    advertiseData.IncludeTxPowerLevel = true;
+
+                    /*Add sample Manufacturer Data for testing*/
+                    ManufacturerData manufData = new ManufacturerData();
+                    manufData.Data = new byte[1] { 0x01 };
+                    manufData.Id = 117;
+                    manufData.DataLength = 1;
+                    advertiseData.AddAdvertisingManufacturerData(packetType, manufData);
+
+                    /*Add sample service Data for testing*/
+                    BluetoothServiceData serviceData = new BluetoothServiceData();
+                    serviceData.Uuid = "1805";
+                    serviceData.DataLength = 1;
+                    serviceData.Data = new byte[1] { 0x01 };
+
+                    advertiseData.AddAdvertisingServiceData(packetType, serviceData);
+
+                    advertiseData.AddAdvertisingServiceData(BluetoothLePacketType.BluetoothLeScanResponsePacket, serviceData);
+                    advertiseData.AddAdvertisingServiceUuid(BluetoothLePacketType.BluetoothLeScanResponsePacket, serviceUuid);
+                    advertiseData.AddAdvertisingServiceSolicitationUuid(BluetoothLePacketType.BluetoothLeScanResponsePacket, serviceSolicitationUuid);
+                    advertiseData.AddAdvertisingManufacturerData(BluetoothLePacketType.BluetoothLeScanResponsePacket, manufData);
+                }
 
-                /*Add sample service Data for testing*/
-                BluetoothServiceData serviceData = new BluetoothServiceData();
-                serviceData.Uuid = "1805";
-                serviceData.DataLength = 3;
-                serviceData.Data = new byte[3] { 0x01, 0x02, 0x03 };
-                advertiseData.AddAdvertisingServiceData(packetType, serviceData);
+                /* Start Advertisement */
+                advertiser.StartAdvertising(advertiseData);
 
-                advertiseData.IncludeDeviceName = true;
-                advertiseData.IncludeTxPowerLevel = true;
+                BluetoothAdapter.Name = name;
 
-                /*Add sample Manufacturer Data for testing*/
-                //ManufacturerData manufData = new ManufacturerData();
-                //manufData.Data = new byte[5] { 0x01, 0x02, 0x03, 0x04, 0x05 };
-                //manufData.Id = 117;
-                //manufData.DataLength = 5;
-                //advertiseData.AddAdvertisingManufacturerData(packetType, manufData);
+                return true;
+            } catch(Exception e) {
+                Log.Info(Globals.LogTag, "Exception in StartAdvertising" + e.Message);
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Exception in StartAdvertising" + e.Message);
+                BluetoothAdapter.Name = name;
+                return false;
             }
-
-            advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
-            await AdvertiseSetup();
-            Assert.IsTrue(advertisingFlag, "Advertisement failed");
         }
-        public static async Task gatt_server_init()
-        {
-            role = "server";
-            Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
 
-            await StartAdvertising();
+        public static async Task<BluetoothGattServer> gatt_server_init()
+        {
+            try
+            {
+                BluetoothGattService service1 = null;
+                BluetoothGattCharacteristic charc1 = null;
+                BluetoothGattDescriptor desc1 = null;
+                BluetoothGattDescriptor cccdesc1 = null;
 
-            server = BluetoothGattServer.CreateServer();
-            Assert.IsNotNull(server, "PRECONDITION Failed: server should not be null.");
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
 
-            service = new BluetoothGattService(serviceUuid, BluetoothGattServiceType.Primary);
-            Assert.IsNotNull(service, "PRECONDITION Failed: service should not be null.");
+                if (server != null && advertisingFlag == true)
+                {
+                    LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "server exist & in advertising");
+                    return server;
+                }
 
-            charc = new BluetoothGattCharacteristic(characteristicUuid, characteristicPermission, characteristicProperties, characteristicValue);
-            Assert.IsNotNull(charc, "PRECONDITION Failed: characteristic should not be null.");
+                if (server == null)
+                {
+                    server = BluetoothGattServer.CreateServer();
+                    service = new BluetoothGattService(serviceUuid, BluetoothGattServiceType.Primary);
+                    charc = new BluetoothGattCharacteristic(characteristicUuid, characteristicPermission, characteristicProperties, characteristicValue);
+                    desc = new BluetoothGattDescriptor(descriptorUuid, descriptorPermissions, descriptorValue);
+                    cccdesc = new BluetoothGattDescriptor(cccdescriptorUuid, cccdescriptorPermissions, cccdescriptorValue);
+
+                    charc.AddDescriptor(desc);
+                    charc.AddDescriptor(cccdesc);
+                    service.AddCharacteristic(charc);
+                    server.RegisterGattService(service);
+                    server.Start();
+                }
 
-            desc = new BluetoothGattDescriptor(descriptorUuid, descriptorPermissions, descriptorValue);
-            Assert.IsNotNull(desc, "PRECONDITION Failed: descriptor should not be null.");
+                if (StartAdvertising() == false)
+                {
+                    Log.Info(Globals.LogTag, "Fail to start advertisement");
+                    gatt_server_exit();
+                    return null;
+                }
 
-            cccdesc = new BluetoothGattDescriptor(cccdescriptorUuid, cccdescriptorPermissions, cccdescriptorValue);
-            Assert.IsNotNull(cccdesc, "PRECONDITION Failed: descriptor should not be null.");
+                LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "done");
 
-            charc.AddDescriptor(desc);
-            charc.AddDescriptor(cccdesc);
-            service.AddCharacteristic(charc);
-            server.RegisterGattService(service);
-            server.Start();
+                return server;
+            } catch(Exception e) {
+                Log.Info(Globals.LogTag, "Exception in gatt server init : " + e.Message);
+                gatt_server_exit();
+                return null;
+            }
         }
 
         public static void gatt_server_exit()
         {
-            if (!server.Equals(null))
+            if (advertiser != null)
+                advertiser.StopAdvertising(advertiseData);
+
+            if (advertiseData != null)
             {
-                server.UnregisterGattServices();
+                advertiseData.Dispose();
+                advertiseData = null;
             }
-            if (!advertiser.Equals(null))
+
+/*
+            if (server != null)
             {
-                advertiser.StopAdvertising(advertiseData);
-                advertisingFlag = false;
+                server.UnregisterGattServices();
+                server.DestroyServer();
+                server = null;
             }
-            role = "";
+*/
         }
 
         public static void gatt_client_destroy()
index a4048d1..92d7d72 100755 (executable)
@@ -5,6 +5,7 @@ using NUnit.Framework.TUnit;
 using Tizen.System;
 using System;
 using Xamarin.Forms;
+using System.Text;
 
 namespace Tizen.Network.Bluetooth.Tests
 {
@@ -12,72 +13,29 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("BluetoothGattAttribute Tests")]
     public class BluetoothGattAttributeTests
     {
-        static bool ReadRequested_flag = false;
-        static bool WriteRequested_flag = false;
-        static bool isBluetoothLeSupported = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
+        string descUuid = "2901";
+        byte[] charValue = Encoding.UTF8.GetBytes("charValue");
+        byte[] descValue = { 0, 0 };
 
         [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.le", out isBluetoothLeSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        private static void Charc_ReadRequested(object sender, ReadRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Read, 0, BluetoothSetup.characteristicValue, BluetoothSetup.characteristicValue.Length - e.Offset);
-            ReadRequested_flag = true;
-        }
-
-
-        public static async Task WaitReadRequested()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitReadRequested");
-                await Task.Delay(3000);
-                count++;
-                if (ReadRequested_flag)
-                    break;
-                if (count == 15)
-                    break;
-            }
-        }
-
-        private static void Charc_WriteRequested(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-        }
-
-        public static async Task WaitWriteRequested()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitWriteRequested");
-                await Task.Delay(3000);
-                count++;
-                if (WriteRequested_flag)
-                    break;
-                if (count == 15)
-                    break;
-            }
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check whether ReadRequested callback is getting invoked or not for Characteristics")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")]
@@ -89,20 +47,52 @@ namespace Tizen.Network.Bluetooth.Tests
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
         [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task ReadRequested_Characteristics_CHECK_EVENT()
+        public async Task ReadRequested_Characteristics_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.ReadRequested += Charc_ReadRequested;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.charc.ReadRequested -= Charc_ReadRequested;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Charc_ReadRequested = null;
+
+                Charc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, charValue, charValue.Length - e.Offset);
+                        BluetoothHelper.DisplayPassLabel("ReadRequested_Characteristics_CHECK_EVENT");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ReadRequested_Characteristics_CHECK_EVENT] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.ReadRequested += Charc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.ReadRequested -= Charc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
-                if (isBluetoothLeSupported == false)
+                if (isBluetoothGattServerSupported == false)
                 {
                     BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
@@ -110,8 +100,8 @@ namespace Tizen.Network.Bluetooth.Tests
             }
             catch (TypeInitializationException e)
             {
-                if (isBluetoothLeSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+                {
                     BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
                 }
@@ -122,7 +112,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check whether ReadRequested callback is getting invoked or not for Desriptor")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")]
@@ -134,17 +124,52 @@ namespace Tizen.Network.Bluetooth.Tests
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Descriptor_RETURN_VALUE test case on the client device.")]
         [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task ReadRequested_Descriptor_CHECK_EVENT()
+        public async Task ReadRequested_Descriptor_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.desc.ReadRequested += Charc_ReadRequested;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.desc.ReadRequested -= Charc_ReadRequested;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                BluetoothGattDescriptor desc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ReadRequested_Descriptor_CHECK_EVENT");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Desc_ReadRequested = null;
+
+                Desc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, descValue, 0);
+                        BluetoothHelper.DisplayPassLabel("ReadRequested_Descriptor_CHECK_EVENT");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ReadRequested_Descriptor_CHECK_EVENT] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+                desc = charc.GetDescriptor(descUuid);
+
+                desc.ReadRequested += Desc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                desc.ReadRequested -= Desc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -156,7 +181,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("ReadRequested_Descriptor_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
                 }
@@ -167,7 +192,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check whether WriteRequested callback is getting invoked or not for Characteristics")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")]
@@ -177,19 +202,53 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task WriteRequested_Characteristics_CHECK_EVENT()
+        public async Task WriteRequested_Characteristics_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write,
+                                            (int)BluetoothError.None, e.Value, 0);
+
+                        BluetoothHelper.DisplayPassLabel("ReadRequested_Characteristics_CHECK_EVENT");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ReadRequested_Characteristics_CHECK_EVENT] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -201,7 +260,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("WriteRequested_Characteristics_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
                 }
@@ -212,7 +271,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check whether WriteRequested callback is getting invoked or not for Descriptor")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")]
@@ -222,19 +281,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Descriptor_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task WriteRequested_Descriptor_CHECK_EVENT()
+        public async Task WriteRequested_Descriptor_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.desc.WriteRequested += Charc_WriteRequested;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.desc.WriteRequested -= Charc_WriteRequested;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                BluetoothGattDescriptor desc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("WriteRequested_Descriptor_CHECK_EVENT");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Desc_WriteRequested = null;
+
+                Desc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write,
+                                            (int)BluetoothError.None, e.Value, 0);
+
+                        BluetoothHelper.DisplayPassLabel("WriteRequested_Descriptor_CHECK_EVENT");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][WriteRequested_Descriptor_CHECK_EVENT] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+                desc = charc.GetDescriptor(descUuid);
+
+                desc.WriteRequested += Desc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                desc.WriteRequested -= Desc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -246,7 +341,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("WriteRequested_Descriptor_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
                 }
index 05d208d..8b930d7 100644 (file)
@@ -14,14 +14,15 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("BluetoothGattCharacteristic Tests")]
     public class BluetoothGattCharacteristicTests
     {
-        static bool isBluetoothGattServerSupported = false;
-        static bool isBluetoothGattClientSupported = false;
-        static BluetoothGattClient client = null;
-        static string svcUuid = "181D";
-        static string charUuid = "2A20";
+        bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattClientSupported = false;
+        BluetoothGattClient client = null;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
 
         [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.le.gatt.server", out isBluetoothGattServerSupported);
@@ -29,19 +30,9 @@ namespace Tizen.Network.Bluetooth.Tests
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
-
-            if (BluetoothSetup.role.Equals("server"))
-            {
-                BluetoothSetup.gatt_server_exit();
-            }
-        }
-
-        private static void Charc_NotificationStateChanged(object sender, NotificationStateChangedEventArg e)
-        {
-            ManualTest.Confirm();
         }
 
         [Test]
@@ -54,18 +45,42 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task NotificationStateChanged_CHECK_EVENT()
+        public async Task NotificationStateChanged_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
+
+                Charc_NotificationStateChanged = (sender, e) => {
+                    Assert.IsNotNull(e.Server, "[TestCase][NotificationStateChanged_CHECK_EVENT] Failed");
+                    Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "[TestCase][NotificationStateChanged_CHECK_EVENT] Failed");
+                    BluetoothHelper.DisplayPassLabel("NotificationStateChanged_CHECK_EVENT");
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
                 await ManualTest.WaitForConfirm();
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-               }
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -86,6 +101,10 @@ namespace Tizen.Network.Bluetooth.Tests
             {
                 Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
             }
+            finally
+            {
+                BluetoothSetup.gatt_server_exit();
+            }
         }
 
         [Test]
@@ -99,7 +118,7 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(2, "Run BluetoothGattServerTests.SendIndicationAsync_RETURN_VALUE 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 static async Task ValueChanged_CHECK_EVENT()
+        public async Task ValueChanged_CHECK_EVENT()
         {
             try
             {
index 6fdbeba..1f4f0f1 100755 (executable)
@@ -12,67 +12,27 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("BluetoothGattServer Tests")]
     public class BluetoothGattServerTests
     {
-        static bool NotificationStateChanged_flag = false;
-        static bool NotificationSent_flag = false;
-        static bool isBluetoothLeSupported = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
+        string valueChanged = "valueChanged";
 
         [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.le", out isBluetoothLeSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        private static void Charc_NotificationStateChanged(object sender, NotificationStateChangedEventArg e)
-        {
-            NotificationStateChanged_flag = true;
-        }
-
-        public static async Task WaitNotificationStateChanged()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitNotificationStateChanged");
-                await Task.Delay(3000);
-                count++;
-                if (NotificationStateChanged_flag)
-                    break;
-                if (count == 20)
-                    break;
-            }
-        }
-
-        private static void Server_NotificationSent(object sender, NotificationSentEventArg e)
-        {
-            NotificationSent_flag = true;
-        }
-
-        public static async Task WaitNotificationSent()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitNotificationSent");
-                await Task.Delay(3000);
-                count++;
-                if (NotificationSent_flag)
-                    break;
-                if (count == 20)
-                    break;
-            }
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check whether NotificationSent callback is getting invoked or not")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.NotificationSent E")]
@@ -82,32 +42,63 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task NotificationSent_CHECK_EVENT()
+        public async Task NotificationSent_CHECK_EVENT()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("NotificationSent_CHECK_EVENT");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
 
-                BluetoothSetup.server.NotificationSent += Server_NotificationSent;
+                Server_NotificationSent = (sender, e) => {
+                    server.NotificationSent -= Server_NotificationSent;
+                    Assert.IsTrue((int)e.Result == 0, "[TestCase][NotificationSent_CHECK_EVENT] Failed");
+                    BluetoothHelper.DisplayPassLabel("NotificationSent_CHECK_EVENT");
+                };
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);;
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
 
-                await WaitNotificationSent();
-                Assert.IsTrue(NotificationSent_flag, "NotificationSent callback is not invoked");
-                BluetoothSetup.server.NotificationSent -= Server_NotificationSent;
-                NotificationSent_flag = false;
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+                        server.NotificationSent += Server_NotificationSent;
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
+
+                        charc.SetValue(origin_val);
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][NotificationSent_CHECK_EVENT] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -119,7 +110,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("NotificationSent_CHECK_EVENT");
                     await ManualTest.WaitForConfirm();
                 }
@@ -130,7 +121,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check SendIndicationAsync method of BluetoothGattServer")]
         [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.SendIndicationAsync M")]
@@ -142,25 +133,57 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task SendIndicationAsync_RETURN_VALUE()
+        public async Task SendIndicationAsync_RETURN_VALUE()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
+
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                        Task.Delay(500).Wait();
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                        charc.SetValue(origin_val);
+                        BluetoothHelper.DisplayPassLabel("SendIndicationAsync_RETURN_VALUE");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][SendIndicationAsync_RETURN_VALUE] FAIL " + ex.Message);
+                    }
+                };
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -172,7 +195,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE");
                     await ManualTest.WaitForConfirm();
                 }
index 125c57f..15a0f32 100755 (executable)
@@ -13,89 +13,27 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("NotificationSentEventArg Tests")]
     public class NotificationSentEventArgTests
     {
-        static bool NotificationStateChanged_flag = false;
-        static bool NotificationSent_flag = false;
-        static bool isBluetoothLeSupported = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
+        string valueChanged = "valueChanged";
 
         [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.le", out isBluetoothLeSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        private static void Charc_NotificationStateChanged(object sender, NotificationStateChangedEventArg e)
-        {
-            NotificationStateChanged_flag = true;
-        }
-
-        public static async Task WaitNotificationStateChanged()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitNotificationStateChanged");
-                await Task.Delay(3000);
-                count++;
-                if (NotificationStateChanged_flag)
-                    break;
-                if (count == 20)
-                    break;
-            }
-        }
-
-        private static void Server_NotificationSent1(object sender, NotificationSentEventArg e)
-        {
-            NotificationSent_flag = true;
-            Assert.IsInstanceOf<string>(e.ClientAddress, "ClientAddress is not of string tpe");
-        }
-
-        private static void Server_NotificationSent2(object sender, NotificationSentEventArg e)
-        {
-            NotificationSent_flag = true;
-            Assert.IsInstanceOf<bool>(e.Completed, "Completed parameter should be of type bool");
-            Assert.IsTrue(e.Completed, "notification sent is not completed");
-        }
-
-        private static void Server_NotificationSent3(object sender, NotificationSentEventArg e)
-        {
-            NotificationSent_flag = true;
-            Assert.IsInstanceOf<int>(e.Result, "Result parameter should be of type int");
-            Assert.AreEqual(e.Result, (int)BluetoothError.None);
-        }
-
-        private static void Server_NotificationSent4(object sender, NotificationSentEventArg e)
-        {
-            NotificationSent_flag = true;
-            Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "Server should be of type BluetoothGattServer");
-            Assert.AreSame(BluetoothSetup.server, e.Server);
-        }
-
-        public static async Task WaitNotificationSent()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitNotificationSent");
-                await Task.Delay(3000);
-                count++;
-                if (NotificationSent_flag)
-                    break;
-                if (count == 20)
-                    break;
-            }
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check ClientAddress parameter of NotificationSentEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.ClientAddress A")]
@@ -105,32 +43,64 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task ClientAddress_PROPERTY_READ_ONLY()
+        public async Task ClientAddress_PROPERTY_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
 
-                BluetoothSetup.server.NotificationSent += Server_NotificationSent1;
+                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                Server_NotificationSent = (sender, e) => {
+                    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");
+                };
 
-                await WaitNotificationSent();
-                Assert.IsTrue(NotificationSent_flag, "NotificationSent callback is not invoked");
-                BluetoothSetup.server.NotificationSent -= Server_NotificationSent1;
-                NotificationSent_flag = false;
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+                        server.NotificationSent += Server_NotificationSent;
+
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
+
+                        charc.SetValue(origin_val);
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ClientAddress_PROPERTY_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -142,7 +112,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -153,7 +123,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Completed parameter of NotificationSentEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Completed A")]
@@ -163,32 +133,64 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Completed_PROPERTY_READ_ONLY()
+        public async Task Completed_PROPERTY_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                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");
+
+                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
+
+                Server_NotificationSent = (sender, e) => {
+                    server.NotificationSent -= Server_NotificationSent;
+                    Assert.IsTrue(e.Completed == true, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed");
+                    Assert.IsInstanceOf<bool>(e.Completed, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed");
+                    BluetoothHelper.DisplayPassLabel("Completed_PROPERTY_READ_ONLY");
+                };
+
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
+
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+                        server.NotificationSent += Server_NotificationSent;
+
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
+
+                        charc.SetValue(origin_val);
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ClientAddress_PROPERTY_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
 
-                BluetoothSetup.server.NotificationSent += Server_NotificationSent2;
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
 
-                await WaitNotificationSent();
-                Assert.IsTrue(NotificationSent_flag, "NotificationSent callback is not invoked");
-                BluetoothSetup.server.NotificationSent -= Server_NotificationSent2;
-                NotificationSent_flag = false;
+                await ManualTest.WaitForConfirm();
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -200,7 +202,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -211,7 +213,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Result parameter error code in NotificationSentEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Result A")]
@@ -221,32 +223,64 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Result_PROPERTY_READ_ONLY()
+        public async Task Result_PROPERTY_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                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");
+
+                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                Server_NotificationSent = (sender, e) => {
+                    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");
+                };
 
-                BluetoothSetup.server.NotificationSent += Server_NotificationSent3;
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+                        server.NotificationSent += Server_NotificationSent;
 
-                await WaitNotificationSent();
-                Assert.IsTrue(NotificationSent_flag, "NotificationSent callback is not invoked");
-                BluetoothSetup.server.NotificationSent -= Server_NotificationSent3;
-                NotificationSent_flag = false;
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                        charc.SetValue(origin_val);
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Result_PROPERTY_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -258,7 +292,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -269,7 +303,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Server parameter of NotificationSentEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Server A")]
@@ -279,32 +313,65 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Server_PROPERTY_READ_ONLY()
+        public async Task Server_PROPERTY_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+                string origin_val = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                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");
+
+                EventHandler<NotificationSentEventArg> Server_NotificationSent = null;
+
+                Server_NotificationSent = (sender, e) => {
+                    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);
+                    BluetoothHelper.DisplayPassLabel("Server_PROPERTY_READ_ONLY");
+                };
 
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
 
-                BluetoothSetup.server.NotificationSent += Server_NotificationSent4;
+                Charc_NotificationStateChanged = (sender, e) => {
+                    try
+                    {
+                        Log.Info(Globals.LogTag, "Charc_NotificationStateChanged");
+                        server.NotificationSent += Server_NotificationSent;
 
-                BluetoothSetup.charc.SetValue(BluetoothSetup.valueChanged);
-                bool status = await BluetoothSetup.server.SendIndicationAsync(BluetoothSetup.charc, null);
-                Assert.IsTrue(status, "status should be true");
+                        origin_val = charc.GetValue(0);
+                        charc.SetValue(valueChanged);
+                        server.SendIndicationAsync(charc, null);
 
-                await WaitNotificationSent();
-                Assert.IsTrue(NotificationSent_flag, "NotificationSent callback is not invoked");
-                BluetoothSetup.server.NotificationSent -= Server_NotificationSent4;
-                NotificationSent_flag = false;
+                        charc.SetValue(origin_val);
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Server_PROPERTY_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
 
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged;
-                NotificationStateChanged_flag = false;
-               }
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -316,7 +383,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
index 412ddd8..82af906 100755 (executable)
@@ -13,52 +13,26 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("NotificationStateChangedEventArg Tests")]
     public class NotificationStateChangedEventArgTests
     {
-        static bool NotificationStateChanged_flag = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
 
         [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.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        public static async Task WaitNotificationStateChanged()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitNotificationStateChanged");
-                await Task.Delay(3000);
-                count++;
-                if (NotificationStateChanged_flag)
-                    break;
-                if (count == 20)
-                    break;
-            }
-        }
-        private static void Charc_NotificationStateChanged1(object sender, NotificationStateChangedEventArg e)
-        {
-            NotificationStateChanged_flag = true;
-            Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "Server is not of BluetoothGattServer type");
-            Assert.AreSame(BluetoothSetup.server, e.Server);
-        }
-
-        private static void Charc_NotificationStateChanged2(object sender, NotificationStateChangedEventArg e)
-        {
-            NotificationStateChanged_flag = true;
-            Assert.IsInstanceOf<bool>(e.Value, "Value param is not of bool type");
-            Assert.IsTrue(e.Value, "notification is not enabled");
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Server parameter of NotificationStateChangedEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Server A")]
@@ -68,20 +42,43 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Server_READ_ONLY()
+        public async Task Server_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged1;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged1;
-                NotificationStateChanged_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Server_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
+
+                Charc_NotificationStateChanged = (sender, e) => {
+                    Assert.IsNotNull(e.Server, "[TestCase][Server_READ_ONLY] Failed");
+                    Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "[TestCase][Server_READ_ONLY] Failed");
+                    Assert.AreSame(server, e.Server);
+                    BluetoothHelper.DisplayPassLabel("Server_READ_ONLY");
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -104,7 +101,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Value parameter of NotificationStateChangedEventArg")]
         [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Value A")]
@@ -114,20 +111,42 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattCharacteristicTests.ValueChanged_CHECK_EVENT test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Value_READ_ONLY()
+        public async Task Value_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-
-                BluetoothSetup.charc.NotificationStateChanged += Charc_NotificationStateChanged2;
-                await WaitNotificationStateChanged();
-                Assert.IsTrue(NotificationStateChanged_flag, "NotificationStateChanged callback is not invoked");
-                BluetoothSetup.charc.NotificationStateChanged -= Charc_NotificationStateChanged2;
-                NotificationStateChanged_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Value_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<NotificationStateChangedEventArg> Charc_NotificationStateChanged = null;
+
+                Charc_NotificationStateChanged = (sender, e) => {
+                    Assert.IsNotNull(e.Value, "[TestCase][Value_READ_ONLY] Failed");
+                    Assert.IsInstanceOf<bool>(e.Value, "[TestCase][Value_READ_ONLY] Failed");
+                    BluetoothHelper.DisplayPassLabel("Value_READ_ONLY");
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.NotificationStateChanged += Charc_NotificationStateChanged;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.NotificationStateChanged -= Charc_NotificationStateChanged;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -139,7 +158,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Value_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
index f8b0565..f713c3e 100755 (executable)
@@ -6,6 +6,7 @@ using NUnit.Framework.TUnit;
 using System;
 using Xamarin.Forms;
 using Tizen.System;
+using System.Text;
 
 namespace Tizen.Network.Bluetooth.Tests
 {
@@ -13,72 +14,27 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("ReadRequestedEventArgs Tests")]
     public class ReadRequestedEventArgsTests
     {
-        static bool ReadRequested_flag = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
+        byte[] charValue = Encoding.UTF8.GetBytes("charValue");
 
         [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.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        private static void Charc_ReadRequested1(object sender, ReadRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, 0, 0, BluetoothSetup.characteristicValue, BluetoothSetup.characteristicValue.Length - e.Offset);
-            ReadRequested_flag = true;
-            Assert.IsInstanceOf<string>(e.ClientAddress, "ClientAddress is not of string type");
-        }
-
-        private static void Charc_ReadRequested2(object sender, ReadRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, 0, 0, BluetoothSetup.characteristicValue, BluetoothSetup.characteristicValue.Length - e.Offset);
-            ReadRequested_flag = true;
-            Assert.IsInstanceOf<int>(e.Offset, "Offset is not of int type");
-        }
-
-        private static void Charc_ReadRequested3(object sender, ReadRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, 0, 0, BluetoothSetup.characteristicValue, BluetoothSetup.characteristicValue.Length - e.Offset);
-            ReadRequested_flag = true;
-            Assert.IsInstanceOf<int>(e.RequestId, "RequestId param is not a int type");
-        }
-
-        private static void Charc_ReadRequested4(object sender, ReadRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, 0, 0, BluetoothSetup.characteristicValue, BluetoothSetup.characteristicValue.Length - e.Offset);
-            ReadRequested_flag = true;
-            Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "Server param is not a BluetoothGattServer type");
-            Assert.AreSame(BluetoothSetup.server, e.Server);
-        }
-
-        public static async Task WaitReadRequested()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitReadRequested");
-                await Task.Delay(3000);
-                count++;
-                if (ReadRequested_flag)
-                    break;
-                if (count == 15)
-                    break;
-            }
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check ClientAddress parameter of ReadRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.ClientAddress A")]
@@ -88,19 +44,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task ClientAddress_READ_ONLY()
+        public async Task ClientAddress_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.ReadRequested += Charc_ReadRequested1;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.charc.ReadRequested -= Charc_ReadRequested1;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Charc_ReadRequested = null;
+
+                Charc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, charValue, charValue.Length - e.Offset);
+
+                        Assert.IsNotNull(e.ClientAddress, "[TestCase][ClientAddress_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<string>(e.ClientAddress, "[TestCase][ClientAddress_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("ClientAddress_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ClientAddress_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.ReadRequested += Charc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.ReadRequested -= Charc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -112,7 +104,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -123,7 +115,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Offset parameter of ReadRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Offset A")]
@@ -133,19 +125,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Offset_READ_ONLY()
+        public async Task Offset_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.ReadRequested += Charc_ReadRequested2;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.charc.ReadRequested -= Charc_ReadRequested2;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Charc_ReadRequested = null;
+
+                Charc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, charValue, charValue.Length - e.Offset);
+
+                        Assert.IsTrue(e.Offset >= 0, "[TestCase][Offset_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<int>(e.Offset, "[TestCase][Offset_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("Offset_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Offset_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.ReadRequested += Charc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.ReadRequested -= Charc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -157,7 +185,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -168,7 +196,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check RequestId parameter of ReadRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.RequestId A")]
@@ -178,19 +206,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task RequestId_READ_ONLY()
+        public async Task RequestId_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.ReadRequested += Charc_ReadRequested3;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.charc.ReadRequested -= Charc_ReadRequested3;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Charc_ReadRequested = null;
+
+                Charc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, charValue, charValue.Length - e.Offset);
+
+                        Assert.IsTrue(e.RequestId >= 0, "[TestCase][RequestId_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<int>(e.RequestId, "[TestCase][RequestId_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("RequestId_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][RequestId_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.ReadRequested += Charc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.ReadRequested -= Charc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -202,7 +266,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -213,7 +277,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Server parameter of ReadRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Server A")]
@@ -223,19 +287,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.ReadValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Server_READ_ONLY()
+        public async Task Server_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.ReadRequested += Charc_ReadRequested4;
-                await WaitReadRequested();
-                Assert.IsTrue(ReadRequested_flag, "ReadRequested callback is not invoked");
-                BluetoothSetup.charc.ReadRequested -= Charc_ReadRequested4;
-                ReadRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Server_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<ReadRequestedEventArgs> Charc_ReadRequested = null;
+
+                Charc_ReadRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        s.SendResponse(e.RequestId, BluetoothGattRequestType.Read,
+                                        0, charValue, charValue.Length - e.Offset);
+
+                        Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "[TestCase][Server_READ_ONLY] Failed");
+                        Assert.AreSame(server, e.Server);
+
+                        BluetoothHelper.DisplayPassLabel("Server_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Server_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.ReadRequested += Charc_ReadRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.ReadRequested -= Charc_ReadRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -247,7 +347,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Server_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
index 010f446..6560fcd 100755 (executable)
@@ -12,90 +12,26 @@ namespace Tizen.Network.Bluetooth.Tests
     [Description("WriteRequestedEventArgs Tests")]
     public class WriteRequestedEventArgsTests
     {
-        static bool WriteRequested_flag = false;
-        static bool isBluetoothGattServerSupported = false;
+        bool isBluetoothGattServerSupported = false;
+        BluetoothGattServer server = null;
+        string svcUuid = "181D";
+        string charUuid = "2A20";
 
         [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.le.gatt.server", out isBluetoothGattServerSupported);
         }
 
         [TearDown]
-        public static void Destroy()
+        public void Destroy()
         {
             LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
             BluetoothSetup.gatt_server_exit();
         }
 
-        public static async Task WaitWriteRequested()
-        {
-            int count = 0;
-            while (true)
-            {
-                Log.Info(Globals.LogTag, "WaitWriteRequested");
-                await Task.Delay(3000);
-                count++;
-                if (WriteRequested_flag)
-                    break;
-                if (count == 15)
-                    break;
-            }
-        }
-
-        private static void Charc_WriteRequested1(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<string>(e.ClientAddress, "ClientAddress param is not a string type");
-        }
-
-        private static void Charc_WriteRequested2(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<int>(e.Offset, "Offset param is not a int type");
-        }
-
-        private static void Charc_WriteRequested3(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<int>(e.RequestId, "RequestId param is not a int type");
-        }
-
-        private static void Charc_WriteRequested4(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "Server param is not a BluetoothGattServer type");
-            Assert.AreSame(BluetoothSetup.server, e.Server);
-        }
-
-        private static void Charc_WriteRequested5(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<byte[]>(e.Value, "Value param is not a byte[] type");
-            Assert.IsNotNull(e.Value, "New value should not be null");
-
-        }
-
-        private static void Charc_WriteRequested6(object sender, WriteRequestedEventArgs e)
-        {
-            BluetoothGattServer s = e.Server;
-            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
-            WriteRequested_flag = true;
-            Assert.IsInstanceOf<bool>(e.Response_needed, "Response_needed param is not a bool type");
-        }
-
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check ClientAddress parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.ClientAddress A")]
@@ -105,19 +41,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task ClientAddress_READ_ONLY()
+        public async Task ClientAddress_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested1;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested1;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        Assert.IsNotNull(e.ClientAddress, "[TestCase][ClientAddress_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<string>(e.ClientAddress, "[TestCase][ClientAddress_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("ClientAddress_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][ClientAddress_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -129,7 +101,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -140,7 +112,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Offset parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Offset A")]
@@ -150,19 +122,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Offset_READ_ONLY()
+        public async Task Offset_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested2;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested2;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        Assert.IsTrue(e.Offset >= 0, "[TestCase][Offset_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<int>(e.Offset, "[TestCase][Offset_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("Offset_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Offset_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -174,7 +182,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -185,7 +193,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check RequestId parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.RequestId A")]
@@ -195,19 +203,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task RequestId_READ_ONLY()
+        public async Task RequestId_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested3;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested3;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        Assert.IsTrue(e.RequestId >= 0, "[TestCase][RequestId_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<int>(e.RequestId, "[TestCase][RequestId_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("RequestId_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][RequestId_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -219,7 +263,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -230,7 +274,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Server parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Server A")]
@@ -240,19 +284,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Server_READ_ONLY()
+        public async Task Server_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested4;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested4;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Server_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        Assert.IsInstanceOf<BluetoothGattServer>(e.Server, "[TestCase][Server_READ_ONLY] Failed");
+                        Assert.AreSame(server, e.Server);
+
+                        BluetoothHelper.DisplayPassLabel("Server_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Server_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -264,7 +344,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Server_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -275,7 +355,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Value parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Value A")]
@@ -285,19 +365,55 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Value_READ_ONLY()
+        public async Task Value_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested5;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested5;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Value_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        Assert.IsNotNull(e.Value, "[TestCase][Value_READ_ONLY] Failed");
+                        Assert.IsInstanceOf<byte[]>(e.Value, "[TestCase][Value_READ_ONLY] Failed");
+
+                        BluetoothHelper.DisplayPassLabel("Value_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Value_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -309,7 +425,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("Value_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }
@@ -320,7 +436,7 @@ namespace Tizen.Network.Bluetooth.Tests
             }
         }
 
-        //[Test]
+        [Test]
         [Category("P1")]
         [Description("Check Value parameter of WriteRequestedEventArgs")]
         [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Response_needed A")]
@@ -330,19 +446,54 @@ namespace Tizen.Network.Bluetooth.Tests
         [Precondition(1, "Bluetooth should be turned on.")]
         [Step(1, "Tap the Run button.")]
         [Step(2, "Run BluetoothGattClientTests.WriteValueAsync_Characteristic_RETURN_VALUE test case on the client device.")]
-        [Step(3, "TC should pass automatically.")]
         [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")]
-        public static async Task Response_needed_READ_ONLY()
+        public async Task Response_needed_READ_ONLY()
         {
             try
             {
-                await BluetoothSetup.gatt_server_init();
-                BluetoothSetup.charc.WriteRequested += Charc_WriteRequested6;
-                await WaitWriteRequested();
-                Assert.IsTrue(WriteRequested_flag, "WriteRequested callback is not invoked");
-                BluetoothSetup.charc.WriteRequested -= Charc_WriteRequested6;
-                WriteRequested_flag = false;
-               }
+                BluetoothGattService srv = null;
+                BluetoothGattCharacteristic charc = null;
+
+                /* We can't occupy the precondition, if GATT Server feature is not supported in Manual TC */
+                if (isBluetoothGattServerSupported == false)
+                {
+                    BluetoothHelper.DisplayLabel("Response_needed_READ_ONLY");
+                    await ManualTest.WaitForConfirm();
+                    return;
+                }
+
+                server = await BluetoothSetup.gatt_server_init();
+                Assert.IsNotNull(server, "Precondition failed: server instance should not be null");
+
+                EventHandler<WriteRequestedEventArgs> Charc_WriteRequested = null;
+
+                Charc_WriteRequested = (sender, e) => {
+                    try
+                    {
+                        BluetoothGattServer s = e.Server;
+
+                        Assert.IsInstanceOf<bool>(e.Response_needed, "[TestCase][Response_needed_READ_ONLY] Failed");
+
+                        if (e.Response_needed == true)
+                            s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0);
+
+                        BluetoothHelper.DisplayPassLabel("Response_needed_READ_ONLY");
+                    }
+                    catch (Exception ex)
+                    {
+                        Assert.Fail("[TestCase][Response_needed_READ_ONLY] FAIL " + ex.Message);
+                    }
+                };
+
+                srv = server.GetService(svcUuid);
+                charc = srv.GetCharacteristic(charUuid);
+
+                charc.WriteRequested += Charc_WriteRequested;
+
+                await ManualTest.WaitForConfirm();
+
+                charc.WriteRequested -= Charc_WriteRequested;
+            }
             catch (NotSupportedException)
             {
                 if (isBluetoothGattServerSupported == false)
@@ -354,7 +505,7 @@ namespace Tizen.Network.Bluetooth.Tests
             catch (TypeInitializationException e)
             {
                 if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
-                               {
+                {
                     BluetoothHelper.DisplayLabel("ResponseNeeded_READ_ONLY");
                     await ManualTest.WaitForConfirm();
                 }