[Applications][TCSACR-197][Add new testcases] 92/195492/5
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 14 Dec 2018 02:33:41 +0000 (11:33 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 14 Dec 2018 10:10:50 +0000 (19:10 +0900)
Added:
 - TerminateBackgroundApplication_TERMINATE_BG_APP()
 - GetAppId_GET_APPID()
 - IsTerminated_GET_PROPERTY_FALSE()
 - IsTerminated_GET_PROPERTY_TRUE()
 - Name_GET()
 - Version_GET()

Change-Id: I22e187d1f6f47c3a296c28268c2317a447b4bb11
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
tct-suite-vs/Tizen.Applications.Tests/testcase/TSApplication.cs
tct-suite-vs/Tizen.Applications.Tests/testcase/TSApplicationManager.cs
tct-suite-vs/Tizen.Applications.Tests/testcase/TSApplicationRunningContext.cs
tct-suite-vs/Tizen.Applications.Tests/tizen-manifest.xml

index cf8e058..a005466 100755 (executable)
@@ -84,6 +84,34 @@ namespace Tizen.Applications.Tests
             Assert.AreEqual (_directoryInfo.Cache, _cachePath, "DirectoryInfo Cache path not correct");
             Assert.AreEqual (_directoryInfo.Data, _dataPath, "DirectoryInfo Data path not correct");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Name property")]
+        [Property("SPEC", "Tizen.Applications.Application.Name A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void Name_GET()
+        {
+            var name = Application.Current.Name;
+            Assert.IsNotNull(name, "Object should not null");
+            Assert.IsInstanceOf<string>(name);
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Version property")]
+        [Property("SPEC", "Tizen.Applications.Application.Version A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void Version_GET()
+        {
+            var version = Application.Current.Version;
+            Assert.IsNotNull(version, "Object should not null");
+            Assert.IsInstanceOf<string>(version);
+        }
     }
 
     public class SubApplication : Application
index 2f7bec1..d853ed4 100755 (executable)
@@ -24,6 +24,7 @@ namespace Tizen.Applications.Tests
         private static bool _flag;
         private static bool _needUnsubscribe1;
         private static bool _needUnsubscribe2;
+        private static bool _needUnsubscribe3;
         private static bool _isLaunched;
         private static bool _isTerminated;
         private static string _argAppId;
@@ -41,6 +42,7 @@ namespace Tizen.Applications.Tests
             _flag = false;
             _needUnsubscribe1 = false;
             _needUnsubscribe2 = false;
+            _needUnsubscribe3 = false;
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
         }
 
@@ -51,6 +53,8 @@ namespace Tizen.Applications.Tests
                 ApplicationManager.ApplicationLaunched -= Eventlaunched;
             if (_needUnsubscribe2 == true)
                 ApplicationManager.ApplicationTerminated -= EventTerminated;
+            if (_needUnsubscribe3 == true)
+                ApplicationManager.ApplicationTerminated -= EventServiceAppTerminated;
             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
         }
 
@@ -353,5 +357,68 @@ namespace Tizen.Applications.Tests
 
             Assert.True(IsRunning, "MyApp should be included in RecentApplications");
         }
+
+        public static void EventServiceAppTerminated(object sender, ApplicationTerminatedEventArgs Args)
+        {
+            Log.Debug("TCT", Args.ApplicationRunningContext.ApplicationId + " Terminated");
+            if (string.Equals(Args.ApplicationRunningContext.ApplicationId, AppServiceId))
+                _isTerminated = true;
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Terminate a service application in the background.")]
+        [Property("SPEC", "Tizen.Applications.ApplicationManager.TerminateBackgroundApplication M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task TerminateBackgroundApplication_TERMINATE_BG_APP()
+        {
+            /*
+             * PRECONDITION
+             * 1. Launch a service-application
+             */
+            AppControl MyAppControl = new AppControl();
+            MyAppControl.ApplicationId = AppServiceId;
+            AppControl.SendLaunchRequest(MyAppControl);
+            ApplicationManager.ApplicationTerminated += EventServiceAppTerminated;
+            _needUnsubscribe3 = true;
+
+            await Task.Delay(5000);
+
+            var _list = await ApplicationManager.GetAllRunningApplicationsAsync();
+            foreach (var app in _list)
+            {
+                if (app.ApplicationId.Contains(AppServiceId))
+                {
+                    _isTerminated = false;
+                    ApplicationManager.TerminateBackgroundApplication(app);
+                    break;
+                }
+            }
+
+            await Task.Delay(5000);
+
+            /* TEST CODE
+             * 1 Add function EventServiceAppTerminated to event ApplicationTerminated.
+             * 2 Set _isTerminated is true in EventServiceAppTerminated.
+             */
+
+            Assert.True(_isTerminated, AppServiceId + " should be terminated");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test: Gets the application ID by running process ID.")]
+        [Property("SPEC", "Tizen.Applications.ApplicationManager.GetAppId M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void GetAppId_GET_APPID()
+        {
+            ApplicationRunningContext runningContext = new ApplicationRunningContext(Application.Current.ApplicationInfo.ApplicationId);
+            var appId = ApplicationManager.GetAppId(runningContext.ProcessId);
+            Assert.AreEqual(appId, Application.Current.ApplicationInfo.ApplicationId, "The appId should be equal to ApplicationId of ApplicationRunningContext");
+        }
     }
 }
index 3d9fed9..54c7300 100755 (executable)
@@ -17,6 +17,7 @@
 using NUnit.Framework;
 using NUnit.Framework.TUnit;
 using System.Threading;
+using System.Threading.Tasks;
 
 namespace Tizen.Applications.Tests
 {
@@ -28,6 +29,7 @@ namespace Tizen.Applications.Tests
         private const string AppId = "org.tizen.example.UIApp.Tizen";
         private const string PackgeId = "UIApp.Tizen";
         private const int ProcessId = 0;
+        private const string AppServiceId = "org.tizen.ServiceAppTest.Tizen";
 
         [SetUp]
         public static void Init()
@@ -151,5 +153,45 @@ namespace Tizen.Applications.Tests
                 Assert.Fail("The application should be resumed");
             }
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test property IsTerminated of ApplicationRunningContext.")]
+        [Property("SPEC", "Tizen.Applications.ApplicationRunningContext.IsTerminated A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void IsTerminated_GET_PROPERTY_FALSE()
+        {
+            Assert.AreEqual(false, _context.IsTerminated, "IsTerminated of " + AppId + " is not correct");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test property IsTerminated of ApplicationRunningContext.")]
+        [Property("SPEC", "Tizen.Applications.ApplicationRunningContext.IsTerminated A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task IsTerminated_GET_PROPERTY_TRUE()
+        {
+            /*
+             * PRECONDITION
+             * 1. Launch a service-application
+             * 2. Terminate the running service-application
+             */
+            AppControl MyAppControl = new AppControl();
+            MyAppControl.ApplicationId = AppServiceId;
+            AppControl.SendLaunchRequest(MyAppControl);
+
+            await Task.Delay(5000);
+
+            ApplicationRunningContext runningContext = new ApplicationRunningContext(AppServiceId);
+            ApplicationManager.TerminateBackgroundApplication(runningContext);
+
+            await Task.Delay(5000);
+
+            Assert.AreEqual(true, runningContext.IsTerminated, "IsTerminated of " + AppId + " is not correct");
+        }
     }
 }
index 394a4b3..8c00b1f 100755 (executable)
@@ -16,6 +16,7 @@
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>\r
         <privilege>http://tizen.org/privilege/appdir.shareddata</privilege>\r
         <privilege>http://tizen.org/privilege/datasharing</privilege>\r
+        <privilege>http://tizen.org/privilege/appmanager.kill.bgapp</privilege>\r
     </privileges>\r
     <provides-appdefined-privileges />\r
 </manifest>\r