[Bluetooth][TCSACR-311] Add StartLeScan TC 98/234498/7
authorWootak Jung <wootak.jung@samsung.com>
Wed, 27 May 2020 02:36:45 +0000 (11:36 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 28 May 2020 06:44:20 +0000 (15:44 +0900)
Change-Id: Ib72d9d68d99ff3478a94ec5d33f4f660a129dfc9
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothAdapter.cs

index 80967f5..b4ea8c4 100644 (file)
@@ -717,5 +717,72 @@ namespace Tizen.Network.Bluetooth.Tests
                 }
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Scan all avaiable LE devices")]
+        [Property("SPEC", "Tizen.Network.Bluetooth.BluetoothAdapter.StartLeScan M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MCST")]
+        [Property("AUTHOR", "Wootak Jung, wootak.jung@samsung.com")]
+        [Property("COVPARAM", "BluetoothLeScanMode")]
+        public static async Task StartLeScan_MODE_CHECK_STATUS()
+        {
+            try
+            {
+                /* PRECONDITION
+                 * 1. Enable Bluetooth
+                 * 2. Register event handler
+                 */
+                if (!BluetoothAdapter.IsBluetoothEnabled)
+                {
+                    Assert.Fail("Bluetooth is not enabled");
+                    return;
+                }
+
+                EventHandler<AdapterLeScanResultChangedEventArgs> scanDeviceResultEventHandler = null;
+                scanDeviceResultEventHandler = (sender, e) =>
+                {
+                    Assert.IsTrue((int)e.Result == 0, "[TestCase][StartLeScan_MODE_CHECK_STATUS] Failed");
+                    _flagDiscovery = true;
+                };
+                BluetoothAdapter.ScanResultChanged += scanDeviceResultEventHandler;
+
+                /* TEST CODE */
+                BluetoothAdapter.StartLeScan(BluetoothLeScanMode.Balanced);
+                _flagDiscovery = false;
+                await waitDiscoveryFlag();
+                Assert.IsTrue(_flagDiscovery, "ScanResultChanged event is not getting called");
+                BluetoothAdapter.StopLeScan();
+
+                BluetoothAdapter.StartLeScan(BluetoothLeScanMode.LowLatency);
+                _flagDiscovery = false;
+                await waitDiscoveryFlag();
+                Assert.IsTrue(_flagDiscovery, "ScanResultChanged event is not getting called");
+                BluetoothAdapter.StopLeScan();
+
+                BluetoothAdapter.StartLeScan(BluetoothLeScanMode.LowEnergy);
+                _flagDiscovery = false;
+                await waitDiscoveryFlag();
+                Assert.IsTrue(_flagDiscovery, "ScanResultChanged event is not getting called");
+                BluetoothAdapter.StopLeScan();
+
+                /* POSTCONDITION
+                 * 1. Unregister event handler
+                 */
+                BluetoothAdapter.ScanResultChanged -= scanDeviceResultEventHandler;
+            }
+            catch (Exception ex)
+            {
+                if (ex is NotSupportedException)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                }
+                else
+                {
+                    Assert.Fail("Throwing exception " + ex.ToString());
+                }
+            }
+        }
     }
 }