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;
public static async Task<BluetoothAudio> 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<BluetoothDevice> 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))
{
}
else if (BluetoothAudioProfileType.AdvancedAudioDistribution == profile)
{
- foreach (string s in pairedDevice.ServiceUuidList)
+ foreach (string s in audioDevice.ServiceUuidList)
{
if (s.Equals(A2dpSnkUuid))
{
}
else if (BluetoothAudioProfileType.AdvancedAudioDistributionSink == profile)
{
- foreach (string s in pairedDevice.ServiceUuidList)
+ foreach (string s in audioDevice.ServiceUuidList)
{
if (s.Equals(A2dpSrcUuid))
{
}
else if (BluetoothAudioProfileType.AudioGateway == profile)
{
- foreach (string s in pairedDevice.ServiceUuidList)
+ foreach (string s in audioDevice.ServiceUuidList)
{
if (s.Equals(HspAgUuid) || s.Equals(HfpAgUuid))
{
IsProfileSupported = true;
}
if (IsProfileSupported)
- BtAudio = pairedDevice.GetProfile<BluetoothAudio>();
+ BtAudio = audioDevice.GetProfile<BluetoothAudio>();
return BtAudio;
}
return BtHid;
}
+ public static bool IsBluetoothAudioProfileConnected(BluetoothAudioProfileType profile)
+ {
+ if (audioDevice == null)
+ {
+ // Get the audio device in the paired list
+ IEnumerable<BluetoothDevice> 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<BluetoothProfileType> 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)
audioProfile.AudioConnectionStateChanged -= audioConnectionCallback;
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Test Address. Check if Address has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.Address A")]
[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<AudioConnectionStateChangedEventArgs> 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)
}
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Test IsConnected. Check if IsConnected has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.IsConnected A")]
[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<AudioConnectionStateChangedEventArgs> audioConnectionCallback = null;
+
+ audioConnectionCallback = (sender, e) => {
+ Assert.IsInstanceOf<bool>(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)
{
}
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Test ProfileType. Check if ProfileType has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.ProfileType A")]
[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<AudioConnectionStateChangedEventArgs> audioConnectionCallback = null;
+
+ audioConnectionCallback = (sender, e) => {
+ Assert.IsInstanceOf<BluetoothAudioProfileType>(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)
{
}
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Test Result. Check if Result has proper value")]
[Property("SPEC", "Tizen.Network.Bluetooth.AudioConnectionStateChangedEventArgs.Result A")]
[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<AudioConnectionStateChangedEventArgs> audioConnectionCallback = null;
+
+ audioConnectionCallback = (sender, e) => {
+ Assert.IsInstanceOf<int>(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)
{
audioProfile.AudioConnectionStateChanged -= audioConnectionCallback;
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Connect to a device of audio profile All")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.Connect M")]
[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)
{
}
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Disconnect the audio profile")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.Disconnect M")]
[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<AudioConnectionStateChangedEventArgs> 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)
{
}
}
-// [Test]
+ [Test]
[Category("P1")]
[Description("Check the Audio connectionstate changed event with the audio profile")]
[Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAudio.AudioConnectionStateChanged E")]
[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<AudioConnectionStateChangedEventArgs> 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)
{