[PackageManager][TCSACR-272] add TCs for dependency info 03/213903/8
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 16 Sep 2019 02:18:38 +0000 (11:18 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 23 Sep 2019 08:39:12 +0000 (17:39 +0900)
Change-Id: I497054214ce66ca8db79cca24ed076d267429bcc
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
tct-suite-vs/Resource/Tizen.Packagemanager.Tests/dependency_test.tpk [new file with mode: 0644]
tct-suite-vs/Resource/Tizen.Packagemanager.Tests/source/TpkPkgTest/tizen-manifest.xml
tct-suite-vs/Resource/Tizen.Packagemanager.Tests/tpkpkgtest.tpk
tct-suite-vs/Tizen.Packagemanager.Tests/res/pkgarchivetest.tpk
tct-suite-vs/Tizen.Packagemanager.Tests/testcase/TSPackage.cs
tct-suite-vs/Tizen.Packagemanager.Tests/testcase/TSPackageArchive.cs
tct-suite-vs/Tizen.Packagemanager.Tests/testcase/TSPackageDependencyInformation.cs [new file with mode: 0755]

diff --git a/tct-suite-vs/Resource/Tizen.Packagemanager.Tests/dependency_test.tpk b/tct-suite-vs/Resource/Tizen.Packagemanager.Tests/dependency_test.tpk
new file mode 100644 (file)
index 0000000..f80eaf1
Binary files /dev/null and b/tct-suite-vs/Resource/Tizen.Packagemanager.Tests/dependency_test.tpk differ
index a993fc9..db4dba9 100755 (executable)
@@ -1,8 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="tpkpkgtest" version="1.0.0">
-       <profile name="mobile" />
-       <ui-application appid="tpkpkgtest" exec="tpkpkgtest" type="capp" multiple="false" taskmanage="true" nodisplay="false" launch_mode="single">
-               <icon>tpkpkgtest.png</icon>
-               <label>tpkpkgtest</label>
-       </ui-application>
+        <profile name="mobile"/>
+        <ui-application appid="tpkpkgtest"
+                        exec="tpkpkgtest"
+                        type="capp"
+                        multiple="false"
+                        taskmanage="true"
+                        nodisplay="false"
+                        launch_mode="single">
+                <icon>tpkpkgtest.png</icon>
+                <label>tpkpkgtest</label>
+        </ui-application>
+        <dependencies>
+                <dependency type="wants" required-version="1.0.0">dependency_package_1</dependency>
+                <dependency type="wants" required-version="1.2.3">dependency_package_2</dependency>
+        </dependencies>
 </manifest>
index 015c510..5e88b19 100644 (file)
Binary files a/tct-suite-vs/Resource/Tizen.Packagemanager.Tests/tpkpkgtest.tpk and b/tct-suite-vs/Resource/Tizen.Packagemanager.Tests/tpkpkgtest.tpk differ
index 104fc08..4fd2ce1 100644 (file)
Binary files a/tct-suite-vs/Tizen.Packagemanager.Tests/res/pkgarchivetest.tpk and b/tct-suite-vs/Tizen.Packagemanager.Tests/res/pkgarchivetest.tpk differ
index b352e80..0aeb1a0 100644 (file)
@@ -21,6 +21,12 @@ namespace Tizen.Applications.Tests
         private Package _wgtPackage = null;
         private Package _watchPackage = null;
         private const string MainAppId = "tpkpkgtest";
+        private const string DependencyPkg1 = "dependency_package_1";
+        private const string DependencyPkg1Type = "wants";
+        private const string DependencyPkg1RequiredVersion = "1.0.0";
+        private const string DependencyPkg2 = "dependency_package_2";
+        private const string DependencyPkg2Type = "wants";
+        private const string DependencyPkg2RequiredVersion = "1.2.3";
 
         [TestFixtureSetUp]
         public void Init()
@@ -645,5 +651,70 @@ namespace Tizen.Applications.Tests
             Assert.IsInstanceOf<ApplicationInfo>(mainapplication, "MainApplication should return ApplicationInfo");
             Assert.AreEqual(mainapplication.ApplicationId, MainAppId, "Main Application ID should be same " + MainAppId);
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if DependencyTo property return correct value")]
+        [Property("SPEC", "Tizen.Applications.Package.DependencyTo A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void DependencyTo_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(_tpkPackage, "Precondition failed: testPackage should not be null");
+
+            // TEST CODE
+            var dependencies = _tpkPackage.DependencyTo;
+            string[] dependencyPkgList = new string[] { DependencyPkg1, DependencyPkg2 };
+            Assert.IsTrue(dependencies is IEnumerable<PackageDependencyInformation>, "Package dependencies should be of type IEnumerable<PackageDependencyInformation>");
+            Assert.IsNotNull(dependencies, "dependencies list should not be null");
+            Assert.IsNotEmpty(dependencies, "dependencies should be not empty.");
+            Assert.AreEqual(dependencies.Count(), 2, "Number elements of returned list of PackageDependencyInformation should correct");
+            foreach (PackageDependencyInformation dependency in dependencies)
+            {
+                Assert.IsTrue(dependencyPkgList.Contains(dependency.To), "return pkg should be in pkgList");
+                if (dependency.To == DependencyPkg1)
+                {
+                    Assert.AreEqual(dependency.From, _tpkPackage.Id, "dependency From should be " + _tpkPackage.Id);
+                    Assert.AreEqual(dependency.To, DependencyPkg1, "dependency To should be " + _tpkPackage.Id);
+                    Assert.AreEqual(dependency.Type, DependencyPkg1Type, "dependency Type should be" + DependencyPkg1Type);
+                    Assert.AreEqual(dependency.RequiredVersion, DependencyPkg1RequiredVersion, "dependency RequiredVersion should be" + DependencyPkg1RequiredVersion);
+                } else if (dependency.To == DependencyPkg2)
+                {
+                    Assert.AreEqual(dependency.From, _tpkPackage.Id, "dependency From should be " + _tpkPackage.Id);
+                    Assert.AreEqual(dependency.To, DependencyPkg2, "dependency To should be " + DependencyPkg2);
+                    Assert.AreEqual(dependency.Type, DependencyPkg2Type, "dependency Type should be" + DependencyPkg2Type);
+                    Assert.AreEqual(dependency.RequiredVersion, DependencyPkg2RequiredVersion, "dependency RequiredVersion should be" + DependencyPkg2RequiredVersion);
+                }
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if DependencyFrom property return correct value")]
+        [Property("SPEC", "Tizen.Applications.Package.DependencyFrom A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void DependencyFrom_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(_tpkPackage, "Precondition failed: testPackage should not be null");
+
+            // TEST CODE
+            var dependencies = _tpkPackage.DependencyFrom;
+            Assert.IsTrue(dependencies is IEnumerable<PackageDependencyInformation>, "Package dependencies should be of type IEnumerable<PackageDependencyInformation>");
+            Assert.IsNotNull(dependencies, "dependencies list should not be null");
+            Assert.IsNotEmpty(dependencies, "dependencies should be not empty.");
+            Assert.AreEqual(dependencies.Count(), 1, "Number elements of returned list of PackageDependencyInformation should correct");
+            List<PackageDependencyInformation> dependencyList = dependencies.ToList();
+            PackageDependencyInformation dependency = dependencyList[0];
+
+            Assert.AreEqual(dependency.From, "dependency_test", "dependency From should be dependency_test");
+            Assert.AreEqual(dependency.To, _tpkPackage.Id, "dependency To should be " + _tpkPackage.Id);
+            Assert.AreEqual(dependency.Type, "wants", "dependency Type should be wants");
+            Assert.AreEqual(dependency.RequiredVersion, "1.0.0", "dependency RequiredVersion should be 1.0.0");
+        }
     }
 }
index 86b4a10..ab464a7 100644 (file)
@@ -8,6 +8,8 @@
 
 using NUnit.Framework;
 using NUnit.Framework.TUnit;
+using System.Collections.Generic;
+using System.Linq;
 
 namespace Tizen.Applications.Tests
 {
@@ -25,6 +27,8 @@ namespace Tizen.Applications.Tests
         private string _label = "pkgarchivetest";
         private string _author = "test author";
         private int _iconSize = 57662;
+        private const string DependencyPkg1 = "dependency_package_1";
+        private const string DependencyPkg2 = "dependency_package_2";
 
         [SetUp]
         public void Init()
@@ -132,6 +136,27 @@ namespace Tizen.Applications.Tests
         {
             Assert.AreEqual(_iconSize, _pkgArchive.Icon.Length, "Icon size of " + _archiveTestPkg + " is not correct");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if DependencyTo property return correct value")]
+        [Property("SPEC", "Tizen.Applications.PackageArchive.DependencyTo A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void DependencyTo_GET()
+        {
+            var dependencies = _pkgArchive.DependencyTo;
+            string[] dependencyPkgList = new string[] { DependencyPkg1, DependencyPkg2 };
+            Assert.IsTrue(dependencies is List<PackageDependencyInformation>, "Package dependencies should be of type List<PackageDependencyInformation>");
+            Assert.IsNotNull(dependencies, "dependencies list should not be null");
+            Assert.IsNotEmpty(dependencies, "dependencies should be not empty.");
+            Assert.AreEqual(dependencies.Count, 2, "Number elements of returned list of PackageDependencyInformation should correct");
+            foreach (PackageDependencyInformation dependency in dependencies)
+            {
+                Assert.IsTrue(dependencyPkgList.Contains(dependency.To), "return pkg should be in pkgList");
+            }
+        }
     }
 
 }
diff --git a/tct-suite-vs/Tizen.Packagemanager.Tests/testcase/TSPackageDependencyInformation.cs b/tct-suite-vs/Tizen.Packagemanager.Tests/testcase/TSPackageDependencyInformation.cs
new file mode 100755 (executable)
index 0000000..fafcbd3
--- /dev/null
@@ -0,0 +1,93 @@
+// Copyright 2019 by Samsung Electronics, Inc.,
+//
+// This software is the confidential and proprietary information
+// of Samsung Electronics, Inc. ("Confidential Information"). You
+// shall not disclose such Confidential Information and shall use
+// it only in accordance with the terms of the license agreement
+// you entered into with Samsung.
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Applications.Tests
+{
+    [TestFixture]
+    [Description("Tizen.Applications.PackageDependencyInformation test class")]
+    public class PackageDependencyInformationTests
+    {
+        PackageDependencyInformation dependency = null;
+
+        [TestFixtureSetUp]
+        public void Init()
+        {
+            var dependencies = TestHelper.TpkPackage.DependencyFrom;
+            Assert.IsTrue(dependencies is IEnumerable<PackageDependencyInformation>, "Package dependencies should be of type IEnumerable<PackageDependencyInformation>");
+            Assert.IsNotNull(dependencies, "dependencies list should not be null");
+            Assert.IsNotEmpty(dependencies, "dependencies should be not empty.");
+            Assert.AreEqual(dependencies.Count(), 1, "Number elements of returned list of PackageDependencyInformation should correct");
+            List<PackageDependencyInformation> dependencyList = dependencies.ToList();
+            dependency = dependencyList[0];
+        }
+
+        [TestFixtureTearDown]
+        public void Destroy()
+        {
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if From property return correct value")]
+        [Property("SPEC", "Tizen.Applications.PackageDependencyInformation.From A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void From_GET()
+        {
+            // TEST CODE
+            Assert.AreEqual(dependency.From, "dependency_test", "dependency From should be dependency_test");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if To property return correct value")]
+        [Property("SPEC", "Tizen.Applications.PackageDependencyInformation.To A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void To_GET()
+        {
+            // TEST CODE
+            Assert.AreEqual(dependency.To, "tpkpkgtest", "dependency To should be tpkpkgtest");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if Type property return correct value")]
+        [Property("SPEC", "Tizen.Applications.PackageDependencyInformation.Type A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void Type_GET()
+        {
+            // TEST CODE
+            Assert.AreEqual(dependency.Type, "wants", "dependency Type should be wants");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checks if RequiredVersion property return correct value")]
+        [Property("SPEC", "Tizen.Applications.PackageDependencyInformation.RequiredVersion A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Kim Ilho, ilho159.kim@samsung.com")]
+        public void RequiredVersion_GET()
+        {
+            // TEST CODE
+            Assert.AreEqual(dependency.RequiredVersion, "1.0.0", "dependency RequiredVersion should be 1.0.0");
+        }
+
+    }
+
+}