From: DoHyun Pyun Date: Mon, 12 Nov 2018 02:46:07 +0000 (+0900) Subject: [Bluetooth][Non-ACR] Enable Bluetooth Audio Manual TCs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F192845%2F5;p=test%2Ftct%2Fcsharp%2Fapi.git [Bluetooth][Non-ACR] Enable Bluetooth Audio Manual TCs Change-Id: Idc2669f9cc68317836c79f6eb763c9de23c99cd7 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 old mode 100755 new mode 100644 index bbbb084..d493c3c --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/BluetoothSetup.cs @@ -25,6 +25,7 @@ namespace BluetoothNetworkUtils public static IBluetoothClientSocket Client = null; public static string dataFromServer = "Test from server"; static BluetoothDevice pairedDevice = null; + static BluetoothDevice audioDevice = null; static BluetoothDevice foundDevice = null; static BluetoothDevice hidDevice = null; public static bool FlagAcceptStateChanged = false; @@ -380,21 +381,39 @@ namespace BluetoothNetworkUtils public static async Task GetBluetoothAudioProfileUtil(BluetoothAudioProfileType profile) { bool IsProfileSupported = false; - if (pairedDevice == null) + if (audioDevice == 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(HspHsUuid) || s.Equals(HfpHsUuid) || s.Equals(A2dpSnkUuid)) + { + audioDevice = item; + break; + } + } + if (audioDevice != null) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found the audio device: " + audioDevice.Address); + break; + } + } + } } - Assert.IsNotNull(pairedDevice, "PRECONDITION Failed: pairedDevice should not be null."); + Assert.IsNotNull(audioDevice, "PRECONDITION Failed: audioDevice should not be null."); if (BluetoothAudioProfileType.HspHfp == profile) { - foreach (string s in pairedDevice.ServiceUuidList) + foreach (string s in audioDevice.ServiceUuidList) { if (s.Equals(HspHsUuid) || s.Equals(HfpHsUuid)) { @@ -405,7 +424,7 @@ namespace BluetoothNetworkUtils } else if (BluetoothAudioProfileType.AdvancedAudioDistribution == profile) { - foreach (string s in pairedDevice.ServiceUuidList) + foreach (string s in audioDevice.ServiceUuidList) { if (s.Equals(A2dpSnkUuid)) { @@ -416,7 +435,7 @@ namespace BluetoothNetworkUtils } else if (BluetoothAudioProfileType.AdvancedAudioDistributionSink == profile) { - foreach (string s in pairedDevice.ServiceUuidList) + foreach (string s in audioDevice.ServiceUuidList) { if (s.Equals(A2dpSrcUuid)) { @@ -427,7 +446,7 @@ namespace BluetoothNetworkUtils } else if (BluetoothAudioProfileType.AudioGateway == profile) { - foreach (string s in pairedDevice.ServiceUuidList) + foreach (string s in audioDevice.ServiceUuidList) { if (s.Equals(HspAgUuid) || s.Equals(HfpAgUuid)) { @@ -441,7 +460,7 @@ namespace BluetoothNetworkUtils IsProfileSupported = true; } if (IsProfileSupported) - BtAudio = pairedDevice.GetProfile(); + BtAudio = audioDevice.GetProfile(); return BtAudio; } @@ -508,6 +527,69 @@ namespace BluetoothNetworkUtils return BtHid; } + public static bool IsBluetoothAudioProfileConnected(BluetoothAudioProfileType profile) + { + if (audioDevice == null) + { + // 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(HspHsUuid) || s.Equals(HfpHsUuid) || s.Equals(A2dpSnkUuid)) + { + audioDevice = item; + break; + } + } + if (audioDevice != null) + { + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "Found the audio device: " + audioDevice.Address); + break; + } + } + } + } + + if (audioDevice == null) + return false; + + IEnumerable profilelist = audioDevice.GetConnectedProfiles(); + if (!profilelist.Any()) + { + // The actual connected profile information is not related with TC result. + LogUtils.Write (LogUtils.DEBUG, LogUtils.TAG, "No connected audio profile"); + return false; + } + else + { + foreach (BluetoothProfileType item in profilelist) + { + if (item == BluetoothProfileType.AdvancedAudioDistribution) { + if (profile == BluetoothAudioProfileType.AdvancedAudioDistribution || profile == BluetoothAudioProfileType.All) + return true; + } else if (item == BluetoothProfileType.Headset) { + if (profile == BluetoothAudioProfileType.HspHfp || profile == BluetoothAudioProfileType.All) + return true; + } else if (item == BluetoothProfileType.AudioGateway) { + if (profile == BluetoothAudioProfileType.AudioGateway || profile == BluetoothAudioProfileType.All) + return true; + } else if (item == BluetoothProfileType.AdvancedAudioDistributionSink) { + if (profile == BluetoothAudioProfileType.AdvancedAudioDistributionSink || profile == BluetoothAudioProfileType.All) + return true; + } + } + } + + return false; + } + public static void RemoveBluetoothDeviceProfileUtil() { if (pairedDevice != null) diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAudioConnectionStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAudioConnectionStateChangedEventArgs.cs old mode 100755 new mode 100644 index 08da5a6..2e84d2f --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAudioConnectionStateChangedEventArgs.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSAudioConnectionStateChangedEventArgs.cs @@ -166,7 +166,7 @@ namespace Tizen.Network.Bluetooth.Tests audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; } -// [Test] + [Test] [Category("P1")] [Description("Test Address. Check if Address has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.Address A")] @@ -174,18 +174,42 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth audio profile device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task Address_READ_ONLY() { try { - // PRECONDITION: - // 1. Turn on the bluetooth - // 2. Keep discoverable bluetooth headset device near the test device. - await SetupCheckAddress(BluetoothAudioProfileType.All); - } + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + EventHandler audioConnectionCallback = null; + + audioConnectionCallback = (sender, e) => { + if (e.Address != null) + { + BluetoothHelper.DisplayPassLabel("AudioConnectionStateChangedEventArgs.Address_READ_ONLY"); + audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; + } + }; + + audioProfile.AudioConnectionStateChanged += audioConnectionCallback; + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.All); + else + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await ManualTest.WaitForConfirm(); + } catch (NotSupportedException) { if (isBluetoothAudioMediaSupported == false && isBluetoothAudioCallSupported == false) @@ -209,7 +233,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test IsConnected. Check if IsConnected has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.IsConnected A")] @@ -217,17 +241,39 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task IsConnected_READ_ONLY() { try { - // PRECONDITION: - // 1. Turn on the bluetooth - // 2. Keep discoverable bluetooth headset device near the test device. - await SetupCheckConnected(BluetoothAudioProfileType.HspHfp); + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + EventHandler audioConnectionCallback = null; + + audioConnectionCallback = (sender, e) => { + Assert.IsInstanceOf(e.IsConnected, "IsConnected value is not of type bool"); + BluetoothHelper.DisplayPassLabel("AudioConnectionStateChangedEventArgs.IsConnected_READ_ONLY"); + audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; + }; + + audioProfile.AudioConnectionStateChanged += audioConnectionCallback; + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.All); + else + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { @@ -252,7 +298,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test ProfileType. Check if ProfileType has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.ProfileType A")] @@ -260,17 +306,39 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth headset device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task ProfileType_READ_ONLY() { try { - // PRECONDITION: - // 1. Turn on the bluetooth - // 2. Keep discoverable bluetooth headset device near the test device. - await SetupCheckProfileType(BluetoothAudioProfileType.AdvancedAudioDistribution); + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + EventHandler audioConnectionCallback = null; + + audioConnectionCallback = (sender, e) => { + Assert.IsInstanceOf(e.ProfileType, "ProfileType parameter should be of type BluetoothAudioProfileType"); + BluetoothHelper.DisplayPassLabel("AudioConnectionStateChangedEventArgs.ProfileType_READ_ONLY"); + audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; + }; + + audioProfile.AudioConnectionStateChanged += audioConnectionCallback; + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.All); + else + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { @@ -295,7 +363,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Test Result. Check if Result has proper value")] [Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.Result A")] @@ -303,17 +371,39 @@ namespace Tizen.Network.Bluetooth.Tests [Property("CRITERIA", "PRO")] [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")] [Precondition(1, "Turn on the bluetooth")] - [Precondition(2, "Keep discoverable bluetooth audio profile device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] [Postcondition(1, "NA")] public static async Task Result_READ_ONLY() { try { - // PRECONDITION: - // 1. Turn on the bluetooth - // 2. Keep discoverable bluetooth headset device near the test device. - await SetupCheckResult(BluetoothAudioProfileType.AdvancedAudioDistribution); + bool isAudioConnected = false; + + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + EventHandler audioConnectionCallback = null; + + audioConnectionCallback = (sender, e) => { + Assert.IsInstanceOf(e.Result, "Result parameter should be of type int"); + BluetoothHelper.DisplayPassLabel("AudioConnectionStateChangedEventArgs.Result_READ_ONLY"); + audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; + }; + + audioProfile.AudioConnectionStateChanged += audioConnectionCallback; + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.All); + else + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { diff --git a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAudio.cs b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAudio.cs old mode 100755 new mode 100644 index f40b26b..e35d00d --- a/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAudio.cs +++ b/tct-suite-vs/Tizen.Bluetooth.Manual.Tests/testcase/TSBluetoothAudio.cs @@ -75,7 +75,7 @@ namespace Tizen.Network.Bluetooth.Tests audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; } -// [Test] + [Test] [Category("P1")] [Description("Connect to a device of audio profile All")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.Connect M")] @@ -83,14 +83,37 @@ 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 audio profile device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] - [Postcondition(1, "Unpair the bluetooth headset device if paired")] + [Postcondition(1, "N/A")] public static async Task Connect_RETURN_CONNECT_PROFILE_ENUM_ALL() { try { - await SetupForConnectAudio(BluetoothAudioProfileType.All); + bool isAudioConnected = false; + + // PRECONDITION + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == true) { + audioProfile.Disconnect(BluetoothAudioProfileType.All); + await Task.Delay(3000); + } + + audioProfile.Connect(BluetoothAudioProfileType.All); + + await Task.Delay(3000); + + // Connect method returns without error + BluetoothHelper.DisplayPassLabel("Connect_RETURN_CONNECT_PROFILE_ENUM_ALL"); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { @@ -115,7 +138,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Disconnect the audio profile")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.Disconnect M")] @@ -123,35 +146,38 @@ 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 audio profile device near the test device and wait for successfull disconnection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] - [Postcondition(1, "Unpair the bluetooth headset device if paired")] + [Postcondition(1, "N/A")] public static async Task Disconnect_RETURN_DISCONNECT_PROFILES_ENUM_ALL() { try { - // PRECONDITION - isConnected = false; - await SetupForConnectAudio(BluetoothAudioProfileType.All); + bool isAudioConnected = false; - // TEST CODE - if(isConnected) + // PRECONDTION + if (audioProfile == null) { - EventHandler audioDisconnectionCallback = null; - audioDisconnectionCallback = (sender, e) => { - if (e.Result == 0 && !e.IsConnected && e.Address != null) - { - ManualTest.Confirm(); - } - }; - audioProfile.AudioConnectionStateChanged += audioDisconnectionCallback; - audioProfile.Disconnect(BluetoothAudioProfileType.All); - await ManualTest.WaitForConfirm(); + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } - // POSTCONDITION - BluetoothSetup.RemoveBluetoothDeviceProfileUtil(); - audioProfile.AudioConnectionStateChanged -= audioDisconnectionCallback; + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) { + audioProfile.Connect(BluetoothAudioProfileType.All); + await Task.Delay(3000); } + + // TEST CODE + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await Task.Delay(3000); + + // Disconnect method returns without error + BluetoothHelper.DisplayPassLabel("Disconnect_RETURN_DISCONNECT_PROFILES_ENUM_ALL"); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) { @@ -176,7 +202,7 @@ namespace Tizen.Network.Bluetooth.Tests } } -// [Test] + [Test] [Category("P1")] [Description("Check the Audio connectionstate changed event with the audio profile")] [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.AudioConnectionStateChanged E")] @@ -184,14 +210,43 @@ 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 audio profile device near the test device and wait for successfull connection.")] + [Precondition(2, "Paired with BT headset.")] [Step(1, "Tap the Run button")] - [Postcondition(1, "Unpair the bluetooth headset device if paired")] + [Postcondition(1, "N/A")] public static async Task AudioConnectionStateChanged_CHECK_EVENT_ENUM_ALL() { try { - await SetupForConnectAudio(BluetoothAudioProfileType.All); + bool isAudioConnected = false; + + // PRECONDTION + if (audioProfile == null) + { + audioProfile = await BluetoothSetup.GetBluetoothAudioProfileUtil(BluetoothAudioProfileType.All); + Assert.IsNotNull(audioProfile, "Precondtion failed: audioProfile should not be null"); + } + + EventHandler audioConnectionCallback = null; + + audioConnectionCallback = (sender, e) => { + if (e.Result == 0) + { + isConnected = e.IsConnected; + BluetoothHelper.DisplayPassLabel("AudioConnectionStateChanged_CHECK_EVENT_ENUM_ALL"); + audioProfile.AudioConnectionStateChanged -= audioConnectionCallback; + } + }; + + audioProfile.AudioConnectionStateChanged += audioConnectionCallback; + + isAudioConnected = BluetoothSetup.IsBluetoothAudioProfileConnected(BluetoothAudioProfileType.All); + + if (isAudioConnected == false) + audioProfile.Connect(BluetoothAudioProfileType.All); + else + audioProfile.Disconnect(BluetoothAudioProfileType.All); + + await ManualTest.WaitForConfirm(); } catch (NotSupportedException) {