[System][ACR-127]Add test for new APIs 69/177169/9
authorpr.jung <pr.jung@samsung.com>
Mon, 5 Feb 2018 05:09:48 +0000 (14:09 +0900)
committerpr.jung <pr.jung@samsung.com>
Tue, 15 May 2018 08:08:57 +0000 (17:08 +0900)
Change-Id: Ic08eb6933e7d5f8a83e67c12dc05dd20cad82ea6
Signed-off-by: pr.jung <pr.jung@samsung.com>
tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs [changed mode: 0755->0644]
tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs [new file with mode: 0644]
tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs [changed mode: 0755->0644]

diff --git a/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs
new file mode 100644 (file)
index 0000000..da4f00e
--- /dev/null
@@ -0,0 +1,153 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.System.Manual.Tests.testcase
+{
+    [TestFixture]
+    [Description("Tizen.System.StorageManager test class")]
+    class StorageManagerTests
+    {
+        [SetUp]
+        public static void Init()
+        {
+        }
+
+        [TearDown]
+        public static void Destroy()
+        {
+
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Tests SetChangedEvent")]
+        [Property("SPEC", "Tizen.System.StorageManager.SetChangedEvent A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Pureum Jung, pr.jung@samsung.com")]
+        [Precondition(1, "Remove SD Card or USB.")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Insert SD card or USB")]
+        [Step(3, "If you don't get \"pass\", please press fail.")]
+        public static async Task SetChangedEvent_CHECK_SDCARD_EVENT()
+        {
+            string profile;
+            bool is_mobile;
+            // PRECONDITION
+            var storages = StorageManager.Storages.Where(s => s.StorageType == StorageArea.External).Select(s => s).ToList();
+
+            Information.TryGetValue<string>("tizen.org/feature/profile", out profile);
+            if (String.Compare(profile, "mobile", true) == 0)
+                is_mobile = true;
+            else
+                is_mobile = false;
+
+            if (is_mobile)
+            {
+                Assert.IsEmpty(storages, "SD Card is inserted already");
+
+                // TEST CODE
+                bool unmountableStateAchieved = false;
+
+                EventHandler callback = (s, e) =>
+                {
+                    var storage = s as Storage;
+                    if (storage == null) return;
+                    if (storage.State == StorageState.Unmountable)
+                    {
+                        unmountableStateAchieved = true;
+                    }
+
+                    Assert.IsTrue(unmountableStateAchieved, "didn't get unmount event.");
+                    Assert.IsTrue(true, "get remove event.");
+                    ManualTest.Confirm();
+                };
+
+                StorageManager.SetChangedEvent(StorageArea.External, callback);
+
+                // need to manually change state of any external storage
+                await ManualTest.WaitForConfirm();
+
+                StorageManager.UnsetChangedEvent(StorageArea.External, callback);
+            }
+            else
+                Assert.Pass("Test skipped! The external storage is Not available");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Tests UnsetChangedEvent")]
+        [Property("SPEC", "Tizen.System.StorageManager.UnsetChangedEvent A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Pureum Jung, pr.jung@samsung.com")]
+        [Precondition(1, "Remove SD Card or USB.")]
+        [Step(1, "Click run TC")]
+        [Step(2, "Insert SD card or USB")]
+        [Step(3, "If you don't get \"pass\", please press fail.")]
+        public static async Task UnsetChangedEvent_CHECK_SDCARD_EVENT()
+        {
+            string profile;
+            bool is_mobile;
+            // PRECONDITION
+            var storages = StorageManager.Storages.Where(s => s.StorageType == StorageArea.External).Select(s => s).ToList();
+
+            Information.TryGetValue<string>("tizen.org/feature/profile", out profile);
+            if (String.Compare(profile, "mobile", true) == 0)
+                is_mobile = true;
+            else
+                is_mobile = false;
+
+            if (is_mobile)
+            {
+                Assert.IsEmpty(storages, "SD Card is inserted already");
+
+                // TEST CODE
+                bool unmountableStateAchieved = false;
+
+                EventHandler callback1 = (s, e) =>
+                {
+                    var storage = s as Storage;
+                    if (storage == null) return;
+                    if (storage.State == StorageState.Unmountable)
+                    {
+                        unmountableStateAchieved = true;
+                    }
+
+                    Assert.IsTrue(unmountableStateAchieved, "didn't get unmount event.");
+                    Assert.IsTrue(true, "get remove event.");
+                    Assert.Fail();
+                };
+                EventHandler callback2 = (s, e) =>
+                {
+                    var storage = s as Storage;
+                    if (storage == null) return;
+                    if (storage.State == StorageState.Unmountable)
+                    {
+                        unmountableStateAchieved = true;
+                    }
+
+                    Assert.IsTrue(unmountableStateAchieved, "didn't get unmount event.");
+                    Assert.IsTrue(true, "get remove event.");
+                    ManualTest.Confirm();
+                };
+
+                StorageManager.SetChangedEvent(StorageArea.External, callback1);
+                StorageManager.SetChangedEvent(StorageArea.External, callback2);
+                StorageManager.UnsetChangedEvent(StorageArea.External, callback1);
+
+
+
+                // need to manually change state of any external storage
+                await ManualTest.WaitForConfirm();
+
+                StorageManager.UnsetChangedEvent(StorageArea.External, callback2);
+            }
+            else
+                Assert.Pass("Test skipped! The external storage is Not available");
+        }
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index e36bded..9cd290c
@@ -172,6 +172,121 @@ namespace Tizen.System.Tests
 
         [Test]
         [Category("P1")]
+        [Description("Checkes if storage.DeviceType has proper value")]
+        [Property("SPEC", "Tizen.System.Storage.DeviceType A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Pureum Jung")]
+        public static void DeviceType_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(internalStorage, "PRECONDITION: Failed to get internal storage for testing.");
+
+            // TEST CODE
+            try
+            {
+                var result = internalStorage.DeviceType;
+            }
+            catch (Exception ex)
+            {
+                Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "Should throw InvalidOperationException");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checkes if storage.Fstype has proper value")]
+        [Property("SPEC", "Tizen.System.Storage.Fstype A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Pureum Jung")]
+        public static void Fstype_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(internalStorage, "PRECONDITION: Failed to get internal storage for testing.");
+
+            // TEST CODE
+            try
+            {
+                var result = internalStorage.Fstype;
+            }
+            catch (Exception ex)
+            {
+                Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "Should throw InvalidOperationException");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checkes if storage.Fsuuid has proper value")]
+        [Property("SPEC", "Tizen.System.Storage.Fsuuid A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Pureum Jung")]
+        public static void Fsuuid_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(internalStorage, "PRECONDITION: Failed to get internal storage for testing.");
+
+            // TEST CODE
+            try
+            {
+                var result = internalStorage.Fsuuid;
+            }
+            catch (Exception ex)
+            {
+                Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "Should throw InvalidOperationException");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checkes if storage.Flags has proper value")]
+        [Property("SPEC", "Tizen.System.Storage.Flags A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Pureum Jung")]
+        public static void Flags_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(internalStorage, "PRECONDITION: Failed to get internal storage for testing.");
+
+            // TEST CODE
+            try
+            {
+                var result = internalStorage.Flags;
+            }
+            catch (Exception ex)
+            {
+                Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "Should throw InvalidOperationException");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Checkes if storage.Primary has proper value")]
+        [Property("SPEC", "Tizen.System.Storage.Primary A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Pureum Jung")]
+        public static void Primary_READ_ONLY()
+        {
+            // PRECONDITION
+            Assert.IsNotNull(internalStorage, "PRECONDITION: Failed to get internal storage for testing.");
+
+            // TEST CODE
+            try
+            {
+                var result = internalStorage.Primary;
+            }
+            catch (Exception ex)
+            {
+                Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "Should throw InvalidOperationException");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
         [Description("Checkes if storage.StorageType has proper value")]
         [Property("SPEC", "Tizen.System.Storage.StorageType A")]
         [Property("SPEC_URL", "-")]