From 40de2b6aec4c64052b03f74b8e78f0ba41aeef9d Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Thu, 7 Feb 2019 10:11:22 +0900 Subject: [PATCH] [Non-ACR][Bluetooth][Enable GetGattClient_RETURN_VALUE testcase] Change-Id: Iac3ba356a470ef5b6034483aad4bba5cfa28a327 Signed-off-by: DoHyun Pyun --- .../testcase/TSBluetoothGattService.cs | 105 +++++++++++++++++++++ .../testcase/TSBluetoothGattService.cs | 12 --- 2 files changed, 105 insertions(+), 12 deletions(-) create mode 100755 tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs new file mode 100755 index 0000000..a4742da --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothGattService.cs @@ -0,0 +1,105 @@ +// 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(); + } + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothGattService.cs b/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothGattService.cs index ebcf8c0..abbeccb 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothGattService.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothGattService.cs @@ -445,18 +445,6 @@ namespace Tizen.Network.Bluetooth.Tests } [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")] - public static void GetGattClient_RETURN_VALUE() - { - // Now way to add service to client in test environment - } - - [Test] [Category("P1")] [Description("Check if Uuid property return same value as passed in constructor")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothGattService.Uuid A")] -- 2.7.4