From: DoHyun Pyun Date: Mon, 2 Nov 2020 01:23:37 +0000 (+0900) Subject: [Bluetooth][Manual][Non-ACR] Make combine TC for HID X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F50%2F246550%2F5;p=test%2Ftct%2Fcsharp%2Fapi.git [Bluetooth][Manual][Non-ACR] Make combine TC for HID To reduce the time consuming for verifying BT C# Manual TCT, we classify testcases using same senario. And remove the duplicate execution. Change-Id: I971187530706340eb75255d111bf34d8cc01474f Signed-off-by: DoHyun Pyun --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine1_Hid.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine1_Hid.cs new file mode 100644 index 0000000..882669f --- /dev/null +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothCombine1_Hid.cs @@ -0,0 +1,386 @@ +using System; +using System.Threading.Tasks; +using BluetoothNetworkUtils; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.System; +using Xamarin.Forms; + +/* ***********************************************************************/ + +// ** Scenario: Manage connections of the HID Profile +// ** +// ** -setup an Access Point: +// ** name/securetype: "Bluetooth_public"/public +// ** -connect to Hid Device +// ** -get the remote device address and connection status +// ** -catch events +// ** + +/* ***********************************************************************/ + +namespace Tizen.Network.Bluetooth.Tests +{ + [TestFixture] + [Description("BluetoothHid Tests")] + public class BluetoothHidTests { + + static BluetoothDevice hidDevice = null; + static bool isBluetoothHidSupported = false; + static bool flagBondCreated = false; + static bool scanFlag = false; + + /* PASS flag Variaibles for TCs */ + static bool pass_HidConnectionStateChanged_CHECK_EVENT = false; + static bool pass_Connect_RETURN_HID_CONNECT = false; + static bool pass_Disconnect_RETURN_HID_DISCONNECT = false; + static bool pass_Address_READ_ONLY = false; + static bool pass_IsConnected_READ_ONLY = false; + static bool pass_Result_READ_ONLY = false; + + static internal class Globals + { + internal const string LogTag = "Tizen.Network.Bluetooth"; + } + + [SetUp] + public static void Init() { + Tizen.Log.Info(Globals.LogTag, "Preconditions for each TEST"); + Information.TryGetValue("tizen.org/feature/network.bluetooth.hid", out isBluetoothHidSupported); + } + + [TearDown] + public static void Destroy() { + Tizen.Log.Info(Globals.LogTag, "Postconditions for each TEST"); + } + + public static async Task WaitForBondflag() + { + int count = 0; + while(true) + { + await Task.Delay(1000); + count++; + + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Waiting..."); + + if (flagBondCreated == true) + break; + + if (count == 10) + break; + } + } + + public static async Task WaitScanFlag() + { + int count = 0; + while (true) + { + await Task.Delay (1000); + count++; + + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Waiting..."); + + if (scanFlag == true) + break; + + count++; + if (count == 10) + break; + } + } + + public static void EventHandlerHidDiscoveryStateChanged(object sender, DiscoveryStateChangedEventArgs e) + { + if (hidDevice != null) + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "hidDevice instance already exist"); + return; + } + + if (e.DiscoveryState == BluetoothDeviceDiscoveryState.Found) + { + BluetoothDevice resultDevice = e.DeviceFound; + BluetoothClass btClass = resultDevice.Class; + + if (btClass.MajorDeviceClassType == BluetoothMajorDeviceClassType.Peripheral) + { + scanFlag = true; + hidDevice = resultDevice; + } + } + } + + public static async Task GetBluetoothHidDevice() + { + if (hidDevice == null) + { + BluetoothAdapter.DiscoveryStateChanged += EventHandlerHidDiscoveryStateChanged; + BluetoothAdapter.StartDiscovery(); + await WaitScanFlag(); + + if (BluetoothAdapter.IsDiscoveryInProgress) + BluetoothAdapter.StopDiscovery (); + + await Task.Delay(1000); + + BluetoothAdapter.DiscoveryStateChanged -= EventHandlerHidDiscoveryStateChanged; + } + + return hidDevice; + } + + public static async Task HidCombine_TEST() + { + try + { + bool hidConnected = false; + bool hidDisconnected = false; + BluetoothHid hidProfile = null; + + if (hidDevice == null) + { + hidDevice = await GetBluetoothHidDevice(); + Assert.IsNotNull(hidDevice, "Precondtion failed: Can't search HID device"); + } + + hidProfile = hidDevice.GetProfile(); + Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); + + /* Bond with hid device */ + if (hidDevice.IsPaired == false) + { + EventHandler EventHandlerBondCreated = null; + + EventHandlerBondCreated = (sender, e) => { + if (e.Device != null && e.Result == 0) + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Success to bond with HID device"); + flagBondCreated = true; + } + }; + + hidDevice.BondCreated += EventHandlerBondCreated; + + hidDevice.CreateBond(); + await WaitForBondflag(); + + hidDevice.BondCreated -= EventHandlerBondCreated; + } + + EventHandler hidConnectionCallback = null; + + hidConnectionCallback = (sender, e) => { + /* PASS condition for HidConnectionStateChanged_CHECK_EVENT */ + pass_HidConnectionStateChanged_CHECK_EVENT = true; + + /* PASS condition for Address_READ_ONLY */ + Assert.IsNotNull(e.Address, "Address should not be Null"); + Assert.AreNotEqual(e.Address, "", "RemoteAddress is invalid"); + pass_Address_READ_ONLY = true; + + /* PASS condition for IsConnected_READ_ONLY */ + Assert.IsInstanceOf(e.IsConnected, "IsConnected value is not of type bool"); + pass_IsConnected_READ_ONLY = true; + + /* PASS condition for Result_READ_ONLY */ + Assert.IsInstanceOf(e.Result, "Result value is not of type int"); + pass_Result_READ_ONLY = true; + }; + hidProfile.HidConnectionStateChanged += hidConnectionCallback; + + /* PASS condition for Connect_RETURN_HID_CONNECT */ + hidProfile.Connect(); + pass_Connect_RETURN_HID_CONNECT = true; + + await Task.Delay (5000); + + /* PASS condition for Disconnect_RETURN_HID_DISCONNECT */ + hidProfile.Disconnect(); + pass_Disconnect_RETURN_HID_DISCONNECT = true; + + await Task.Delay (3000); + + hidProfile.HidConnectionStateChanged -= hidConnectionCallback; + } + catch (NotSupportedException) + { + if (isBluetoothHidSupported == false) + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Not Supported"); + } + catch (TypeInitializationException e) + { + if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Not Supported"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Check connection state changed event in hid device")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.HidConnectionStateChanged E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Step(2, "If Hid device is connected then passed automatically otherwise, it is fail")] + [Postcondition(1, "NA")] + public static async Task HidConnectionStateChanged_CHECK_EVENT() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("HidConnectionStateChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_HidConnectionStateChanged_CHECK_EVENT == false) + await HidCombine_TEST(); + + Assert.True(pass_HidConnectionStateChanged_CHECK_EVENT, "[TestCase][HidConnectionStateChanged_CHECK_EVENT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Connect to a device of HID profile")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.Connect M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Postcondition(1, "NA")] + public static async Task Connect_RETURN_HID_CONNECT() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("Connect_RETURN_HID_CONNECT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Connect_RETURN_HID_CONNECT == false) + await HidCombine_TEST(); + + Assert.True(pass_Connect_RETURN_HID_CONNECT, "[TestCase][Connect_RETURN_HID_CONNECT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Disconnect to a device of HID profile")] + [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.Disconnect M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "M")] + [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Postcondition(1, "NA")] + public static async Task Disconnect_RETURN_HID_DISCONNECT() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("Disconnect_RETURN_HID_DISCONNECT"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Disconnect_RETURN_HID_DISCONNECT == false) + await HidCombine_TEST(); + + Assert.True(pass_Disconnect_RETURN_HID_DISCONNECT, "[TestCase][Disconnect_RETURN_HID_DISCONNECT] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Address. Check if Address has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.Address A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Postcondition(1, "NA")] + public static async Task Address_READ_ONLY() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("Address_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Address_READ_ONLY == false) + await HidCombine_TEST(); + + Assert.True(pass_Address_READ_ONLY, "[TestCase][Address_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test IsConnected. Check if IsConnected has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.IsConnected A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Postcondition(1, "NA")] + public static async Task IsConnected_READ_ONLY() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("IsConnected_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_IsConnected_READ_ONLY == false) + await HidCombine_TEST(); + + Assert.True(pass_IsConnected_READ_ONLY, "[TestCase][IsConnected_READ_ONLY] Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Result. Check if Result has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.Result A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] + [Step(1, "Tap the Run button")] + [Postcondition(1, "NA")] + public static async Task Result_READ_ONLY() + { + /* We can't occupy the precondition, if HID feature is not supported in Manual TC */ + if (isBluetoothHidSupported == false) + { + BluetoothHelper.DisplayLabel("Result_READ_ONLY"); + await ManualTest.WaitForConfirm(); + return; + } + + if (pass_Result_READ_ONLY == false) + await HidCombine_TEST(); + + Assert.True(pass_Result_READ_ONLY, "[TestCase][Result_READ_ONLY] Fail"); + } + } +} diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHid.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHid.cs deleted file mode 100755 index 103255f..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothHid.cs +++ /dev/null @@ -1,254 +0,0 @@ -using System; -using System.Threading.Tasks; -using BluetoothNetworkUtils; -using NUnit.Framework; -using NUnit.Framework.TUnit; -using Tizen.System; -using Xamarin.Forms; - -/* ***********************************************************************/ - -// ** Scenario: Manage connections of the HID Profile -// ** -// ** -setup an Access Point: -// ** name/securetype: "Bluetooth_public"/public -// ** -connect to Hid Device -// ** -get the remote device address and connection status -// ** -catch events -// ** - -/* ***********************************************************************/ - -namespace Tizen.Network.Bluetooth.Tests -{ - [TestFixture] - [Description("BluetoothHid Tests")] - public class BluetoothHidTests { - - static BluetoothHid hidProfile = null; - static bool hidStateChanged = false; - static bool isBluetoothHidSupported = false; - - static internal class Globals - { - internal const string LogTag = "Tizen.Network.Bluetooth"; - } - - [SetUp] - public static void Init() { - Tizen.Log.Info(Globals.LogTag, "Preconditions for each TEST"); - Information.TryGetValue("tizen.org/feature/network.bluetooth.hid", out isBluetoothHidSupported); - } - - [TearDown] - public static void Destroy() { - Tizen.Log.Info(Globals.LogTag, "Postconditions for each TEST"); - } - - [Test] - [Category("P1")] - [Description("Check connection state changed event in hid device")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.HidConnectionStateChanged E")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "EVL")] - [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Step(2, "If Hid device is connected then passed automatically otherwise, it is fail")] - [Postcondition(1, "NA")] - public static async Task HidConnectionStateChanged_CHECK_EVENT() - { - try - { - bool hidConnected = false; - bool hidDisconnected = false; - - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - EventHandler hidConnectionCallback = null; - - // TEST CODE - hidConnectionCallback = (sender, e) => { - if (e.Result == 0 && e.IsConnected == true) - { - hidConnected = true; - } - else if (e.Result == 0 && e.IsConnected == false) - { - hidDisconnected = true; - } - - if (hidConnected == true && hidDisconnected == true) - { - // true and false state was called - Assert.IsTrue(true); - ManualTest.Confirm(); - } - }; - hidProfile.HidConnectionStateChanged += hidConnectionCallback; - Tizen.Log.Info(Globals.LogTag, "setting cb"); - hidProfile.Connect(); - - await Task.Delay (5000); - - hidProfile.Disconnect(); - - await ManualTest.WaitForConfirm(); - - //POSTCONDITION - hidProfile.HidConnectionStateChanged -= hidConnectionCallback; - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("HidConnectionStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("HidConnectionStateChanged_CHECK_EVENT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Hid Connect")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.Connect M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "MR")] - [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Postcondition(1, "NA")] - public static async Task Connect_RETURN_HID_CONNECT() - { - try - { - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - Tizen.Log.Info(Globals.LogTag, "setting cb"); - hidProfile.Connect(); - - await Task.Delay (5000); - - BluetoothHelper.DisplayPassLabel("Connect_RETURN_HID_CONNECT"); - await ManualTest.WaitForConfirm(); - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("Connect_RETURN_HID_CONNECT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Connect_RETURN_HID_CONNECT"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Hid Disconnect")] - [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothHid.Disconnect M")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "M")] - [Property("AUTHOR", "Sandeep Hattiholi sandeephattiholi@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Postcondition(1, "NA")] - public static async Task Disconnect_RETURN_HID_DISCONNECT() - { - try - { - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - EventHandler hidConnectionCallback = null; - - hidConnectionCallback = (sender, e) => { - if (e.Result == 0 && e.IsConnected) - { - hidStateChanged = e.IsConnected; - } - }; - hidProfile.HidConnectionStateChanged += hidConnectionCallback; - Tizen.Log.Info(Globals.LogTag, "setting cb"); - hidProfile.Connect(); - await Task.Delay (5000); - - hidProfile.HidConnectionStateChanged -= hidConnectionCallback; - - if(hidStateChanged) - { - // TEST CODE - hidProfile.Disconnect(); - - BluetoothHelper.DisplayPassLabel("Disconnect_RETURN_HID_DISCONNECT"); - await ManualTest.WaitForConfirm(); - } - else - { - Assert.IsTrue(false); - ManualTest.Confirm(); - } - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("Disconnect_RETURN_HID_DISCONNECT"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Disconnect_RETURN_HID_DISCONNECT"); - 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/TSHidConnectionStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSHidConnectionStateChangedEventArgs.cs deleted file mode 100755 index e6166c1..0000000 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSHidConnectionStateChangedEventArgs.cs +++ /dev/null @@ -1,202 +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("HidConnectionStateChangedEventArgs Tests")] - public class HidConnectionStateChangedEventArgsTests - { - static BluetoothHid hidProfile = null; - static bool isBluetoothHidSupported = false; - - [SetUp] - public static void Init() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST"); - Information.TryGetValue("tizen.org/feature/network.bluetooth.hid", out isBluetoothHidSupported); - } - [TearDown] - public static void Destroy() - { - LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); - } - - [Test] - [Category("P1")] - [Description("Test Address. Check if Address has proper value")] - [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.Address A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Postcondition(1, "NA")] - public static async Task Address_READ_ONLY() - { - try { - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - EventHandler hidConnectionCallback = null; - - // TEST CODE - hidConnectionCallback = (sender, e) => { - Assert.IsNotNull(e.Address); - Assert.AreNotEqual(e.Address, ""); - ManualTest.Confirm(); - }; - hidProfile.HidConnectionStateChanged += hidConnectionCallback; - hidProfile.Connect(); - await ManualTest.WaitForConfirm(); - - //POSTCONDITION - hidProfile.HidConnectionStateChanged -= hidConnectionCallback; - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - - [Test] - [Category("P1")] - [Description("Test IsConnected. Check if IsConnected has proper value")] - [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.IsConnected A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Postcondition(1, "NA")] - public static async Task IsConnected_READ_ONLY() - { - try { - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - EventHandler hidConnectionCallback = null; - - // TEST CODE - hidConnectionCallback = (sender, e) => { - Assert.IsInstanceOf(e.IsConnected, "IsConnected value is not of type bool"); - ManualTest.Confirm(); - }; - hidProfile.HidConnectionStateChanged += hidConnectionCallback; - hidProfile.Connect(); - await ManualTest.WaitForConfirm(); - - //POSTCONDITION - hidProfile.HidConnectionStateChanged -= hidConnectionCallback; - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("IsConnected_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == 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()); - } - } - - [Test] - [Category("P1")] - [Description("Test Result. Check if Result has proper value")] - [Property("SPEC", "Tizen.Network.Bluetooth.HidConnectionStateChangedEventArgs.Result A")] - [Property("SPEC_URL", "-")] - [Property("CRITERIA", "PRO")] - [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] - [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth Hid device near the test device.")] - [Step(1, "Tap the Run button")] - [Postcondition(1, "NA")] - public static async Task Result_READ_ONLY() - { - try { - // PRECONDTION - if (hidProfile == null) - { - hidProfile = await BluetoothSetup.GetBluetoothHidProfileUtil(); - Assert.IsNotNull(hidProfile, "Precondtion failed: hidProfile should not be null"); - } - - EventHandler hidConnectionCallback = null; - - // TEST CODE - hidConnectionCallback = (sender, e) => { - Assert.IsInstanceOf(e.Result, "Result value is not of type int"); - ManualTest.Confirm(); - }; - hidProfile.HidConnectionStateChanged += hidConnectionCallback; - hidProfile.Connect(); - await ManualTest.WaitForConfirm(); - - //POSTCONDITION - hidProfile.HidConnectionStateChanged -= hidConnectionCallback; - } - catch (NotSupportedException) - { - if (isBluetoothHidSupported == false) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (TypeInitializationException e) - { - if (isBluetoothHidSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { - BluetoothHelper.DisplayLabel("Address_READ_ONLY"); - await ManualTest.WaitForConfirm(); - } - } - catch (Exception ex) - { - Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); - } - } - } -}