[Security][TCSACR-184]Add test cases for checking & requesting policy for many privil... 50/194550/6
authorErnest Borowski <e.borowski@partner.samsung.com>
Thu, 28 Jun 2018 17:57:39 +0000 (19:57 +0200)
committerErnest Borowski <e.borowski@partner.samsung.com>
Wed, 30 Jan 2019 18:48:11 +0000 (19:48 +0100)
Tests cleanup

Change-Id: I9507494484a253b97dfd213f77787ff9c995d7cb
Signed-off-by: Ernest Borowski <e.borowski@partner.samsung.com>
17 files changed:
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/Program.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/Tizen.PrivacyPrivilegeManager.Manual.Tests.sln [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/shared/res/Tizen.Security.PrivacyPrivilegeManager.Manual.Tests.png [moved from tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/shared/res/Tizen.PrivacyPrivilegeManager.Manual.Tests.png with 100% similarity, mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSCheckPermission.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSCheckPermissions.cs [new file with mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSGetResponseContext.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSPermissionRequestResponse.cs [new file with mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestMultipleResponseEventArgs.cs [new file with mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestPermission.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestPermissions.cs [new file with mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestResponseEventArgs.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/Constans.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/Profiles.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/TestBase.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/TestHelpers.cs [new file with mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/TestUI.cs [moved from tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/UIAbstractClass.cs with 57% similarity, mode: 0644]
tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/tizen-manifest.xml

old mode 100755 (executable)
new mode 100644 (file)
index 4010ccf..591ca37
@@ -14,8 +14,8 @@
  *  limitations under the License
  */
 
-using System;
 using NUnit.Framework;
+using System;
 using Xamarin.Forms;
 
 namespace XamarinApplication.Tizen
@@ -40,10 +40,17 @@ namespace XamarinApplication.Tizen
 
         static void Main(string[] args)
         {
-            Console.WriteLine("TCT : Main()");
-            var app = new Program();
-            global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
-            app.Run(args);
+            try
+            {
+                Console.WriteLine("TCT : Main()");
+                Program app = new Program();
+                global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
+                app.Run(args);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("Stack trace: \n" + ex.StackTrace + "\nException message: " + ex.Message);
+            }
         }
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index c3f2847..54105fc
@@ -2,8 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 15
 VisualStudioVersion = 15.0.26730.15
 MinimumVisualStudioVersion = 15.0.26124.0
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.PrivacyPrivilegeManager.Manual.Tests", "Tizen.PrivacyPrivilegeManager.Manual.Tests.csproj", "{D92BEEAC-3B2A-45F8-8C53-53B92550404A}"
-EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\nunit.framework\nunit.framework.csproj", "{B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\nunitlite.csproj", "{FDB8025A-C029-461F-895E-287B4C65939B}"
@@ -12,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplate", "..\Templa
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplateForWearable", "..\Template\ManualTemplateForWearable\ManualTemplateForWearable.csproj", "{D36CED01-29BD-4EB3-8903-62E0BF2A822D}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.PrivacyPrivilegeManager.Manual.Tests", "Tizen.PrivacyPrivilegeManager.Manual.Tests.csproj", "{494B95D0-7EDB-4D5A-87A8-6B189CC96463}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -22,18 +22,6 @@ Global
                Release|x86 = Release|x86
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.ActiveCfg = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.Build.0 = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.ActiveCfg = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.Build.0 = Debug|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.Build.0 = Release|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.ActiveCfg = Release|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.Build.0 = Release|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.ActiveCfg = Release|Any CPU
-               {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.Build.0 = Release|Any CPU
                {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -58,18 +46,42 @@ Global
                {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.Build.0 = Release|Any CPU
                {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.ActiveCfg = Release|Any CPU
                {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.NUI|Any CPU.ActiveCfg = Debug|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.NUI|Any CPU.Build.0 = Debug|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.Build.0 = Release|Any CPU
                {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {269F89A7-E648-4811-8421-844E00ACF5F0}.NUI|Any CPU.ActiveCfg = Debug|Any CPU
-               {269F89A7-E648-4811-8421-844E00ACF5F0}.NUI|Any CPU.Build.0 = Debug|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x64.Build.0 = Debug|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x86.Build.0 = Debug|Any CPU
                {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|Any CPU.Build.0 = Release|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x64.ActiveCfg = Release|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x64.Build.0 = Release|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x86.ActiveCfg = Release|Any CPU
+               {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x86.Build.0 = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x64.Build.0 = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x86.Build.0 = Debug|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.Build.0 = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x64.ActiveCfg = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x64.Build.0 = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x86.ActiveCfg = Release|Any CPU
+               {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x86.Build.0 = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|x64.Build.0 = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Debug|x86.Build.0 = Debug|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|Any CPU.Build.0 = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|x64.ActiveCfg = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|x64.Build.0 = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|x86.ActiveCfg = Release|Any CPU
+               {494B95D0-7EDB-4D5A-87A8-6B189CC96463}.Release|x86.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
old mode 100755 (executable)
new mode 100644 (file)
index 8c0e6b6..d503eaa
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
 
 namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 {
-    using global::System;
-    using global::System.Linq;
-    using global::System.Threading.Tasks;
     using global::Xamarin.Forms;
     using NUnit.Framework;
     using NUnit.Framework.TUnit;
@@ -28,12 +25,12 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
     /// Contains <see cref="TSCheckPermission"/> class
     /// <para>It`s used test if <see cref="Tizen.Security.PrivacyPrivilegeManager.CheckPermission()" /> works as expected.</para>
     /// </summary>
-    public class TSCheckPermission : UIAbstractClass
+    public class TSCheckPermission : TestBase
     {
         /// <summary>
-        /// Holds privilege that will be tested
+        /// Holds privileges that will be tested
         /// </summary>
-        private string _privilege;
+        private string[] _privileges;
 
         /// <summary>
         /// Holds Correct method return value
@@ -41,6 +38,11 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         private CheckResult _correctResult;
 
         /// <summary>
+        /// Holds information if ArgumentException is expected
+        /// </summary>
+        private bool _expectedArgumentException;
+
+        /// <summary>
         /// Initializes environment before TCT test runs.
         /// </summary>
         [SetUp]
@@ -52,7 +54,6 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             }
 
             LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
-            executeCount = 1;
         }
 
         /// <summary>
@@ -60,75 +61,14 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// </summary>
         private void Check()
         {
-            foreach (string privilege in Constans.Privileges)
-            {
-                CheckResult result = TestBase.CheckPermission(privilege);
-                Color backgroundColor = Color.Red;
-
-                if (result == CheckResult.Ask)
-                {
-                    backgroundColor = Color.Green;
-                }
-
-                _UIlist.Add(new Label()
-                {
-                    Text = "Execute number: " + executeCount++ + " Privilege: \n" + privilege + "\nStatus: " + result,
-                    BackgroundColor = backgroundColor,
-                    TextColor = Color.White,
-                });
-
-                _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
-            }
-        }
-
-        /// <summary>
-        /// Checks Privilege status and displays results.
-        /// </summary>
-        private void CheckSinglePrivilege()
-        {
-            CheckResult result = TestBase.CheckPermission(_privilege);
-            string labelText = "Execute number: " + executeCount++ + " Privilege: \n" + _privilege + "\nStatus: " + result;
-
-            if (TestBase.ErrorOccured)
-            {
-                labelText += "\n" + TestBase.ErrorMessage;
-            }
-
-            Color backgroundColor = Color.Red;
-            if (result == _correctResult)
+            foreach (string privilege in _privileges)
             {
-                backgroundColor = Color.Green;
-                ManualTest.Confirm();
+                CheckResult result = CheckPermission(privilege, _expectedArgumentException);
+                Color backgroundColor = Color.Green;
+                string labelText = " Privilege: \n" + privilege + "\nStatus: " + result;
+                Assert.IsFalse(ErrorOccured, "Error occured during CheckPermission test: " + ErrorMessage);
+                Assert.AreEqual(result, _correctResult, "wrong result for privilege: " + privilege + " expected " + _correctResult + " and got: " + result);
             }
-
-            _UIlist.Add(new Label()
-            {
-                Text = labelText,
-                BackgroundColor = backgroundColor,
-                TextColor = Color.White,
-            });
-
-            _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
-        }
-
-        /// <summary>
-        /// Handles Buttons OnClick event.
-        /// </summary>
-        /// <param name="sender">Sender</param>
-        /// <param name="e">Event arguments</param>
-        private void OnClick(object sender, EventArgs e)
-        {
-            CheckSinglePrivilege();
-        }
-
-        /// <summary>
-        /// Handles Buttons OnClick event.
-        /// </summary>
-        /// <param name="sender">Sender</param>
-        /// <param name="e">Event arguments</param>
-        private void OnClickMultiplePrivileges(object sender, EventArgs e)
-        {
-            Check();
         }
 
         [Test]
@@ -144,17 +84,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
         [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
         [Step(1, " Click run TC")]
-        [Step(2, " Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        [Step(5, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        public async Task CheckPermission_REAL_PRIVILEGES()
+        [Postcondition(1, "NA")]
+        public void CheckPermission_REAL_PRIVILEGES()
         {
-            CreateLayout();
-            _button.Clicked += OnClickMultiplePrivileges;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClickMultiplePrivileges;
+            _expectedArgumentException = false;
+            _privileges = Constans.Privileges;
+            _correctResult = CheckResult.Ask;
+            Check();
         }
 
         [Test]
@@ -166,18 +102,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\nIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongString\nStatus: Deny")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_LONG_STRING()
+        public void CheckPermission_LONG_STRING()
         {
-            CreateLayout();
-            _privilege = Constans.LongString;
+            _expectedArgumentException = false;
+            _privileges = new string[] { Constans.LongString };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -189,18 +120,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for .\nException message: Invalid parameter")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_STRING_EMPTY()
+        public void CheckPermission_STRING_EMPTY()
         {
-            CreateLayout();
-            _privilege = Constans.Empty;
+            _expectedArgumentException = true;
+            _privileges = new string[] { Constans.Empty };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -212,18 +138,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\nrandom_string\nStatus: Deny\n")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_NON_EXISTING()
+        public void CheckPermission_NON_EXISTING()
         {
-            CreateLayout();
-            _privilege = Constans.NoExisting;
+            _expectedArgumentException = false;
+            _privileges = new string[] { Constans.NoExisting };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -235,18 +156,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\nHttp://TIZen.Org/PrIVIlege/AccOunt.Read\nStatus: Deny\n")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_RANDOM_LETTER_CASE_PRIVILEGE()
+        public void CheckPermission_RANDOM_LETTER_CASE_PRIVILEGE()
         {
-            CreateLayout();
-            _privilege = Constans.RandomLetterCasePrivilege;
+            _expectedArgumentException = false;
+            _privileges = new string[] { Constans.RandomLetterCasePrivilege };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -258,18 +174,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n#@!$%^&*()+-_[]{}'\"\\|/.,;:?<>'`~\nStatus: Deny\n")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_SPECIAL_CHARACTERS()
+        public void CheckPermission_SPECIAL_CHARACTERS()
         {
-            CreateLayout();
-            _privilege = Constans.SpecialCharacters;
+            _expectedArgumentException = false;
+            _privileges = new string[] { Constans.SpecialCharacters };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -281,18 +192,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for .\nException message: Invalid parameter")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_STRING_NULL()
+        public void CheckPermission_STRING_NULL()
         {
-            CreateLayout();
-            _privilege = Constans.Null;
+            _expectedArgumentException = true;
+            _privileges = new string[] { Constans.Null };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
 
         [Test]
@@ -304,18 +210,13 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
         [Precondition(1, "NA")]
         [Step(1, "Click run TC")]
-        [Step(2, "Click button")]
-        [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\nHTTP://TIZEN.ORG/PRIVILEGE/ACCOUNT.READ\nStatus: Deny")]
         [Postcondition(1, "NA")]
-        public async Task CheckPermission_UPPER_LETTER_CASE_PRIVILEGE()
+        public void CheckPermission_UPPER_LETTER_CASE_PRIVILEGE()
         {
-            CreateLayout();
-            _privilege = Constans.UpperLetterCasePrivilege;
+            _expectedArgumentException = false;
+            _privileges = new string[] { Constans.UpperLetterCasePrivilege };
             _correctResult = CheckResult.Deny;
-            _button.Clicked += OnClick;
-            await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            Check();
         }
     }
 }
diff --git a/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSCheckPermissions.cs b/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSCheckPermissions.cs
new file mode 100644 (file)
index 0000000..c30e22e
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+namespace Tizen.PrivacyPrivilegeManager.Manual.Tests.testcase
+{
+    using global::Xamarin.Forms;
+    using NUnit.Framework;
+    using NUnit.Framework.TUnit;
+    using Tizen.Security;
+
+    /// <summary>
+    /// Contains <see cref="TSCheckPermissions"/> class
+    /// <para>It`s used test if <see cref="Tizen.Security.PrivacyPrivilegeManager.CheckPermissions()" /> works as expected.</para>
+    /// </summary>
+    class TSCheckPermissions : TestBase
+    {
+        /// <summary>
+        /// Holds Correct method return value
+        /// </summary>
+        private CheckResult _correctResult;
+
+        /// <summary>
+        /// Holds privileges that will be tested
+        /// </summary>
+        private string[] _privileges;
+
+        /// <summary>
+        /// Initializes environment before TCT test runs.
+        /// </summary>
+        [SetUp]
+        public void Init()
+        {
+            if (Profile.GetProfile().CompareTo(Profile.MobileProfile) != 0)
+            {
+                Assert.Pass("Privacy privileges not supported");
+            }
+
+            LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
+        }
+
+        /// <summary>
+        /// Checks Privileges status and displays results.
+        /// </summary>
+        private void Check()
+        {
+            CheckResult[] results = CheckPermissions(_privileges);
+            Color backgroundColor = Color.Green;
+
+            string labelText = "";
+            if (ErrorOccured)
+            {
+                labelText += "\n" + ErrorMessage;
+                backgroundColor = Color.Red;
+                Assert.Fail("Error occured during CheckPermissions test");
+            }
+            else
+            {
+                for (int it = 0; it < _privileges.Length; ++it)
+                {
+                    if (results[it] != _correctResult)
+                    {
+                        backgroundColor = Color.Red;
+                        Assert.Fail("Wrong CheckPermissions status:\nPrivilege: \n" + _privileges[it] + "\nStatus: " + results[it]);
+                    }
+                    labelText += "\n Privilege: \n" + _privileges[it] + "\nStatus: " + results[it];
+                }
+            }
+
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if CheckPermissions method works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.CheckPermissions M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        public void CheckPermissions_REAL_PRIVILEGES()
+        {
+            _correctResult = CheckResult.Ask;
+            _privileges = Constans.Privileges;
+            Check();
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if CheckPermissions method works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.CheckPermissions M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        public void CheckPermissions_REAL_PRIVILEGES_WITH_DUPLICATES()
+        {
+            _correctResult = CheckResult.Ask;
+            _privileges = new string[Constans.Privileges.Length * 2];
+            Constans.Privileges.CopyTo(_privileges, 0);
+            Constans.Privileges.CopyTo(_privileges, Constans.Privileges.Length);
+            Check();
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if CheckPermissions method works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.CheckPermissions M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        public void CheckPermissions_FAKE_PRIVILEGES()
+        {
+            _correctResult = CheckResult.Deny;
+            _privileges = new string[] {Constans.LongString, Constans.NoExisting, Constans.RandomLetterCasePrivilege,
+                                        Constans.SpecialCharacters, Constans.UpperLetterCasePrivilege};
+            Check();
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index f4c1f51..4927d83
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
 namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 {
     using global::System;
-    using global::System.Linq;
     using global::System.Threading.Tasks;
-    using global::Xamarin.Forms;
     using NUnit.Framework;
     using NUnit.Framework.TUnit;
     using Tizen.Security;
@@ -28,7 +26,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
     /// Contains <see cref="TSGetResponseContext"/> class
     /// <para>It is used test if <see cref="Tizen.Security.PrivacyPrivilegeManager.GetResponseContext()"/> works as expected.</para>
     /// </summary>
-    public class TSGetResponseContext : UIAbstractClass
+    public class TSGetResponseContext : TestHelpers
     {
         /// <summary>
         /// Initializes environment before TCT test runs.
@@ -42,12 +40,6 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             }
 
             LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
-
-            foreach (string privilege in Constans.Privileges)
-            {
-                SetupPPMHandler(privilege);
-            }
-
             executeCount = 1;
         }
 
@@ -60,15 +52,10 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
             foreach (string privilege in Constans.Privileges)
             {
-                PrivacyPrivilegeManager.ResponseContext context = null;
-                if (PrivacyPrivilegeManager.GetResponseContext(privilege).TryGetTarget(out context))
-                {
-                    context.ResponseFetched -= PPM_RequestResponse;
-                }
+                DestroyPPMHandler(privilege);
             }
         }
 
-
         /// <summary>
         /// Handles catching PrivilegeManager responses.
         /// </summary>
@@ -78,49 +65,65 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         {
             if (e.cause == CallCause.Answer)
             {
-                switch (e.result)
-                {
-                    case RequestResult.AllowForever:
-                        {
-                            LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User allowed usage of privilege " + e.privilege + " forever.");
-                            break;
-                        }
-
-                    case RequestResult.DenyForever:
-                        {
-                            LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User denied usage of privilege " + e.privilege + " forever.");
-                            break;
-                        }
-
-                    case RequestResult.DenyOnce:
-                        {
-                            LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User allowed usage of privilege " + e.privilege + " once.");
-                            break;
-                        }
-                }
-
-                _UIlist.Add(new Label()
-                {
-                    Text = "Execute number: " + executeCount++ + " Privilege: \n" + e.privilege + "\nStatus: " + e.result,
-                });
-                _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
+                executeCount++;
+                LogPrivilegeRequestResponse(e.privilege, e.result);
             }
             else
             {
                 LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "Error occured during requesting permission for " + e.privilege);
             }
+            DestroyPPMHandler(e.privilege);
+            ChangeButtonState(true);
         }
 
         /// <summary>
         /// Setups event handler for catching PrivilegeManager responses.
         /// </summary>
         /// <param name="privilege">Privilege name</param>
-        private void SetupPPMHandler(string privilege)
+        protected override void SetupPPMHandler(string privilege)
         {
-            PrivacyPrivilegeManager.ResponseContext context = null;
-            if (PrivacyPrivilegeManager.GetResponseContext(privilege).TryGetTarget(out context))
+            if (privilege == null)
+            {
+                return;
+            }
+            if (PrivacyPrivilegeManager.GetResponseContext(privilege).TryGetTarget(out PrivacyPrivilegeManager.ResponseContext context))
             {
                 context.ResponseFetched += PPM_RequestResponse;
+                context.ResponseFetched -= PPM_RequestResponse;
+                context.ResponseFetched += PPM_RequestResponse;
+                if (PrivacyPrivilegeManager.GetResponseContext(privilege).TryGetTarget(out PrivacyPrivilegeManager.ResponseContext context2))
+                {
+                    context.ResponseFetched -= PPM_RequestResponse;
+                    context2.ResponseFetched += PPM_RequestResponse;
+                    GC.Collect();
+                    GC.WaitForPendingFinalizers();
+                }
+                else
+                {
+                    LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "Error occured during Settuping second ppm handler permission for " + privilege);
+                }
+            }
+            else
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "Error occured during Settuping ppm handler permission for " + privilege);
+            }
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+        }
+
+        /// <summary>
+        /// Destroys hander for PrivilegeManager single privilege request response
+        /// </summary>
+        /// <param name="privilege">Privilege with subscribled handler</param>
+        private void DestroyPPMHandler(string privilege)
+        {
+            if (privilege == null)
+            {
+                return;
+            }
+            if (PrivacyPrivilegeManager.GetResponseContext(privilege).TryGetTarget(out PrivacyPrivilegeManager.ResponseContext context))
+            {
+                context.ResponseFetched -= PPM_RequestResponse;
             }
         }
 
@@ -131,47 +134,22 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <param name="e">Event arguments</param>
         private void OnClick(object sender, EventArgs e)
         {
-            Check();
+            ChangeButtonState(false);
+            Check(_privileges);
         }
 
         /// <summary>
-        /// Checks Privileges status and displays results.
+        /// Handles Buttons OnClickMultiple event.
         /// </summary>
-        private void Check()
+        /// <param name="sender">Sender</param>
+        /// <param name="e">Event arguments</param>
+        private async void OnClickMultiple(object sender, EventArgs e)
         {
-            foreach (string privilege in Constans.Privileges)
-            {
-                CheckResult result = TestBase.CheckPermission(privilege);
-                Color backgroundColor = Color.Red;
-                string labelText = "Execute number: " + executeCount++ + " Privilege: \n" + privilege + "\nStatus: " + result;
-
-                if (TestBase.ErrorOccured)
-                {
-                    labelText += "\n" + TestBase.ErrorMessage;
-                }
-
-                if (result == CheckResult.Ask)
-                {
-                    backgroundColor = Color.Green;
-                    TestBase.RequestPermission(privilege);
-
-                    if (TestBase.ErrorOccured)
-                    {
-                        labelText += "\n" + TestBase.ErrorMessage;
-                    }
-                }
-
-                _UIlist.Add(new Label()
-                {
-                    Text = labelText,
-                    BackgroundColor = backgroundColor,
-                    TextColor = Color.White,
-                });
-
-                _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
-            }
+            ChangeButtonState(false);
+            await CheckMultiple(_privileges);
         }
 
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if popup works.")]
@@ -190,15 +168,14 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(4, " Click button")]
         [Step(5, " Check Logs output (inside program)")]
         [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        //// I can`t add more than 6 steps beacause when I do so the App is crashing
-        //[Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        //[Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        //[Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
-        //[Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
-        //[Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
-        //[Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Allow")]
-        //[Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Allow")]
-        //[Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Allow")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
+        [Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Allow")]
+        [Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Allow")]
+        [Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Allow")]
         [Postcondition(1, " Open Settings")]
         [Postcondition(2, " Open \"Privacy and security\"")]
         [Postcondition(3, " Open \"Privacy settings\"")]
@@ -207,6 +184,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         public async Task ResponseFetched_GET_RESPONSE_CONTEXT()
         {
             CreateLayout();
+            _privileges = Constans.Privileges;
             _button.Clicked += OnClick;
             //// Waits for user confirmation.
             await ManualTest.WaitForConfirm();
@@ -215,6 +193,159 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 
         [Test]
         [Category("P1")]
+        [Description("Test: Check if popup works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.MultipleResponseContext.ResponseFetched E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        [Step(2, " Click button")]
+        [Step(3, " Allow Privileges")]
+        [Step(4, " Click button")]
+        [Step(5, " Check Logs output (inside program)")]
+        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
+        [Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Allow")]
+        [Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Allow")]
+        [Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Allow")]
+        [Postcondition(1, " Open Settings")]
+        [Postcondition(2, " Open \"Privacy and security\"")]
+        [Postcondition(3, " Open \"Privacy settings\"")]
+        [Postcondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        public async Task ResponseFetched_GET_MULTIPLE_RESPONSE_CONTEXT()
+        {
+            CreateLayout();
+            _privileges = Constans.Privileges;
+            _button.Clicked += OnClickMultiple;
+            //// Waits for user confirmation.
+            await ManualTest.WaitForConfirm();
+            _button.Clicked -= OnClickMultiple;
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if popup works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.MultipleResponseContext.ResponseFetched E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(6, "Open \"Location\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(7, "Open \"Contacts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        [Step(2, " Click button")]
+        [Step(3, " Allow Privileges")]
+        [Step(4, " Check Logs output (inside program)")]
+        [Step(5, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
+        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/contact.read\nStatus:Ask")]
+        [Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/contact.write\nStatus:Ask")]
+        [Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/download\nStatus:Allow")]
+        [Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/location\nStatus:Ask")]
+        [Step(15, " Good output: Privilege:\nhttp://tizen.org/privilege/contact.read\nStatus: AllowForever")]
+        [Step(16, " Good output: Privilege:\nhttp://tizen.org/privilege/contact.write\nStatus: AllowForever")]
+        [Step(17, " Good output: Privilege:\nhttp://tizen.org/privilege/location\nStatus: AllowForever")]
+        [Postcondition(1, " Open Settings")]
+        [Postcondition(2, " Open \"Privacy and security\"")]
+        [Postcondition(3, " Open \"Privacy settings\"")]
+        [Postcondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(6, "Open \"Location\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(7, "Open \"Contacts\" and uncheck Tizen.Security.PrivacyManager")]
+        public async Task ResponseFetched_GET_MULTIPLE_RESPONSE_CONTEXT_SECOND_REQUEST()
+        {
+            requestAdditionalPrivilegesInCallback = true;
+            CreateLayout();
+            _privileges = Constans.Privileges;
+            _button.Clicked += OnClickMultiple;
+            //// Waits for user confirmation.
+            await ManualTest.WaitForConfirm();
+            _button.Clicked -= OnClickMultiple;
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if popup works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.MultipleResponseContext.ResponseFetched E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        [Step(2, " Click button")]
+        [Step(3, " Allow Privileges")]
+        [Step(4, " Click button")]
+        [Step(5, " Check Logs output (inside program)")]
+        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
+        [Step(7, " Good output: privilege:\nhttp://tizen.org/privilege/account.write\nstatus: Ask")]
+        [Step(8, " Good output: privilege:\nhttp://tizen.org/privilege/call\nstatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/contact.read\nStatus: Ask")]
+        [Step(10, " Good output: privilege:\nhttp://tizen.org/privilege/contact.write\nstatus: Ask")]
+        [Step(11, " Good output: privilege:\nhttp://tizen.org/privilege/download\nstatus: Allow")]
+        [Step(12, " Good output: privilege:\nhttp://tizen.org/privilege/location\nstatus: Ask")]
+        [Step(13, " Good output: privilege:\nhttp://tizen.org/privilege/account.read\nstatus: AllowForever")]
+        [Step(14, " Good output: privilege:\nhttp://tizen.org/privilege/account.write\nstatus: AllowForever")]
+        [Step(15, " Good output: privilege:\nhttp://tizen.org/privilege/call\nstatus: AllowForever")]
+        [Step(16, " Good output: privilege:\nhttp://tizen.org/privilege/contact.read\nstatus: AllowForever")]
+        [Step(17, " Good output: privilege:\nhttp://tizen.org/privilege/contact.write\nstatus: AllowForever")]
+        [Step(18, " Good output: privilege:\nhttp://tizen.org/privilege/location\nstatus: AllowForever")]
+        [Step(19, " Good output: privilege:\nhttp://tizen.org/privilege/account.read\nstatus: Allow")]
+        [Step(20, " Good output: privilege:\nhttp://tizen.org/privilege/account.write\nstatus: Allow")]
+        [Step(21, " Good output: privilege:\nhttp://tizen.org/privilege/call\nstatus: Allow")]
+        [Step(22, " Good output: privilege:\nhttp://tizen.org/privilege/contact.read\nstatus: Allow")]
+        [Step(23, " Good output: privilege:\nhttp://tizen.org/privilege/contact.write\nstatus: Allow")]
+        [Step(24, " Good output: privilege:\nhttp://tizen.org/privilege/download\nstatus: Allow")]
+        [Step(25, " Good output: privilege:\nhttp://tizen.org/privilege/location\nstatus: Allow")]
+        [Postcondition(1, " Open Settings")]
+        [Postcondition(2, " Open \"Privacy and security\"")]
+        [Postcondition(3, " Open \"Privacy settings\"")]
+        [Postcondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        public async Task ResponseFetched_GET_MULTIPLE_RESPONSE_CONTEXT_MULTI_REQUESTS()
+        {
+            CreateLayout();
+            _button.Clicked += OnClickMultipleRequestsAsync;
+            //// Waits for user confirmation.
+            await ManualTest.WaitForConfirm();
+            _button.Clicked -= OnClickMultipleRequestsAsync;
+        }
+
+        /// <summary>
+        /// Executes multiple requests test case
+        /// </summary>
+        /// <param name="sender">Sender</param>
+        /// <param name="e">Event</param>
+        private async void OnClickMultipleRequestsAsync(object sender, EventArgs e)
+        {
+            ChangeButtonState(false);
+            await CheckMultiple(Constans.Privileges);
+            await CheckMultiple(Constans.SecondaryPrivileges);
+        }
+
+        [Test]
+        [Category("P1")]
         [Description("Test: Check if popup will appear again after DenyOnce.")]
         [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.GetResponseContext M")]
         [Property("SPEC_URL", "-")]
@@ -231,15 +362,14 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(4, " Click button")]
         [Step(5, " Check Logs output (inside program)")]
         [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        //// I can`t add more than 6 steps beacause when I do so the App is crashing
-        //[Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        //[Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        //[Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: DenyForever")]
-        //[Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: DenyForever")]
-        //[Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: DenForever")]
-        //[Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Deny")]
-        //[Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Deny")]
-        //[Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Deny")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: DenyForever")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: DenyForever")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: DenForever")]
+        [Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Deny")]
+        [Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Deny")]
+        [Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Deny")]
         [Postcondition(1, " Open Settings")]
         [Postcondition(2, " Open \"Privacy and security\"")]
         [Postcondition(3, " Open \"Privacy settings\"")]
@@ -248,6 +378,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         public async Task GetResponseContext_DENY_FOREVER()
         {
             CreateLayout();
+            _privileges = Constans.Privileges;
             _button.Clicked += OnClick;
             //// Waits for user confirmation.
             await ManualTest.WaitForConfirm();
@@ -272,18 +403,17 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(4, " Click button")]
         [Step(5, " Check Logs output (inside program)")]
         [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        //// I can`t add more than 6 steps beacause when I do so the App is crashing
-        //[Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        //[Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        //[Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: DenyOnce")]
-        //[Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: DenyOnce")]
-        //[Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: DenOnce")]
-        //[Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        //[Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        //[Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        //[Step(15, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
-        //[Step(16, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
-        //[Step(17, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: DenyOnce")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: DenyOnce")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: DenOnce")]
+        [Step(12, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
+        [Step(13, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(14, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(15, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: AllowForever")]
+        [Step(16, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: AllowForever")]
+        [Step(17, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: AllowForever")]
         [Postcondition(1, " Open Settings")]
         [Postcondition(2, " Open \"Privacy and security\"")]
         [Postcondition(3, " Open \"Privacy settings\"")]
@@ -292,6 +422,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         public async Task GetResponseContext_DENY_ONCE()
         {
             CreateLayout();
+            _privileges = Constans.Privileges;
             _button.Clicked += OnClick;
             //// Waits for user confirmation.
             await ManualTest.WaitForConfirm();
diff --git a/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSPermissionRequestResponse.cs b/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSPermissionRequestResponse.cs
new file mode 100644 (file)
index 0000000..7de45a5
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+namespace Tizen.PrivacyPrivilegeManager.Manual.Tests.testcase
+{
+    using global::System;
+    using NUnit.Framework;
+    using NUnit.Framework.TUnit;
+    using Tizen.Security;
+    class TSPermissionRequestResponse
+    {
+        /// <summary>
+        /// Initializes environment before TCT test runs.
+        /// </summary>
+        [SetUp]
+        public void Init()
+        {
+            if (Profile.GetProfile().CompareTo(Profile.MobileProfile) != 0)
+            {
+                Assert.Pass("Privacy privileges not supported");
+            }
+
+            LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Create instance of PermissionRequestResponse")]
+        [Property("SPEC", "Tizen.Security.PermissionRequestResponse.PermissionRequestResponse C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void PermissionRequestResponse_CONSTRUCTOR()
+        {
+            try
+            {
+                PermissionRequestResponse requestResponse = new PermissionRequestResponse();
+                Assert.IsInstanceOf<PermissionRequestResponse>(requestResponse, "Should return PermissionRequestResponse");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "Can`t make instance of PermissionRequestResponse.\n" + ex.Message);
+                Assert.Fail("Can`t make instance of PermissionRequestResponse.\n" + ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if property PermissionRequestResponse.Result is accessable.")]
+        [Property("SPEC", "Tizen.Security.PermissionRequestResponse.Result A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void Result_READ_ONLY()
+        {
+            try
+            {
+                PermissionRequestResponse requestResponse = new PermissionRequestResponse();
+                RequestResult result = requestResponse.Result;
+                Assert.IsInstanceOf<RequestResult>(result, "Should return RequestResult");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ex.Message);
+                Assert.Fail(ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if property PermissionRequestResponse.Privilege is accessable.")]
+        [Property("SPEC", "Tizen.Security.PermissionRequestResponse.Privilege A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void Privilege_READ_ONLY()
+        {
+            try
+            {
+                PermissionRequestResponse requestResponse = new PermissionRequestResponse();
+                string privilege = requestResponse.Privilege;
+                Assert.IsNull(privilege, "Should be null");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ex.Message);
+                Assert.Fail(ex.Message);
+            }
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestMultipleResponseEventArgs.cs b/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestMultipleResponseEventArgs.cs
new file mode 100644 (file)
index 0000000..08ea916
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and8
+ *  limitations under the License
+ */
+
+namespace Tizen.PrivacyPrivilegeManager.Manual.Tests.testcase
+{
+    using global::System;
+    using NUnit.Framework;
+    using NUnit.Framework.TUnit;
+    using Tizen.Security;
+
+    /// <summary>
+    /// Contains <see cref="TSRequestMultipleResponseEventArgs"/> class
+    /// <para>It is used test if <see cref="Tizen.Security.TSRequestMultipleResponseEventArgs" /> works as expected.</para>
+    /// </summary>
+    class TSRequestMultipleResponseEventArgs
+    {
+        /// <summary>
+        /// Initializes environment before TCT test runs.
+        /// </summary>
+        [SetUp]
+        public void Init()
+        {
+            if (Profile.GetProfile().CompareTo(Profile.MobileProfile) != 0)
+            {
+                Assert.Pass("Privacy privileges not supported");
+            }
+
+            LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Create instance of RequestMultipleResponseEventArgs")]
+        [Property("SPEC", "Tizen.Security.RequestMultipleResponseEventArgs.RequestMultipleResponseEventArgs C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void RequestMultipleResponseEventArgs_CONSTRUCTOR()
+        {
+            try
+            {
+                RequestMultipleResponseEventArgs eventArgs = new RequestMultipleResponseEventArgs();
+                Assert.IsInstanceOf<RequestMultipleResponseEventArgs>(eventArgs, "Should return RequestMultipleResponseEventArgs");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "Can`t make instance of RequestMultipleResponseEventArgs.\n" + ex.Message);
+                Assert.Fail("Can`t make instance of RequestMultipleResponseEventArgs.\n" + ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if property RequestMultipleResponseEventArgs.cause is accessable.")]
+        [Property("SPEC", "Tizen.Security.RequestMultipleResponseEventArgs.Cause A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void Cause_READ_ONLY()
+        {
+            try
+            {
+                RequestMultipleResponseEventArgs eventArgs = new RequestMultipleResponseEventArgs();
+                CallCause cause = eventArgs.Cause;
+                Assert.IsInstanceOf<CallCause>(cause, "Should return CallCause");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ex.Message);
+                Assert.Fail(ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if property RequestMultipleResponseEventArgs.Responses are accessable.")]
+        [Property("SPEC", "Tizen.Security.RequestMultipleResponseEventArgs.Responses A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void Responses_READ_ONLY()
+        {
+            try
+            {
+                RequestMultipleResponseEventArgs eventArgs = new RequestMultipleResponseEventArgs();
+                global::System.Collections.Generic.IEnumerable<PermissionRequestResponse> responses = eventArgs.Responses;
+                Assert.IsNull(responses, "Should be null");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ex.Message);
+                Assert.Fail(ex.Message);
+            }
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index 1c44f85..8c512e1
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 {
     using global::System;
-    using global::System.Linq;
     using global::System.Threading.Tasks;
     using global::Xamarin.Forms;
     using NUnit.Framework;
     using NUnit.Framework.TUnit;
-    using Tizen.Security;
+
 
     /// <summary>
     /// Contains <see cref="TSRequestPermission"/> class
     /// <para>It is used test if <see cref="Tizen.Security.PrivacyPrivilegeManager.RequestPermission(string)" /> works as expected.</para>
     /// </summary>
-    public class TSRequestPermission : UIAbstractClass
+    public class TSRequestPermission : TestBase
     {
+        private readonly TestUI testUI = new TestUI();
+        //private readonly TestBase testBase = new TestBase();
         /// <summary>
         /// Holds privilege that will be tested
         /// </summary>
-        private string _privilege;
+        private string[] _privileges;
+
+        /// <summary>
+        /// Holds information about expected error status for testcase
+        /// </summary>
+        protected bool _expectError = false;
 
         /// <summary>
         /// Initializes environment before TCT test runs.
@@ -47,17 +53,8 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             }
 
             LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
-            executeCount = 1;
-        }
-
-        /// <summary>
-        /// Handles Buttons OnClick event.
-        /// </summary>
-        /// <param name="sender">Sender</param>
-        /// <param name="e">Event arguments</param>
-        private void OnClickMultiplePrivileges(object sender, EventArgs e)
-        {
-            Check();
+            testUI.executeCount = 1;
+            _expectError = false;
         }
 
         /// <summary>
@@ -67,77 +64,30 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <param name="e">Event arguments</param>
         private void OnClick(object sender, EventArgs e)
         {
-            CheckSinglePrivilege();
+            Request();
         }
 
         /// <summary>
         /// Checks Privileges status and displays results.
         /// </summary>
-        private void Check()
+        private void Request()
         {
-            foreach (string privilege in Constans.Privileges)
+            foreach (string privilege in _privileges)
             {
-                CheckResult result = TestBase.CheckPermission(privilege);
-                Color backgroundColor = Color.Red;
-                string labelText = "Execute number: " + executeCount++ + " Privilege: \n" + privilege + "\nStatus: " + result;
-
-                if (TestBase.ErrorOccured)
-                {
-                    labelText += "\n" + TestBase.ErrorMessage;
-                }
+                Color msgColor = Color.Green;
+                string labelText = "Sending request for privilege: " + privilege;
+                RequestPermission(privilege);
 
-                if (result == CheckResult.Ask)
+                if (ErrorOccured)
                 {
-                    backgroundColor = Color.Green;
-                    TestBase.RequestPermission(privilege);
-
-                    if (TestBase.ErrorOccured)
-                    {
-                        labelText += "\n" + TestBase.ErrorMessage;
-                    }
+                    labelText += "\nError occured: " + ErrorMessage;
+                    if (!_expectError)
+                        msgColor = Color.Red;
                 }
-
-                _UIlist.Add(new Label()
-                {
-                    Text = labelText,
-                    BackgroundColor = backgroundColor,
-                    TextColor = Color.White,
-                });
-
-                _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
+                testUI.AddNewLabel(labelText, msgColor);
             }
         }
 
-        /// <summary>
-        /// Checks Privileges status and displays results.
-        /// </summary>
-        private void CheckSinglePrivilege()
-        {
-            CheckResult result = TestBase.CheckPermission(_privilege);
-            Color backgroundColor = Color.Red;
-            string labelText = "Execute number: " + executeCount++ + " Privilege: \n" + _privilege + "\nStatus: " + result;
-
-            if (TestBase.ErrorOccured)
-            {
-                labelText += "\n" + TestBase.ErrorMessage;
-            }
-
-            if (result == CheckResult.Deny)
-            {
-                backgroundColor = Color.Green;
-                ManualTest.Confirm();
-            }
-
-            _UIlist.Add(new Label()
-            {
-                Text = labelText,
-                BackgroundColor = backgroundColor,
-                TextColor = Color.White,
-            });
-
-            _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
-        }
-
         [Test]
         [Category("P1")]
         [Description("Test: Check if popup works.")]
@@ -155,13 +105,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(3, " Allow Privileges")]
         [Step(4, " Click button")]
         [Step(5, " Check Logs output (inside program)")]
-        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
-        //// Can`t add more than 6 steps beacause when I do so the App is crashing
-        // [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
-        // [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
-        // [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Allow")]
-        // [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Allow")]
-        // [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Allow")]
+        [Step(6, "Three popups should appear")]
         [Postcondition(1, " Open Settings")]
         [Postcondition(2, " Open \"Privacy and security\"")]
         [Postcondition(3, " Open \"Privacy settings\"")]
@@ -169,10 +113,11 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Postcondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
         public async Task RequestPermission_REAL_PRIVILEGES()
         {
-            CreateLayout();
-            _button.Clicked += OnClickMultiplePrivileges;
+            testUI.CreateLayout();
+            _privileges = Constans.Privileges;
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClickMultiplePrivileges;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -187,14 +132,16 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
         [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for .\nException message: Invalid parameter")]
+        [Step(5, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_STRING_EMPTY()
         {
-            CreateLayout();
-            _privilege = Constans.Empty;
-            _button.Clicked += OnClick;
+            _expectError = true;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.Empty };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -208,15 +155,15 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(1, "Click run TC")]
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for IamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongString.\nException message: Invalid parameter")]
+        [Step(4, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_LONG_STRING()
         {
-            CreateLayout();
-            _privilege = Constans.LongString;
-            _button.Clicked += OnClick;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.LongString };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -230,15 +177,15 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(1, "Click run TC")]
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for random_string.\nException message: Invalid parameter")]
+        [Step(4, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_NON_EXISTING()
         {
-            CreateLayout();
-            _privilege = Constans.NoExisting;
-            _button.Clicked += OnClick;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.NoExisting };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -252,15 +199,15 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(1, "Click run TC")]
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for Http://TIZen.Org/PrIVIlege/AccOunt.Read. \nException message: Invalid parameter")]
+        [Step(4, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_RANDOM_LETTER_CASE_PRIVILEGE()
         {
-            CreateLayout();
-            _privilege = Constans.RandomLetterCasePrivilege;
-            _button.Clicked += OnClick;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.RandomLetterCasePrivilege };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -274,15 +221,15 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(1, "Click run TC")]
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for #@!$%^&*()+-_[]{}'\"\\|/.,;:?<>'`~.\nException message: Invalid parameter")]
+        [Step(4, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_SPECIAL_CHARACTERS()
         {
-            CreateLayout();
-            _privilege = Constans.SpecialCharacters;
-            _button.Clicked += OnClick;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.SpecialCharacters };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -297,14 +244,16 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
         [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for .\nException message: Invalid parameter")]
+        [Step(5, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_STRING_NULL()
         {
-            CreateLayout();
-            _privilege = Constans.Null;
-            _button.Clicked += OnClick;
+            _expectError = true;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.Null };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
 
         [Test]
@@ -318,15 +267,15 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         [Step(1, "Click run TC")]
         [Step(2, "Click button")]
         [Step(3, " Check Logs output (inside program)")]
-        [Step(4, " Good output: Privilege:\n\nStatus: Deny\nCan not check permission for HTTP://TIZEN.ORG/PRIVILEGE/ACCOUNT.READ. \nException message: Invalid parameter")]
+        [Step(4, " Popup should not appear")]
         [Postcondition(1, "NA")]
         public async Task RequestPermission_UPPER_LETTER_CASE_PRIVILEGE()
         {
-            CreateLayout();
-            _privilege = Constans.UpperLetterCasePrivilege;
-            _button.Clicked += OnClick;
+            testUI.CreateLayout();
+            _privileges = new string[] { Constans.UpperLetterCasePrivilege };
+            testUI._button.Clicked += OnClick;
             await ManualTest.WaitForConfirm();
-            _button.Clicked -= OnClick;
+            testUI._button.Clicked -= OnClick;
         }
     }
 }
diff --git a/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestPermissions.cs b/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/TSRequestPermissions.cs
new file mode 100644 (file)
index 0000000..fc78268
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+namespace Tizen.PrivacyPrivilegeManager.Manual.Tests.testcase
+{
+    using global::System;
+    using global::System.Threading.Tasks;
+    using NUnit.Framework;
+    using NUnit.Framework.TUnit;
+
+    /// <summary>
+    /// Contains <see cref="TSRequestPermissions"/> class
+    /// <para>It is used test if <see cref="Tizen.Security.PrivacyPrivilegeManager.RequestPermissions(string[])" /> works as expected.</para>
+    /// </summary>
+    class TSRequestPermissions : TestHelpers
+    {
+
+        /// <summary>
+        /// Initializes environment before TCT test runs.
+        /// </summary>
+        [SetUp]
+        public void Init()
+        {
+            if (Profile.GetProfile().CompareTo(Profile.MobileProfile) != 0)
+            {
+                Assert.Pass("Privacy privileges not supported");
+            }
+
+            LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
+            executeCount = 1;
+        }
+
+        /// <summary>
+        /// Handles Buttons OnClick event.
+        /// </summary>
+        /// <param name="sender">Sender</param>
+        /// <param name="e">Event arguments</param>
+        private async void OnClickMultiplePrivileges(object sender, EventArgs e)
+        {
+            ChangeButtonState(false);
+            await CheckMultiple(_privileges);
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if popups works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.RequestPermissions M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, " Open Settings")]
+        [Precondition(2, " Open \"Privacy and security\"")]
+        [Precondition(3, " Open \"Privacy settings\"")]
+        [Precondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Precondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        [Step(1, " Click run TC")]
+        [Step(2, " Click button")]
+        [Step(3, " Allow Privileges")]
+        [Step(4, " Click button")]
+        [Step(5, " Check Logs output (inside program)")]
+        [Step(6, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Ask")]
+        [Step(7, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Ask")]
+        [Step(8, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Ask")]
+        [Step(9, " Good output: Privilege:\nhttp://tizen.org/privilege/account.read\nStatus: Allow")]
+        [Step(10, " Good output: Privilege:\nhttp://tizen.org/privilege/account.write\nStatus: Allow")]
+        [Step(11, " Good output: Privilege:\nhttp://tizen.org/privilege/call\nStatus: Allow")]
+        [Postcondition(1, " Open Settings")]
+        [Postcondition(2, " Open \"Privacy and security\"")]
+        [Postcondition(3, " Open \"Privacy settings\"")]
+        [Postcondition(4, " Open \"Accounts\" and uncheck Tizen.Security.PrivacyManager")]
+        [Postcondition(5, " Open \"Call\" and uncheck Tizen.Security.PrivacyManager")]
+        public async Task RequestPermissions_REAL_PRIVILEGES()
+        {
+            CreateLayout();
+            _privileges = Constans.Privileges;
+            _button.Clicked += OnClickMultiplePrivileges;
+            await ManualTest.WaitForConfirm();
+            _button.Clicked -= OnClickMultiplePrivileges;
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if popups works.")]
+        [Property("SPEC", "Tizen.Security.PrivacyPrivilegeManager.RequestPermissions M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Step(1, " Click run TC")]
+        [Step(2, " Click button")]
+        [Step(3, " Allow Privileges")]
+        [Step(4, " Click button")]
+        [Step(5, " Check Logs output (inside program)")]
+        public async Task RequestPermissions_FAKE_PRIVILEGES()
+        {
+            CreateLayout();
+            _privileges = new string[] {Constans.LongString, Constans.NoExisting, Constans.RandomLetterCasePrivilege,
+                                        Constans.SpecialCharacters, Constans.UpperLetterCasePrivilege};
+            _button.Clicked += OnClickMultiplePrivileges;
+            await ManualTest.WaitForConfirm();
+            _button.Clicked -= OnClickMultiplePrivileges;
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index dd2ab2b..cb76cbf
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
     /// <summary>
     /// Contains <see cref="TSRequestResponseEventArgs"/> class
     /// <para>It is used test if <see cref="Tizen.Security.RequestResponseEventArgs" /> works as expected.</para>
-    /// </summary>s
+    /// </summary>
     class TSRequestResponseEventArgs
     {
         /// <summary>
@@ -56,7 +56,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         {
             try
             {
-                var eventArgs = new RequestResponseEventArgs();
+                RequestResponseEventArgs eventArgs = new RequestResponseEventArgs();
                 Assert.IsInstanceOf<RequestResponseEventArgs>(eventArgs, "Should return RequestResponseEventArgs");
             }
             catch (Exception ex)
@@ -81,8 +81,8 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         {
             try
             {
-                var eventArgs = new RequestResponseEventArgs();
-                var cause = eventArgs.cause;
+                RequestResponseEventArgs eventArgs = new RequestResponseEventArgs();
+                CallCause cause = eventArgs.cause;
                 Assert.IsInstanceOf<CallCause>(cause, "Should return CallCause");
             }
             catch (Exception ex)
@@ -107,8 +107,8 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         {
             try
             {
-                var eventArgs = new RequestResponseEventArgs();
-                var result = eventArgs.result;
+                RequestResponseEventArgs eventArgs = new RequestResponseEventArgs();
+                RequestResult result = eventArgs.result;
                 Assert.IsInstanceOf<RequestResult>(result, "Should return RequestResult");
             }
             catch (Exception ex)
@@ -133,8 +133,8 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         {
             try
             {
-                var eventArgs = new RequestResponseEventArgs();
-                var privilege = eventArgs.privilege;
+                RequestResponseEventArgs eventArgs = new RequestResponseEventArgs();
+                string privilege = eventArgs.privilege;
                 Assert.IsNull(privilege, "Should return null");
             }
             catch (Exception ex)
@@ -143,5 +143,31 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
                 Assert.Fail(ex.Message);
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Check if property RequestResponseEventArgs.Response is accessable.")]
+        [Property("SPEC", "Tizen.Security.RequestResponseEventArgs.Response A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Ernest Borowski, e.borowski@partner.samsung.com")]
+        [Precondition(1, "NA")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Click button")]
+        [Postcondition(1, "NA")]
+        public void Response_READ_ONLY()
+        {
+            try
+            {
+                RequestResponseEventArgs eventArgs = new RequestResponseEventArgs();
+                PermissionRequestResponse response = eventArgs.Response;
+                Assert.IsInstanceOf<PermissionRequestResponse>(response, "Should return null");
+            }
+            catch (Exception ex)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ex.Message);
+                Assert.Fail(ex.Message);
+            }
+        }
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index f44b165..5845390
@@ -25,42 +25,42 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <summary>
         /// Contains null string.
         /// </summary>
-        private static string _null = null;
+        private static readonly string _null = null;
 
         /// <summary>
         /// Contains empty string.
         /// </summary>
-        private static string empty = string.Empty;
+        private static readonly string empty = string.Empty;
 
         /// <summary>
         /// Contains string with random letters.
         /// </summary>
-        private static string noExisting = "random_string";
+        private static readonly string noExisting = "random_string";
 
         /// <summary>
         /// Contains long string.
         /// </summary>
-        private static string longString = "IamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongString";
+        private static readonly string longString = "IamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongStringIamVeryLongString";
 
         /// <summary>
         /// Contains privilege with letters in upper case.
         /// </summary>
-        private static string upperLetterCasePrivilege = "HTTP://TIZEN.ORG/PRIVILEGE/ACCOUNT.READ";
+        private static readonly string upperLetterCasePrivilege = "HTTP://TIZEN.ORG/PRIVILEGE/ACCOUNT.READ";
 
         /// <summary>
         /// Contains privilege which letters are in random case.
         /// </summary>
-        private static string randomLetterCasePrivilege = "Http://TIZen.Org/PrIVIlege/AccOunt.Read";
+        private static readonly string randomLetterCasePrivilege = "Http://TIZen.Org/PrIVIlege/AccOunt.Read";
 
         /// <summary>
         /// Contains string with special characters.
         /// </summary>
-        private static string specialCharacters = "#@!$%^&*()+-_[]{}'\"\\|/.,;:?<>'`~";
+        private static readonly string specialCharacters = "#@!$%^&*()+-_[]{}'\"\\|/.,;:?<>'`~";
 
         /// <summary>
         /// Contains array of privileges.
         /// </summary>
-        private static string[] privileges = new string[]
+        private static readonly string[] privileges = new string[]
          {
                 "http://tizen.org/privilege/account.read",
                 "http://tizen.org/privilege/account.write",
@@ -68,6 +68,17 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
          };
 
         /// <summary>
+        /// Contains secondary array of privileges. e.g. for multiple requests test.
+        /// </summary>
+        private static readonly string[] secondaryPrivileges = new string[]
+        {
+            "http://tizen.org/privilege/contact.read",
+            "http://tizen.org/privilege/contact.write",
+            "http://tizen.org/privilege/download",
+            "http://tizen.org/privilege/location",
+        };
+
+        /// <summary>
         /// Gets Empty string.
         /// </summary>
         public static string Empty
@@ -154,5 +165,16 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
                 return privileges;
             }
         }
+
+        /// <summary>
+        /// Gets secondary privacy privileges array. e.g. for testing multiple requests
+        /// </summary>
+        public static string[] SecondaryPrivileges
+        {
+            get
+            {
+                return secondaryPrivileges;
+            }
+        }
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
index 6abc04d..e4fcf42
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *  Copyright (c) 2017 - 2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 {
     using global::System;
+    using global::System.Collections.Generic;
+    using global::System.Linq;
     using NUnit.Framework.TUnit;
     using Tizen.Security;
 
     /// <summary>
     /// <see cref="TestBase"/> Class
-    /// <para> Contains wrapped methods which Connect with <see cref="Tizen.Security.PrivacyPrivilegeManager" /></para>
+    /// <para> Contains wrapped methods which Connect with <see cref="Tizen.PrivacyPrivilegeManager" /></para>
     /// </summary>
     public class TestBase
     {
         /// <summary>
         /// Contains error Message
         /// </summary>
-        private static string errorMessage;
-
-        /// <summary>
-        /// Contains information about errors
-        /// </summary>
-        private static bool errorOccured;
+        private string errorMessage;
 
         /// <summary>
         /// Gets error Message if exception occurred
         /// </summary>
-        public static string ErrorMessage
+        public string ErrorMessage
         {
             get
             {
-                ErrorOccured = false;
                 return errorMessage;
             }
 
@@ -56,16 +52,11 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <summary>
         /// Gets information if exception occurred
         /// </summary>
-        public static bool ErrorOccured
+        public bool ErrorOccured
         {
             get
             {
-                return errorOccured;
-            }
-
-            private set
-            {
-                errorOccured = value;
+                return !(errorMessage == null || errorMessage == "");
             }
         }
 
@@ -75,33 +66,71 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// </summary>
         /// <param name="privilege">Privilege name</param>
         /// <returns>CheckResult state</returns>
-        public static CheckResult CheckPermission(string privilege)
+        public CheckResult CheckPermission(string privilege, bool expectedArgumentException = false)
         {
-            ErrorOccured = false;
+            ErrorMessage = "";
             CheckResult result;
             try
             {
                 result = PrivacyPrivilegeManager.CheckPermission(privilege);
             }
+            catch (ArgumentException ex)
+            {
+                if (expectedArgumentException)
+                {
+                    result = CheckResult.Deny;
+                }
+                else
+                {
+                    ErrorMessage = "Can not check permission for " + privilege + ".\nException message:" + ex.Message;
+                    LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ErrorMessage);
+                    result = CheckResult.Deny;
+                }
+            }
             catch (Exception ex)
             {
                 ErrorMessage = "Can not check permission for " + privilege + ".\nException message:" + ex.Message;
                 LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ErrorMessage);
                 result = CheckResult.Deny;
-                ErrorOccured = true;
             }
 
             return result;
         }
 
         /// <summary>
+        /// Checks status of privileges
+        /// <para>It is wrapper for <see cref="PrivacyPrivilegeManager.CheckPermissions(string[])"/></para>
+        /// </summary>
+        /// <param name="privileges">Privileges name</param>
+        /// <returns>CheckResult states</returns>
+        public CheckResult[] CheckPermissions(string[] privileges)
+        {
+            ErrorMessage = "";
+            CheckResult[] results = null;
+            try
+            {
+                results = PrivacyPrivilegeManager.CheckPermissions(privileges).ToArray();
+            }
+            catch (Exception ex)
+            {
+                ErrorMessage = "Can not check permission for " + string.Join(" ", privileges) + ".\nException message:" + ex.Message;
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ErrorMessage);
+                results = new CheckResult[privileges.Length];
+                for (int it = 0; it < privileges.Length; ++it)
+                    results[it] = CheckResult.Deny;
+            }
+
+            return results;
+        }
+
+        /// <summary>
         /// Requests access to privilege
         /// <para>It is wrapper for <see cref="PrivacyPrivilegeManager.RequestPermission(string)"/></para>
         /// </summary>
         /// <param name="privilege">Privilege name</param>
-        public static void RequestPermission(string privilege)
+        public void RequestPermission(string privilege)
         {
-            ErrorOccured = false;
+            ErrorMessage = "";
             try
             {
                 PrivacyPrivilegeManager.RequestPermission(privilege);
@@ -110,8 +139,27 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             {
                 ErrorMessage = "Can not request permission for " + privilege + ".\nException message: " + ex.Message;
                 LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, ErrorMessage);
-                ErrorOccured = true;
             }
         }
+
+        /// <summary>
+        /// Returns priviliges array with ask status
+        /// </summary>
+        /// <returns>Privileges array</returns>
+        public List<string> GetPrivilegesWithAskStatus(string[] privileges, CheckResult[] responses)
+        {
+            List<string> privilegesWithAskStatus = new List<string>();
+            string log = "GetPrivilegesWithAskStatus:\n";
+            for (int it = 0; it < privileges.Length; it++)
+            {
+                if (responses[it] == CheckResult.Ask)
+                {
+                    privilegesWithAskStatus.Add(privileges[it]);
+                }
+                log += "Priv: " + privileges[it] + " response: " + responses[it];
+            }
+            LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, log);
+            return privilegesWithAskStatus;
+        }
     }
-}
\ No newline at end of file
+}
diff --git a/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/TestHelpers.cs b/tct-suite-vs/Tizen.PrivacyPrivilegeManager.Manual.Tests/testcase/support/TestHelpers.cs
new file mode 100644 (file)
index 0000000..16625d0
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ *  Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
+{
+    using global::NUnit.Framework.TUnit;
+    using global::System;
+    using global::System.Collections.Generic;
+    using global::System.Threading.Tasks;
+    using global::Xamarin.Forms;
+    using Tizen.Security;
+
+    public abstract class TestHelpers : TestUI
+    {
+        private readonly TestBase testBase = new TestBase();
+        /// <summary>
+        /// Contains privileges for current test case
+        /// </summary>
+        protected static string[] _privileges;
+
+        /// <summary>
+        /// Contains privileges for current test case
+        /// </summary>
+        protected static bool requestAdditionalPrivilegesInCallback = false;
+
+        /// <summary>
+        /// Logs Request result for privilege to system log and UI
+        /// </summary>
+        /// <param name="privilege">Privilege name</param>
+        /// <param name="result">Privilege request result</param>
+        protected void LogPrivilegeRequestResponse(string privilege, RequestResult result)
+        {
+            switch (result)
+            {
+                case RequestResult.AllowForever:
+                    {
+                        LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User allowed usage of privilege " + privilege + " forever.");
+                        break;
+                    }
+
+                case RequestResult.DenyForever:
+                    {
+                        LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User denied usage of privilege " + privilege + " forever.");
+                        break;
+                    }
+
+                case RequestResult.DenyOnce:
+                    {
+                        LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "User denied usage of privilege " + privilege + " once.");
+                        break;
+                    }
+            }
+            AddNewLabel("Execute number: " + executeCount + " Privilege: \n" + privilege + "\nStatus: " + result);
+        }
+
+        /// <summary>
+        /// Checks Privileges status and displays results.
+        /// </summary>
+        protected void Check(string[] privileges)
+        {
+            bool gotCheckResult = false;
+            foreach (string privilege in privileges)
+            {
+                CheckResult result = testBase.CheckPermission(privilege);
+                Color backgroundColor = Color.Red;
+                string labelText = "Execute number: " + executeCount++ + "\nPrivilege: \n" + privilege + "\nStatus: " + result;
+
+                if (testBase.ErrorOccured)
+                {
+                    labelText += "\n" + testBase.ErrorMessage;
+                }
+
+                if (result == CheckResult.Ask)
+                {
+                    gotCheckResult = true;
+                    backgroundColor = Color.Green;
+                    SetupPPMHandler(privilege);
+                    testBase.RequestPermission(privilege);
+
+                    if (testBase.ErrorOccured)
+                    {
+                        labelText += "\n" + testBase.ErrorMessage;
+                        backgroundColor = Color.Red;
+                    }
+                }
+
+                if (!gotCheckResult)
+                {
+                    ChangeButtonState(true);
+                }
+                AddNewLabel(labelText, backgroundColor);
+            }
+        }
+
+        protected virtual void SetupPPMHandler(string privilege) { }
+
+        /// <summary>
+        /// Checks Privileges status and displays results.
+        /// </summary>
+        protected async Task CheckMultiple(string[] privileges)
+        {
+            CheckResult[] results = testBase.CheckPermissions(privileges);
+            Color backgroundColor = Color.White;
+
+            string labelText = "Execute number: " + executeCount++;
+            if (testBase.ErrorOccured)
+            {
+                labelText += "\n" + testBase.ErrorMessage;
+                backgroundColor = Color.Red;
+            }
+            for (int it = 0; it < privileges.Length; it++)
+            {
+                labelText += "\nPrivilege: \n" + privileges[it] + "\nStatus: " + results[it];
+            }
+            AddNewLabel(labelText, backgroundColor);
+            backgroundColor = Color.Green;
+            List<string> privilegesWithAskStatus = testBase.GetPrivilegesWithAskStatus(privileges, results);
+            if (privilegesWithAskStatus == null || privilegesWithAskStatus.Count == 0)
+            {
+                LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, "NO Privileges with ask status! ");
+                AddNewLabel("No privileges with ask status!", Color.Red);
+                ChangeButtonState(true);
+                return;
+            }
+
+            labelText = "Privileges with ask status: \n" + string.Join("\n", privilegesWithAskStatus);
+            LogUtils.Write(LogUtils.ERROR, LogUtils.TAG, labelText);
+            bool errorOccured = false;
+            RequestMultipleResponseEventArgs request = null;
+            try
+            {
+                LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "before");
+                request = await PrivacyPrivilegeManager.RequestPermissions(privilegesWithAskStatus);
+                LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "after");
+                if (request.Cause == CallCause.Error)
+                {
+                    errorOccured = true;
+                    labelText += "\nRequestPermissions response returned error.";
+                }
+                foreach (PermissionRequestResponse response in request.Responses)
+                {
+                    LogPrivilegeRequestResponse(response.Privilege, response.Result);
+                }
+
+                if (requestAdditionalPrivilegesInCallback)
+                {
+                    _privileges = Constans.SecondaryPrivileges;
+                    requestAdditionalPrivilegesInCallback = false;
+                    await CheckMultiple(_privileges);
+                }
+            }
+            catch (Exception ex)
+            {
+                errorOccured = true;
+                labelText += "\nEx_msg: " + ex.Message;
+            }
+
+            if (errorOccured)
+            {
+                backgroundColor = Color.Red;
+            }
+
+            ChangeButtonState(true);
+            AddNewLabel(labelText, backgroundColor);
+        }
+    }
+}
 namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
 {
     using global::System.Collections.ObjectModel;
+    using global::System.Linq;
     using global::Xamarin.Forms;
     using NUnit.Framework;
-    using NUnit.Framework.TUnit;
 
     /// <summary>
-    /// Contains <see cref="UIAbstractClass"/> class
+    /// Contains <see cref="TestUI"/> class
     /// <para>It is used to create UI for each test case separately</para>
     /// </summary>
-    public abstract class UIAbstractClass
+    public class TestUI
     {
+
+        /// <summary>
+        /// Provides locking mechanism for changing button state
+        /// </summary>
+        private readonly object _syncLock = new object();
+
         /// <summary>
         /// Holds TestPage instance
         /// </summary>
@@ -35,7 +41,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <summary>
         /// Holds Buton
         /// </summary>
-        protected Button _button;
+        public Button _button;
 
         /// <summary>
         /// Holds ListView
@@ -50,12 +56,70 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
         /// <summary>
         /// Holds execute number, enumerates every time user clicks button
         /// </summary>
-        protected int executeCount = 1;
+        public int executeCount = 1;
+
+        /// <summary>
+        /// Adds lablel with application logs
+        /// </summary>
+        /// <param name="labelText">text that will be logged inside <see cref="Label"/></param>
+        /// <param name="backgroundColor"><see cref="Label"/> background color</param>
+        public void AddNewLabel(string labelText, Color backgroundColor)
+        {
+            //Can not declare default parameters value because they have to be compile-time constant
+            if (backgroundColor != Color.White)
+            {
+                AddNewLabel(labelText, backgroundColor, Color.White);
+            }
+            else
+            {
+                AddNewLabel(labelText, backgroundColor, Color.Black);
+            }
+        }
+
+        /// <summary>
+        /// Adds lablel with application logs
+        /// </summary>
+        /// <param name="labelText">text that will be logged inside <see cref="Label"/></param>
+        public void AddNewLabel(string labelText)
+        {
+            //Can not declare default parameters value because they have to be compile-time constant
+            AddNewLabel(labelText, Color.White, Color.Black);
+        }
+
+        /// <summary>
+        /// Adds lablel with application logs
+        /// </summary>
+        /// <param name="labelText">text that will be logged inside <see cref="Label"/></param>
+        /// <param name="backgroundColor"><see cref="Label"/> background color</param>
+        /// <param name="textColor">text background color</param>
+        public void AddNewLabel(string labelText, Color backgroundColor, Color textColor)
+        {
+            _UIlist.Add(new Label()
+            {
+                Text = labelText,
+                BackgroundColor = backgroundColor,
+                TextColor = textColor,
+            });
+
+            _listView.ScrollTo(_listView.ItemsSource.OfType<Label>().Last(), ScrollToPosition.End, true);
+        }
+
+        /// <summary>
+        /// Changes button state
+        /// </summary>
+        /// <param name="isEnabled">Desired button state</param>
+        public void ChangeButtonState(bool isEnabled)
+        {
+            lock (_syncLock)
+            {
+                _button.IsEnabled = isEnabled;
+            }
+        }
 
         /// <summary>
         /// Creates UI for test case.
         /// </summary>
-        protected void CreateLayout()
+        public void CreateLayout()
         {
             executeCount = 1;
 
@@ -70,9 +134,9 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             // Defining Grid childs size
             RowDefinition row = new RowDefinition();
             RowDefinition row2 = new RowDefinition();
-            row.Height = new GridLength(5.0, GridUnitType.Star);
+            row.Height = new GridLength(1.0, GridUnitType.Star);
             layout.RowDefinitions.Add(row);
-            row2.Height = new GridLength(1.0, GridUnitType.Star);
+            row2.Height = new GridLength(5.0, GridUnitType.Star);
             layout.RowDefinitions.Add(row2);
             layout.BackgroundColor = Color.White;
 
@@ -85,7 +149,7 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             };
 
             //// Template for displaying Labels Text (Logs) in ListView
-            var template = new DataTemplate(() =>
+            DataTemplate template = new DataTemplate(() =>
             {
                 Label display = new Label();
                 display.SetBinding(Label.TextProperty, new Binding("Text"));
@@ -120,10 +184,12 @@ namespace Tizen.PrivacyPrivilegeManager.Manual.Tests
             };
 
             // Adding childs to Main Grid
-            layout.Children.Add(_listView, 0, 0);
-            layout.Children.Add(_button, 0, 1);
-            var contentPage = new ContentPage();
-            contentPage.Content = layout;
+            layout.Children.Add(_listView, 0, 1);
+            layout.Children.Add(_button, 0, 0);
+            ContentPage contentPage = new ContentPage
+            {
+                Content = layout
+            };
             _testPage.ExecuteTC(contentPage);
         }
     }
index 376561c..bad7e5e 100644 (file)
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest package="Tizen.PrivacyPrivilegeManager.Manual.Tests" version="1.0.0" api-version="6" xmlns="http://tizen.org/ns/packages">
+<manifest package="Tizen.PrivacyPrivilegeManager.Manual.Tests" version="1.0.0" api-version="4.0" xmlns="http://tizen.org/ns/packages">
     <profile name="common" />
     <ui-application appid="Tizen.PrivacyPrivilegeManager.Manual.Tests" exec="Tizen.PrivacyPrivilegeManager.Manual.Tests.dll" multiple="false" taskmanage="true" splash-screen-display="true" type="dotnet" launch_mode="single">
-        <icon>Tizen.PrivacyPrivilegeManager.Manual.Tests.png</icon>
+        <icon>Tizen.Security.PrivacyPrivilegeManager.Manual.Tests.png</icon>
         <label>Tizen.PrivacyPrivilegeManager.Manual.Tests</label>
+        <splash-screens />
     </ui-application>
     <shortcut-list />
     <privileges>
         <privilege>http://tizen.org/privilege/account.write</privilege>
         <privilege>http://tizen.org/privilege/account.read</privilege>
         <privilege>http://tizen.org/privilege/call</privilege>
+        <privilege>http://tizen.org/privilege/contact.read</privilege>
+        <privilege>http://tizen.org/privilege/contact.write</privilege>
+        <privilege>http://tizen.org/privilege/download</privilege>
+        <privilege>http://tizen.org/privilege/location</privilege>
+        <privilege>http://tizen.org/privacy/storage</privilege>
+        <privilege>http://tizen.org/privacy/message</privilege>
     </privileges>
+    <provides-appdefined-privileges />
 </manifest>