From: Seoyeon Kim Date: Fri, 31 Jul 2020 04:16:32 +0000 (+0900) Subject: [NUI][TCSACR-338][Add Tizen.NUI.Components.Pagination testcases] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5e0b5e29703119f4aa717ecfac1317af316c842;p=test%2Ftct%2Fcsharp%2Fapi.git [NUI][TCSACR-338][Add Tizen.NUI.Components.Pagination testcases] - Added test cases of Tizen.NUI.Components.Pagination APIs : Pagination(string style) Pagination(Tizen.NUI.Components.PaginationStyle paginationStyle) Tizen.NUI.Components.PaginationStyle Style { get; } Tizen.NUI.Size IndicatorSize { get; set; } Tizen.NUI.BaseComponents.Selector IndicatorImageUrl { get; set; } int IndicatorSpacing { get; set; } int IndicatorCount { get; set; } int SelectedIndex { get; set; } Tizen.NUI.Position GetIndicatorPosition(int index) virtual void SelectIn(Tizen.NUI.VisualMap selectInIndicator) virtual void SelectOut(Tizen.NUI.VisualMap selectOutIndicator) override ViewStyle CreateViewStyle() override void Dispose(Tizen.NUI.DisposeTypes type) PaginationStyle() PaginationStyle(PaginationStyle style) Tizen.NUI.Size IndicatorSize { get; set; } Tizen.NUI.BaseComponents.Selector IndicatorImageUrl { get; set; } int IndicatorSpacing { get; set; } override void CopyFrom(Tizen.NUI.Binding.BindableObject bindableObject) Change-Id: I43e0f2a984a64470eacde4b70a6e9001e4f6c694 Signed-off-by: Seoyeon Kim --- diff --git a/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPagination.cs b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPagination.cs new file mode 100755 index 000000000..0283b9043 --- /dev/null +++ b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPagination.cs @@ -0,0 +1,438 @@ +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using System.Threading.Tasks; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components.Test; + +namespace Tizen.NUI.Components.Tests +{ + [TestFixture] + [Description("Tizen.NUI.Components.Pagination Tests")] + public class PaginationTests + { + private const string TAG = "TCT"; + + public PaginationTests() + { + } + + ~PaginationTests() + { + } + + [SetUp] + public void Init() + { + Tizen.Log.Info(TAG, "Init() is called!"); + } + + [TearDown] + public void Destroy() + { + Tizen.Log.Info(TAG, "Destroy() is called!"); + } + + [Test] + [Category("P1")] + [Description("Create a Pagination object. Check whether Pagination is successfully created or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Pagination C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Pagination_INIT() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + Assert.IsInstanceOf(pagination, "Costruct Pagination Fail"); + } + + [Test] + [Category("P1")] + [Description("Test Pagination constructor using string. Check whether Pagination is successfully created or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Pagination C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Pagination_INIT_WITH_STRING() + { + /* TEST CODE */ + StyleManager.Instance.Theme = "default"; + StyleManager.Instance.RegisterStyle("defaultPagination", "default", typeof(DefaultPaginationStyle)); + var pagination = new Pagination("defaultPagination"); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination!"); + } + + [Test] + [Category("P2")] + [Description("Check exception when constructing a Pagination with null string style.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Pagination C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTX")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Pagination_INIT_WITH_NULL_STRING_Exception() + { + /* TEST CODE */ + try + { + var pagination = new Pagination(""); + Assert.Fail("Should throw the Exception: There is no style of null string !"); + } + catch (InvalidOperationException e) + { + Assert.Pass("InvalidOperationException: passed!"); + } + } + + [Test] + [Category("P2")] + [Description("Check exception when constructing a Pagination with nonexistent style.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Pagination C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTX")] + [Property("COVPARAM", "string")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Pagination_INIT_WITH_STRING_Exception() + { + /* TEST CODE */ + try + { + var pagination = new Pagination("defaultPaginationX"); + Assert.Fail("Should throw the Exception: There is no style of defaultPaginationX !"); + } + catch(InvalidOperationException e) + { + Assert.Pass("InvalidOperationException: passed!"); + } + } + + [Test] + [Category("P1")] + [Description("Test Pagination constructor using style. Check whether Pagination is successfully created or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Pagination C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "PaginationStyle")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Pagination_INIT_WITH_STYLE() + { + /* TEST CODE */ + var style = new PaginationStyle(); + Assert.IsNotNull(style, "Should be not null!"); + Assert.IsInstanceOf(style, "Should be an instance of PaginationStyle!"); + + var pagination = new Pagination(style); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination!"); + } + + [Test] + [Category("P1")] + [Description("Test Style. Check whether Style is readable.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Style A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Style_CHECK_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination!"); + + var style = pagination.Style; + Assert.IsNotNull(style, "Should be not null"); + Assert.IsInstanceOf(style, "Should be an instance of PaginationStyle!"); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorSize. Check IndicatorSize works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.IndicatorSize A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorSize_SET_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + + Assert.IsInstanceOf(pagination, "Costruct Pagination Fail"); + pagination.IndicatorSize = new Size(100,100); + Assert.AreEqual(100, pagination.IndicatorSize.Width, "Retrieved IndicatorSize width should be equal to set value."); + Assert.AreEqual(100, pagination.IndicatorSize.Height, "Retrieved IndicatorSize height should be equal to set value."); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorImageUrl. Check IndicatorImageUrl works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.IndicatorImageUrl A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorImageUrl_SET_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + Assert.IsInstanceOf(pagination, "Costruct Pagination Fail"); + + pagination.IndicatorImageUrl = new Selector{All="background"}; + Assert.AreEqual("background", pagination.IndicatorImageUrl.All, "Retrieved IndicatorImageUrl should be equal to set value."); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorSpacing. Check whether IndicatorSpacing works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.IndicatorSpacing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorSpacing_SET_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should return Pagination instance."); + + pagination.IndicatorSpacing = 0; + Assert.AreEqual(0, pagination.IndicatorSpacing, "Retrieved IndicatorSpacing should be equal to set value"); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorCount. Check whether IndicatorCount works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.IndicatorCount A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorCount_SET_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should return Pagination instance."); + + pagination.IndicatorCount = 0; + Assert.AreEqual(0, pagination.IndicatorCount, "Retrieved IndicatorCount should be equal to set value"); + } + + [Test] + [Category("P2")] + [Description("Check exception when IndicatorCount receive an invalid value.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.IndicatorCount A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorCount_SET_Exception() + { + /* TEST CODE */ + try + { + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should return Pagination instance."); + + pagination.IndicatorCount = -1; + Assert.Fail("Should throw the ArgumentException !"); + } + catch(ArgumentException e) + { + Assert.Pass("ArgumentException: passed!"); + } + } + + [Test] + [Category("P1")] + [Description("Test SelectedIndex. Check whether SelectedIndex works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.SelectedIndex A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void SelectedIndex_SET_GET_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should return Pagination instance."); + + pagination.SelectedIndex = 0; + Assert.AreEqual(0, pagination.SelectedIndex, "Retrieved SelectedIndex should be equal to set value"); + } + + [Test] + [Category("P1")] + [Description("Test GetIndicatorPosition.Check whether GetIndicatorPosition returns the value expected.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.GetIndicatorPosition M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void GetIndicatorPosition_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Should be not null!"); + Assert.IsInstanceOf(pagination, "Should return Pagination instance."); + pagination.Size = new Size(100, 10); + pagination.IndicatorSize = new Size(10, 10); + pagination.IndicatorCount = 10; + Assert.AreEqual(0.0f, pagination.GetIndicatorPosition(0).X, "Should be equals to the origin value of IndicatorPosition.X"); + Assert.AreEqual(0.0f, pagination.GetIndicatorPosition(0).Y, "Should be equals to the origin value of IndicatorPosition.Y"); + } + + [Test] + [Category("P1")] + [Description("Test SelectOut.Check whether SelectOut set correctly.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.SelectOut M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void SelectOut_CHECK_SET_VALUE() + { + /* TEST CODE */ + try + { + var pagination = new MyPagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination type"); + pagination.Size = new Size(100, 10); + + ImageVisual indicator = new ImageVisual() + { + Size = new Size2D(10, 10), + Opacity = 1.0f, + }; + pagination.SelectOutTest(indicator); + Assert.AreEqual(0.5f, indicator.Opacity, "Should be equals to the opacity of ImageVisual indicator"); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test SelectIn.Check whether SelectIn set correctly.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.SelectIn M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void SelectIn_CHECK_SET_VALUE() + { + /* TEST CODE */ + try + { + var pagination = new MyPagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination type"); + pagination.Size = new Size(100, 10); + + ImageVisual indicator = new ImageVisual() + { + Size = new Size2D(10, 10), + Opacity = 0.5f, + }; + pagination.SelectInTest(indicator); + Assert.AreEqual(1.0f, indicator.Opacity, "Should be equals to the opacity of ImageVisual indicator"); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test CreateViewStyle. Check whether CreateViewStyle works or not.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.CreateViewStyle M")] + [Property("SPEC_URL", " - ")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void CreateViewStyle_CHECK_RETURN_VALUE() + { + /* TEST CODE */ + try + { + var pagination = new MyPagination(); + ViewStyle style = pagination.CreateMyViewStyle(); + Assert.IsNotNull(style, "Should be not null"); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + [Test] + [Category("P1")] + [Description("Test Dispose, try to dispose the Pagination.")] + [Property("SPEC", "Tizen.NUI.Components.Pagination.Dispose M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void Dispose_CHECK_RETURN_TYPE() + { + /* TEST CODE */ + try + { + var pagination = new Pagination(); + Assert.IsNotNull(pagination, "Can't create success object Pagination"); + Assert.IsInstanceOf(pagination, "Should be an instance of Pagination type"); + + pagination.Dispose(); + } + catch (Exception e) + { + Tizen.Log.Error(TAG, "Caught Exception" + e.ToString()); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); + Assert.Fail("Caught Exception" + e.ToString()); + } + } + + public class MyPagination : Pagination + { + public MyPagination() : base() {} + + public ViewStyle CreateMyViewStyle() + { + return base.CreateViewStyle(); + } + + public void SelectOutTest(VisualMap indicator) + { + SelectOut(indicator); + } + protected override void SelectOut(VisualMap selectOutIndicator) + { + base.SelectOut(selectOutIndicator); + } + + public void SelectInTest(VisualMap indicator) + { + SelectIn(indicator); + } + protected override void SelectIn(VisualMap selectOutIndicator) + { + base.SelectIn(selectOutIndicator); + } + } + + public class DefaultPaginationStyle : StyleBase + { + protected override ViewStyle GetViewStyle() + { + return new PaginationStyle(); + } + } + } +} diff --git a/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPaginationStyle.cs b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPaginationStyle.cs new file mode 100755 index 000000000..25c4bf312 --- /dev/null +++ b/tct-suite-vs/Tizen.NUI.Components.Tests/testcase/TSPaginationStyle.cs @@ -0,0 +1,139 @@ +using NUnit.Framework; +using NUnit.Framework.TUnit; +using System; +using Tizen.NUI; +using Tizen.NUI.Components; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using Tizen.NUI.Components.Test; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Components.Tests +{ + [TestFixture] + [Description("Tizen.NUI.Components.PaginationStyle Tests")] + public class PaginationStyleTests + { + private const string TAG = "Components"; + + [SetUp] + public void Init() + { + Tizen.Log.Info(TAG, "Init() is called!"); + } + + [TearDown] + public void Destroy() + { + Tizen.Log.Info(TAG, "Destroy() is called!"); + } + + [Test] + [Category("P1")] + [Description("Test PaginationStyle empty constructor. Check it has been triggered")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.PaginationStyle C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void PaginationStyle_INIT() + { + /* TEST CODE */ + var style = new PaginationStyle(); + Assert.IsNotNull(style, "Should be not null!"); + Assert.IsInstanceOf(style, "Should be an instance of PaginationStyle!"); + } + + [Test] + [Category("P1")] + [Description("Test PaginationStyle constructor using style. Check it has been triggered")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.PaginationStyle C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("COVPARAM", "PaginationStyle")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void PaginationStyle_INIT_WITH_STYLE() + { + /* TEST CODE */ + var style1 = new PaginationStyle(); + Assert.IsNotNull(style1, "Should be not null!"); + Assert.IsInstanceOf(style1, "Should be an instance of PaginationStyle!"); + + var style2 = new PaginationStyle(style1); + Assert.IsNotNull(style2, "Should be not null!"); + Assert.IsInstanceOf(style2, "Should be an instance of PaginationStyle!"); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorSize. Check whether IndicatorSize is readable and writable.")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.IndicatorSize A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorSize_SET_GET_VALUE() + { + /* TEST CODE */ + var style = new PaginationStyle(); + Assert.IsNotNull(style, "Should be not null"); + Assert.IsInstanceOf(style, "Should be equal!"); + style.IndicatorSize = new Size(10,10); + Assert.AreEqual(10, style.IndicatorSize.Width, "Should be equals to the set value"); + Assert.AreEqual(10, style.IndicatorSize.Height, "Should be equals to the set value"); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorImageUrl. Check IndicatorImageUrl works or not.")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.IndicatorImageUrl A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorImageUrl_SET_GET_VALUE() + { + /* TEST CODE */ + var style = new PaginationStyle(); + Assert.IsNotNull(style, "Should be not null"); + Assert.IsInstanceOf(style, "Should be equal!"); + style.IndicatorImageUrl = new Selector{All="background"}; + Assert.AreEqual("background", style.IndicatorImageUrl.All, "Retrieved IndicatorImageUrl should be equal to set value."); + } + + [Test] + [Category("P1")] + [Description("Test IndicatorSpacing. Check whether IndicatorSpacing works or not.")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.IndicatorSpacing A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void IndicatorSpacing_SET_GET_VALUE() + { + /* TEST CODE */ + var style = new PaginationStyle(); + Assert.IsNotNull(style, "Should be not null!"); + Assert.IsInstanceOf(style, "Should be equal!"); + style.IndicatorSpacing = 0; + Assert.AreEqual(0, style.IndicatorSpacing, "Retrieved IndicatorSpacing should be equal to set value"); + } + + [Test] + [Category("P1")] + [Description("Test CopyFrom. Check whether CopyFrom works or not.")] + [Property("SPEC", "Tizen.NUI.Components.PaginationStyle.CopyFrom M")] + [Property("SPEC_URL", " - ")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")] + public void CopyFrom_NO_RETURN_VALUE() + { + try + { + var style1 = new PaginationStyle(); + var style2 = new PaginationStyle(); + style2.CopyFrom(style1); + } + catch (Exception e) + { + Assert.Fail("Caught Exception" + e.ToString()); + } + } + } +}