Fix Tizen.System.SystemSettings unittest (#1519)
[platform/core/csapi/tizenfx.git] / test / Tizen.System.SystemSettings.UnitTest / SystemSettings.UnitTest / test / TSFontSizeChangedEventArgs.cs
1 using System.Threading.Tasks;
2 using Tizen.System;
3
4 /*
5 string format = string.Format("Current Tizen.System.SystemSettings.FontSize : {0}", (int)Tizen.System.SystemSettings.FontSize);
6 Tizen.Log.Debug("CS-SYSTEM-SETTING", format);
7 */
8
9 namespace SystemSettingsUnitTest
10 {
11     //[TestFixture]
12     //[Description("Tizen.System.FontSizeChangedEventArgs Tests")]
13     public static class FontSizeChangedEventArgsTests
14     {
15         private static bool s_fontSizeSmallCallbackCalled = false;
16         ////[Test]
17         //[Category("P1")]
18         //[Description("Check FontSizeChangedEventArgs Value property")]
19         //[Property("SPEC", "Tizen.System.FontSizeChangedEventArgs.Value A")]
20         //[Property("SPEC_URL", "-")]
21         //[Property("CRITERIA", "PRE")]
22         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
23         public static async Task Value_ENUM_SMALL()
24         {
25             LogUtils.StartTest();
26             /*
27                 * PRECONDITION
28                 * 1. Assign event handler
29                 */
30             Tizen.System.SystemSettings.FontSizeChanged += OnFontSizeChangedSmallValue;
31
32             SystemSettingsFontSize preValue = Tizen.System.SystemSettings.FontSize;
33             Tizen.System.SystemSettings.FontSize = Tizen.System.SystemSettingsFontSize.Small;
34             await Task.Delay(2000);
35             Assert.IsTrue(s_fontSizeSmallCallbackCalled, "Value_ENUM_SMALL: EventHandler added. Not getting called");
36
37             /*
38                 * POSTCONDITION
39                 * 1. Reset callback called flag
40                 * 2. Remove event handler
41                 * 3. Reset property value
42                 */
43             Tizen.System.SystemSettings.FontSizeChanged -= OnFontSizeChangedSmallValue;
44             s_fontSizeSmallCallbackCalled = false;
45             Tizen.System.SystemSettings.FontSize = preValue;
46             LogUtils.WriteOK();
47         }
48         private static void OnFontSizeChangedSmallValue(object sender, Tizen.System.FontSizeChangedEventArgs e)
49         {
50             s_fontSizeSmallCallbackCalled = true;
51             /* TEST CODE */
52             Assert.IsInstanceOf<Tizen.System.SystemSettingsFontSize>(e.Value, "OnFontSizeChangedSmallValue: FontSize not an instance of SystemSettingsFontSize");
53             Assert.IsTrue(e.Value == Tizen.System.SystemSettingsFontSize.Small, "OnFontSizeChangedSmallValue: The callback should receive the latest value for the property.");
54         }
55
56         private static bool s_fontSizeNormalCallbackCalled = false;
57         ////[Test]
58         //[Category("P1")]
59         //[Description("Check FontSizeChangedEventArgs Value property")]
60         //[Property("SPEC", "Tizen.System.FontSizeChangedEventArgs.Value A")]
61         //[Property("SPEC_URL", "-")]
62         //[Property("CRITERIA", "PRE")]
63         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
64         public static async Task Value_ENUM_NORMAL()
65         {
66             LogUtils.StartTest();
67             /*
68                 * PRECONDITION
69                 * 1. Assign event handler
70                 */
71             Tizen.System.SystemSettings.FontSizeChanged += OnFontSizeChangedNormalValue;
72
73             SystemSettingsFontSize preValue = Tizen.System.SystemSettings.FontSize;
74             Tizen.System.SystemSettings.FontSize = Tizen.System.SystemSettingsFontSize.Normal;
75             await Task.Delay(2000);
76             Assert.IsTrue(s_fontSizeNormalCallbackCalled, "Value_ENUM_NORMAL: EventHandler added. Not getting called");
77
78             /*
79                 * POSTCONDITION
80                 * 1. Reset callback called flag
81                 * 2. Remove event handler
82                 * 3. Reset property value
83                 */
84             Tizen.System.SystemSettings.FontSizeChanged -= OnFontSizeChangedNormalValue;
85             s_fontSizeNormalCallbackCalled = false;
86             Tizen.System.SystemSettings.FontSize = preValue;
87             LogUtils.WriteOK();
88         }
89         private static void OnFontSizeChangedNormalValue(object sender, Tizen.System.FontSizeChangedEventArgs e)
90         {
91             s_fontSizeNormalCallbackCalled = true;
92             /* TEST CODE */
93             Assert.IsInstanceOf<Tizen.System.SystemSettingsFontSize>(e.Value, "OnFontSizeChangedNormalValue: FontSize not an instance of SystemSettingsFontSize");
94             Assert.IsTrue(e.Value == Tizen.System.SystemSettingsFontSize.Normal, "OnFontSizeChangedNormalValue: The callback should receive the latest value for the property.");
95         }
96
97         private static bool s_fontSizeLargeCallbackCalled = false;
98         ////[Test]
99         //[Category("P1")]
100         //[Description("Check FontSizeChangedEventArgs Value property")]
101         //[Property("SPEC", "Tizen.System.FontSizeChangedEventArgs.Value A")]
102         //[Property("SPEC_URL", "-")]
103         //[Property("CRITERIA", "PRE")]
104         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
105         public static async Task Value_ENUM_LARGE()
106         {
107             LogUtils.StartTest();
108             /*
109                 * PRECONDITION
110                 * 1. Assign event handler
111                 */
112             Tizen.System.SystemSettings.FontSizeChanged += OnFontSizeChangedLargeValue;
113
114             SystemSettingsFontSize preValue = Tizen.System.SystemSettings.FontSize;
115             Tizen.System.SystemSettings.FontSize = Tizen.System.SystemSettingsFontSize.Large;
116             await Task.Delay(2000);
117             Assert.IsTrue(s_fontSizeLargeCallbackCalled, "Value_ENUM_LARGE: EventHandler added. Not getting called");
118
119             /*
120                 * POSTCONDITION
121                 * 1. Reset callback called flag
122                 * 2. Remove event handler
123                 * 3. Reset property value
124                 */
125             Tizen.System.SystemSettings.FontSizeChanged -= OnFontSizeChangedLargeValue;
126             s_fontSizeLargeCallbackCalled = false;
127             Tizen.System.SystemSettings.FontSize = preValue;
128             LogUtils.WriteOK();
129         }
130         private static void OnFontSizeChangedLargeValue(object sender, Tizen.System.FontSizeChangedEventArgs e)
131         {
132             s_fontSizeLargeCallbackCalled = true;
133             /* TEST CODE */
134             Assert.IsInstanceOf<Tizen.System.SystemSettingsFontSize>(e.Value, "OnFontSizeChangedLargeValue: FontSize not an instance of SystemSettingsFontSize");
135             Assert.IsTrue(e.Value == Tizen.System.SystemSettingsFontSize.Large, "OnFontSizeChangedLargeValue: The callback should receive the latest value for the property.");
136         }
137
138         private static bool s_fontSizeHugeCallbackCalled = false;
139         ////[Test]
140         //[Category("P1")]
141         //[Description("Check FontSizeChangedEventArgs Value property")]
142         //[Property("SPEC", "Tizen.System.FontSizeChangedEventArgs.Value A")]
143         //[Property("SPEC_URL", "-")]
144         //[Property("CRITERIA", "PRE")]
145         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
146         public static async Task Value_ENUM_HUGE()
147         {
148             LogUtils.StartTest();
149             /*
150                 * PRECONDITION
151                 * 1. Assign event handler
152                 */
153             Tizen.System.SystemSettings.FontSizeChanged += OnFontSizeChangedHugeValue;
154
155             SystemSettingsFontSize preValue = Tizen.System.SystemSettings.FontSize;
156             Tizen.System.SystemSettings.FontSize = Tizen.System.SystemSettingsFontSize.Huge;
157             await Task.Delay(2000);
158             Assert.IsTrue(s_fontSizeHugeCallbackCalled, "Value_ENUM_HUGE: EventHandler added. Not getting called");
159
160             /*
161                 * POSTCONDITION
162                 * 1. Reset callback called flag
163                 * 2. Remove event handler
164                 * 3. Reset property value
165                 */
166             Tizen.System.SystemSettings.FontSizeChanged -= OnFontSizeChangedHugeValue;
167             s_fontSizeHugeCallbackCalled = false;
168             Tizen.System.SystemSettings.FontSize = preValue;
169             LogUtils.WriteOK();
170         }
171         private static void OnFontSizeChangedHugeValue(object sender, Tizen.System.FontSizeChangedEventArgs e)
172         {
173             s_fontSizeHugeCallbackCalled = true;
174             /* TEST CODE */
175             Assert.IsInstanceOf<Tizen.System.SystemSettingsFontSize>(e.Value, "OnFontSizeChangedHugeValue: FontSize not an instance of SystemSettingsFontSize");
176             Assert.IsTrue(e.Value == Tizen.System.SystemSettingsFontSize.Huge, "OnFontSizeChangedHugeValue: The callback should receive the latest value for the property.");
177         }
178
179         private static bool s_fontSizeGiantCallbackCalled = false;
180         ////[Test]
181         //[Category("P1")]
182         //[Description("Check FontSizeChangedEventArgs Value property")]
183         //[Property("SPEC", "Tizen.System.FontSizeChangedEventArgs.Value A")]
184         //[Property("SPEC_URL", "-")]
185         //[Property("CRITERIA", "PRE")]
186         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
187         public static async Task Value_ENUM_GIANT()
188         {
189             LogUtils.StartTest();
190             /*
191                 * PRECONDITION
192                 * 1. Assign event handler
193                 */
194             Tizen.System.SystemSettings.FontSizeChanged += OnFontSizeChangedGiantValue;
195
196             SystemSettingsFontSize preValue = Tizen.System.SystemSettings.FontSize;
197             Tizen.System.SystemSettings.FontSize = Tizen.System.SystemSettingsFontSize.Giant;
198             await Task.Delay(2000);
199             Assert.IsTrue(s_fontSizeGiantCallbackCalled, "Value_ENUM_GIANT: EventHandler added. Not getting called");
200
201             /*
202                 * POSTCONDITION
203                 * 1. Reset callback called flag
204                 * 2. Remove event handler
205                 * 3. Reset property value
206                 */
207             Tizen.System.SystemSettings.FontSizeChanged -= OnFontSizeChangedGiantValue;
208             s_fontSizeGiantCallbackCalled = false;
209             Tizen.System.SystemSettings.FontSize = preValue;
210             LogUtils.WriteOK();
211         }
212         private static void OnFontSizeChangedGiantValue(object sender, Tizen.System.FontSizeChangedEventArgs e)
213         {
214             s_fontSizeGiantCallbackCalled = true;
215             /* TEST CODE */
216             Assert.IsInstanceOf<Tizen.System.SystemSettingsFontSize>(e.Value, "OnFontSizeChangedGiantValue: FontSize nto an instance of SystemSettingsFontSize");
217             Assert.IsTrue(e.Value == Tizen.System.SystemSettingsFontSize.Giant, "OnFontSizeChangedGiantValue: The callback should receive the latest value for the property.");
218         }
219
220     }
221 }