From d21cf70b79212c5c567293f73b4116ec9a74a4b4 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 15 Jan 2019 14:45:39 +0900 Subject: [PATCH] [Non-ACR][Bluetooth][Manual] Enable Bluetooth LeDevice TCs Change-Id: I827f6eb9e541cd515967d9878c207ec9dee7ced6 --- .../TSAdapterLeScanResultChangedEventArgs.cs | 54 +- .../testcase/TSBluetoothHelper.cs | 6 + .../testcase/TSBluetoothLeDevice.cs | 738 ++++++++++++--------- 3 files changed, 465 insertions(+), 333 deletions(-) mode change 100755 => 100644 tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeDevice.cs diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAdapterLeScanResultChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAdapterLeScanResultChangedEventArgs.cs index 386d078..df4c6e9 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAdapterLeScanResultChangedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAdapterLeScanResultChangedEventArgs.cs @@ -27,7 +27,7 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST"); } -// [Test] + [Test] [Category("P1")] [Description("Test Result. Check the Result value")] [Property("SPEC", "Tizen.Network.Bluetooth.AdapterLeScanResultChangedEventArgs.Result A")] @@ -35,16 +35,31 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task Result_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanDevice(); - Assert.IsNotNull(leDevice, "[TestCase][Result_PROPERTY] Le Scan is giving error: " + BluetoothSetup.result); - } + EventHandler scanDeviceResultEventHandler = null; + + scanDeviceResultEventHandler = (sender, e) => { + BluetoothAdapter.StopLeScan(); + Task.Delay(1000).Wait(); + + Assert.IsTrue((int)e.Result == 0, "[TestCase][Result_PROPERTY_READ_ONLY] Failed"); + BluetoothHelper.DisplayPassLabel("Result_PROPERTY_READ_ONLY"); + }; + + BluetoothAdapter.ScanResultChanged += scanDeviceResultEventHandler; + + BluetoothAdapter.StartLeScan(); + + await ManualTest.WaitForConfirm(); + + BluetoothAdapter.ScanResultChanged -= scanDeviceResultEventHandler; + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -67,7 +82,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test DeviceData. Check the DeviceData value")] [Property("SPEC", "Tizen.Network.Bluetooth.AdapterLeScanResultChangedEventArgs.DeviceData A")] @@ -75,17 +90,34 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Exist the nearby BLE device on the advertising mode")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task DeviceData_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanDevice(); - Assert.IsNotNull(leDevice, "[TestCase][DeviceData_PROPERTY] Failed to find Le device"); - } - catch (NotSupportedException) + EventHandler scanDeviceResultEventHandler = null; + + scanDeviceResultEventHandler = (sender, e) => { + BluetoothAdapter.StopLeScan(); + Task.Delay(1000).Wait(); + + Assert.IsNotNull(e.DeviceData, "[TestCase][DeviceData_PROPERTY_READ_ONLY] Failed"); + Assert.IsInstanceOf(e.DeviceData, "[TestCase][DeviceData_PROPERTY_READ_ONLY] Failed"); + + BluetoothHelper.DisplayPassLabel("DeviceData_PROPERTY_READ_ONLY"); + }; + + BluetoothAdapter.ScanResultChanged += scanDeviceResultEventHandler; + + BluetoothAdapter.StartLeScan(); + + await ManualTest.WaitForConfirm(); + + BluetoothAdapter.ScanResultChanged -= scanDeviceResultEventHandler; + } + catch (NotSupportedException) { if (isBluetoothLeSupported == false) { diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHelper.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHelper.cs index db1291e..8e4fcaa 100755 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHelper.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHelper.cs @@ -26,6 +26,12 @@ namespace Tizen.Network.Bluetooth.Tests ManualTest.DisplayCustomLabel(msg + " is passed. \n Please press pass.\n"); } + // Create message method. + internal static void DisplayRetryLabel(String msg) + { + ManualTest.DisplayCustomLabel(msg + " is failed. \n Please re-run the testcase.\n"); + } + // Create AppControl launch method internal static void LaunchVisiblityAppControl(String timeout) { diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeDevice.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeDevice.cs old mode 100755 new mode 100644 index 30f192a..eec4ad5 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeDevice.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothLeDevice.cs @@ -15,8 +15,8 @@ namespace Tizen.Network.Bluetooth.Tests public class BluetoothLeDeviceTests { static BluetoothLeDevice leDevice = null; - static bool isFound = false; static bool isBluetoothLeSupported = false; + static bool isGattConnected = false; [SetUp] public static void Init() @@ -34,7 +34,7 @@ namespace Tizen.Network.Bluetooth.Tests BluetoothSetup.gatt_client_exit(); } -// [Test] + [Test] [Category("P1")] [Description("Test AddressType property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.AddressType A")] @@ -42,25 +42,32 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task AddressType_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("AddressType_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - if (Enum.IsDefined (typeof(BluetoothLeDeviceAddressType), leDevice.AddressType)) - Log.Info("TCT", "[TestCase][AddressType_PROPERTY] Pass : Address Type is : " + leDevice.AddressType); - else - Assert.Fail("[TestCase][AddressType_PROPERTY] Fail"); + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } // Test case scenarios can't be generated for individual BluetoothLeDeviceAddressType enum // values as the value is getting set from capi framework. - } + Assert.IsInstanceOf(leDevice.AddressType, "[TestCase][AddressType_PROPERTY] Fail"); + Assert.True(Enum.IsDefined(typeof(BluetoothLeDeviceAddressType), leDevice.AddressType), "[TestCase][AddressType_PROPERTY] Fail"); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -83,7 +90,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test AdvertsingDataInformation property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.AdvertsingDataInformation A")] @@ -91,26 +98,30 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task AdvertsingDataInformation_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); - - byte[] advDataInfo = leDevice.AdvertsingDataInformation; - if (advDataInfo != null && advDataInfo.Length > 0) + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) { - Assert.IsInstanceOf(advDataInfo.Length, "Adv info length Should be of type integer"); - Log.Info("TCT", "[TestCase][AdvertsingDataInformation_PROPERTY] Pass : Adv Data length is : " + advDataInfo.Length); + BluetoothHelper.DisplayLabel("AdvertsingDataInformation_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; } - else + + if (leDevice == null) { - Assert.Fail("AdvertsingDataInformation byte array is not proper - FAIL"); + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); } + + Assert.IsNotNull(leDevice.AdvertsingDataInformation, "[TestCase][AdvertsingDataInformation_PROPERTY_READ_ONLY] Fail"); + Assert.IsInstanceOf(leDevice.AdvertsingDataInformation.Length, "[TestCase][AdvertsingDataInformation_PROPERTY_READ_ONLY] Fail"); + Assert.True(leDevice.AdvertsingDataInformation.Length > 0, "[TestCase][AdvertsingDataInformation_PROPERTY_READ_ONLY] Fail"); } catch (NotSupportedException) { @@ -134,31 +145,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void AppearanceTest(BluetoothLePacketType type) - { - leDevice.PacketType = type; - try - { - int appearance = leDevice.Appearance; - if (appearance != -1) - { - Assert.IsInstanceOf(leDevice.Appearance); - Log.Info("TCT", "[TestCase][Appearance_PROPERTY] Pass" + appearance); - isFound = true; - } - else - { - Assert.Fail("[TestCase][Appearance_PROPERTY] Appearance not found in packet type : " + type); - } - } - catch (Exception ex) - { - Log.Info("TCT", "[TestCase][Appearance_PROPERTY] Fail - No data found for Appearance" + ex); - Assert.Fail("Le get Appearance should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test Appearance property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.Appearance A")] @@ -166,29 +153,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task Appearance_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("Appearance_PROPERTY_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"); + } // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - AppearanceTest(BluetoothLePacketType.BluetoothLeAdvertisingPacket); - if (!isFound) + Log.Info("TCT", "[TestCase][DeviceName_PROPERTY] Packet type is set to BluetoothLeAdvertisingPacket"); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + int appearance = leDevice.Appearance; + if (appearance == -1) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - AppearanceTest(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + appearance = leDevice.Appearance; + if (appearance == -1) + { Assert.Fail("[TestCase][Appearance_PROPERTY] Appearance not found in any packet data FAIL"); + } } - isFound = false; - } + Assert.IsInstanceOf(leDevice.Appearance); + Log.Info("TCT", "[TestCase][Appearance_PROPERTY] Pass" + appearance); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -211,31 +213,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void DeviceNameTest(BluetoothLePacketType type) - { - leDevice.PacketType = type; - try - { - string name = leDevice.DeviceName; - if (name != null) - { - Assert.IsInstanceOf(leDevice.DeviceName); - Log.Info("TCT", "[TestCase][DeviceName_PROPERTY] Pass : Device name is : " + name); - isFound = true; - } - else - { - Assert.Fail("[TestCase][DeviceName_PROPERTY] Device name not found in packet " + type); - } - } - catch (Exception ex) - { - Log.Info("TCT", "[TestCase][DeviceName_PROPERTY] Fail - No data for device name" + ex); - Assert.Fail("Le get device name should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test DeviceName property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.DeviceName A")] @@ -243,28 +221,41 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task DeviceName_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("DeviceName_PROPERTY_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"); + } // TEST CODE Log.Info("TCT", "[TestCase][DeviceName_PROPERTY] Packet type is set to BluetoothLeAdvertisingPacket"); - DeviceNameTest(BluetoothLePacketType.BluetoothLeAdvertisingPacket); - if (!isFound) + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + string deviceName = leDevice.DeviceName; + if (deviceName == null) { - DeviceNameTest(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) - Assert.Fail("[TestCase][DeviceName_PROPERTY] Device name not found in any packet data FAIL"); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + deviceName = leDevice.DeviceName; + Assert.IsNotNull(deviceName, "[TestCase][DeviceName_PROPERTY] Device name not found in any packet data FAIL"); } - isFound = false; - } + Assert.IsInstanceOf(leDevice.DeviceName); + Log.Info("TCT", "[TestCase][DeviceName_PROPERTY] Pass : Device name is : " + deviceName); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -287,33 +278,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void TestManufacturerData(BluetoothLePacketType type) - { - Log.Info("TCT", "[TestCase][ManufacturerData_PROPERTY] - Packet Type is : " + type); - leDevice.PacketType = type; - try - { - ManufacturerData data = new ManufacturerData(); - data = leDevice.ManufacturerData; - if (data != null) - { - Assert.IsNotNull(data.Data, "Data property of ManufacturerData is not proper"); - Assert.IsInstanceOf(data.DataLength, "DataLength property of ManufacturerData is not proper"); - Assert.IsInstanceOf(data.Id, "Id property of ManufacturerData is not proper"); - Log.Info("TCT", "[TestCase][ManufacturerData_PROPERTY] PASS: Found Manufacturer data Id : " + data.Id + " Length : " + data.DataLength); - isFound = true; - } - else - Assert.Fail("[TestCase][ManufacturerData_PROPERTY] - No manufacturer data present in packet type : " + type); - } - catch (Exception ex) - { - Log.Info("TCT", "[TestCase][ManufacturerData_PROPERTY] - Failed with error : " + ex); - Assert.Fail("Le get manufacturer data should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test ManufacturerData property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.ManufacturerData A")] @@ -321,30 +286,43 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task ManufacturerData_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("ManufacturerData_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - TestManufacturerData(BluetoothLePacketType.BluetoothLeAdvertisingPacket); + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } - if (!isFound) + // TEST CODE + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + ManufacturerData data = new ManufacturerData(); + data = leDevice.ManufacturerData; + if (data == null) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - TestManufacturerData(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) - Assert.Fail("[TestCase][ManufacturerData_PROPERTY] - No manufacturer data present in either packet type : FAIL "); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + data = leDevice.ManufacturerData; + Assert.IsNotNull(data, "[TestCase][DeviceName_PROPERTY] No manufacturer data present in either packet type : FAIL"); } - isFound = false; - } + Assert.IsNotNull(data.Data, "Data property of ManufacturerData is not proper"); + Assert.IsInstanceOf(data.DataLength, "DataLength property of ManufacturerData is not proper"); + Assert.IsInstanceOf(data.Id, "Id property of ManufacturerData is not proper"); + Log.Info("TCT", "[TestCase][ManufacturerData_PROPERTY] PASS: Found Manufacturer data Id : " + data.Id + " Length : " + data.DataLength); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -367,7 +345,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test RemoteAddress property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.RemoteAddress A")] @@ -375,28 +353,31 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task RemoteAddress_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("RemoteAddress_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - string address = leDevice.RemoteAddress; - if (!address.Equals(null)) + if (leDevice == null) { - Log.Info("TCT", "[TestCase][RemoteAddress_PROPERTY] Pass :" + address); - Assert.IsInstanceOf(leDevice.RemoteAddress, "should of type string"); + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); } - else - { - Assert.Fail("[TestCase][RemoteAddress_PROPERTY] Fail"); - } - } + + // TEST CODE + Assert.IsNotNull(leDevice.RemoteAddress, "[TestCase][RemoteAddress_PROPERTY] Fail"); + Assert.IsInstanceOf(leDevice.RemoteAddress, "[TestCase][RemoteAddress_PROPERTY] Fail"); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -419,7 +400,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test Rssi property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.Rssi A")] @@ -427,20 +408,31 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task Rssi_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("Rssi_PROPERTY_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"); + } // TEST CODE Assert.IsInstanceOf(leDevice.Rssi); Log.Info("TCT", "[TestCase][Rssi_PROPERTY] Pass" + leDevice.Rssi); - } + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -463,7 +455,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test ScanDataInformation property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.ScanDataInformation A")] @@ -471,15 +463,26 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task ScanDataInformation_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("ScanDataInformation_PROPERTY_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"); + } byte[] scanDataInfo = leDevice.ScanDataInformation; if (scanDataInfo != null && scanDataInfo.Length > 0) @@ -513,31 +516,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void SSUidTest(BluetoothLePacketType type) - { - leDevice.PacketType = type; - try - { - IEnumerable ssuuid = leDevice.ServiceSolictationUuid; - if (ssuuid != null) - { - foreach (string uuid in ssuuid) - Log.Info("TCT", "[TestCase][ServiceSolictationUuid_PROPERTY] UUID is : " + uuid); - - Log.Info("TCT", "[TestCase][ServiceSolictationUuid] PASS"); - isFound = true; - } - else - Assert.Fail("[TestCase][ServiceSolictationUuid_PROPERTY] FAIL OR TRY with different packet type"); - } - catch (Exception ex) - { - Log.Info("TCT", "[TestCase][ServiceSolictationUuid_PROPERTY] - Failed with error : " + ex); - Assert.Fail("Le get service solicitation uuid should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test ServiceSolictationUuid property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.ServiceSolictationUuid A")] @@ -545,29 +524,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task ServiceSolictationUuid_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup (); - Assert.IsNotNull (leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("ServiceSolictationUuid_PROPERTY_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"); + } // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - SSUidTest(BluetoothLePacketType.BluetoothLeAdvertisingPacket); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + IEnumerable ssuuid = leDevice.ServiceSolictationUuid; + if (ssuuid == null) + { + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + ssuuid = leDevice.ServiceSolictationUuid; + + Assert.IsNotNull(ssuuid, "[TestCase][ServiceSolictationUuid_PROPERTY] No SSUID data found in either packet type : FAIL"); + } - if (!isFound) + foreach (string uuid in ssuuid) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - SSUidTest(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) - Assert.Fail("[TestCase][ServiceSolictationUuid_PROPERTY] - No SSUID data found in either packet type : FAIL "); + Log.Info("TCT", "[TestCase][ServiceSolictationUuid_PROPERTY] UUID is : " + uuid); } - isFound = false; - } + Log.Info("TCT", "[TestCase][ServiceSolictationUuid] PASS"); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -590,30 +584,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void UUidTest(BluetoothLePacketType type) - { - leDevice.PacketType = type; - try - { - IEnumerable svcuuid = leDevice.ServiceUuid; - if (svcuuid != null) - { - foreach (string uuid in svcuuid) - Log.Info("TCT", "[TestCase][ServiceUuid_PROPERTY] UUID is : " + uuid); - - Log.Info("TCT", "[TestCase][ServiceUuid_PROPERTY] PASS"); - isFound = true; - } - else - Assert.Fail("[TestCase][ServiceUuid_PROPERTY]] FAIL OR TRY with different packet type"); - } - catch (Exception ex) - { - Assert.Fail("LE read service uuid should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test ServiceUuid property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.ServiceUuid A")] @@ -621,30 +592,44 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task ServiceUuid_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("ServiceUuid_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - UUidTest(BluetoothLePacketType.BluetoothLeAdvertisingPacket); + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } - if (!isFound) + // TEST CODE + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + IEnumerable svcuuid = leDevice.ServiceUuid; + if (svcuuid == null) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - UUidTest(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) - Assert.Fail("[TestCase][ServiceUuid_PROPERTY] - No Service uuid data found in either packet type : FAIL "); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + svcuuid = leDevice.ServiceUuid; + + Assert.IsNotNull(svcuuid, "[TestCase][ServiceUuid_PROPERTY_READ_ONLY] No SVC UUID found in either packet type : FAIL"); } - isFound = false; - } + foreach (string uuid in svcuuid) + { + Log.Info("TCT", "[TestCase][ServiceUuid_PROPERTY] UUID is : " + uuid); + } + Log.Info("TCT", "[TestCase][ServiceUuid_PROPERTY] PASS"); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -667,22 +652,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void TxPowerLevelTest(BluetoothLePacketType type) - { - leDevice.PacketType = type; - int txLevel = leDevice.TxPowerLevel; - - if (txLevel != -1) - { - Assert.IsInstanceOf(leDevice.TxPowerLevel, "BluetoothLeDevice TxPowerLevel is not valid"); - Log.Info("TCT", "[TestCase][TxPowerLevel_PROPERTY] Pass - Tx Power Level is : " + txLevel); - isFound = true; - } - else - Assert.Fail("[TestCase][TxPowerLevel_PROPERTY]] FAIL OR TRY with different packet type"); - } - -// [Test] + [Test] [Category("P1")] [Description("Test TxPowerLevel property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.TxPowerLevel A")] @@ -690,30 +660,43 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task TxPowerLevel_PROPERTY_READ_ONLY() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("TxPowerLevel_PROPERTY_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - TxPowerLevelTest(BluetoothLePacketType.BluetoothLeAdvertisingPacket); + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } - if (!isFound) + // TEST CODE + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + int txLevel = leDevice.TxPowerLevel; + if (txLevel == -1) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - TxPowerLevelTest(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + txLevel = leDevice.TxPowerLevel; + if (txLevel == -1) + { Assert.Fail("[TestCase][TxPowerLevel_PROPERTY] - No TxPowerLevel data found in either packet type : FAIL "); + } } - isFound = false; - } + Assert.IsInstanceOf(leDevice.TxPowerLevel, "BluetoothLeDevice TxPowerLevel is not valid"); + Log.Info("TCT", "[TestCase][TxPowerLevel_PROPERTY] Pass - Tx Power Level is : " + txLevel); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -736,32 +719,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void TestGetServiceData(BluetoothLePacketType type) - { - leDevice.PacketType = type; - try - { - IEnumerable serviceList = leDevice.GetServiceDataList(); - if (serviceList == null) - { - Assert.Fail("[TestCase][GetServiceDataList_RETURN_LIST] - GetServiceDataList is Empty in packet type " + type); - } - else - { - foreach (BluetoothLeServiceData data in serviceList) - { - Log.Info("TCT", "[TestCase][GetServiceDataList_RETURN_LIST] PASS: Retrieved service data list UUID : " + data.ServiceUuid + " length is " + data.ServiceDataLength); - } - isFound = true; - } - } catch (Exception ex) - { - Log.Info("TCT", "[TestCase][GetServiceDataList_RETURN_LIST] Exception caught with error : " + ex); - Assert.Fail("Le Get ServiceData should not throw exception " + ex.ToString()); - } - } - -// [Test] + [Test] [Category("P1")] [Description("Test GetServiceDataList method of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.GetServiceDataList M")] @@ -769,32 +727,43 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task GetServiceDataList_RETURN_LIST() { try { - isFound = false; - - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("GetServiceDataList_RETURN_LIST"); + await ManualTest.WaitForConfirm(); + return; + } - // TEST CODE - // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket - TestGetServiceData(BluetoothLePacketType.BluetoothLeAdvertisingPacket); + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } - if (!isFound) + // TEST CODE + leDevice.PacketType = BluetoothLePacketType.BluetoothLeAdvertisingPacket; + IEnumerable serviceList = leDevice.GetServiceDataList(); + if (serviceList == null) { - // Test with enum value : BluetoothLePacketType.BluetoothLeScanResponsePacket - TestGetServiceData(BluetoothLePacketType.BluetoothLeScanResponsePacket); - if (!isFound) - Assert.Fail("[TestCase][GetServiceDataList Property] - No GetServiceDataList found in either packet type : FAIL "); + leDevice.PacketType = BluetoothLePacketType.BluetoothLeScanResponsePacket; + serviceList = leDevice.GetServiceDataList(); + + Assert.IsNotNull(serviceList, "[TestCase][GetServiceDataList Property] No GetServiceDataList found in either packet type : FAIL"); } - isFound = false; - } + foreach (BluetoothLeServiceData data in serviceList) + { + Log.Info("TCT", "[TestCase][GetServiceDataList_RETURN_LIST] PASS: Retrieved service data list UUID : " + data.ServiceUuid + " length is " + data.ServiceDataLength); + } + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -817,7 +786,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test PacketType property of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.PacketType A")] @@ -825,15 +794,26 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRW")] [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] [Precondition(1, "Open Bluetooth in Settings on test device and turn on Bluetooth")] - [Precondition(2, "Run StartAdvertising test case on another device")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task PacketType_PROPERTY_READ_WRITE() { try { - leDevice = await BluetoothSetup.LeScanSetup(); - Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("PacketType_PROPERTY_READ_WRITE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } // TEST CODE BluetoothLePacketType PacketType; @@ -867,7 +847,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test GattConnect method of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.GattConnect M")] @@ -875,7 +855,7 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run ReadRequested_Characteristics_CHECK_EVENT TC on the server device.")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button.")] [Step(2, "TC should pass automatically.")] [Postcondition(1, "If TC fails, turn off and turn on Bluetooth. Try again.")] @@ -883,9 +863,43 @@ namespace Tizen.Network.Bluetooth.Tests { try { - // TEST CODE - await BluetoothSetup.gatt_client_init(); - } + BluetoothGattClient client = null; + + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("GattConnect_RETURN_VALUE"); + 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) => { + leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; + if (e.Result == 0 && e.IsConnected == true) + { + isGattConnected = true; + BluetoothHelper.DisplayPassLabel("GattConnect_RETURN_VALUE"); + } + else + { + BluetoothHelper.DisplayRetryLabel("GattConnect_RETURN_VALUE"); + } + }; + + client = leDevice.GattConnect(false); + + leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; + + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -897,7 +911,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothLeSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("GattConnect_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -908,7 +922,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test GattDisconnect method of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.GattDisconnect M")] @@ -916,7 +930,7 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run ReadRequested_Characteristics_CHECK_EVENT TC on the server device.")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button.")] [Step(2, "TC should pass automatically.")] [Postcondition(1, "If TC fails, turn off and turn on Bluetooth. Try again.")] @@ -924,12 +938,45 @@ namespace Tizen.Network.Bluetooth.Tests { try { - await BluetoothSetup.gatt_client_init(); + BluetoothGattClient client = null; - BluetoothSetup.leDevice.GattDisconnect(); - await Task.Delay(10000); - Assert.IsTrue(!BluetoothSetup.StateChanged_flag, "GattConnectionStateChanged callback is not invoked for Disconnect"); - } + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("GattDisconnect_RETURN_VALUE"); + await ManualTest.WaitForConfirm(); + return; + } + + if (leDevice == null) + { + leDevice = await BluetoothSetup.LeScanSetup(); + Assert.IsNotNull(leDevice, "Precondition failed: Le device instance should not be null"); + } + + if (isGattConnected == false) + { + leDevice.GattConnect(false); + await Task.Delay(2000); + } + + EventHandler LeDevice_GattConnectionStateChanged = null; + + LeDevice_GattConnectionStateChanged = (sender, e) => { + leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; + if (e.Result == 0 && e.IsConnected == false) + { + isGattConnected = false; + BluetoothHelper.DisplayPassLabel("GattDisconnect_RETURN_VALUE"); + } + }; + + leDevice.GattDisconnect(); + + leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; + + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -941,7 +988,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothLeSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("GattDisconnect_RETURN_VALUE"); await ManualTest.WaitForConfirm(); } @@ -952,7 +999,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - //[Test] + [Test] [Category("P1")] [Description("Test GattConnectionStateChanged event of BluetoothLeDevice")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothLeDevice.GattConnectionStateChanged E")] @@ -960,7 +1007,7 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Gowtham Anandha Babu, gowtham.ab@samsung.com")] [Precondition(1, "Bluetooth should be turned on.")] - [Precondition(2, "Run ReadRequested_Characteristics_CHECK_EVENT TC on the server device.")] + [Precondition(2, "Run GATT Server test case on another device")] [Step(1, "Tap the Run button.")] [Step(2, "TC should pass automatically.")] [Postcondition(1, "If TC fails, turn off and turn on Bluetooth. Try again.")] @@ -968,8 +1015,46 @@ namespace Tizen.Network.Bluetooth.Tests { try { - await BluetoothSetup.gatt_client_init(); - } + BluetoothGattClient client = null; + + /* We can't occupy the precondition, if BT LE feature is not supported in Manual TC */ + if (isBluetoothLeSupported == false) + { + BluetoothHelper.DisplayLabel("GattConnectionStateChanged_CHECK_EVENT"); + 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) => { + leDevice.GattConnectionStateChanged -= LeDevice_GattConnectionStateChanged; + if (e.Result == 0) + { + isGattConnected = e.IsConnected; + BluetoothHelper.DisplayPassLabel("GattConnectionStateChanged_CHECK_EVENT"); + } + }; + + if (isGattConnected == true) + { + leDevice.GattDisconnect(); + } + else + { + client = leDevice.GattConnect(false); + } + + leDevice.GattConnectionStateChanged += LeDevice_GattConnectionStateChanged; + + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothLeSupported == false) @@ -981,7 +1066,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothLeSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("GattConnectionStateChanged_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } @@ -990,6 +1075,15 @@ namespace Tizen.Network.Bluetooth.Tests { Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); } + finally + { + if (leDevice != null && isGattConnected == true) + { + leDevice.GattDisconnect(); + await Task.Delay(2000); + isGattConnected = false; + } + } } } } -- 2.7.4