73f8fea3d522ef28a9a5eedff6633a212d0d4b71
[test/tct/csharp/api.git] /
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16
17 using NUnit.Framework;
18 using NUnit.Framework.TUnit;
19 using System;
20 using System.Threading;
21 using System.Threading.Tasks;
22 using Tizen;
23 using Tizen.Common;
24
25 using Tizen.Applications.Notifications;
26 using Tizen.Applications.NotificationEventListener;
27
28 namespace Tizen.Applications.NotificationEventListener.Tests
29 {
30     [TestFixture]
31     [Description("NotificationEventArgs.LockStyleArgs Api Tests")]
32     public class NotificationEventArgsLockStyleArgsTests
33     {
34         private static string _iconpath;
35         private static string _thumbnail;
36
37         [SetUp]
38         public static void Init()
39         {
40             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
41         }
42
43         [TearDown]
44         public static void Destroy()
45         {
46             LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
47         }
48
49         private static void ChangedEventForIconPath(object sender, NotificationEventArgs args)
50         {
51             NotificationEventArgs.LockStyleArgs style = args.GetStyle<NotificationEventArgs.LockStyleArgs>();
52             _iconpath = style.IconPath;
53         }
54
55         private static void ChangedEventForThumbnail(object sender, NotificationEventArgs args)
56         {
57             NotificationEventArgs.LockStyleArgs style = args.GetStyle<NotificationEventArgs.LockStyleArgs>();
58             _thumbnail = style.Thumbnail;
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("LockStyleArgs constructor")]
64         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.LockStyleArgs.LockStyleArgs C")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "CONSTR")]
67         [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
68         public static void LockStyleArgs_INIT()
69         {
70             NotificationEventArgs.LockStyleArgs lockStyle = new NotificationEventArgs.LockStyleArgs();
71             Assert.IsInstanceOf<NotificationEventArgs.LockStyleArgs>(lockStyle, "LockStyleArgs object is not of correct instance");
72         }
73
74         [Test]
75         [Category("P1")]
76         [Description("Check whether IconPath returns expected value or not")]
77         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.LockStyleArgs.IconPath A")]
78         [Property("SPEC_URL", "-")]
79         [Property("CRITERIA", "PRO")]
80         [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
81         public static async Task IconPath_PROPERTY_READ_ONLY()
82         {
83             try
84             {
85                 NotificationListenerManager.Added += ChangedEventForIconPath;
86
87                 Notification noti = new Notification
88                 {
89                     Title = "Notification"
90                 };
91
92                 Notification.LockStyle style = new Notification.LockStyle();
93                 style.IconPath = "IconPath";
94                 style.ThumbnailPath = "ThumbnailPath";
95
96                 noti.AddStyle(style);
97
98                 NotificationManager.Post(noti);
99                 await Task.Delay(1000);
100
101                 Assert.AreEqual(_iconpath, "IconPath", "the set value and the get value should be equal");
102
103                 NotificationManager.Delete(noti);
104
105                 NotificationListenerManager.Added -= ChangedEventForIconPath;
106             }
107             catch (Exception e)
108             {
109                 Assert.True(false, e.Message);
110             }
111         }
112
113         [Test]
114         [Category("P1")]
115         [Description("Check whether Thumbnail returns expected value or not")]
116         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.LockStyleArgs.Thumbnail A")]
117         [Property("SPEC_URL", "-")]
118         [Property("CRITERIA", "PRO")]
119         [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
120         public static async Task Thumbnail_PROPERTY_READ_ONLY()
121         {
122             try
123             {
124                 NotificationListenerManager.Added += ChangedEventForThumbnail;
125
126                 Notification noti = new Notification
127                 {
128                     Title = "Notification"
129                 };
130
131                 Notification.LockStyle style = new Notification.LockStyle();
132                 style.IconPath = "IconPath";
133                 style.ThumbnailPath = "ThumbnailPath";
134
135                 noti.AddStyle(style);
136
137                 NotificationManager.Post(noti);
138                 await Task.Delay(1000);
139
140                 Assert.AreEqual(_thumbnail, "ThumbnailPath", "the set value and the get value should be equal");
141
142                 NotificationManager.Delete(noti);
143
144                 NotificationListenerManager.Added -= ChangedEventForThumbnail;
145             }
146             catch (Exception e)
147             {
148                 Assert.True(false, e.Message);
149             }
150         }
151     }
152 }