From f8f2a46366a874d721550a63771ce2e9fa5433fe Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 5 Feb 2018 14:09:48 +0900 Subject: [PATCH] [System][ACR-127]Add test for new APIs Change-Id: Ic08eb6933e7d5f8a83e67c12dc05dd20cad82ea6 Signed-off-by: pr.jung --- .../testcase/TSStorage.cs | 0 .../testcase/TSStorageManager.cs | 153 +++++++++++++++++++++ .../Tizen.System.Tests/testcase/TSStorage.cs | 115 ++++++++++++++++ 3 files changed, 268 insertions(+) mode change 100755 => 100644 tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs create mode 100644 tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs mode change 100755 => 100644 tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs diff --git a/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs old mode 100755 new mode 100644 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 index 0000000..da4f00e --- /dev/null +++ b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs @@ -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("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("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"); + } + } +} diff --git a/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs b/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs old mode 100755 new mode 100644 index e36bded..9cd290c --- a/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs +++ b/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs @@ -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", "-")] -- 2.7.4