--- /dev/null
+// 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;
+
+ [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("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("RemoteAddress_PROPERTY_READ_ONLY");
+ await ManualTest.WaitForConfirm();
+ return;
+ }
+
+ _client = await BluetoothSetup.gatt_client_init();
+ Assert.IsNotNull(_client, "Precondition failed: _client instance should not be null");
+
+ 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("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());
+ }
+ finally
+ {
+ await BluetoothSetup.gatt_client_exit();
+ }
+ }
+ }
+}