[NUI] Update TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Theme / TSThemeManager.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/Theme/ThemeManager")]
14     internal class PublicThemeManagerTest
15     {
16         private const string tag = "NUITEST";
17         private string path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Test_Theme.xaml";
18
19         [SetUp]
20         public void Init()
21         {
22             tlog.Info(tag, "Init() is called!");
23         }
24
25         [TearDown]
26         public void Destroy()
27         {
28             tlog.Info(tag, "Destroy() is called!");
29         }
30
31         [Test]
32         [Category("P1")]
33         [Description("ThemeManager CurrentTheme.")]
34         [Property("SPEC", "Tizen.NUI.ThemeManager.CurrentTheme  A")]
35         [Property("SPEC_URL", "-")]
36         [Property("CRITERIA", "PRW")]
37         [Property("COVPARAM", "")]
38         public void ThemeManagerCurrentTheme()
39         {
40             tlog.Debug(tag, $"ThemeManagerCurrentTheme START");
41
42             Theme theme = new Theme(path);
43             ThemeManager.CurrentTheme = theme;
44             tlog.Debug(tag, "CurrentTheme : " + ThemeManager.CurrentTheme);
45
46             tlog.Debug(tag, "ThemeId : " + ThemeManager.ThemeId);
47             tlog.Debug(tag, "BaseTheme : " + ThemeManager.BaseTheme);
48
49             tlog.Debug(tag, $"ThemeManagerCurrentTheme END (OK)");
50         }
51
52         [Test]
53         [Category("P1")]
54         [Description("ThemeManager PlatformThemeEnabled.")]
55         [Property("SPEC", "Tizen.NUI.ThemeManager.PlatformThemeEnabled  A")]
56         [Property("SPEC_URL", "-")]
57         [Property("CRITERIA", "PRW")]
58         [Property("COVPARAM", "")]
59         public void ThemeManagerplatformThemeEnabled()
60         {
61             tlog.Debug(tag, $"ThemeManagerplatformThemeEnabled START");
62
63             ThemeManager.PlatformThemeEnabled = true;
64             tlog.Debug(tag, "PlatformThemeEnabled : " + ThemeManager.PlatformThemeEnabled);
65
66             var result = ThemeManager.ApplyPlatformTheme("Tizen.NUI.Theme.Common");
67             tlog.Debug(tag, "ApplyPlatformTheme : " + result);
68             tlog.Debug(tag, "GetPlatformStyle : " + ThemeManager.GetPlatformStyle("style"));
69             tlog.Debug(tag, "GetPlatformStyle : " + ThemeManager.GetPlatformStyle(typeof(ViewStyle)));
70
71             tlog.Debug(tag, $"ThemeManagerplatformThemeEnabled END (OK)");
72         }
73
74         [Test]
75         [Category("P1")]
76         [Description("Test ThemeManager ApplyTheme.")]
77         [Property("SPEC", "Tizen.NUI.ThemeManager.ApplyTheme  M")]
78         [Property("SPEC_URL", "-")]
79         [Property("CRITERIA", "MR")]
80         [Property("COVPARAM", "")]
81         public void ThemeManagerApplyTheme()
82         {
83             tlog.Debug(tag, $"ThemeManagerApplyTheme START");
84
85             var testingTarget = new Theme(path);
86             Assert.IsNotNull(testingTarget, "should be not null");
87             Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
88
89             try
90             {
91                 ThemeManager.ApplyTheme(testingTarget);
92             }
93             catch (Exception e)
94             {
95                 tlog.Debug(tag, e.Message.ToString());
96                 Assert.Fail("Caught Exception : Failed!");
97             }
98
99             tlog.Debug(tag, $"ThemeManagerApplyTheme END (OK)");
100         }
101
102         [Test]
103         [Category("P1")]
104         [Description("Test ThemeManager ApplyTheme.")]
105         [Property("SPEC", "Tizen.NUI.ThemeManager.ApplyTheme  M")]
106         [Property("SPEC_URL", "-")]
107         [Property("CRITERIA", "MR")]
108         [Property("COVPARAM", "")]
109         public void ThemeManagerApplyThemeNullThemeId()
110         {
111             tlog.Debug(tag, $"ThemeManagerApplyThemeNullThemeId START");
112
113             var testingTarget = new Theme();
114             Assert.IsNotNull(testingTarget, "should be not null");
115             Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
116
117             try
118             {
119                 ThemeManager.ApplyTheme(testingTarget);
120             }
121             catch (Exception e)
122             {
123                 tlog.Debug(tag, e.Message.ToString());
124                 Assert.Fail("Caught Exception : Failed!");
125             }
126
127             tlog.Debug(tag, $"ThemeManagerApplyThemeNullThemeId END (OK)");
128         }
129
130         [Test]
131         [Category("P1")]
132         [Description("Test ThemeManager GetStyle.")]
133         [Property("SPEC", "Tizen.NUI.ThemeManager.GetStyle  M")]
134         [Property("SPEC_URL", "-")]
135         [Property("CRITERIA", "MR")]
136         [Property("COVPARAM", "")]
137         public void ThemeManagerGetStyle()
138         {
139             tlog.Debug(tag, $"ThemeManagerGetStyle START");
140
141             var testingTarget = new Theme(path);
142             Assert.IsNotNull(testingTarget, "should be not null");
143             Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
144
145             ViewStyle style = new ViewStyle()
146             {
147                 Color = Color.Cyan,
148             };
149             testingTarget.AddStyle("style", style);
150             ThemeManager.CurrentTheme = testingTarget;
151
152             tlog.Debug(tag, "GetStyle : " + ThemeManager.GetStyle("style"));
153             tlog.Debug(tag, "GetStyle : " + ThemeManager.GetStyle(typeof(View)));
154             tlog.Debug(tag, "GetUpdateStyleWithoutClone : " + ThemeManager.GetUpdateStyleWithoutClone("style"));
155             tlog.Debug(tag, "GetUpdateStyleWithoutClone : " + ThemeManager.GetUpdateStyleWithoutClone(typeof(ViewStyle)));
156
157             tlog.Debug(tag, $"ThemeManagerGetStyle END (OK)");
158         }
159
160         [Test]
161         [Category("P1")]
162         [Description("Test ThemeManager ApplyFallbackTheme.")]
163         [Property("SPEC", "Tizen.NUI.ThemeManager.ApplyFallbackTheme  M")]
164         [Property("SPEC_URL", "-")]
165         [Property("CRITERIA", "MR")]
166         [Property("COVPARAM", "")]
167         public void ThemeManagerApplyFallbackTheme()
168         {
169             tlog.Debug(tag, $"ThemeManagerApplyFallbackTheme START");
170
171             var testingTarget = new Theme(path);
172             Assert.IsNotNull(testingTarget, "should be not null");
173             Assert.IsInstanceOf<Theme>(testingTarget, "should be an instance of testing target class!");
174
175             try
176             {
177                 ThemeManager.ApplyFallbackTheme(testingTarget);
178             }
179             catch (Exception e)
180             {
181                 tlog.Debug(tag, e.Message.ToString());
182                 Assert.Fail("Caught Exception : Failed!");
183             }
184
185             tlog.Debug(tag, $"ThemeManagerApplyFallbackTheme END (OK)");
186         }
187     }
188 }
189