[SystemSettings] Add SystemSettings.UnitTest (#679)
[platform/core/csapi/tizenfx.git] / test / Tizen.System.SystemSettings.UnitTest / SystemSettings.UnitTest / test / TSLocaleTimeFormat24HourSettingChangedEventArgs.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.LocaleTimeFormat24HourSettingChangedEventArgs Tests")]
11     public static class LocaleTimeFormat24HourSettingChangedEventArgsTests
12     {
13         private static bool s_timeFormatCallbackCalled = false;
14         private static readonly bool s_localeTimeformat24HourValue = !Tizen.System.SystemSettings.LocaleTimeFormat24HourEnabled;
15         ////[Test]
16         //[Category("P1")]
17         //[Description("Check LocaleTimeFormat24HourSettingChangedEventArgs Value property")]
18         //[Property("SPEC", "Tizen.System.LocaleTimeFormat24HourSettingChangedEventArgs.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.LocaleTimeFormat24HourSettingChanged += OnLocaleTimeformat24HourChangedValue;
30
31             bool preValue = Tizen.System.SystemSettings.LocaleTimeFormat24HourEnabled;
32             Tizen.System.SystemSettings.LocaleTimeFormat24HourEnabled = s_localeTimeformat24HourValue;
33             await Task.Delay(2000);
34             Assert.IsTrue(s_timeFormatCallbackCalled, "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_timeFormatCallbackCalled = false;
43             Tizen.System.SystemSettings.LocaleTimeFormat24HourSettingChanged -= OnLocaleTimeformat24HourChangedValue;
44             Tizen.System.SystemSettings.LocaleTimeFormat24HourEnabled = preValue;
45             LogUtils.WriteOK();
46         }
47
48         private static void OnLocaleTimeformat24HourChangedValue(object sender, Tizen.System.LocaleTimeFormat24HourSettingChangedEventArgs e)
49         {
50             s_timeFormatCallbackCalled = true;
51             /* TEST CODE */
52             Assert.IsInstanceOf<bool>(e.Value, "OnLocaleTimeformat24HourChangedValue: LocaleTimeFormat24HourEnabled not an instance of bool");
53             Assert.IsTrue(e.Value == s_localeTimeformat24HourValue, "OnLocaleTimeformat24HourChangedValue: The callback should receive the latest value for the property.");
54         }
55     }
56 }