+++ /dev/null
-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.StyleManager Tests")]
- public class StyleManagerTests
- {
- private const string TAG = "Components";
- private bool flagOnThemeChangedEvent = false;
-
- [SetUp]
- public void Init()
- {
- Tizen.Log.Info(TAG, "Init() is called!");
- }
-
- [TearDown]
- public void Destroy()
- {
- Tizen.Log.Info(TAG, "Destroy() is called!");
- }
-
- private void OnThemeChangedEvent(object obj, StyleManager.ThemeChangeEventArgs args)
- {
- flagOnThemeChangedEvent = true;
- }
-
- [Test]
- [Category("P1")]
- [Description("Test ThemeChangedEvent. Check Event Handler of Value Change.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.ThemeChangedEvent E")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "EVL")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void ThemeChangedEvent_SET_GET_VALUE()
- {
- /* TEST CODE */
-
- try
- {
- flagOnThemeChangedEvent = false;
- StyleManager.Instance.Theme = "MyFamily";
- StyleManager.Instance.ThemeChangedEvent += OnThemeChangedEvent;
- StyleManager.Instance.Theme = "MyFood";
- Assert.IsTrue(flagOnThemeChangedEvent, "Item change event should received");
- StyleManager.Instance.ThemeChangedEvent -= OnThemeChangedEvent;
- }
- 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 Instance. Check whether Instance is readable.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.Instance A")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "PRO")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void Instance_SET_GET_VALUE()
- {
- /* TEST CODE */
- var manager = StyleManager.Instance;
- Assert.IsNotNull(manager, "Should be not null");
- Assert.IsInstanceOf<StyleManager>(manager, "Should be an instance of StyleManager!");
- }
-
- [Test]
- [Category("P1")]
- [Description("Test Theme. Check whether Theme is readable and writable.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.Theme A")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "PRW")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void Theme_SET_GET_VALUE()
- {
- /* TEST CODE */
- StyleManager.Instance.Theme = "FAMILY";
- // Theme name does not distinguish capital character. All the capital character is changed into small character.
- Assert.AreEqual("FAMILY", StyleManager.Instance.Theme, "Should be equals to the set value");
- }
-
- [Test]
- [Category("P1")]
- [Description("Test RegisterStyle. Check whether RegisterStyle works or not.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterStyle_NO_RETURN_VALUE()
- {
- try
- {
- StyleManager.Instance.RegisterStyle("MyButtonStyle", "default", typeof(MyButtonStyle));
- }
- catch (Exception e)
- {
- Assert.Fail("Caught Exception" + e.ToString());
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterStyle receive a null style.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterStyle_NULL_Style_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterStyle(null, "default", typeof(MyButtonStyle));
- Assert.Fail("Should throw the InvalidOperationException!");
- }
- catch (InvalidOperationException e)
- {
- Assert.Pass("InvalidOperationException: passed!");
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterStyle receive a null theme.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterStyle_NULL_Theme_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterStyle("NButtonStyle", null, typeof(MyButtonStyle));
- StyleManager.Instance.RegisterStyle("NButtonStyle", null, typeof(ButtonStyle));
- Assert.Fail("Should throw the InvalidOperationException!");
- }
- catch (InvalidOperationException e)
- {
- Assert.Pass("InvalidOperationException: passed!");
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterStyle receive a null style type.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterStyle_NULL_STYLE_TYPE_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterStyle("NonButtonStyle", "default", null);
- Assert.Fail("Should throw the ArgumentException!");
- }
- catch (ArgumentException e)
- {
- Assert.Pass("ArgumentException: passed!");
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterStyle receive same style in same theme.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterStyle_STYLE_Repeat_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterStyle("NonButtonStyle", "default", typeof(MyButtonStyle));
- StyleManager.Instance.RegisterStyle("NonButtonStyle", "default", typeof(MyButtonStyle));
- Assert.Fail("Should throw the InvalidOperationException!");
- }
- catch (InvalidOperationException e)
- {
- Assert.Pass("InvalidOperationException: passed!");
- }
- }
-
- [Test]
- [Category("P1")]
- [Description("Test GetViewStyle. Check whether GetViewStyle works or not.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.GetViewStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void GetViewStyle_CHECK_RETURN_VALUE()
- {
- try
- {
- StyleManager.Instance.Theme = "default";
- StyleManager.Instance.RegisterStyle("FamilyButton", "default", typeof(MyButtonStyle));
- var style = StyleManager.Instance.GetViewStyle("FamilyButton");
- Assert.IsNotNull(style, "Should be not null");
- Assert.IsInstanceOf<ButtonStyle>(style, "Should be an instance of ButtonStyle!");
- }
- catch (Exception e)
- {
- Assert.Fail("Caught Exception" + e.ToString());
- }
- }
-
- [Test]
- [Category("P1")]
- [Description("Test RegisterComponentStyle. Check whether RegisterComponentStyle works or not.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterComponentStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterComponentStyle_NO_RETURN_VALUE()
- {
- try
- {
- StyleManager.Instance.RegisterComponentStyle("MyButtonStyle1", typeof(Button) ,typeof(MyButtonStyle));
- }
- catch (Exception e)
- {
- Assert.Fail("Caught Exception" + e.ToString());
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterComponentStyle receive a null style.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterComponentStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterComponentStyle_NULL_Style_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterComponentStyle(null, typeof(Button) ,typeof(MyButtonStyle));
- Assert.Fail("Should throw the ArgumentException!");
- }
- catch (ArgumentException e)
- {
- Assert.Pass("ArgumentException: passed!");
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterComponentStyle receive a null component type.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterComponentStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterComponentStyle_NULL_TYPE_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterComponentStyle("MyButtonStyle", null ,typeof(MyButtonStyle));
- Assert.Fail("Should throw the ArgumentException!");
- }
- catch (ArgumentException e)
- {
- Assert.Pass("ArgumentException: passed!");
- }
- }
-
- [Test]
- [Category("P2")]
- [Description("Check exception when RegisterComponentStyle receive a null style type.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.RegisterComponentStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MEX")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void RegisterComponentStyle_NULL_STYLE_TYPE_Exception()
- {
- try
- {
- StyleManager.Instance.RegisterComponentStyle("MyButtonStyle", typeof(Button) , null);
- Assert.Fail("Should throw the ArgumentException!");
- }
- catch(ArgumentException e)
- {
- Assert.Pass("ArgumentException: passed!");
- }
- }
-
- [Test]
- [Category("P1")]
- [Description("Test GetComponentStyle. Check whether GetComponentStyle works or not.")]
- [Property("SPEC", "Tizen.NUI.Components.StyleManager.GetComponentStyle M")]
- [Property("SPEC_URL", " - ")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
- public void GetComponentStyle_CHECK_RETURN_VALUE()
- {
- try
- {
- StyleManager.Instance.Theme = "FoodButton";
- StyleManager.Instance.RegisterComponentStyle("FoodButton", typeof(Button), typeof(MyButtonStyle));
- var style = StyleManager.Instance.GetComponentStyle(typeof(Button));
- Assert.IsNotNull(style, "Should be not null");
- Assert.IsInstanceOf<ButtonStyle>(style, "Should be an instance of ButtonStyle!");
- }
- catch (Exception e)
- {
- Assert.Fail("Caught Exception" + e.ToString());
- }
- }
-
- public class MyButtonStyle : StyleBase
- {
- protected override ViewStyle GetViewStyle()
- {
- return new ButtonStyle();
- }
- }
- }
-}