2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 using NUnit.Framework;
18 using NUnit.Framework.TUnit;
20 using System.Threading;
21 using System.Threading.Tasks;
25 using Tizen.Applications.Notifications;
26 using Tizen.Applications.NotificationEventListener;
28 namespace Tizen.Applications.NotificationEventListener.Tests
31 [Description("NotificationEventArgs.ReplyActionArgs Api Tests")]
32 public class NotificationEventArgsReplyActionArgsTests
34 private static int _replymax;
35 private static string _placeholdertext;
36 private static NotificationEventListener.ButtonIndex _parentIndex;
37 private static string _buttontext;
40 public static void Init()
42 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
46 public static void Destroy()
48 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
51 private static void ChangedEventForParentIndex(object sender, NotificationEventArgs args)
53 NotificationEventArgs.ActiveStyleArgs style = args.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
54 NotificationEventArgs.ReplyActionArgs action = style.Reply;
55 _parentIndex = action.ParentIndex;
58 private static void ChangedEventForPlaceHolderText(object sender, NotificationEventArgs args)
60 NotificationEventArgs.ActiveStyleArgs style = args.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
61 NotificationEventArgs.ReplyActionArgs action = style.Reply;
62 _placeholdertext = action.PlaceHolderText;
65 private static void ChangedEventForReplyMax(object sender, NotificationEventArgs args)
67 NotificationEventArgs.ActiveStyleArgs style = args.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
68 NotificationEventArgs.ReplyActionArgs action = style.Reply;
69 _replymax = action.ReplyMax;
72 private static void ChangedEventForButton(object sender, NotificationEventArgs args)
74 NotificationEventArgs.ActiveStyleArgs style = args.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
75 NotificationEventArgs.ReplyActionArgs action = style.Reply;
76 NotificationEventArgs.ButtonActionArgs btn = action.Button;
77 _buttontext = btn.Text;
83 [Description("ReplyActionArgs constructor")]
84 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.ReplyActionArgs C")]
85 [Property("SPEC_URL", "-")]
86 [Property("CRITERIA", "CONSTR")]
87 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
88 public static void ReplyActionArgs_INIT()
90 NotificationEventArgs.ReplyActionArgs reply = new NotificationEventArgs.ReplyActionArgs();
91 Assert.IsInstanceOf<NotificationEventArgs.ReplyActionArgs>(reply, "ReplyActionArgs object is not of correct instance");
96 [Description("Check whether property ParentIndex returns expected value or not")]
97 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.ParentIndex A")]
98 [Property("SPEC_URL", "-")]
99 [Property("CRITERIA", "PRO,PRE")]
100 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
101 public static async Task ParentIndex_GET_ENUM_FIRST()
105 NotificationListenerManager.Added += ChangedEventForParentIndex;
107 AppControl appcontrol = new AppControl();
108 appcontrol.ApplicationId = "ButtonTest";
110 Notification.ButtonAction button = new Notification.ButtonAction();
111 button.Index = Notifications.ButtonIndex.First;
112 button.Text = "Reply";
113 button.ImagePath = "test";
114 button.Action = appcontrol;
116 Notification.ReplyAction action = new Notification.ReplyAction();
117 action.ParentIndex = Notifications.ButtonIndex.First;
118 action.ReplyMax = 160;
119 action.PlaceHolderText = "Input";
120 action.Button = button;
122 Notification.ActiveStyle style = new Notification.ActiveStyle();
123 style.IsAutoRemove = false;
124 style.BackgroundImage = "test";
125 style.ReplyAction = action;
127 Notification noti = new Notification();
128 noti.Title = "Notification";
129 noti.AddStyle(style);
131 NotificationManager.Post(noti);
132 await Task.Delay(1000);
134 Assert.AreEqual((int)_parentIndex, (int)Notifications.ButtonIndex.First, "the set value and the get value should be equal");
136 NotificationManager.Delete(noti);
138 NotificationListenerManager.Added -= ChangedEventForParentIndex;
142 Assert.True(false, e.Message);
148 [Description("Check whether property ParentIndex returns expected value or not")]
149 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.ParentIndex A")]
150 [Property("SPEC_URL", "-")]
151 [Property("CRITERIA", "PRO,PRE")]
152 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
153 public static async Task ParentIndex_GET_ENUM_SECOND()
157 NotificationListenerManager.Added += ChangedEventForParentIndex;
159 AppControl appcontrol = new AppControl();
160 appcontrol.ApplicationId = "ButtonTest";
162 Notification.ButtonAction button = new Notification.ButtonAction();
163 button.Index = Notifications.ButtonIndex.Second;
164 button.Text = "Reply";
165 button.ImagePath = "test";
166 button.Action = appcontrol;
168 Notification.ReplyAction action = new Notification.ReplyAction();
169 action.ParentIndex = Notifications.ButtonIndex.Second;
170 action.ReplyMax = 160;
171 action.PlaceHolderText = "Input";
172 action.Button = button;
174 Notification.ActiveStyle style = new Notification.ActiveStyle();
175 style.IsAutoRemove = false;
176 style.BackgroundImage = "test";
177 style.ReplyAction = action;
179 Notification noti = new Notification();
180 noti.Title = "Notification";
181 noti.AddStyle(style);
183 NotificationManager.Post(noti);
184 await Task.Delay(1000);
186 Assert.AreEqual((int)_parentIndex, (int)Notifications.ButtonIndex.Second, "the set value and the get value should be equal");
188 NotificationManager.Delete(noti);
190 NotificationListenerManager.Added -= ChangedEventForParentIndex;
194 Assert.True(false, e.Message);
200 [Description("Check whether property ParentIndex returns expected value or not")]
201 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.ParentIndex A")]
202 [Property("SPEC_URL", "-")]
203 [Property("CRITERIA", "PRO,PRE")]
204 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
205 public static async Task ParentIndex_GET_ENUM_THIRD()
209 NotificationListenerManager.Added += ChangedEventForParentIndex;
211 AppControl appcontrol = new AppControl();
212 appcontrol.ApplicationId = "ButtonTest";
214 Notification.ButtonAction button = new Notification.ButtonAction();
215 button.Index = Notifications.ButtonIndex.Third;
216 button.Text = "Reply";
217 button.ImagePath = "test";
218 button.Action = appcontrol;
220 Notification.ReplyAction action = new Notification.ReplyAction();
221 action.ParentIndex = Notifications.ButtonIndex.Third;
222 action.ReplyMax = 160;
223 action.PlaceHolderText = "Input";
224 action.Button = button;
226 Notification.ActiveStyle style = new Notification.ActiveStyle();
227 style.IsAutoRemove = false;
228 style.BackgroundImage = "test";
229 style.ReplyAction = action;
231 Notification noti = new Notification();
232 noti.Title = "Notification";
233 noti.AddStyle(style);
235 NotificationManager.Post(noti);
236 await Task.Delay(1000);
238 Assert.AreEqual((int)_parentIndex, (int)Notifications.ButtonIndex.Third, "the set value and the get value should be equal");
240 NotificationManager.Delete(noti);
242 NotificationListenerManager.Added -= ChangedEventForParentIndex;
246 Assert.True(false, e.Message);
252 [Description("Check whether property PlaceHolderText returns expected value or not")]
253 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.PlaceHolderText A")]
254 [Property("SPEC_URL", "-")]
255 [Property("CRITERIA", "PRO")]
256 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
257 public static async Task PlaceHolderText_PROPERTY_READ_ONLY()
261 NotificationListenerManager.Added += ChangedEventForPlaceHolderText;
263 AppControl appcontrol = new AppControl();
264 appcontrol.ApplicationId = "Replytest";
266 Notification.ButtonAction button = new Notification.ButtonAction();
267 button.Index = Notifications.ButtonIndex.First;
268 button.Text = "Reply";
269 button.ImagePath = "test";
270 button.Action = appcontrol;
272 Notification.ReplyAction action = new Notification.ReplyAction();
273 action.ParentIndex = Notifications.ButtonIndex.First;
274 action.ReplyMax = 160;
275 action.PlaceHolderText = "Input";
276 action.Button = button;
278 Notification.ActiveStyle style = new Notification.ActiveStyle();
279 style.IsAutoRemove = false;
280 style.BackgroundImage = "test";
281 style.ReplyAction = action;
283 Notification noti = new Notification();
284 noti.Title = "Notification";
285 noti.AddStyle(style);
287 NotificationManager.Post(noti);
288 await Task.Delay(1000);
290 Assert.AreEqual(_placeholdertext, "Input", "the set value and the get value should be equal");
292 NotificationManager.Delete(noti);
294 NotificationListenerManager.Added -= ChangedEventForPlaceHolderText;
298 Assert.True(false, e.Message);
304 [Description("Check whether property ReplyMax returns expected value or not")]
305 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.ReplyMax A")]
306 [Property("SPEC_URL", "-")]
307 [Property("CRITERIA", "PRO")]
308 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
309 public static async Task ReplyMax_PROPERTY_READ_ONLY()
313 NotificationListenerManager.Added += ChangedEventForReplyMax;
315 AppControl appcontrol = new AppControl();
316 appcontrol.ApplicationId = "ButtonTest";
318 Notification.ButtonAction button = new Notification.ButtonAction();
319 button.Index = Notifications.ButtonIndex.First;
320 button.Text = "Reply";
321 button.ImagePath = "test";
322 button.Action = appcontrol;
324 Notification.ReplyAction action = new Notification.ReplyAction();
325 action.ParentIndex = Notifications.ButtonIndex.First;
326 action.ReplyMax = 160;
327 action.PlaceHolderText = "Input";
328 action.Button = button;
330 Notification.ActiveStyle style = new Notification.ActiveStyle();
331 style.IsAutoRemove = false;
332 style.BackgroundImage = "test";
333 style.ReplyAction = action;
335 Notification noti = new Notification();
336 noti.Title = "Notification";
337 noti.AddStyle(style);
339 NotificationManager.Post(noti);
340 await Task.Delay(1000);
342 Assert.AreEqual(_replymax, 160, "the set value and the get value should be equal");
344 NotificationManager.Delete(noti);
346 NotificationListenerManager.Added -= ChangedEventForReplyMax;
350 Assert.True(false, e.Message);
356 [Description("Check whether Button returns expected value or not")]
357 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.ReplyActionArgs.Button A")]
358 [Property("SPEC_URL", "-")]
359 [Property("CRITERIA", "PRO")]
360 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
361 public static async Task Button_PROPERTY_READ_ONLY()
365 NotificationListenerManager.Added += ChangedEventForButton;
367 AppControl appcontrol = new AppControl();
368 appcontrol.ApplicationId = "ButtonTest";
370 Notification.ButtonAction button = new Notification.ButtonAction();
371 button.Index = Notifications.ButtonIndex.First;
372 button.Text = "Reply";
373 button.ImagePath = "test";
374 button.Action = appcontrol;
376 Notification.ReplyAction action = new Notification.ReplyAction();
377 action.ParentIndex = Notifications.ButtonIndex.First;
378 action.ReplyMax = 160;
379 action.PlaceHolderText = "Input";
380 action.Button = button;
382 Notification.ActiveStyle style = new Notification.ActiveStyle();
383 style.IsAutoRemove = false;
384 style.BackgroundImage = "test";
385 style.ReplyAction = action;
387 Notification noti = new Notification();
388 noti.Title = "Notification";
389 noti.AddStyle(style);
391 NotificationManager.Post(noti);
392 await Task.Delay(1000);
394 Assert.AreEqual(_buttontext, "Reply", "the set value and the get value should be equal");
396 NotificationManager.Delete(noti);
398 NotificationListenerManager.Added -= ChangedEventForButton;
402 Assert.True(false, e.Message);