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)
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()
using Tizen.System;
using System;
using Xamarin.Forms;
+using System.Text;
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")]
[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();
}
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();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check whether ReadRequested callback is getting invoked or not for Desriptor")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ReadRequested_Descriptor_CHECK_EVENT");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check whether WriteRequested callback is getting invoked or not for Characteristics")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("WriteRequested_Characteristics_CHECK_EVENT");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check whether WriteRequested callback is getting invoked or not for Descriptor")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("WriteRequested_Descriptor_CHECK_EVENT");
await ManualTest.WaitForConfirm();
}
[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);
}
[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]
[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)
{
Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
}
+ finally
+ {
+ BluetoothSetup.gatt_server_exit();
+ }
}
[Test]
[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
{
[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")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("NotificationSent_CHECK_EVENT");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check SendIndicationAsync method of BluetoothGattServer")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.SendIndicationAsync M")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE");
await ManualTest.WaitForConfirm();
}
[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")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Completed parameter of NotificationSentEventArg")]
[Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Completed A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Result parameter error code in NotificationSentEventArg")]
[Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Result A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Server parameter of NotificationSentEventArg")]
[Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Server A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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")]
[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)
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Value parameter of NotificationStateChangedEventArg")]
[Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Value A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Value_READ_ONLY");
await ManualTest.WaitForConfirm();
}
using System;
using Xamarin.Forms;
using Tizen.System;
+using System.Text;
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")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Offset parameter of ReadRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Offset A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check RequestId parameter of ReadRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.RequestId A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Server parameter of ReadRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Server A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Server_READ_ONLY");
await ManualTest.WaitForConfirm();
}
[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")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Offset parameter of WriteRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Offset A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Offset_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check RequestId parameter of WriteRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.RequestId A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("RequestId_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Server parameter of WriteRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Server A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Server_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Value parameter of WriteRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Value A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("Value_READ_ONLY");
await ManualTest.WaitForConfirm();
}
}
}
- //[Test]
+ [Test]
[Category("P1")]
[Description("Check Value parameter of WriteRequestedEventArgs")]
[Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Response_needed A")]
[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)
catch (TypeInitializationException e)
{
if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
- {
+ {
BluetoothHelper.DisplayLabel("ResponseNeeded_READ_ONLY");
await ManualTest.WaitForConfirm();
}