--- /dev/null
+using System;
+using System.Threading.Tasks;
+using System.Linq;
+using System.Collections.Generic;
+using BluetoothNetworkUtils;
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System.Collections.ObjectModel;
+using Tizen.System;
+
+namespace Tizen.Network.Bluetooth.Tests
+{
+ [TestFixture]
+ [Description("BluetoothProfile Tests")]
+ public class BluetoothProfileTests
+ {
+ bool isBluetoothSupported = false;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Preconditions for each TEST");
+ Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out isBluetoothSupported);
+ }
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.INFO, "Postconditions for each TEST");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Get the BluetoothProfile instance from abstract class")]
+ [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothProfile.BluetoothProfile M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "CONSTR")]
+ [Property("AUTHOR", "Shikha, shikha.ta@samsung.com")]
+ [Precondition(1, "Turn on the bluetooth")]
+ [Precondition(2, "Paired with the remote device.")]
+ [Step(1, "Tap the Run button")]
+ [Postcondition(1, "NA")]
+ public async Task BluetoothProfile_INIT()
+ {
+ try
+ {
+ string HspHsUuid = "00001108-0000-1000-8000-00805F9B34FB";
+ string HfpHsUuid = "0000111E-0000-1000-8000-00805F9B34FB";
+ string A2dpSnkUuid = "0000110B-0000-1000-8000-00805F9B34FB";
+ string HidUuid = "00001124-0000-1000-8000-00805F9B34FB";
+ string OppUuid = "00001105-0000-1000-8000-00805F9B34FB";
+ BluetoothDevice audioDevice = null;
+ BluetoothDevice avrcpDevice = null;
+ BluetoothDevice hidDevice = null;
+ BluetoothDevice oppClientDevice = null;
+ BluetoothAudio audioProfile = null;
+ BluetoothAvrcp avrcpProfile = null;
+ BluetoothHid hidProfile = null;
+ BluetoothOppClient oppClientProfile = null;
+
+ // Get the device instance in the paired list
+ IEnumerable<BluetoothDevice> list = BluetoothAdapter.GetBondedDevices();
+ if (!list.Any())
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "There is no bonded device");
+ Assert.True(false, "No bonded device!!");
+ }
+ else
+ {
+ foreach (BluetoothDevice item in list)
+ {
+ foreach (string s in item.ServiceUuidList)
+ {
+ if (audioDevice == null && (s.Equals(HspHsUuid) || s.Equals(HfpHsUuid)))
+ {
+ audioDevice = item;
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found audio Device");
+ break;
+ }
+ if (avrcpDevice == null && s.Equals(A2dpSnkUuid))
+ {
+ avrcpDevice = item;
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found AVRCP Device");
+ break;
+ }
+ if (hidDevice == null &&s.Equals(HidUuid))
+ {
+ hidDevice = item;
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found HID Device");
+ break;
+ }
+ if (oppClientDevice == null &&s.Equals(OppUuid))
+ {
+ oppClientDevice = item;
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Found OPP Device");
+ break;
+ }
+ }
+ }
+ }
+
+ Assert.IsTrue(!(audioDevice == null && avrcpDevice == null &&
+ hidDevice == null && oppClientDevice == null),
+ "[TestCase][BluetoothProfile_INIT] Failed");
+
+ if (audioDevice != null)
+ {
+ audioProfile = audioDevice.GetProfile<BluetoothAudio>();
+ Assert.IsInstanceOf<BluetoothAudio>(audioProfile, "BluetoothProfile_INIT");
+ Assert.IsNotNull(audioProfile, "BluetoothProfile_INIT");
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "audioProfile Success!");
+ }
+
+ if (avrcpDevice != null)
+ {
+ avrcpProfile = avrcpDevice.GetProfile<BluetoothAvrcp>();
+ Assert.IsInstanceOf<BluetoothAvrcp>(avrcpProfile, "BluetoothProfile_INIT");
+ Assert.IsNotNull(avrcpProfile, "BluetoothProfile_INIT");
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "avrcpProfile Success!");
+ }
+
+ if (hidDevice != null)
+ {
+ hidProfile = hidDevice.GetProfile<BluetoothHid>();
+ Assert.IsInstanceOf<BluetoothHid>(hidProfile, "BluetoothProfile_INIT");
+ Assert.IsNotNull(hidProfile, "BluetoothProfile_INIT");
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "hidProfile Success!");
+ }
+
+ if (oppClientDevice != null)
+ {
+ oppClientProfile = oppClientDevice.GetProfile<BluetoothOppClient>();
+ Assert.IsInstanceOf<BluetoothOppClient>(oppClientProfile, "BluetoothProfile_INIT");
+ Assert.IsNotNull(oppClientProfile, "BluetoothProfile_INIT");
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "oppClientDevice Success!");
+ }
+ }
+ catch (NotSupportedException)
+ {
+ if (isBluetoothSupported == false)
+ {
+ BluetoothHelper.DisplayLabel("BluetoothProfile_INIT");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (TypeInitializationException e)
+ {
+ if (isBluetoothSupported == false && e.InnerException.GetType() == typeof(NotSupportedException))
+ {
+ BluetoothHelper.DisplayLabel("BluetoothProfile_INIT");
+ await ManualTest.WaitForConfirm();
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+ }
+ }
+ }
+}