From 052076dfc3228c4c8c9d9f4c8f96983dcffcd6e9 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 18 Feb 2019 13:34:01 +0900 Subject: [PATCH] [Storage][TCSACR-222][Check ArgumentException] Change-Id: If20ceba28d9ecae2e694e6801417c9b9f41c5352 Signed-off-by: pr.jung --- .../testcase/TSStorage.cs | 19 ++--- .../testcase/TSStorageManager.cs | 29 +++----- .../Tizen.System.Tests/testcase/TSStorage.cs | 87 +++++++++++----------- 3 files changed, 63 insertions(+), 72 deletions(-) mode change 100755 => 100644 tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs mode change 100755 => 100644 tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.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 index e1a601f..dcad9a2 --- a/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs +++ b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorage.cs @@ -17,9 +17,18 @@ namespace Tizen.System.Tests [Description("Tizen.System.Storage test class")] public class StorageTests { + static bool support = true; + [SetUp] public void Init() { + bool ret; + bool value; + ret = Information.TryGetValue("http://tizen.org/feature/storage.external", out value); + if (ret && value) + support = true; + else + support = false; } [TearDown] @@ -42,18 +51,10 @@ namespace Tizen.System.Tests [Step(4, "If you do not get \"pass\", please press fail.")] public async Task StorageStateChanged_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) + if (support) { Assert.IsNotEmpty(storages, "SD card is not inserted"); diff --git a/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs old mode 100755 new mode 100644 index 9d2b6f4..2dc4f41 --- a/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs +++ b/tct-suite-vs/Tizen.System.Manual.Tests/testcase/TSStorageManager.cs @@ -10,9 +10,18 @@ namespace Tizen.System.Manual.Tests.testcase [Description("Tizen.System.StorageManager test class")] class StorageManagerTests { + static bool support = true; + [SetUp] public void Init() { + bool ret; + bool value; + ret = Information.TryGetValue("http://tizen.org/feature/storage.external", out value); + if (ret && value) + support = true; + else + support = false; } [TearDown] @@ -36,18 +45,10 @@ namespace Tizen.System.Manual.Tests.testcase [Step(4, "If you don't get \"pass\", please press fail.")] public 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) + if (support) { Assert.IsEmpty(storages, "SD Card is inserted already"); @@ -94,18 +95,10 @@ namespace Tizen.System.Manual.Tests.testcase [Step(4, "If you don't get \"pass\", please press fail.")] public 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) + if (support) { Assert.IsEmpty(storages, "SD Card is inserted already"); diff --git a/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs b/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs index 9d8bc9f..1b1b1e6 100644 --- a/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs +++ b/tct-suite-vs/Tizen.System.Tests/testcase/TSStorage.cs @@ -21,6 +21,7 @@ namespace Tizen.System.Tests static Storage internalStorage = null; static Storage externalStorage = null; static int internalStorageId = 0; + static bool support = true; static void Debug(string msg) { @@ -37,6 +38,13 @@ namespace Tizen.System.Tests [SetUp] public void Init() { + bool ret; + bool value; + ret = Information.TryGetValue("http://tizen.org/feature/storage.external", out value); + if (ret && value) + support = true; + else + support = false; } [TearDown] @@ -74,25 +82,44 @@ namespace Tizen.System.Tests [Test] [Category("P2")] - [Description("Check if GetAbsolutePath() raises exception for ringtone directory")] + [Description("Check if GetAbsolutePath() raises not supported exception for external storage")] [Property("SPEC", "Tizen.System.Storage.GetAbsolutePath M")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "MEX")] [Property("AUTHOR", "Dinesh Dwivedi, dinesh.d@samsung.com")] public void GetAbsolutePath_CHECK_NOT_SUPPORTED_EXCEPTION() { - string profile; - bool is_mobile; - - // PRECONDITION - // 1. Device must have external storage (SD Card) installed. - Information.TryGetValue("tizen.org/feature/profile", out profile); - if (String.Compare(profile, "mobile", true) == 0) - is_mobile = true; + if (support) + { + Assert.Pass("Test skipped! Can't test not supported exception"); + } else - is_mobile = false; + { + if (externalStorage != null) + { + try + { + externalStorage.GetAbsolutePath(DirectoryType.Camera); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } + } + } + } - if (is_mobile) + [Test] + [Category("P2")] + [Description("Check if GetAbsolutePath() raises exception for ringtone directory")] + [Property("SPEC", "Tizen.System.Storage.GetAbsolutePath M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MEX")] + [Property("AUTHOR", "Dinesh Dwivedi, dinesh.d@samsung.com")] + public void GetAbsolutePath_CHECK_ARGUMENT_EXCEPTION() + { + if (support) { Assert.IsNotNull(externalStorage, "PRECONDITION: Failed to get external storage for testing."); @@ -104,25 +131,12 @@ namespace Tizen.System.Tests } catch (Exception ex) { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "this operation should raise NotSupportedException exception"); + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); } } else { - if (externalStorage != null) - { - try - { - externalStorage.GetAbsolutePath(DirectoryType.Ringtones); - Assert.IsTrue(false, "this operation should raise NotSupportedException exception"); - } - catch (Exception ex) - { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "this operation should raise NotSupportedException exception"); - } - } - else // Can not connect usb on TV emulator - Assert.Pass("Test skipped! The external storage is Not available"); + Assert.Pass("Test skipped! The external storage is Not available"); } } @@ -312,18 +326,7 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Dinesh Dwivedi, dinesh.d@samsung.com")] public void StorageType_GET_ENUM_STORAGEAREA_EXTERNAL() { - string profile; - bool is_mobile; - - // PRECONDITION - // 1. Device must have external storage (SD Card) installed. - 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) + if (support) { Assert.IsNotNull(externalStorage, "PRECONDITION: Failed to get external storage for testing."); @@ -334,13 +337,7 @@ namespace Tizen.System.Tests } else { - if (externalStorage != null) - { - var result = externalStorage.StorageType; - Assert.IsTrue(StorageArea.External == result, "Wrong external storage type"); - } - else // Can not connect usb on TV emulator - Assert.Pass("Test skipped! The external storage is Not available"); + Assert.Pass("Test skipped! The external storage is Not available"); } } -- 2.7.4