934ffc42d62195873a03eb733569e6e78a6e4a9f
[platform/core/csapi/tizenfx.git] / test / Tizen.System.SystemSettings.UnitTest / SystemSettings.UnitTest / test / TSFontTypeChangedEventArgs.cs
1 using System.Threading.Tasks;
2 using System;
3 using System.Threading;
4 using Tizen.System;
5
6
7 namespace SystemSettingsUnitTest
8 {
9     //[TestFixture]
10     //[Description("Tizen.System.FontTypeChangedEventArgs Tests")]
11     public static class FontTypeChangedEventArgsTests
12     {
13         private static bool s_fontTypeCallbackCalled = false;
14         private static readonly string s_fontTypeValue = "BreezeSans";
15         ////[Test]
16         //[Category("P1")]
17         //[Description("Check FontTypeChangedEventArgs Value property")]
18         //[Property("SPEC", "Tizen.System.FontTypeChangedEventArgs.Value A")]
19         //[Property("SPEC_URL", "-")]
20         //[Property("CRITERIA", "PRO")]
21         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
22         public static async Task Value_PROPERTY_READ_ONLY()
23         {
24             LogUtils.StartTest();
25             /*
26                 * PRECONDITION
27                 * 1. Assign event handler
28                 */
29             Tizen.System.SystemSettings.FontTypeChanged += OnFontTypeChangedValue;
30
31             string preValue = Tizen.System.SystemSettings.FontType;
32             Tizen.System.SystemSettings.FontType = s_fontTypeValue;
33             await Task.Delay(2000);
34             Assert.IsTrue(s_fontTypeCallbackCalled, "Value_PROPERTY_READ_ONLY: EventHandler added. Not getting called");
35
36             /*
37                 * POSTCONDITION
38                 * 1. Reset callback called flag
39                 * 2. Remove event handler
40                 * 3. Reset property value
41                 */
42             s_fontTypeCallbackCalled = false;
43             Tizen.System.SystemSettings.FontTypeChanged -= OnFontTypeChangedValue;
44             Tizen.System.SystemSettings.FontType = preValue;
45             LogUtils.WriteOK();
46         }
47         private static void OnFontTypeChangedValue(object sender, Tizen.System.FontTypeChangedEventArgs e)
48         {
49             s_fontTypeCallbackCalled = true;
50             /* TEST CODE */
51             Assert.IsInstanceOf<string>(e.Value, "OnFontTypeChangedValue: FontType not an instance of string");
52             Assert.IsTrue(s_fontTypeValue.CompareTo(e.Value) == 0, "OnFontTypeChangedValue: The callback should receive the latest value for the property.");
53         }
54     }
55 }