From: DoHyun Pyun Date: Fri, 22 Jan 2021 01:06:58 +0000 (+0900) Subject: [Bluetooth][Manual][Non-ACR] Make combine TC for GATT X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64f985c089334b862ec3269d774799d8941ae60f;p=test%2Ftct%2Fcsharp%2Fapi.git [Bluetooth][Manual][Non-ACR] Make combine TC for GATT Change-Id: I89efea289dcac3d37cea2160c529391004655a51 Signed-off-by: DoHyun Pyun --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine12_GattClient.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine12_GattClient.cs new file mode 100644 index 0000000..852acd9 --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine12_GattClient.cs @@ -0,0 +1,835 @@ +using System; +using System.Threading.Tasks; +using BluetoothNetworkUtils; +using System.Linq; +using System.Collections.Generic; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Xamarin.Forms; +using Tizen.System; + +namespace Tizen.Network.Bluetooth.Tests +{ + [TestFixture] + [Description("BluetoothGattClient Tests")] + public class BluetoothGattClientTests + { + static bool scanFlag = false; + static BluetoothLeDevice leDevice = null; + static bool isBluetoothGattClientSupported = false; + + string remoteBleAddr = PreconditionUtils.GetBleAddress(); + string defaultRemoteAddr = PreconditionUtils.GetDefaultAddress(); + + static bool pass_CreateClient_RETURN_VALUE = false; + static bool pass_ConnectAsync_RETURN_VALUE_TRUE = false; + static bool pass_ConnectAsync_RETURN_VALUE_FALSE = false; + static bool pass_DisconnectAsync_RETURN_VALUE = false; + static bool pass_ConnectionStateChanged_CHECK_EVENT = false; + static bool pass_IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_Result_GattConnectionStateChangedEventArgs_READ_ONLY = false; + static bool pass_RemoteAddress_PROPERTY_READ_ONLY = false; + static bool pass_GetService_RETURN_VALUE = false; + static bool pass_GetServices_RETURN_VALUE = false; + static bool pass_GetGattClient_RETURN_VALUE = false; + static bool pass_ReadValueAsync_Characteristic_RETURN_VALUE = false; + static bool pass_ReadValueAsync_Descriptor_RETURN_VALUE = false; + static bool pass_WriteValueAsync_Characteristic_RETURN_VALUE = false; + static bool pass_WriteValueAsync_Descriptor_RETURN_VALUE = false; + static bool pass_ValueChanged_CHECK_EVENT = false; + static bool pass_Value_ValueChangedEventArgs_READ_ONLY = false; + static bool pass_DestroyClient_RETURN_VALUE = false; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); + Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out isBluetoothGattClientSupported); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + } + + public async Task WaitScanFlag() + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Inside waitScanFlag"); + int count = 0; + while (true) + { + if (scanFlag == true) + break; + + await Task.Delay (100); + count++; + + if (count == 200) + break; + } + } + + public async Task LeScanSetup() + { + EventHandler scanResultEventHandler = null; + + scanResultEventHandler = (sender, e) => { + + if (leDevice != null) + return; + + if (e.DeviceData != null) + { + if (remoteBleAddr.Equals(defaultRemoteAddr)) + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Use the first found device"); + } + else if (e.DeviceData.RemoteAddress.Equals(remoteBleAddr)) + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Found the matching device" + e.DeviceData.RemoteAddress); + } + else + { + return; + } + + leDevice = e.DeviceData; + scanFlag = true; + } + }; + + BluetoothAdapter.ScanResultChanged += scanResultEventHandler; + + BluetoothAdapter.StartLeScan(); + await WaitScanFlag(); + + BluetoothAdapter.StopLeScan(); + await Task.Delay(1000); + + scanFlag = false; + + BluetoothAdapter.ScanResultChanged -= scanResultEventHandler; + } + + public async Task GattClientCombine_TEST() + { + BluetoothGattClient client = null; + bool isConnected = false; + + try + { + bool status = false; + string svcUuid = "181D"; + string charUuid = "2A20"; + string descUuid = "2901"; + string charc_value = "1234"; + string desc_value = "1"; + + await LeScanSetup(); + + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + + /* PASS condition for CreateClient_RETURN_VALUE */ + client = BluetoothGattClient.CreateClient(remoteBleAddr); + Assert.IsInstanceOf(client, "[TestCase][CreateClient_RETURN_VALUE] Failed"); + Assert.IsNotNull(client, "Client instance should not be null"); + pass_CreateClient_RETURN_VALUE = true; + + EventHandler OnConnectionStateChanged = (sender, e) => + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "OnConnectionStateChanged"); + + /* PASS condition for ConnectionStateChanged_CHECK_EVENT */ + pass_ConnectionStateChanged_CHECK_EVENT = true; + + /* PASS condition for IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.IsConnected, "[GattConnectionStateChangedEventArgs][IsConnected] Failed"); + pass_IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.RemoteAddress, "[GattConnectionStateChangedEventArgs][RemoteAddress] Failed"); + Assert.True(String.Equals(e.RemoteAddress, PreconditionUtils.GetBleAddress()), "[GattConnectionStateChangedEventArgs][RemoteAddress]Failed"); + pass_RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY = true; + + /* PASS condition for Result_GattConnectionStateChangedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Result, "[GattConnectionStateChangedEventArgs][Result] Failed"); + pass_Result_GattConnectionStateChangedEventArgs_READ_ONLY = true; + + isConnected = e.IsConnected; + }; + + client.ConnectionStateChanged += OnConnectionStateChanged; + + /* PASS condition for ConnectAsync_RETURN_VALUE_TRUE */ + await client.ConnectAsync(true); + + /* Wait to exchange MTU, and configuration info */ + await Task.Delay (5000); + Assert.IsTrue(isConnected == true, "GATT client Connect Failed"); + pass_ConnectAsync_RETURN_VALUE_TRUE = true; + + /* PASS condition for DisconnectAsync_RETURN_VALUE */ + await client.DisconnectAsync(); + + await Task.Delay (3000); + Assert.IsTrue(isConnected == false, "GATT client Disconnect Failed"); + pass_DisconnectAsync_RETURN_VALUE = true; + + /* PASS condition for ConnectAsync_RETURN_VALUE_FALSE */ + await client.ConnectAsync(false); + + /* Wait to exchange MTU, and configuration info */ + await Task.Delay (5000); + Assert.IsTrue(isConnected == true, "GATT client Connect Failed"); + pass_ConnectAsync_RETURN_VALUE_FALSE = true; + + client.ConnectionStateChanged -= OnConnectionStateChanged; + + /* PASS condition for RemoteAddress_PROPERTY_READ_ONLY */ + Assert.IsNotNull(client.RemoteAddress, "RemoteAddress shold not be null"); + Assert.AreEqual(client.RemoteAddress, PreconditionUtils.GetBleAddress()); + pass_RemoteAddress_PROPERTY_READ_ONLY = true; + + /* PASS condition for GetService_RETURN_VALUE */ + BluetoothGattService srv = client.GetService(svcUuid); + Assert.IsNotNull(srv, "Service returned should not be null"); + Assert.AreEqual(srv.Uuid, svcUuid, "Fetched Service UUID is not matching"); + pass_GetService_RETURN_VALUE = true; + + /* PASS condition for GetServices_RETURN_VALUE */ + IEnumerable srv_list; + srv_list = client.GetServices(); + Assert.IsNotNull(srv_list, "Service list should not be null"); + pass_GetServices_RETURN_VALUE = true; + + /* PASS condition for GetGattClient_RETURN_VALUE */ + BluetoothGattClient svc_client = srv.GetGattClient(); + + Assert.IsNotNull(svc_client, "svc_client returned should not be null"); + Assert.AreSame(client, svc_client); + pass_GetGattClient_RETURN_VALUE = true; + + /* PASS condition for ReadValueAsync_Characteristic_RETURN_VALUE */ + BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); + + status = await client.ReadValueAsync(charc); + Assert.IsTrue(status, "ReadValueAsync Char Status should be true"); + pass_ReadValueAsync_Characteristic_RETURN_VALUE = true; + + /* Wait to progress */ + await Task.Delay (500); + + /* PASS condition for ReadValueAsync_Descriptor_RETURN_VALUE */ + BluetoothGattDescriptor desc = charc.GetDescriptor(descUuid); + + status = await client.ReadValueAsync(desc); + Assert.IsTrue(status, "ReadValueAsync Desc Status should be true"); + pass_ReadValueAsync_Descriptor_RETURN_VALUE = true; + + /* Wait to progress */ + await Task.Delay (500); + + /* PASS condition for WriteValueAsync_Characteristic_RETURN_VALUE */ + charc.SetValue(charc_value); + + status = await client.WriteValueAsync(charc); + Assert.IsTrue(status, "WriteValueAsync Status should be true"); + + string value = charc.GetValue(0); + Assert.AreEqual(charc_value, value); + pass_WriteValueAsync_Characteristic_RETURN_VALUE = true; + + /* Wait to progress */ + await Task.Delay (500); + + /* PASS condition for WriteValueAsync_Descriptor_RETURN_VALUE */ + desc.SetValue(desc_value); + + status = await client.WriteValueAsync(desc); + Assert.IsTrue(status, "WriteValueAsync Status should be true"); + + string value_ret = desc.GetValue(0); + Assert.AreEqual(desc_value, value_ret); + pass_WriteValueAsync_Descriptor_RETURN_VALUE = true; + + EventHandler Charc_ValueChanged = null; + + Charc_ValueChanged = (sender, e) => { + /* PASS condition for ValueChanged_CHECK_EVENT */ + pass_ValueChanged_CHECK_EVENT = true; + + /* PASS condition for Value_ValueChangedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.Value, "[ValueChangedEventArgs][Value] Failed"); + Assert.IsInstanceOf(e.Value, "[ValueChangedEventArgs][Value] Failed"); + pass_Value_ValueChangedEventArgs_READ_ONLY = true; + + charc.ValueChanged -= Charc_ValueChanged; + + client.DisconnectAsync(); + isConnected = false; + + Task.Delay(3000).Wait(); + + try + { + /* PASS condition for DestroyClient_RETURN_VALUE */ + client.DestroyClient(); + client = null; + pass_DestroyClient_RETURN_VALUE = true; + } + catch (Exception ex) + { + Assert.Fail("[DestroyClient] FAIL " + ex.Message); + } + + BluetoothHelper.DisplayPassLabel("GattClientCombine_TEST"); + }; + + charc.ValueChanged += Charc_ValueChanged; + + await ManualTest.WaitForConfirm(); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + finally + { + if (isConnected == true) + { + client.DisconnectAsync(); + isConnected = false; + } + + if (client != null) + { + client.Dispose(); + } + } + } + + [Test] + [Category("P1")] + [Description("Test CreateClient method of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.CreateClient M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task CreateClient_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_CreateClient_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_CreateClient_RETURN_VALUE, "[TestCase][CreateClient_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ConnectAsync method of BluetoothGattClient with auto connection enabled")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ConnectAsync_RETURN_VALUE_TRUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE_TRUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ConnectAsync_RETURN_VALUE_TRUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ConnectAsync_RETURN_VALUE_TRUE, "[TestCase][ConnectAsync_RETURN_VALUE_TRUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ConnectAsync method of BluetoothGattClient with auto connection disabled")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ConnectAsync_RETURN_VALUE_FALSE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE_FALSE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ConnectAsync_RETURN_VALUE_FALSE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ConnectAsync_RETURN_VALUE_FALSE, "[TestCase][ConnectAsync_RETURN_VALUE_FALSE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test DisconnectAsync method of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.DisconnectAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task DisconnectAsync_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_DisconnectAsync_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_DisconnectAsync_RETURN_VALUE, "[TestCase][DisconnectAsync_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ConnectionStateChanged event of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectionStateChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ConnectionStateChanged_CHECK_EVENT() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ConnectionStateChanged_CHECK_EVENT == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ConnectionStateChanged_CHECK_EVENT, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test IsConnected parameter of GattConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.IsConnected A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY == false) + await GattClientCombine_TEST(); + + Assert.True(pass_IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][IsConnected_GattConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test RemoteAddress parameter of GattConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.RemoteAddress A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Step(2, "TC should pass automatically.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY == false) + await GattClientCombine_TEST(); + + Assert.True(pass_RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][RemoteAddress_GattConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Result parameter of GattConnectionStateChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.Result A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Step(2, "TC should pass automatically.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Result_GattConnectionStateChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("Result_GattConnectionStateChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Result_GattConnectionStateChangedEventArgs_READ_ONLY == false) + await GattClientCombine_TEST(); + + Assert.True(pass_Result_GattConnectionStateChangedEventArgs_READ_ONLY, "[TestCase][Result_GattConnectionStateChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test RemoteAddress property of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.RemoteAddress A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task RemoteAddress_PROPERTY_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_RemoteAddress_PROPERTY_READ_ONLY == false) + await GattClientCombine_TEST(); + + Assert.True(pass_RemoteAddress_PROPERTY_READ_ONLY, "[TestCase][RemoteAddress_PROPERTY_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test GetService method of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.GetService M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task GetService_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_GetService_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_GetService_RETURN_VALUE, "[TestCase][GetService_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test GetServices method of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.GetServices M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task GetServices_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_GetServices_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_GetServices_RETURN_VALUE, "[TestCase][GetServices_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P0")] + [Description("Check if GetGattClient correct parent client")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattService.GetGattClient M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Dinesh Dwivedi, dinesh.d@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task GetGattClient_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_GetGattClient_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_GetGattClient_RETURN_VALUE, "[TestCase][GetGattClient_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ReadValueAsync for BluetoothGattCharacteristic")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ReadValueAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Property("COVPARAM", "BluetoothGattCharacteristic")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ReadValueAsync_Characteristic_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ReadValueAsync_Characteristic_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ReadValueAsync_Characteristic_RETURN_VALUE, "[TestCase][ReadValueAsync_Characteristic_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test ReadValueAsync method for BluetoothGattDescriptor")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ReadValueAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Property("COVPARAM", "BluetoothGattDescriptor")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Descriptor_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ReadValueAsync_Descriptor_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ReadValueAsync_Descriptor_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ReadValueAsync_Descriptor_RETURN_VALUE, "[TestCase][ReadValueAsync_Descriptor_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test WriteValueAsync method for BluetoothGattCharacteristic")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.WriteValueAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Property("COVPARAM", "BluetoothGattCharacteristic")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.WriteRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Step(2, "TC should pass automatically.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task WriteValueAsync_Characteristic_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_WriteValueAsync_Characteristic_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_WriteValueAsync_Characteristic_RETURN_VALUE, "[TestCase][WriteValueAsync_Characteristic_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test WriteValueAsync method for BluetoothGattDescriptor")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.WriteValueAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Property("COVPARAM", "BluetoothGattDescriptor")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.WriteRequested_Descriptor_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Step(2, "TC should pass automatically.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task WriteValueAsync_Descriptor_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_WriteValueAsync_Descriptor_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_WriteValueAsync_Descriptor_RETURN_VALUE, "[TestCase][WriteValueAsync_Descriptor_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether ValueChanged callback is getting invoked or not")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattCharacteristic.ValueChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [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 async Task ValueChanged_CHECK_EVENT() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ValueChanged_CHECK_EVENT == false) + await GattClientCombine_TEST(); + + Assert.True(pass_ValueChanged_CHECK_EVENT, "[TestCase][ValueChanged_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Value parameter of ValueChangedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.ValueChangedEventArgs.Value A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [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 async Task Value_ValueChangedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("Value_ValueChangedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Value_ValueChangedEventArgs_READ_ONLY == false) + await GattClientCombine_TEST(); + + Assert.True(pass_Value_ValueChangedEventArgs_READ_ONLY, "[TestCase][Value_ValueChangedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test DestroyClient method of BluetoothGattClient")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.DestroyClient M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] + [Step(1, "Tap the Run button.")] + [Step(2, "TC should pass automatically.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task DestroyClient_RETURN_VALUE() + { + /* We can't occupy the precondition, if Gatt client feature is not supported in Manual TC */ + if (isBluetoothGattClientSupported == false) + { + BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_DestroyClient_RETURN_VALUE == false) + await GattClientCombine_TEST(); + + Assert.True(pass_DestroyClient_RETURN_VALUE, "[TestCase][DestroyClient_RETURN_VALUE] Fail"); + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine13_GattServer.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine13_GattServer.cs new file mode 100644 index 0000000..63de7e2 --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine13_GattServer.cs @@ -0,0 +1,934 @@ +using System; +using System.Text; +using System.Threading.Tasks; +using BluetoothNetworkUtils; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.System; +using Xamarin.Forms; + +namespace Tizen.Network.Bluetooth.Tests +{ + [TestFixture] + [Description("BluetoothGattServer Tests")] + public class BluetoothGattServerTests + { + static bool isBluetoothGattServerSupported = false; + + static bool pass_ReadRequested_Characteristics_CHECK_EVENT = false; + static bool pass_ReadRequested_Descriptor_CHECK_EVENT = false; + static bool pass_ClientAddress_ReadRequestedEventArgs_READ_ONLY = false; + static bool pass_Offset_ReadRequestedEventArgs_READ_ONLY = false; + static bool pass_RequestId_ReadRequestedEventArgs_READ_ONLY = false; + static bool pass_Server_ReadRequestedEventArgs_READ_ONLY = false; + static bool pass_WriteRequested_Characteristics_CHECK_EVENT = false; + static bool pass_WriteRequested_Descriptor_CHECK_EVENT = false; + static bool pass_ClientAddress_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_Offset_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_RequestId_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_Server_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_Value_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_Response_needed_WriteRequestedEventArgs_READ_ONLY = false; + static bool pass_NotificationStateChanged_CHECK_EVENT = false; + static bool pass_Server_NotificationStateChangedEventArg_READ_ONLY = false; + static bool pass_Value_NotificationStateChangedEventArg_READ_ONLY = false; + static bool pass_NotificationSent_CHECK_EVENT = false; + static bool pass_SendIndicationAsync_RETURN_VALUE = false; + static bool pass_ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY = false; + static bool pass_Completed_NotificationSentEventArg_PROPERTY_READ_ONLY = false; + static bool pass_Result_NotificationSentEventArg_PROPERTY_READ_ONLY = false; + static bool pass_Server_NotificationSentEventArg_PROPERTY_READ_ONLY = false; + + [SetUp] + 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 void Destroy() + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); + } + + public async Task GattServerCombine_TEST() + { + BluetoothGattServer server = null; + + try + { + string svcUuid = "181D"; + string charUuid = "2A20"; + string descUuid = "2901"; + string valueChanged = "valueChanged"; + string origin_val = null; + string clientAddress = null; + byte[] charValue = Encoding.UTF8.GetBytes("charValue"); + byte[] descValue = { 0, 0 }; + + BluetoothGattService srv = null; + BluetoothGattCharacteristic charc = null; + BluetoothGattDescriptor desc = null; + + server = await BluetoothSetup.gatt_server_init(); + Assert.IsNotNull(server, "Precondition failed: server instance should not be null"); + + EventHandler Charc_ReadRequested = null; + EventHandler Charc_WriteRequested = null; + + EventHandler Desc_ReadRequested = null; + EventHandler Desc_WriteRequested = null; + + EventHandler Charc_NotificationStateChanged = null; + EventHandler Server_NotificationSent = null; + + Charc_ReadRequested = (sender, e) => { + try + { + BluetoothGattServer s = e.Server; + + /* PASS condition for ReadRequested_Characteristics_CHECK_EVENT */ + pass_ReadRequested_Characteristics_CHECK_EVENT = true; + + charc.ReadRequested -= Charc_ReadRequested; + + s.SendResponse(e.RequestId, BluetoothGattRequestType.Read, 0, charValue, charValue.Length - e.Offset); + + /* PASS condition for ClientAddress_ReadRequestedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.ClientAddress, "[ReadRequestedEventArgs][ClientAddress] Failed"); + Assert.IsInstanceOf(e.ClientAddress, "[ReadRequestedEventArgs][ClientAddress] Failed"); + pass_ClientAddress_ReadRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for Offset_ReadRequestedEventArgs_READ_ONLY */ + Assert.IsTrue(e.Offset >= 0, "[ReadRequestedEventArgs][Offset] Failed"); + Assert.IsInstanceOf(e.Offset, "[ReadRequestedEventArgs][Offset] Failed"); + pass_Offset_ReadRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for RequestId_ReadRequestedEventArgs_READ_ONLY */ + Assert.IsTrue(e.RequestId >= 0, "[ReadRequestedEventArgs][RequestId] Failed"); + Assert.IsInstanceOf(e.RequestId, "[ReadRequestedEventArgs][RequestId] Failed"); + pass_RequestId_ReadRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for Server_ReadRequestedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Server, "[ReadRequestedEventArgs][Server] Failed"); + Assert.AreSame(server, e.Server); + pass_Server_ReadRequestedEventArgs_READ_ONLY = true; + + clientAddress = e.ClientAddress; + } + catch (Exception ex) + { + Assert.Fail("[ReadRequested_Characteristics_CHECK_EVENT] FAIL " + ex.Message); + } + }; + + Charc_WriteRequested = (sender, e) => { + try + { + BluetoothGattServer s = e.Server; + + /* PASS condition for WriteRequested_Characteristics_CHECK_EVENT */ + pass_WriteRequested_Characteristics_CHECK_EVENT = true; + + charc.WriteRequested -= Charc_WriteRequested; + + /* PASS condition for Response_needed_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Response_needed, "[WriteRequestedEventArgs][Response_needed] Failed"); + pass_Response_needed_WriteRequestedEventArgs_READ_ONLY = true; + + if (e.Response_needed == true) + s.SendResponse(e.RequestId, BluetoothGattRequestType.Write, (int)BluetoothError.None, e.Value, 0); + + /* PASS condition for ClientAddress_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.ClientAddress, "[WriteRequestedEventArgs][ClientAddress] Failed"); + Assert.IsInstanceOf(e.ClientAddress, "[WriteRequestedEventArgs][ClientAddress] Failed"); + pass_ClientAddress_WriteRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for Offset_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsTrue(e.Offset >= 0, "[WriteRequestedEventArgs][Offset] Failed"); + Assert.IsInstanceOf(e.Offset, "[WriteRequestedEventArgs][Offset] Failed"); + pass_Offset_WriteRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for RequestId_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsTrue(e.RequestId >= 0, "[WriteRequestedEventArgs][RequestId] Failed"); + Assert.IsInstanceOf(e.RequestId, "[WriteRequestedEventArgs][RequestId] Failed"); + pass_RequestId_WriteRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for Server_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsInstanceOf(e.Server, "[WriteRequestedEventArgs][Server] Failed"); + Assert.AreSame(server, e.Server); + pass_Server_WriteRequestedEventArgs_READ_ONLY = true; + + /* PASS condition for Value_WriteRequestedEventArgs_READ_ONLY */ + Assert.IsNotNull(e.Value, "[WriteRequestedEventArgs][Value] Failed"); + Assert.IsInstanceOf(e.Value, "[WriteRequestedEventArgs][Value] Failed"); + pass_Value_WriteRequestedEventArgs_READ_ONLY = true; + } + catch (Exception ex) + { + Assert.Fail("[WriteRequested_Characteristics_CHECK_EVENT] FAIL " + ex.Message); + } + }; + + Desc_ReadRequested = (sender, e) => { + desc.ReadRequested -= Desc_ReadRequested; + + try + { + BluetoothGattServer s = e.Server; + s.SendResponse(e.RequestId, BluetoothGattRequestType.Read, 0, descValue, 0); + } + catch (Exception ex) + { + Assert.Fail("[ReadRequested_Descriptor_CHECK_EVENT] FAIL " + ex.Message); + } + + /* PASS condition for ReadRequested_Descriptor_CHECK_EVENT */ + pass_ReadRequested_Descriptor_CHECK_EVENT = true; + }; + + 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); + } + catch (Exception ex) + { + Assert.Fail("[WriteRequested_Descriptor_CHECK_EVENT] FAIL " + ex.Message); + } + + /* PASS condition for WriteRequested_Descriptor_CHECK_EVENT */ + pass_WriteRequested_Descriptor_CHECK_EVENT = true; + }; + + srv = server.GetService(svcUuid); + charc = srv.GetCharacteristic(charUuid); + desc = charc.GetDescriptor(descUuid); + + charc.ReadRequested += Charc_ReadRequested; + charc.WriteRequested += Charc_WriteRequested; + + desc.ReadRequested += Desc_ReadRequested; + desc.WriteRequested += Desc_WriteRequested; + + Server_NotificationSent = (sender, e) => { + server.NotificationSent -= Server_NotificationSent; + + /* PASS condition for NotificationSent_CHECK_EVENT */ + pass_NotificationSent_CHECK_EVENT = true; + + /* PASS condition for ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY */ + Assert.IsNotNull(e.ClientAddress, "[NotificationSentEventArg][ClientAddress] Failed"); + Assert.IsInstanceOf(e.ClientAddress, "[NotificationSentEventArg][ClientAddress] Failed"); + pass_ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY = true; + + /* PASS condition for Completed_NotificationSentEventArg_PROPERTY_READ_ONLY */ + Assert.IsInstanceOf(e.Completed, "[NotificationSentEventArg][Completed] Failed"); + Assert.IsTrue(e.Completed == true, "[NotificationSentEventArg][Completed] Failed"); + pass_Completed_NotificationSentEventArg_PROPERTY_READ_ONLY = true; + + /* PASS condition for Result_NotificationSentEventArg_PROPERTY_READ_ONLY */ + Assert.IsInstanceOf(e.Result, "[NotificationSentEventArg][Result] Failed"); + Assert.IsTrue((int)e.Result == 0, "[NotificationSentEventArg][Result] Failed"); + pass_Result_NotificationSentEventArg_PROPERTY_READ_ONLY = true; + + /* PASS condition for Server_NotificationSentEventArg_PROPERTY_READ_ONLY */ + Assert.IsNotNull(e.Server, "[NotificationSentEventArg][Server] Failed"); + Assert.IsInstanceOf(e.Server, "[NotificationSentEventArg][Server] Failed"); + Assert.AreSame(server, e.Server); + pass_Server_NotificationSentEventArg_PROPERTY_READ_ONLY = true; + + BluetoothHelper.DisplayCustomLabel("NotificationSent is success, wait for disconnet"); + + /* Wait for disconnection from client */ + Task.Delay(5000).Wait(); + + BluetoothHelper.DisplayPassLabel("GattServerCombine_TEST"); + }; + + Charc_NotificationStateChanged = (sender, e) => { + try + { + Log.Info(Globals.LogTag, "Charc_NotificationStateChanged"); + + /* PASS condition for NotificationStateChanged_CHECK_EVENT */ + pass_NotificationStateChanged_CHECK_EVENT = true; + + /* PASS condition for Server_NotificationStateChangedEventArg_READ_ONLY */ + Assert.IsNotNull(e.Server, "[NotificationStateChangedEventArg][Server] Failed"); + Assert.IsInstanceOf(e.Server, "[NotificationStateChangedEventArg][Server] Failed"); + Assert.AreSame(server, e.Server); + pass_Server_NotificationStateChangedEventArg_READ_ONLY = true; + + /* PASS condition for Value_NotificationStateChangedEventArg_READ_ONLY */ + Assert.IsNotNull(e.Value, "[NotificationStateChangedEventArg][Value] Failed"); + Assert.IsInstanceOf(e.Value, "[NotificationStateChangedEventArg][Value] Failed"); + pass_Value_NotificationStateChangedEventArg_READ_ONLY = true; + + server.NotificationSent += Server_NotificationSent; + + origin_val = charc.GetValue(0); + charc.SetValue(valueChanged); + + /* PASS condition for SendIndicationAsync_RETURN_VALUE */ + server.SendIndicationAsync(charc, clientAddress); + pass_SendIndicationAsync_RETURN_VALUE = true; + + charc.SetValue(origin_val); + + charc.NotificationStateChanged -= Charc_NotificationStateChanged; + } + catch (Exception ex) + { + Assert.Fail("[TestCase][NotificationSent_CHECK_EVENT] FAIL " + ex.Message); + } + }; + + charc.NotificationStateChanged += Charc_NotificationStateChanged; + + await ManualTest.WaitForConfirm(); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + finally + { + if (server != null) + { + BluetoothSetup.gatt_server_exit(); + server = null; + } + } + } + + [Test] + [Category("P1")] + [Description("Check whether ReadRequested callback is getting invoked or not for Characteristics")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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 async Task ReadRequested_Characteristics_CHECK_EVENT() + { + /* 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; + } + + if (pass_ReadRequested_Characteristics_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_ReadRequested_Characteristics_CHECK_EVENT, "[TestCase][ReadRequested_Characteristics_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether ReadRequested callback is getting invoked or not for Desriptor")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on.")] + [Step(1, "Tap the Run button.")] + [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 async Task ReadRequested_Descriptor_CHECK_EVENT() + { + /* 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; + } + + if (pass_ReadRequested_Descriptor_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_ReadRequested_Descriptor_CHECK_EVENT, "[TestCase][ReadRequested_Descriptor_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check ClientAddress parameter of ReadRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.ClientAddress A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ClientAddress_ReadRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("ClientAddress_ReadRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ClientAddress_ReadRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_ClientAddress_ReadRequestedEventArgs_READ_ONLY, "[TestCase][ClientAddress_ReadRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Offset parameter of ReadRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Offset A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Offset_ReadRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Offset_ReadRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Offset_ReadRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Offset_ReadRequestedEventArgs_READ_ONLY, "[TestCase][Offset_ReadRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check RequestId parameter of ReadRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.RequestId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task RequestId_ReadRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("RequestId_ReadRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_RequestId_ReadRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_RequestId_ReadRequestedEventArgs_READ_ONLY, "[TestCase][RequestId_ReadRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Server parameter of ReadRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Server A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Server_ReadRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Server_ReadRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Server_ReadRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Server_ReadRequestedEventArgs_READ_ONLY, "[TestCase][Server_ReadRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether WriteRequested callback is getting invoked or not for Characteristics")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task WriteRequested_Characteristics_CHECK_EVENT() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("WriteRequested_Characteristics_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_WriteRequested_Characteristics_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_WriteRequested_Characteristics_CHECK_EVENT, "[TestCase][WriteRequested_Characteristics_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether WriteRequested callback is getting invoked or not for Descriptor")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task WriteRequested_Descriptor_CHECK_EVENT() + { + /* 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; + } + + if (pass_WriteRequested_Descriptor_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_WriteRequested_Descriptor_CHECK_EVENT, "[TestCase][WriteRequested_Descriptor_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check ClientAddress parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.ClientAddress A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ClientAddress_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("ClientAddress_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ClientAddress_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_ClientAddress_WriteRequestedEventArgs_READ_ONLY, "[TestCase][ClientAddress_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Offset parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Offset A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Offset_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Offset_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Offset_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Offset_WriteRequestedEventArgs_READ_ONLY, "[TestCase][Offset_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check RequestId parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.RequestId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task RequestId_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("RequestId_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_RequestId_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_RequestId_WriteRequestedEventArgs_READ_ONLY, "[TestCase][RequestId_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Server parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Server A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Server_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Server_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Server_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Server_WriteRequestedEventArgs_READ_ONLY, "[TestCase][Server_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Value parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Value A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Value_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Value_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Value_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Value_WriteRequestedEventArgs_READ_ONLY, "[TestCase][Value_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Value parameter of WriteRequestedEventArgs")] + [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Response_needed A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Response_needed_WriteRequestedEventArgs_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Response_needed_WriteRequestedEventArgs_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Response_needed_WriteRequestedEventArgs_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Response_needed_WriteRequestedEventArgs_READ_ONLY, "[TestCase][Response_needed_WriteRequestedEventArgs_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether NotificationStateChanged callback is getting invoked or not")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattCharacteristic.NotificationStateChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task NotificationStateChanged_CHECK_EVENT() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("NotificationStateChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_NotificationStateChanged_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_NotificationStateChanged_CHECK_EVENT, "[TestCase][NotificationStateChanged_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Server parameter of NotificationStateChangedEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Server A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Server_NotificationStateChangedEventArg_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Server_NotificationStateChangedEventArg_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Server_NotificationStateChangedEventArg_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Server_NotificationStateChangedEventArg_READ_ONLY, "[TestCase][Server_NotificationStateChangedEventArg_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Value parameter of NotificationStateChangedEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Value A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Value_NotificationStateChangedEventArg_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Value_NotificationStateChangedEventArg_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Value_NotificationStateChangedEventArg_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Value_NotificationStateChangedEventArg_READ_ONLY, "[TestCase][Value_NotificationStateChangedEventArg_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check whether NotificationSent callback is getting invoked or not")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.NotificationSent E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task NotificationSent_CHECK_EVENT() + { + /* 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; + } + + if (pass_NotificationSent_CHECK_EVENT == false) + await GattServerCombine_TEST(); + + Assert.True(pass_NotificationSent_CHECK_EVENT, "[TestCase][NotificationSent_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check SendIndicationAsync method of BluetoothGattServer")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.SendIndicationAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [Precondition(1, "Bluetooth should be turned on")] + [Precondition(1, "\"nRF Connect for Mobile\" must be installed on client device. Download link available in user guide.")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task SendIndicationAsync_RETURN_VALUE() + { + /* 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; + } + + if (pass_SendIndicationAsync_RETURN_VALUE == false) + await GattServerCombine_TEST(); + + Assert.True(pass_SendIndicationAsync_RETURN_VALUE, "[TestCase][SendIndicationAsync_RETURN_VALUE] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check ClientAddress parameter of NotificationSentEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.ClientAddress A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY, "[TestCase][ClientAddress_NotificationSentEventArg_PROPERTY_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Completed parameter of NotificationSentEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Completed A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Completed_NotificationSentEventArg_PROPERTY_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Completed_NotificationSentEventArg_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Completed_NotificationSentEventArg_PROPERTY_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Completed_NotificationSentEventArg_PROPERTY_READ_ONLY, "[TestCase][Completed_NotificationSentEventArg_PROPERTY_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Result parameter error code in NotificationSentEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Result A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Result_NotificationSentEventArg_PROPERTY_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Result_NotificationSentEventArg_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Result_NotificationSentEventArg_PROPERTY_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Result_NotificationSentEventArg_PROPERTY_READ_ONLY, "[TestCase][Result_NotificationSentEventArg_PROPERTY_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Check Server parameter of NotificationSentEventArg")] + [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Server A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] + [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.")] + [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] + public async Task Server_NotificationSentEventArg_PROPERTY_READ_ONLY() + { + /* We can't occupy the precondition, if Gatt server feature is not supported in Manual TC */ + if (isBluetoothGattServerSupported == false) + { + BluetoothHelper.DisplayLabel("Server_NotificationSentEventArg_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Server_NotificationSentEventArg_PROPERTY_READ_ONLY == false) + await GattServerCombine_TEST(); + + Assert.True(pass_Server_NotificationSentEventArg_PROPERTY_READ_ONLY, "[TestCase][Server_NotificationSentEventArg_PROPERTY_READ_ONLY] Fail"); + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattAttribute.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattAttribute.cs deleted file mode 100755 index 92d7d72..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattAttribute.cs +++ /dev/null @@ -1,355 +0,0 @@ -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using System; -using Xamarin.Forms; -using System.Text; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothGattAttribute Tests")] - public class BluetoothGattAttributeTests - { - 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 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check whether ReadRequested callback is getting invoked or not for Characteristics")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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 async Task ReadRequested_Characteristics_CHECK_EVENT() - { - try - { - 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 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 (isBluetoothGattServerSupported == false) - { - BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ReadRequested_Characteristics_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check whether ReadRequested callback is getting invoked or not for Desriptor")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.ReadRequested E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Step(1, "Tap the Run button.")] - [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 async Task ReadRequested_Descriptor_CHECK_EVENT() - { - try - { - 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 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) - { - BluetoothHelper.DisplayLabel("ReadRequested_Descriptor_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ReadRequested_Descriptor_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check whether WriteRequested callback is getting invoked or not for Characteristics")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task WriteRequested_Characteristics_CHECK_EVENT() - { - try - { - 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 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) - { - BluetoothHelper.DisplayLabel("WriteRequested_Characteristics_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("WriteRequested_Characteristics_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check whether WriteRequested callback is getting invoked or not for Descriptor")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattAttribute.WriteRequested E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task WriteRequested_Descriptor_CHECK_EVENT() - { - try - { - 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 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) - { - BluetoothHelper.DisplayLabel("WriteRequested_Descriptor_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("WriteRequested_Descriptor_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs deleted file mode 100644 index ba5cab0..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattCharacteristic.cs +++ /dev/null @@ -1,200 +0,0 @@ -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using System.Linq; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; -using System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothGattCharacteristic Tests")] - public class BluetoothGattCharacteristicTests - { - bool isBluetoothGattServerSupported = false; - bool isBluetoothGattClientSupported = false; - BluetoothGattClient client = null; - BluetoothGattServer server = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - bool isClientConnected = false; - BluetoothLeDevice leDevice = null; - - [SetUp] - 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); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out isBluetoothGattClientSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - if (isClientConnected == true) - { - client.DisconnectAsync(); - isClientConnected = false; - } - - if (client != null) - { - client.Dispose(); - } - } - - [Test] - [Category("P1")] - [Description("Check whether NotificationStateChanged callback is getting invoked or not")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattCharacteristic.NotificationStateChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task NotificationStateChanged_CHECK_EVENT() - { - try - { - 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 Charc_NotificationStateChanged = null; - - Charc_NotificationStateChanged = (sender, e) => { - Assert.IsNotNull(e.Server, "[TestCase][NotificationStateChanged_CHECK_EVENT] Failed"); - Assert.IsInstanceOf(e.Server, "[TestCase][NotificationStateChanged_CHECK_EVENT] Failed"); - BluetoothHelper.DisplayPassLabel("NotificationStateChanged_CHECK_EVENT"); - }; - - srv = server.GetService(svcUuid); - charc = srv.GetCharacteristic(charUuid); - - charc.NotificationStateChanged += Charc_NotificationStateChanged; - - await ManualTest.WaitForConfirm(); - - charc.NotificationStateChanged -= Charc_NotificationStateChanged; - } - catch (NotSupportedException) - { - if (isBluetoothGattServerSupported == false) - { - BluetoothHelper.DisplayLabel("NotificationStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("NotificationStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - BluetoothSetup.gatt_server_exit(); - } - } - - [Test] - [Category("P1")] - [Description("Check whether ValueChanged callback is getting invoked or not")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattCharacteristic.ValueChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [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 async Task ValueChanged_CHECK_EVENT() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isClientConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - - EventHandler Charc_ValueChanged = null; - - Charc_ValueChanged = (sender, e) => { - Assert.IsNotNull(e.Value, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); - Assert.IsInstanceOf(e.Value, "[TestCase][ValueChanged_CHECK_EVENT] Failed"); - ManualTest.Confirm(); - }; - - /* Wait to exchange MTU, and configuration info */ - await Task.Delay (1000); - - charc.ValueChanged += Charc_ValueChanged; - - await ManualTest.WaitForConfirm(); - - charc.ValueChanged -= Charc_ValueChanged; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ValueChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs deleted file mode 100644 index 911b9a7..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattClient.cs +++ /dev/null @@ -1,867 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using System.Linq; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothGattClient Tests")] - public class BluetoothGattClientTests - { - string svcUuid = "181D"; - string charUuid = "2A20"; - string descUuid = "2901"; - string charc_value = "1234"; - string desc_value = "1"; - bool isBluetoothGattClientSupported = false; - BluetoothGattClient client = null; - bool isConnected = false; - BluetoothLeDevice leDevice = null; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out isBluetoothGattClientSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - if (isConnected == true) - { - client.DisconnectAsync(); - isConnected = false; - } - - if (client != null) - { - client.Dispose(); - } - } - - [Test] - [Category("P1")] - [Description("Test CreateClient method of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.CreateClient M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task CreateClient_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][CreateClient_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Client instance should not be null"); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("CreateClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ConnectAsync method of BluetoothGattClient with auto connection enabled")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ConnectAsync_RETURN_VALUE_TRUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ConnectAsync_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ConnectAsync method of BluetoothGattClient with auto connection disabled")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ConnectAsync_RETURN_VALUE_FALSE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ConnectAsync_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); -/* - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - }*/ - - await client.ConnectAsync(false); - isConnected = true; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ConnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test DisconnectAsync method of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.DisconnectAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task DisconnectAsync_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][DisconnectAsync_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - await client.DisconnectAsync(); - isConnected = false; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("DisconnectAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ConnectionStateChanged event of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ConnectionStateChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ConnectionStateChanged_CHECK_EVENT() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - EventHandler OnConnectionStateChanged = (sender, e) => - { - Assert.IsInstanceOf(e.IsConnected, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed"); - Assert.IsTrue(e.IsConnected == true, "[TestCase][ConnectionStateChanged_CHECK_EVENT] Failed"); - ManualTest.Confirm(); - }; - client.ConnectionStateChanged += OnConnectionStateChanged; - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - await ManualTest.WaitForConfirm(); - - client.ConnectionStateChanged -= OnConnectionStateChanged; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ConnectionStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test RemoteAddress property of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.RemoteAddress A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task RemoteAddress_PROPERTY_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][RemoteAddress_PROPERTY_READ_ONLY] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - Assert.IsNotNull(client.RemoteAddress, "RemoteAddress shold not be null"); - Assert.AreEqual(client.RemoteAddress, PreconditionUtils.GetBleAddress()); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test GetService method of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.GetService M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task GetService_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][GetService_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - Assert.IsNotNull(srv, "Service returned should not be null"); - Assert.AreEqual(srv.Uuid, svcUuid, "Fetched Service UUID is not matching"); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("GetService_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test GetServices method of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.GetServices M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task GetServices_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][GetServices_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - IEnumerable srv_list; - srv_list = client.GetServices(); - Assert.IsNotNull(srv_list, "Service list should not be null"); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("GetServices_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ReadValueAsync for BluetoothGattCharacteristic")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ReadValueAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Property("COVPARAM", "BluetoothGattCharacteristic")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ReadValueAsync_Characteristic_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ReadValueAsync_Characteristic_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - - bool status = await client.ReadValueAsync(charc); - Assert.IsTrue(status, "ReadValueAsync Status should be true"); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test ReadValueAsync method for BluetoothGattDescriptor")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.ReadValueAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Property("COVPARAM", "BluetoothGattDescriptor")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Descriptor_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ReadValueAsync_Descriptor_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][ReadValueAsync_Descriptor_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - BluetoothGattDescriptor desc = charc.GetDescriptor(descUuid); - - bool status = await client.ReadValueAsync(desc); - Assert.IsTrue(status, "ReadValueAsync Status should be true"); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ReadValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test WriteValueAsync method for BluetoothGattCharacteristic")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.WriteValueAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Property("COVPARAM", "BluetoothGattCharacteristic")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.WriteRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Step(2, "TC should pass automatically.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task WriteValueAsync_Characteristic_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][WriteValueAsync_Characteristic_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - charc.SetValue(charc_value); - - bool status = await client.WriteValueAsync(charc); - Assert.IsTrue(status, "WriteValueAsync Status should be true"); - - string value = charc.GetValue(0); - Assert.AreEqual(charc_value, value); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Characteristic_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test WriteValueAsync method for BluetoothGattDescriptor")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.WriteValueAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Property("COVPARAM", "BluetoothGattDescriptor")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.WriteRequested_Descriptor_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Step(2, "TC should pass automatically.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task WriteValueAsync_Descriptor_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][WriteValueAsync_Descriptor_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - BluetoothGattDescriptor desc = charc.GetDescriptor(descUuid); - - desc.SetValue(desc_value); - - bool status = await client.WriteValueAsync(desc); - Assert.IsTrue(status, "WriteValueAsync Status should be true"); - - string value = desc.GetValue(0); - Assert.AreEqual(desc_value, value); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("WriteValueAsync_Descriptor_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test DestroyClient method of BluetoothGattClient")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattClient.DestroyClient M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MCST")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Step(2, "TC should pass automatically.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task DestroyClient_RETURN_VALUE() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][DestroyClient_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - await client.DisconnectAsync(); - isConnected = false; - - client.Dispose(); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("DestroyClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattServer.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattServer.cs deleted file mode 100755 index 1f4f0f1..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattServer.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothGattServer Tests")] - public class BluetoothGattServerTests - { - bool isBluetoothGattServerSupported = false; - BluetoothGattServer server = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - string valueChanged = "valueChanged"; - - [SetUp] - 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check whether NotificationSent callback is getting invoked or not")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.NotificationSent E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task NotificationSent_CHECK_EVENT() - { - try - { - 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"); - - EventHandler Server_NotificationSent = null; - - Server_NotificationSent = (sender, e) => { - server.NotificationSent -= Server_NotificationSent; - Assert.IsTrue((int)e.Result == 0, "[TestCase][NotificationSent_CHECK_EVENT] Failed"); - BluetoothHelper.DisplayPassLabel("NotificationSent_CHECK_EVENT"); - }; - - EventHandler 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][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) - { - BluetoothHelper.DisplayLabel("NotificationSent_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("NotificationSent_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check SendIndicationAsync method of BluetoothGattServer")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattServer.SendIndicationAsync M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on")] - [Precondition(1, "\"nRF Connect for Mobile\" must be installed on client device. Download link available in user guide.")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task SendIndicationAsync_RETURN_VALUE() - { - try - { - 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 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); - - Task.Delay(500).Wait(); - - charc.SetValue(origin_val); - BluetoothHelper.DisplayPassLabel("SendIndicationAsync_RETURN_VALUE"); - } - catch (Exception ex) - { - Assert.Fail("[TestCase][SendIndicationAsync_RETURN_VALUE] 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) - { - BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("SendIndicationAsync_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs deleted file mode 100644 index bca8a22..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2019 by Samsung Electronics, Inc., -// -// This software is the confidential and proprietary information -// of Samsung Electronics, Inc. ("Confidential Information"). You -// shall not disclose such Confidential Information and shall use -// it only in accordance with the terms of the license agreement -// you entered into with Samsung. - -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using System.Linq; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("Tizen.Network.Bluetooth.BluetoothGattService test class")] - public class BluetoothGattServiceTests - { - string svcUuid = "181D"; - bool _isBluetoothGattClientSupported = false; - BluetoothGattClient client = null; - bool isConnected = false; - BluetoothLeDevice leDevice = null; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out _isBluetoothGattClientSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - if (isConnected == true) - { - client.DisconnectAsync(); - isConnected = false; - } - - if (client != null) - { - client.Dispose(); - } - } - - [Test] - [Category("P0")] - [Description("Check if GetGattClient correct parent client")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattService.GetGattClient M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Dinesh Dwivedi, dinesh.d@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task GetGattClient_RETURN_VALUE() - { - try - { - BluetoothGattClient svc_client = null; - - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (_isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][GetGattClient_RETURN_VALUE] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - Assert.IsNotNull(srv, "Service returned should not be null"); - Assert.AreEqual(srv.Uuid, svcUuid, "Fetched Service UUID is not matching"); - - svc_client = srv.GetGattClient(); - - Assert.IsNotNull(svc_client, "svc_client returned should not be null"); - Assert.AreSame(client, svc_client); - } - catch (NotSupportedException) - { - if (_isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("GetGattClient_RETURN_VALUE"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSGattConnectionStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSGattConnectionStateChangedEventArgs.cs deleted file mode 100644 index fdbea1e..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSGattConnectionStateChangedEventArgs.cs +++ /dev/null @@ -1,286 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("GattConnectionStateChangedEventArgs Tests")] - public class GattConnectionStateChangedEventArgsTests - { - bool isBluetoothGattClientSupported = false; - BluetoothLeDevice leDevice = null; - bool isGattConnected = false; - BluetoothGattClient client = null; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out isBluetoothGattClientSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - [Test] - [Category("P1")] - [Description("Test IsConnected parameter of GattConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.IsConnected A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task IsConnected_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("IsConnected_READ_ONLY"); - await ManualTest.WaitForConfirm(); - return; - } - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - EventHandler LeDevice_GattConnectionStateChanged = null; - - LeDevice_GattConnectionStateChanged = (sender, e) => { - Log.Info(Globals.LogTag, "GattConnectionStateChanged invoked!! Result: " + e.Result + ", IsConnected: " + e.IsConnected); - - leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; - if (e.Result != (int)BluetoothError.None && e.Result != (int)BluetoothError.AlreadyDone) - { - Log.Info(Globals.LogTag, "Fail to connect " + (int)e.Result); - BluetoothHelper.DisplayRetryLabel("IsConnected_READ_ONLY"); - return; - } - - isGattConnected = e.IsConnected; - Assert.IsInstanceOf(e.IsConnected, "[TestCase][IsConnected_READ_ONLY] Failed"); - Assert.IsTrue(e.IsConnected == true, "[TestCase][IsConnected_READ_ONLY] Failed"); - ManualTest.Confirm(); - }; - - client = leDevice.GattConnect(true); - leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("IsConnected_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("IsConnected_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - if (leDevice != null && isGattConnected == true) - { - leDevice.GattDisconnect(); - await Task.Delay(2000); - isGattConnected = false; - } - client?.Dispose(); - } - } - - [Test] - [Category("P1")] - [Description("Test RemoteAddress parameter of GattConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.RemoteAddress A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Step(2, "TC should pass automatically.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task RemoteAddress_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("RemoteAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - return; - } - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - EventHandler LeDevice_GattConnectionStateChanged = null; - - LeDevice_GattConnectionStateChanged = (sender, e) => { - Log.Info(Globals.LogTag, "GattConnectionStateChanged invoked!! Result: " + e.Result + ", IsConnected: " + e.IsConnected); - - leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; - if (e.Result != (int)BluetoothError.None && e.Result != (int)BluetoothError.AlreadyDone) - { - Log.Info(Globals.LogTag, "Fail to connect " + (int)e.Result); - BluetoothHelper.DisplayRetryLabel("RemoteAddress_READ_ONLY"); - return; - } - - isGattConnected = e.IsConnected; - Assert.IsInstanceOf(e.RemoteAddress, "[TestCase][RemoteAddress_READ_ONLY] Failed"); - Assert.True(String.Equals(e.RemoteAddress, PreconditionUtils.GetBleAddress()), "[TestCase][RemoteAddress_READ_ONLY] Failed"); - ManualTest.Confirm(); - }; - - client = leDevice.GattConnect(true); - leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("RemoteAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("RemoteAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - if (leDevice != null && isGattConnected == true) - { - leDevice.GattDisconnect(); - await Task.Delay(2000); - isGattConnected = false; - } - client?.Dispose(); - } - } - - [Test] - [Category("P1")] - [Description("Test Result parameter of GattConnectionStateChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.GattConnectionStateChangedEventArgs.Result A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run BluetoothGattAttributeTests.ReadRequested_Characteristics_CHECK_EVENT test case on the server device.")] - [Step(1, "Tap the Run button.")] - [Step(2, "TC should pass automatically.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Result_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if BT GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - return; - } - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - EventHandler LeDevice_GattConnectionStateChanged = null; - - LeDevice_GattConnectionStateChanged = (sender, e) => { - Log.Info(Globals.LogTag, "GattConnectionStateChanged invoked!! Result: " + e.Result + ", IsConnected: " + e.IsConnected); - - leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; - if (e.Result != (int)BluetoothError.None && e.Result != (int)BluetoothError.AlreadyDone) - { - Log.Info(Globals.LogTag, "Fail to connect " + (int)e.Result); - BluetoothHelper.DisplayRetryLabel("Result_READ_ONLY"); - return; - } - - isGattConnected = e.IsConnected; - Assert.IsInstanceOf(e.Result, "[TestCase][Result_READ_ONLY] Failed"); - ManualTest.Confirm(); - }; - - client = leDevice.GattConnect(true); - leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Result_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - finally - { - if (leDevice != null && isGattConnected == true) - { - leDevice.GattDisconnect(); - await Task.Delay(2000); - isGattConnected = false; - } - client?.Dispose(); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationSentEventArg.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationSentEventArg.cs deleted file mode 100755 index 10a8857..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationSentEventArg.cs +++ /dev/null @@ -1,396 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("NotificationSentEventArg Tests")] - public class NotificationSentEventArgTests - { - private bool _isBluetoothGattServerSupported = false; - private BluetoothGattServer _server = null; - private string _svcUuid = "181D"; - private string _charUuid = "2A20"; - private string _valueChanged = "valueChanged"; - - [SetUp] - 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check ClientAddress parameter of NotificationSentEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.ClientAddress A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ClientAddress_PROPERTY_READ_ONLY() - { - try - { - 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; - } - - _server = await BluetoothSetup.gatt_server_init(); - Assert.IsNotNull(_server, "Precondition failed: server instance should not be null"); - - EventHandler Server_NotificationSent = null; - - Server_NotificationSent = (sender, e) => { - _server.NotificationSent -= Server_NotificationSent; - Assert.IsNotNull(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed"); - Assert.IsInstanceOf(e.ClientAddress, "[TestCase][ClientAddress_PROPERTY_READ_ONLY] Failed"); - BluetoothHelper.DisplayPassLabel("ClientAddress_PROPERTY_READ_ONLY"); - }; - - EventHandler 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); - } - }; - - srv = _server.GetService(_svcUuid); - charc = srv.GetCharacteristic(_charUuid); - - charc.NotificationStateChanged += Charc_NotificationStateChanged; - - await ManualTest.WaitForConfirm(); - - charc.NotificationStateChanged -= Charc_NotificationStateChanged; - } - catch (NotSupportedException) - { - if (_isBluetoothGattServerSupported == false) - { - BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ClientAddress_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Completed parameter of NotificationSentEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Completed A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Completed_PROPERTY_READ_ONLY() - { - try - { - 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("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 Server_NotificationSent = null; - - Server_NotificationSent = (sender, e) => { - _server.NotificationSent -= Server_NotificationSent; - Assert.IsInstanceOf(e.Completed, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed"); - Assert.IsTrue(e.Completed == true, "[TestCase][Completed_PROPERTY_READ_ONLY] Failed"); - BluetoothHelper.DisplayPassLabel("Completed_PROPERTY_READ_ONLY"); - }; - - EventHandler 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][Completed_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) - { - BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Completed_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Result parameter error code in NotificationSentEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Result A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Result_PROPERTY_READ_ONLY() - { - try - { - 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 Server_NotificationSent = null; - - Server_NotificationSent = (sender, e) => { - _server.NotificationSent -= Server_NotificationSent; - Assert.IsInstanceOf(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"); - }; - - EventHandler 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][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) - { - BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Result_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Server parameter of NotificationSentEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationSentEventArg.Server A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Server_PROPERTY_READ_ONLY() - { - try - { - 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 Server_NotificationSent = null; - - Server_NotificationSent = (sender, e) => { - _server.NotificationSent -= Server_NotificationSent; - Assert.IsNotNull(e.Server, "[TestCase][Server_PROPERTY_READ_ONLY] Failed"); - Assert.IsInstanceOf(e.Server, "[TestCase][Server_PROPERTY_READ_ONLY] Failed"); - Assert.AreSame(_server, e.Server); - BluetoothHelper.DisplayPassLabel("Server_PROPERTY_READ_ONLY"); - }; - - EventHandler 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][Server_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) - { - BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (_isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Server_PROPERTY_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationStateChangedEventArg.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationStateChangedEventArg.cs deleted file mode 100755 index b5f39e8..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSNotificationStateChangedEventArg.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("NotificationStateChangedEventArg Tests")] - public class NotificationStateChangedEventArgTests - { - bool isBluetoothGattServerSupported = false; - BluetoothGattServer server = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - - [SetUp] - 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check Server parameter of NotificationStateChangedEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Server A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Server_READ_ONLY() - { - try - { - 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 Charc_NotificationStateChanged = null; - - Charc_NotificationStateChanged = (sender, e) => { - Assert.IsNotNull(e.Server, "[TestCase][Server_READ_ONLY] Failed"); - Assert.IsInstanceOf(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) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Value parameter of NotificationStateChangedEventArg")] - [Property("SPEC", "Tizen.Network.Bluetooth.NotificationStateChangedEventArg.Value A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Value_READ_ONLY() - { - try - { - 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 Charc_NotificationStateChanged = null; - - Charc_NotificationStateChanged = (sender, e) => { - Assert.IsNotNull(e.Value, "[TestCase][Value_READ_ONLY] Failed"); - Assert.IsInstanceOf(e.Value, "[TestCase][Value_READ_ONLY] Failed"); - BluetoothHelper.DisplayPassLabel("Value_READ_ONLY"); - }; - - srv = server.GetService(svcUuid); - charc = srv.GetCharacteristic(charUuid); - - charc.NotificationStateChanged += Charc_NotificationStateChanged; - - await ManualTest.WaitForConfirm(); - - charc.NotificationStateChanged -= Charc_NotificationStateChanged; - } - catch (NotSupportedException) - { - if (isBluetoothGattServerSupported == false) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSReadRequestedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSReadRequestedEventArgs.cs deleted file mode 100755 index 45278ee..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSReadRequestedEventArgs.cs +++ /dev/null @@ -1,360 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; -using System.Text; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("ReadRequestedEventArgs Tests")] - public class ReadRequestedEventArgsTests - { - bool isBluetoothGattServerSupported = false; - BluetoothGattServer server = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - byte[] charValue = Encoding.UTF8.GetBytes("charValue"); - - [SetUp] - 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check ClientAddress parameter of ReadRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.ClientAddress A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ClientAddress_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Offset parameter of ReadRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Offset A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Offset_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("Offset_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Offset_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check RequestId parameter of ReadRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.RequestId A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task RequestId_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("RequestId_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("RequestId_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Server parameter of ReadRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.ReadRequestedEventArgs.Server A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Server_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs deleted file mode 100644 index 3f03ad8..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSValueChangedEventArgs.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using System.Linq; -using System.Collections.Generic; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("ValueChangedEventArgs Tests")] - public class ValueChangedEventArgsTests - { - bool isBluetoothGattClientSupported = false; - BluetoothGattClient client = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - bool isConnected = false; - BluetoothLeDevice leDevice = null; - - [SetUp] - public void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le.gatt.client", out isBluetoothGattClientSupported); - } - - [TearDown] - public void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - if (isConnected == true) - { - client.DisconnectAsync(); - isConnected = false; - } - - if (client != null) - { - client.Dispose(); - } - } - - [Test] - [Category("P1")] - [Description("Check Value parameter of ValueChangedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.ValueChangedEventArgs.Value A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [Precondition(1, "Bluetooth should be turned on.")] - [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 async Task Value_READ_ONLY() - { - try - { - /* We can't occupy the precondition, if GATT Client feature is not supported in Manual TC */ - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - return; - } - - client = BluetoothGattClient.CreateClient(PreconditionUtils.GetBleAddress()); - Assert.IsInstanceOf(client, "[TestCase][Value_READ_ONLY] Failed"); - Assert.IsNotNull(client, "Precondition failed: client instance should not be null"); - - if (leDevice == null) - { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - } - - await client.ConnectAsync(true); - isConnected = true; - - BluetoothGattService srv = client.GetService(svcUuid); - BluetoothGattCharacteristic charc = srv.GetCharacteristic(charUuid); - - EventHandler Charc_ValueChanged = null; - - Charc_ValueChanged = (sender, e) => { - Assert.IsNotNull(e.Value, "[TestCase][Value_READ_ONLY] Failed"); - Assert.IsInstanceOf(e.Value, "[TestCase][Value_READ_ONLY] Failed"); - ManualTest.Confirm(); - }; - - charc.ValueChanged += Charc_ValueChanged; - - await ManualTest.WaitForConfirm(); - - charc.ValueChanged -= Charc_ValueChanged; - } - catch (NotSupportedException) - { - if (isBluetoothGattClientSupported == false) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattClientSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSWriteRequestedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSWriteRequestedEventArgs.cs deleted file mode 100755 index 6560fcd..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSWriteRequestedEventArgs.cs +++ /dev/null @@ -1,519 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Xamarin.Forms; -using Tizen.System; - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("WriteRequestedEventArgs Tests")] - public class WriteRequestedEventArgsTests - { - bool isBluetoothGattServerSupported = false; - BluetoothGattServer server = null; - string svcUuid = "181D"; - string charUuid = "2A20"; - - [SetUp] - 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 void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - BluetoothSetup.gatt_server_exit(); - } - - [Test] - [Category("P1")] - [Description("Check ClientAddress parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.ClientAddress A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task ClientAddress_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ClientAddress_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Offset parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Offset A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Offset_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("Offset_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Offset_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check RequestId parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.RequestId A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task RequestId_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("RequestId_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("RequestId_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Server parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Server A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Server_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Server_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Value parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Value A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Value_READ_ONLY() - { - try - { - 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 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(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) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Value_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Check Value parameter of WriteRequestedEventArgs")] - [Property("SPEC", "Tizen.Network.Bluetooth.WriteRequestedEventArgs.Response_needed A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] - [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.")] - [Postcondition(1, "If TC fails, turn off and turn on Bluetooth on both the devices. Try again.")] - public async Task Response_needed_READ_ONLY() - { - try - { - 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 Charc_WriteRequested = null; - - Charc_WriteRequested = (sender, e) => { - try - { - BluetoothGattServer s = e.Server; - - Assert.IsInstanceOf(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) - { - BluetoothHelper.DisplayLabel("ResponseNeeded_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothGattServerSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("ResponseNeeded_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -}