[Security/Privilege][ACR-142][Add exception handling for new feature] 28/177628/3
authorYunjin Lee <yunjin-.lee@samsung.com>
Wed, 2 May 2018 08:30:01 +0000 (17:30 +0900)
committerLee Sanghoon <shooney.lee@samsung.com>
Fri, 11 May 2018 01:29:10 +0000 (01:29 +0000)
Change-Id: I7a56a19d4c820a03af6dbf5485197a4691f0c50f
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
tct-suite-vs/Tizen.Privilege.Tests/testcase/TSPrivilege.cs

index f9ffde9..c9c53d6 100755 (executable)
@@ -2,6 +2,7 @@ using NUnit.Framework;
 using NUnit.Framework.TUnit;
 using System;
 using Tizen.Applications;
+using Tizen.System;
 
 namespace Tizen.Security.Tests
 {
@@ -26,10 +27,13 @@ namespace Tizen.Security.Tests
         private static PackageType tpk = PackageType.TPK;
         private static PackageType wgt = PackageType.WGT;
 
+        static bool isPrivacyPrivilegeSupported = true;
+
         [SetUp]
         public static void Init()
         {
             LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST");
+            Information.TryGetValue("http://tizen.org/feature/security.privacy_privilege", out isPrivacyPrivilegeSupported);
         }
 
         [TearDown]
@@ -322,6 +326,10 @@ namespace Tizen.Security.Tests
                 Assert.IsNotNull(ret, "Privacy display name should not be null.");
                 Assert.IsTrue(ret.Length >= 0, "Length of Privacy display name should be greater than 0.");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.Fail("Privilege.GetPrivacyDisplayName: " + e.ToString());
@@ -342,6 +350,10 @@ namespace Tizen.Security.Tests
                 var ret = Privilege.GetPrivacyDisplayName(internetPrivilege);
                 Assert.Fail("Expects to throw ArgumentException exception  when privilege param is not-privacy related, but exception not thrown");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetPrivacyDisplayName does not accept non-privacy related privilege.");
@@ -363,6 +375,10 @@ namespace Tizen.Security.Tests
                 var ret = Privilege.GetPrivacyDisplayName(null);
                 Assert.Fail("Expects to throw ArgumentException exception when null inputted for privilege param, but exception not thrown");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetPrivacyDisplayName does not accept null input.");
@@ -385,6 +401,10 @@ namespace Tizen.Security.Tests
                 Assert.IsInstanceOf<bool>(ret, "Object should be bool type.");
                 Assert.IsTrue(ret, "Object is not equal");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.Fail("Privilege.GetPrivacyPrivilegeStatus: " + e.ToString());
@@ -406,6 +426,10 @@ namespace Tizen.Security.Tests
                 Assert.IsInstanceOf<bool>(ret, "Object should be bool type.");
                 Assert.IsFalse(ret, "Object is not equal");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.Fail("Privilege.GetPrivacyPrivilegeStatus: " + e.ToString());
@@ -426,6 +450,10 @@ namespace Tizen.Security.Tests
                 var ret = Privilege.GetPrivacyPrivilegeStatus(internetPrivilege);
                 Assert.Fail("Expects to throw ArgumentException exception when privilege param is not-privacy related, but exception not thrown");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.IsTrue(e.GetType().Name.Equals("ArgumentException"), "GetPrivacyPrivilegeStatus does not accept non-privacy related privilege.");
@@ -446,6 +474,10 @@ namespace Tizen.Security.Tests
                 var ret = Privilege.GetPrivacyPrivilegeStatus(null);
                 Assert.Fail("Expects to throw ArgumentException exception when null inputted for version param, but exception not thrown");
             }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isPrivacyPrivilegeSupported == false, "Invalid NotSupportedException");
+            }
             catch (Exception e)
             {
                 Assert.IsTrue(e.GetType().Name.Equals("ArgumentNullException"), "GetPrivacyPrivilegeStatus does not accept null input parameter.");