From ecf559fcb4b4c2c378775101cf754807aac3c7d8 Mon Sep 17 00:00:00 2001 From: "chaehee.hong" Date: Thu, 13 Apr 2023 18:06:52 +0900 Subject: [PATCH] [Download][TCSACR-531] Add new APIs for download caching - Add test cases for UsesCache - Add test cases for ResetCache Change-Id: Idf98b722213bd4551dccad90de743d2f14c41905 --- .../testcase/TSCacheManager.cs | 51 ++++++++++++++++++++ .../Tizen.Download.Tests/testcase/TSRequest.cs | 56 ++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 tct-suite-vs/Tizen.Download.Tests/testcase/TSCacheManager.cs diff --git a/tct-suite-vs/Tizen.Download.Tests/testcase/TSCacheManager.cs b/tct-suite-vs/Tizen.Download.Tests/testcase/TSCacheManager.cs new file mode 100644 index 0000000..037bc49 --- /dev/null +++ b/tct-suite-vs/Tizen.Download.Tests/testcase/TSCacheManager.cs @@ -0,0 +1,51 @@ +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading.Tasks; +using Tizen.System; + +namespace Tizen.Content.Download.Tests +{ + + [TestFixture] + [Description("Tizen.Content.Download.CacheManager Tests.")] + public class CacheManagerTests { + private bool _isDownloadSupported = false; + + [SetUp] + public void Init() { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG , "Preconditions for each Test"); + Information.TryGetValue("http://tizen.org/feature/download", out _isDownloadSupported); + } + + [TearDown] + public void Destroy() { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG , "Postconditions for each Test"); + } + + [Test] + [Category("P1")] + [Description("Test CacheManager.ResetCache method")] + [Property("SPEC", "Tizen.Content.Download.CacheManager.ResetCache M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Chaehee Hong, chaehee.hong@samsung.com")] + public void ResetCache_CHECK_RESET_CACHE_OPERATION() + { + try + { + CacheManager.ResetCache(); + } + catch (NotSupportedException) + { + Assert.IsTrue(_isDownloadSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(false, "Exception occurs. Msg : " + ex.ToString()); + } + + Tizen.Log.Info("Tizen.Content.Download" , "TC Completed"); + } + } +} diff --git a/tct-suite-vs/Tizen.Download.Tests/testcase/TSRequest.cs b/tct-suite-vs/Tizen.Download.Tests/testcase/TSRequest.cs index 30d38c7..3636f0b 100755 --- a/tct-suite-vs/Tizen.Download.Tests/testcase/TSRequest.cs +++ b/tct-suite-vs/Tizen.Download.Tests/testcase/TSRequest.cs @@ -1239,6 +1239,62 @@ namespace Tizen.Content.Download.Tests } } + [Test] + [Category("P1")] + [Description("Test Request.UsesCache. Check whether UsesCache is readable and writable")] + [Property("SPEC", "Tizen.Content.Download.Request.UsesCache A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Chaehee Hong, chaehee.hong@samsung.com")] + public void UsesCache_READ_WRITE() + { + try + { + req = new Tizen.Content.Download.Request(url); + Assert.IsNotNull(req, "Request object should not be null after initializing"); + + req.UsesCache = true; + Assert.IsInstanceOf(req.UsesCache, "UsesCache is not of the type bool"); + Assert.IsTrue(req.UsesCache, "Request propety \"UsesCache\": the set value and the get value should be true"); + + req.UsesCache = false; + Assert.IsInstanceOf(req.UsesCache, "UsesCache is not of the type bool"); + Assert.IsFalse(req.UsesCache, "Request propety \"UsesCache\": the set value and the get value should be false"); + + req.Dispose(); + Tizen.Log.Info("Tizen.Content.Download", "TC Completed"); + } + catch (NotSupportedException) + { + Assert.IsTrue(isDownloadSupported == false, "Invalid NotSupportedException"); + } + } + + [Test] + [Category("P1")] + [Description("Test Request.UsesCache. Check whether default value of UsesCache is false")] + [Property("SPEC", "Tizen.Content.Download.Request.UsesCache A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PDV")] + [Property("AUTHOR", "Chaehee Hong, chaehee.hong@samsung.com")] + public void UsesCache_Default_READ() + { + try + { + req = new Tizen.Content.Download.Request(url); + Assert.IsNotNull(req, "Request object should not be null after initializing"); + + Assert.IsInstanceOf(req.UsesCache, "UsesCache is not of the type bool"); + Assert.IsFalse(req.UsesCache, "Request propety \"UsesCache\": default value must be false"); + req.Dispose(); + Tizen.Log.Info("Tizen.Content.Download", "TC Completed"); + } + catch (NotSupportedException) + { + Assert.IsTrue(isDownloadSupported == false, "Invalid NotSupportedException"); + } + } + void OnStateChangedStart(object sender, StateChangedEventArgs e) { Tizen.Log.Info("Tizen.Content.Download" , "OnStateChanged"); -- 2.7.4