Fix Tizen.System.SystemSettings unittest (#1519)
[platform/core/csapi/tizenfx.git] / test / Tizen.System.SystemSettings.UnitTest / SystemSettings.UnitTest / test / TSWallpaperLockScreenChangedEventArgs.cs
1 using System;
2 using System.Threading.Tasks;
3 using Tizen.System;
4
5
6 namespace SystemSettingsUnitTest
7 {
8     //[TestFixture]
9     //[Description("Tizen.System.WallpaperLockScreenChangedEventArgs Tests")]
10     public static class WallpaperLockScreenChangedEventArgsTests
11     {
12         private static bool s_wallpaperLockScreenCallbackCalled = false;
13         private static readonly string s_wallpaperLockScreenValue = SystemSettingsTestInput.GetStringValue((int)Tizen.System.SystemSettingsKeys.WallpaperLockScreen);
14         ////[Test]
15         //[Category("P1")]
16         //[Description("Check WallpaperLockScreenChangedEventArgs Value property")]
17         //[Property("SPEC", "Tizen.System.WallpaperLockScreenChangedEventArgs.Value A")]
18         //[Property("SPEC_URL", "-")]
19         //[Property("CRITERIA", "PRO")]
20         //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
21         public static async Task Value_PROPERTY_READ_ONLY()
22         {
23             try
24             {
25                 LogUtils.StartTest();
26                 /*
27                  * PRECONDITION
28                  * 1. Assign event handler
29                  */
30                 Tizen.System.SystemSettings.WallpaperLockScreenChanged += OnWallpaperLockScreenChangedValue;
31
32                 string preValue = Tizen.System.SystemSettings.WallpaperLockScreen;
33                 Tizen.System.SystemSettings.WallpaperLockScreen = s_wallpaperLockScreenValue;
34                 await Task.Delay(2000);
35                 Assert.IsTrue(s_wallpaperLockScreenCallbackCalled, "Value_PROPERTY_READ_ONLY: 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                 s_wallpaperLockScreenCallbackCalled = false;
44                 Tizen.System.SystemSettings.WallpaperLockScreenChanged -= OnWallpaperLockScreenChangedValue;
45                 Tizen.System.SystemSettings.WallpaperLockScreen = preValue;
46                 LogUtils.WriteOK();
47             }
48             catch (NotSupportedException)
49             {
50                 bool isSupport = true;
51                 Information.TryGetValue<bool>("tizen.org/feature/systemsetting.lock_screen", out isSupport);
52                 Assert.IsTrue(isSupport == false, "Invalid NotSupportedException");
53                 Tizen.Log.Debug("CS-SYSTEM-SETTINGS", ">>>>>> NotSupport(tizen.org/feature/systemsetting.lock_screen)");
54                 LogUtils.NotSupport();
55             }
56         }
57         private static void OnWallpaperLockScreenChangedValue(object sender, Tizen.System.WallpaperLockScreenChangedEventArgs e)
58         {
59             s_wallpaperLockScreenCallbackCalled = true;
60             /* TEST CODE */
61             Assert.IsInstanceOf<string>(e.Value, "OnWallpaperLockScreenChangedValue: WallpaperLockScreen not an instance of string");
62             Assert.IsTrue(s_wallpaperLockScreenValue.CompareTo(e.Value) == 0, "OnWallpaperLockScreenChangedValue: The callback should receive the latest value for the property.");
63         }
64     }
65 }