From: DoHyun Pyun Date: Mon, 19 Nov 2018 03:50:10 +0000 (+0900) Subject: Enable Bluetooth AVRCP Manual TCs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F193288%2F4;p=test%2Ftct%2Fcsharp%2Fapi.git Enable Bluetooth AVRCP Manual TCs Change-Id: If8feb2a8bb8d0fa88ab5696c5b6ea46a09161a10 Signed-off-by: DoHyun Pyun --- diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs index d493c3cb3..23617adb4 100644 --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs @@ -26,6 +26,7 @@ namespace BluetoothNetworkUtils public static string dataFromServer = "Test from server"; static BluetoothDevice pairedDevice = null; static BluetoothDevice audioDevice = null; + static BluetoothDevice avrcpDevice = null; static BluetoothDevice foundDevice = null; static BluetoothDevice hidDevice = null; public static bool FlagAcceptStateChanged = false; @@ -466,19 +467,37 @@ namespace BluetoothNetworkUtils public static async Task GetBluetoothAvrcpProfileUtil() { - if (pairedDevice == null) + if (avrcpDevice == null) { - BluetoothAdapter.DiscoveryStateChanged += EventHandlerDiscoveryStateChanged; - BluetoothAdapter.StartDiscovery (); - await Task.Delay (5000); - - if (BluetoothAdapter.IsDiscoveryInProgress) - BluetoothAdapter.StopDiscovery (); + // Get the audio device in the paired list + IEnumerable list = BluetoothAdapter.GetBondedDevices(); + if (!list.Any()) { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "There is no bonded device"); + } + else + { + foreach (BluetoothDevice item in list) + { + foreach (string s in item.ServiceUuidList) + { + if (s.Equals(A2dpSnkUuid)) + { + avrcpDevice = item; + break; + } + } + if (avrcpDevice != null) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found the avrcpDevice device: " + avrcpDevice.Address); + break; + } + } + } } - Assert.IsNotNull(pairedDevice, "PRECONDITION Failed: pairedDevice should not be null."); + Assert.IsNotNull(avrcpDevice, "PRECONDITION Failed: avrcpDevice should not be null."); - BtAvrcp = pairedDevice.GetProfile(); + BtAvrcp = avrcpDevice.GetProfile(); return BtAvrcp; } diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAvrcp.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAvrcp.cs old mode 100755 new mode 100644 index 4ca788b8c..2a9d0133c --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAvrcp.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAvrcp.cs @@ -29,15 +29,6 @@ namespace Tizen.Network.Bluetooth.Tests LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST"); } - public static void EventHandlerTargetConnectionChanged(object sender, TargetConnectionStateChangedEventArgs e) - { - if (e.IsConnected) - { - Assert.True(e.IsConnected, "Target is not connected"); - ManualTest.Confirm(); - } - } - public static async Task Setup() { avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); @@ -58,7 +49,7 @@ namespace Tizen.Network.Bluetooth.Tests await Task.Delay(5000); } -// [Test] + [Test] [Category("P1")] [Description("Listen target connection state changed event")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.TargetConnectionStateChanged E")] @@ -66,28 +57,45 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task TargetConnectionStateChanged_CHECK_EVENT() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - Assert.IsNotNull(avrcpProfile, "Precondition failed: Avrcp Profile should not be null"); - Assert.IsNotNull(audioProfile, "Precondition failed: Audio Profile should not be null"); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); } - + + EventHandler EventHandlerTargetConnectionChanged = null; + + EventHandlerTargetConnectionChanged = (sender, e) => { + BluetoothHelper.DisplayPassLabel("TargetConnectionStateChanged_CHECK_EVENT"); + avrcpProfile.TargetConnectionStateChanged -= EventHandlerTargetConnectionChanged; + }; + avrcpProfile.TargetConnectionStateChanged += EventHandlerTargetConnectionChanged; - audioProfile.Connect(BluetoothAudioProfileType.HspHfp); - await ManualTest.WaitForConfirm(); - // POSTCONDITION - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - avrcpProfile.TargetConnectionStateChanged -= EventHandlerTargetConnectionChanged; - } + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + else + audioProfile.Disconnect(BluetoothAudioProfileType.AdvancedAudioDistribution); + + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothAudioControlSupported == false) @@ -110,12 +118,7 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void EventHandlerShuffleModeChanged(object sender, ShuffleModeChangedeventArgs e) - { - ManualTest.Confirm(); - } - -// [Test] + [Test] [Category("P1")] [Description("Listen ShuffleMode changed")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.ShuffleModeChanged E")] @@ -123,27 +126,48 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] [Step(1, "Tap the Run button")] - [Step(2, "Change the shuffle mode in the connected bluetooth headset")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaShuffleStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] [Postcondition(1, "NA")] public static async Task ShuffleModeChanged_CHECK_EVENT() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); } + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerShuffleModeChanged = null; + + EventHandlerShuffleModeChanged = (sender, e) => { + BluetoothHelper.DisplayPassLabel("ShuffleModeChanged_CHECK_EVENT"); + avrcpProfile.ShuffleModeChanged -= EventHandlerShuffleModeChanged; + }; + avrcpProfile.ShuffleModeChanged += EventHandlerShuffleModeChanged; await ManualTest.WaitForConfirm(); - - // POSTCONDITION - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - avrcpProfile.ShuffleModeChanged -= EventHandlerShuffleModeChanged; - } + } catch (NotSupportedException) { if (isBluetoothAudioControlSupported == false) @@ -166,12 +190,83 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void EventHandlerScanModeChanged(object sender, ScanModeChangedEventArgs e) + [Test] + [Category("P1")] + [Description("Test Mode. Check if Mode has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.ShuffleModeChangedeventArgs.Mode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] + [Step(1, "Tap the Run button")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaShuffleStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] + [Postcondition(1, "NA")] + public static async Task Mode_ShuffleModeChangedeventArgs_READ_ONLY() { - ManualTest.Confirm(); + try + { + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerShuffleModeChanged = null; + + EventHandlerShuffleModeChanged = (sender, e) => { + bool result = Enum.IsDefined(typeof(ShuffleMode), e.Mode); + Assert.True(result, "Mode value is not defined in enum"); + Assert.IsInstanceOf(e.Mode, "Mode value is not of type ShuffleMode"); + + BluetoothHelper.DisplayPassLabel("ShuffleModeChangedeventArgs_Mode_READ_ONLY"); + avrcpProfile.ShuffleModeChanged -= EventHandlerShuffleModeChanged; + }; + + avrcpProfile.ShuffleModeChanged += EventHandlerShuffleModeChanged; + await ManualTest.WaitForConfirm(); + } + catch (NotSupportedException) + { + if (isBluetoothAudioControlSupported == false) + { + BluetoothHelper.DisplayLabel("ShuffleModeChangedeventArgs_Mode_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (TypeInitializationException e) + { + if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + { + BluetoothHelper.DisplayLabel("ShuffleModeChangedeventArgs_Mode_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } } -// [Test] + [Test] [Category("P1")] [Description("Listen ScanMode changed")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.ScanModeChanged E")] @@ -179,27 +274,48 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] [Step(1, "Tap the Run button")] - [Step(2, "Change the scan mode in the connected bluetooth headset")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaScanStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] [Postcondition(1, "NA")] public static async Task ScanModeChanged_CHECK_EVENT() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); } - + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerScanModeChanged = null; + + EventHandlerScanModeChanged = (sender, e) => { + BluetoothHelper.DisplayPassLabel("ScanModeChanged_CHECK_EVENT"); + avrcpProfile.ScanModeChanged -= EventHandlerScanModeChanged; + }; + avrcpProfile.ScanModeChanged += EventHandlerScanModeChanged; await ManualTest.WaitForConfirm(); - - // POSTCONDITON - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - avrcpProfile.ScanModeChanged -= EventHandlerScanModeChanged; - } + } catch (NotSupportedException) { if (isBluetoothAudioControlSupported == false) @@ -211,7 +327,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("ScanModeChanged_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } @@ -222,12 +338,83 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void EventHandlerEqualizerStateChanged(object sender, EqualizerStateChangedEventArgs e) + [Test] + [Category("P1")] + [Description("Test Mode. Check if Mode has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.ScanModeChangedEventArgs.Mode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] + [Step(1, "Tap the Run button")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaScanStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] + [Postcondition(1, "NA")] + public static async Task Mode_ScanModeChangedEventArgs_READ_ONLY() { - ManualTest.Confirm(); + try + { + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerScanModeChanged = null; + + EventHandlerScanModeChanged = (sender, e) => { + bool result = Enum.IsDefined(typeof(ScanMode), e.Mode); + Assert.True(result, "Mode value is not defined in enum"); + Assert.IsInstanceOf(e.Mode, "Mode value is not of type ScanMode"); + + BluetoothHelper.DisplayPassLabel("ScanModeChangedEventArgs_Mode_READ_ONLY"); + avrcpProfile.ScanModeChanged -= EventHandlerScanModeChanged; + }; + + avrcpProfile.ScanModeChanged += EventHandlerScanModeChanged; + await ManualTest.WaitForConfirm(); + } + catch (NotSupportedException) + { + if (isBluetoothAudioControlSupported == false) + { + BluetoothHelper.DisplayLabel("ScanModeChangedEventArgs_Mode_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (TypeInitializationException e) + { + if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + { + BluetoothHelper.DisplayLabel("ScanModeChangedEventArgs_Mode_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } } -// [Test] + [Test] [Category("P1")] [Description("Listen EqualizerState changed")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.EqualizerStateChanged E")] @@ -235,28 +422,48 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] [Step(1, "Tap the Run button")] - [Step(2, "Change the equalizer state in the connected bluetooth headset")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaEqualizerStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] [Postcondition(1, "NA")] public static async Task EqualizerStateChanged_CHECK_EVENT() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); } - // TEST CODE + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerEqualizerStateChanged = null; + + EventHandlerEqualizerStateChanged = (sender, e) => { + BluetoothHelper.DisplayPassLabel("EqualizerStateChanged_CHECK_EVENT"); + avrcpProfile.EqualizerStateChanged -= EventHandlerEqualizerStateChanged; + }; + avrcpProfile.EqualizerStateChanged += EventHandlerEqualizerStateChanged; await ManualTest.WaitForConfirm(); - - // POSTCONDITON: - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - avrcpProfile.EqualizerStateChanged -= EventHandlerEqualizerStateChanged; - } + } catch (NotSupportedException) { if (isBluetoothAudioControlSupported == false) @@ -268,7 +475,7 @@ namespace Tizen.Network.Bluetooth.Tests catch (TypeInitializationException e) { if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) - { + { BluetoothHelper.DisplayLabel("EqualizerStateChanged_CHECK_EVENT"); await ManualTest.WaitForConfirm(); } @@ -279,12 +486,83 @@ namespace Tizen.Network.Bluetooth.Tests } } - public static void EventHandlerRepeatModeChanged(object sender, RepeatModeChangedEventArgs e) + [Test] + [Category("P1")] + [Description("Test State. Check if State has proper value")] + [Property("SPEC", "Tizen.Network.Bluetooth.EqualizerStateChangedEventArgs.State A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] + [Step(1, "Tap the Run button")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaEqualizerStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] + [Postcondition(1, "NA")] + public static async Task State_EqualizerStateChangedEventArgs_READ_ONLY() { - ManualTest.Confirm(); + try + { + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerEqualizerStateChanged = null; + + EventHandlerEqualizerStateChanged = (sender, e) => { + bool result = Enum.IsDefined(typeof(EqualizerState), e.State); + Assert.True(result, "State value is not defined in enum"); + Assert.IsInstanceOf(e.State, "State value is not of type EqualizerState"); + + BluetoothHelper.DisplayPassLabel("EqualizerStateChangedEventArgs_State_READ_ONLY"); + avrcpProfile.EqualizerStateChanged -= EventHandlerEqualizerStateChanged; + }; + + avrcpProfile.EqualizerStateChanged += EventHandlerEqualizerStateChanged; + await ManualTest.WaitForConfirm(); + } + catch (NotSupportedException) + { + if (isBluetoothAudioControlSupported == false) + { + BluetoothHelper.DisplayLabel("EqualizerStateChangedEventArgs_State_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (TypeInitializationException e) + { + if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + { + BluetoothHelper.DisplayLabel("EqualizerStateChangedEventArgs_State_READ_ONLY"); + await ManualTest.WaitForConfirm(); + } + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } } -// [Test] + [Test] [Category("P1")] [Description("Listen RepeatMode changed")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.RepeatModeChanged E")] @@ -292,28 +570,124 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "EVL")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] [Step(1, "Tap the Run button")] - [Step(2, "Change the repeat mode in the connected bluetooth headset")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaRepeatStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] [Postcondition(1, "NA")] public static async Task RepeatModeChanged_CHECK_EVENT() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) { - await Setup(); - await ConnectSetup(); + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } - - // TEST CODE + + EventHandler EventHandlerRepeatModeChanged = null; + + EventHandlerRepeatModeChanged = (sender, e) => { + BluetoothHelper.DisplayPassLabel("RepeatModeChanged_CHECK_EVENT"); + avrcpProfile.RepeatModeChanged -= EventHandlerRepeatModeChanged; + }; + avrcpProfile.RepeatModeChanged += EventHandlerRepeatModeChanged; await ManualTest.WaitForConfirm(); + } + catch (NotSupportedException) + { + if (isBluetoothAudioControlSupported == false) + { + BluetoothHelper.DisplayLabel("RepeatModeChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + } + } + catch (TypeInitializationException e) + { + if (isBluetoothAudioControlSupported == false && e.InnerException.GetType() == typeof(NotSupportedException)) + { + BluetoothHelper.DisplayLabel("RepeatModeChanged_CHECK_EVENT"); + await ManualTest.WaitForConfirm(); + } + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Mode. Check the Mode value")] + [Property("SPEC", "Tizen.Network.Bluetooth.RepeatModeChangedEventArgs.Mode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] + [Precondition(1, "Turn on the bluetooth")] + [Precondition(2, "Paired with BT headset.")] + [Precondition(3, "Sdb is connected as root with the target. \n>sdb root on")] + [Step(1, "Tap the Run button")] + [Step(2, "Run next command in the linux shell.\n>sdb shell dbus-send --system --type=signal /org/projectx/bt/avrcp org.projectx.bt_event.MediaRepeatStatus uint32:1")] + [Step(3, "(Because there is no UX senario or entry point to invoke this event, so we should generate the event using command line to pass this TCT")] + [Postcondition(1, "NA")] + public static async Task Mode_RepeatModeChangedEventArgs_READ_ONLY() + { + try + { + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } - // POSTCONDITON: - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - avrcpProfile.RepeatModeChanged -= EventHandlerRepeatModeChanged; - } + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); + } + + EventHandler EventHandlerRepeatModeChanged = null; + + EventHandlerRepeatModeChanged = (sender, e) => { + bool result = Enum.IsDefined(typeof(RepeatMode), e.Mode); + Assert.True(result, "Mode value is not defined in enum"); + Assert.IsInstanceOf(e.Mode, "Mode value is not of type RepeatMode"); + + BluetoothHelper.DisplayPassLabel("RepeatModeChanged_CHECK_EVENT"); + avrcpProfile.RepeatModeChanged -= EventHandlerRepeatModeChanged; + }; + + avrcpProfile.RepeatModeChanged += EventHandlerRepeatModeChanged; + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothAudioControlSupported == false) @@ -336,7 +710,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify equalizer state to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyEqualizerState M")] @@ -345,23 +719,40 @@ namespace Tizen.Network.Bluetooth.Tests [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyEqualizerState_RETURN_VALUE_NOTIFY() { try { - // PRECONDITION - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) { - await Setup(); - await ConnectSetup(); + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyEqualizerState(EqualizerState.On); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -385,7 +776,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify repeat mode to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyRepeatMode M")] @@ -393,22 +784,40 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] - [Step(2, "Check if log show \"[TestCase][NotifyRepeatMode] Pass\".")] [Postcondition(1, "NA")] public static async Task NotifyRepeatMode_RETURN_VALUE_NOTIFY() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) { - await Setup(); - await ConnectSetup(); + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyRepeatMode(RepeatMode.AllTrack); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -432,7 +841,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify shuffle mode to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyShuffleMode M")] @@ -440,22 +849,40 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyShuffleMode_RETURN_VALUE_NOTIFY() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyShuffleMode(ShuffleMode.AllTrack); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -479,7 +906,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify scan mode to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyScanMode M")] @@ -487,22 +914,40 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyScanMode_RETURN_VALUE_NOTIFY() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyScanMode(ScanMode.AllTrack); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -526,7 +971,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify player state to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyPlayerState M")] @@ -534,22 +979,40 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyPlayerState_RETURN_VALUE_NOTIFY() { try { - if (avrcpProfile == null || audioProfile == null) + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) { - await Setup(); - await ConnectSetup(); + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyPlayerState(PlayerState.Playing); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -573,7 +1036,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify current position to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyCurrentPosition M")] @@ -581,7 +1044,7 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyCurrentPosition_RETURN_VALUE_NOTIFY() @@ -589,16 +1052,33 @@ namespace Tizen.Network.Bluetooth.Tests try { uint position = 0; + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); - if (avrcpProfile == null || audioProfile == null) + if (isAudioConnected == false) { - await Setup(); - await ConnectSetup(); + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyCurrentPosition(position); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) { @@ -622,7 +1102,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Notify track data to remote device")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAvrcp.NotifyTrack M")] @@ -630,32 +1110,49 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "MR")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task NotifyTrack_RETURN_VALUE_NOTIFY() { try { - Track track = new Track(); + bool isAudioConnected = false; + Track track = new Track(); - track.Title = "title"; - track.Artist = "artist"; - track.Album = "album"; - track.Genre = "genre"; - track.TrackNum = 5; - track.TotalTracks = 6; - track.Duration = 4000; + track.Title = "title"; + track.Artist = "artist"; + track.Album = "album"; + track.Genre = "genre"; + track.TrackNum = 5; + track.TotalTracks = 6; + track.Duration = 4000; - if (avrcpProfile == null || audioProfile == null) + if (audioProfile == null) { - await Setup(); - await ConnectSetup(); + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.AdvancedAudioDistribution); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + if (avrcpProfile == null) + { + avrcpProfile = await BluetoothSetup.GetBluetoothAvrcpProfileUtil(); + Assert.IsNotNull(avrcpProfile, "Precondtion failed: avrcpProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + { + audioProfile.Connect(BluetoothAudioProfileType.AdvancedAudioDistribution); + await Task.Delay(3000); } avrcpProfile.NotifyTrack(track); - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); + // This testcase is for Method return. If there is no excception to call the method, then TC is passed. + + ManualTest.Confirm(); } catch (NotSupportedException) {