[Bluetooth][Non-ACR] Fix null dereference issues 52/175652/4
authorWootak Jung <wootak.jung@samsung.com>
Wed, 11 Apr 2018 09:35:45 +0000 (18:35 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 13 Apr 2018 07:49:37 +0000 (16:49 +0900)
Change-Id: I594ef29755a5932180d5cd3ace8a5b008c12fba3
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSAdvertisingStateChangedEventArgs.cs
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothGattAttribute.cs
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothLeAdvertiseData.cs
tct-suite-vs/Tizen.Bluetooth.Tests/testcase/TSBluetoothLeAdvertiser.cs

index 6b43343..1bf6b68 100755 (executable)
@@ -28,6 +28,13 @@ namespace Tizen.Network.Bluetooth.Tests
             // check whether feature is supported or not.
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le", out _isBluetoothLeSupported);
+
+            if (_isBluetoothSupported == false || _isBluetoothLeSupported == false)
+            {
+                /* The precondition function should not be called in not supported case */
+                return;
+            }
+
             try
             {
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
@@ -39,7 +46,9 @@ namespace Tizen.Network.Bluetooth.Tests
                 {
                     BluetoothSetup.DisposeBluetoothLeAdvertiserDataUtil();
                     _advertiseData = BluetoothSetup.GetBluetoothLeAdvertiserDataUtil();
-                    _advertiseData.AddAdvertisingServiceUuid(BluetoothLePacketType.BluetoothLeAdvertisingPacket, "1123");
+
+                    if (_advertiseData != null)
+                        _advertiseData.AddAdvertisingServiceUuid(BluetoothLePacketType.BluetoothLeAdvertisingPacket, "1123");
                 }
             }
             catch (Exception ex)
@@ -137,6 +146,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
 
                 /* TEST CODE */
@@ -175,6 +193,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                               "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
 
                 /* TEST CODE */
@@ -222,6 +249,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                               "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
 
                 /* TEST CODE */
index c7e717f..4b73344 100755 (executable)
@@ -165,7 +165,15 @@ namespace Tizen.Network.Bluetooth.Tests
                 * 1. Enable Bluetooth
                 */
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
-                Assert.IsNotNull(_attributeObjs, "PRECONDITION Failed: Test data is not initialized properly, null _attributes");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
 
                 /* TEST CODE */
                 foreach (KeyValuePair<BluetoothGattAttribute, AttributeTestData> item in _attributeObjs)
@@ -206,7 +214,15 @@ namespace Tizen.Network.Bluetooth.Tests
                 * 1. Enable Bluetooth
                 */
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
-                Assert.IsNotNull(_attributeObjs, "PRECONDITION Failed: Test data is not initialized properly, null _attributes");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
 
                 /* TEST CODE */
                 foreach (KeyValuePair<BluetoothGattAttribute, AttributeTestData> item in _attributeObjs)
@@ -278,6 +294,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt8Value = sbyte.MaxValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt8, signedInt8Value, _valueOffset);
             }
             catch (Exception ex)
@@ -306,6 +334,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt16Value = Int16.MaxValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt16, signedInt16Value, _valueOffset);
             }
             catch (Exception ex)
@@ -334,6 +374,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt32Value = Int32.MaxValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt32, signedInt32Value, _valueOffset);
             }
             catch (Exception ex)
@@ -362,6 +414,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int unsignedInt8Value = byte.MaxValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt8, unsignedInt8Value, _valueOffset);
             }
             catch (Exception ex)
@@ -390,6 +454,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int unsignedInt16Value = UInt16.MaxValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt16, unsignedInt16Value, _valueOffset);
             }
             catch (Exception ex)
@@ -419,6 +495,18 @@ namespace Tizen.Network.Bluetooth.Tests
             {
                 // UInt32.MaxValue can not be set to a int variable. CAPI only allow int values.
                 int unsignedInt32Value = unchecked((int)UInt32.MaxValue);
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt32, unsignedInt32Value, _valueOffset);
             }
             catch (Exception ex)
@@ -447,6 +535,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt8Value = sbyte.MinValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt8, signedInt8Value, _valueOffset);
             }
             catch (Exception ex)
@@ -475,6 +575,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt16Value = Int16.MinValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt16, signedInt16Value, _valueOffset);
             }
             catch (Exception ex)
@@ -503,6 +615,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int signedInt32Value = Int32.MinValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.SignedInt32, signedInt32Value, _valueOffset);
             }
             catch (Exception ex)
@@ -531,6 +655,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int unsignedInt8Value = byte.MinValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt8, unsignedInt8Value, _valueOffset);
             }
             catch (Exception ex)
@@ -559,6 +695,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int unsignedInt16Value = UInt16.MinValue;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt16, unsignedInt16Value, _valueOffset);
             }
             catch (Exception ex)
@@ -588,6 +736,18 @@ namespace Tizen.Network.Bluetooth.Tests
             {
                 // UInt32.MaxValue can not be set to a int variable. CAPI only allow int values.
                 int unsignedInt32Value = unchecked((int)UInt32.MinValue);
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetIntValues(IntDataType.UnsignedInt32, unsignedInt32Value, _valueOffset);
             }
             catch (Exception ex)
@@ -616,6 +776,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int mantissa = 123, exponent = 2;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetFloatValue(FloatDataType.Float, mantissa, exponent, _valueOffset);
             }
             catch (Exception ex)
@@ -644,6 +816,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int mantissa = -123, exponent = 2;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetFloatValue(FloatDataType.SFloat, mantissa, exponent, _valueOffset);
             }
             catch (Exception ex)
@@ -672,6 +856,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int mantissa = 42, exponent = 5;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetFloatValue(FloatDataType.SFloat, mantissa, exponent, _valueOffset);
             }
             catch (Exception ex)
@@ -700,6 +896,18 @@ namespace Tizen.Network.Bluetooth.Tests
             try
             {
                 int mantissa = -42, exponent = 5;
+
+                Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 TestGetSetFloatValue(FloatDataType.SFloat, mantissa, exponent, _valueOffset);
             }
             catch (Exception ex)
@@ -730,7 +938,15 @@ namespace Tizen.Network.Bluetooth.Tests
                 * 1. Enable Bluetooth
                 */
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
-                Assert.IsNotNull(_attributeObjs, "PRECONDITION Failed: Test data is not initialized properly, null _attributes");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
 
                 /* TEST CODE */
                 foreach (KeyValuePair<BluetoothGattAttribute, AttributeTestData> item in _attributeObjs)
@@ -768,7 +984,15 @@ namespace Tizen.Network.Bluetooth.Tests
                 * 1. Enable Bluetooth
                 */
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
-                Assert.IsNotNull(_attributeObjs, "PRECONDITION Failed: Test data is not initialized properly, null _attributes");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
 
                 /* TEST CODE */
                 foreach (KeyValuePair<BluetoothGattAttribute, AttributeTestData> item in _attributeObjs)
@@ -814,7 +1038,15 @@ namespace Tizen.Network.Bluetooth.Tests
                 * 1. Enable Bluetooth
                 */
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
-                Assert.IsNotNull(_attributeObjs, "PRECONDITION Failed: Test data is not initialized properly, null _attributes");
+
+                /* After completing the precondition, TCT can be run
+                              "_attributeObjs is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_attributeObjs == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
 
                 foreach (KeyValuePair<BluetoothGattAttribute, AttributeTestData> item in _attributeObjs)
                 {
index 50bf629..231f467 100755 (executable)
@@ -22,6 +22,13 @@ namespace Tizen.Network.Bluetooth.Tests
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for BT LE TEST");
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le", out _isBluetoothLeSupported);
+
+            if (_isBluetoothSupported == false || _isBluetoothLeSupported == false)
+            {
+                /* The precondition function should not be called in not supported case */
+                return;
+            }
+
             try
             {
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
@@ -100,6 +107,16 @@ namespace Tizen.Network.Bluetooth.Tests
                     Assert.Fail("Bluetooth is not enabled");
                     return;
                 }
+
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
                 BluetoothLeAdvertiseData leAdvertiseDataInstance = new BluetoothLeAdvertiseData();
                 Assert.IsInstanceOf<BluetoothLeAdvertiseData>(leAdvertiseDataInstance, "Should return BluetoothLeAdvertiseData instance.");
@@ -139,6 +156,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -184,6 +210,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -229,6 +264,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -274,6 +318,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -315,6 +368,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -356,6 +418,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -397,6 +468,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -438,6 +518,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with enum value : BluetoothLePacketType.BluetoothLeAdvertisingPacket
@@ -481,6 +570,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
                 foreach (BluetoothLeAdvertisingMode val in _connectEnums)
                 {
@@ -522,6 +620,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
 
                 // Test with connect value true
@@ -562,6 +669,15 @@ namespace Tizen.Network.Bluetooth.Tests
                     return;
                 }
 
+                /* After completing the precondition, TCT can be run
+                              "_advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 /* TEST CODE */
                 BluetoothLeAdvertiseData newAdvertiseData = new BluetoothLeAdvertiseData();
                 Assert.IsNotNull(newAdvertiseData, "PRECONDITION: Failed to get AdvertiseData for testing");
index 93c4cb4..3575f86 100755 (executable)
@@ -23,6 +23,13 @@ namespace Tizen.Network.Bluetooth.Tests
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for BT LE TEST");
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth", out _isBluetoothSupported);
             Information.TryGetValue("http://tizen.org/feature/network.bluetooth.le", out _isBluetoothLeSupported);
+
+            if (_isBluetoothSupported == false || _isBluetoothLeSupported == false)
+            {
+                /* The precondition function should not be called in not supported case */
+                return;
+            }
+
             try
             {
                 Assert.IsTrue(BluetoothAdapter.IsBluetoothEnabled, "PRECONDITION Failed: Bluetooth services should have beeen initialised");
@@ -33,7 +40,9 @@ namespace Tizen.Network.Bluetooth.Tests
                 {
                     BluetoothSetup.DisposeBluetoothLeAdvertiserDataUtil();
                     _advertiseData = BluetoothSetup.GetBluetoothLeAdvertiserDataUtil();
-                    _advertiseData.AddAdvertisingServiceUuid(BluetoothLePacketType.BluetoothLeAdvertisingPacket, "1123");
+
+                    if (_advertiseData != null)
+                        _advertiseData.AddAdvertisingServiceUuid(BluetoothLePacketType.BluetoothLeAdvertisingPacket, "1123");
                 }
             }
             catch (Exception ex)
@@ -125,6 +134,16 @@ namespace Tizen.Network.Bluetooth.Tests
                     Assert.Fail("Failed to intialize Bluetooth.");
                     return;
                 }
+
+                /* After completing the precondition, TCT can be run
+                              "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
 
                 /* TEST CODE */
@@ -169,6 +188,16 @@ namespace Tizen.Network.Bluetooth.Tests
                     Assert.Fail("Failed to intialize Bluetooth.");
                     return;
                 }
+
+                /* After completing the precondition, TCT can be run
+                              "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
 
                 /* TEST CODE */
@@ -215,6 +244,16 @@ namespace Tizen.Network.Bluetooth.Tests
                     Assert.Fail("Failed to intialize Bluetooth.");
                     return;
                 }
+
+                /* After completing the precondition, TCT can be run
+                              "_advertiser or _advertiseData is null" case, only le supported feature is NULL.
+                              other case is abnormal, so assert fail */
+                if (_advertiser == null || _advertiseData == null)
+                {
+                    Assert.IsTrue(_isBluetoothLeSupported == false, "Invalid NotSupportedException");
+                    return;
+                }
+
                 _advertiser.AdvertisingStateChanged += AdvertisingChangedEventHandler;
                 await AdvertiseSetup();