--- /dev/null
+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");
+ }
+ }
+}
[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", "-")]