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.AccessoryArgs Api Tests")]
32 public class NotificationEventArgsAccessoryArgsTests
34 private static NotificationEventListener.AccessoryOption _soundoption;
35 private static string _soundpath;
36 private static bool _isvibration = false;
37 private static NotificationEventListener.AccessoryOption _ledoption;
38 private static int _ledonms;
39 private static int _ledoffms;
40 private static Color _ledcolor;
43 public static void Init()
45 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
49 public static void Destroy()
51 LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
54 private static void ChangedEventForSoundOption(object sender, NotificationEventArgs args)
56 _soundoption = args.Accessory.SoundOption;
59 private static void ChangedEventForSoundPath(object sender, NotificationEventArgs args)
61 _soundpath = args.Accessory.SoundPath;
64 private static void ChangedEventForCanVibrate(object sender, NotificationEventArgs args)
66 _isvibration = args.Accessory.CanVibrate;
69 private static void ChangedEventForLedOption(object sender, NotificationEventArgs args)
71 _ledoption = args.Accessory.LedOption;
74 private static void ChangedEventForLedOnMs(object sender, NotificationEventArgs args)
76 _ledonms = args.Accessory.LedOnMillisecond;
79 private static void ChangedEventForLedOffMs(object sender, NotificationEventArgs args)
81 _ledoffms = args.Accessory.LedOffMillisecond;
84 private static void ChangedEventForLedColor(object sender, NotificationEventArgs args)
86 _ledcolor = args.Accessory.LedColor;
91 [Description("AccessoryArgs constructor")]
92 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.AccessoryArgs C")]
93 [Property("SPEC_URL", "-")]
94 [Property("CRITERIA", "CONSTR")]
95 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
96 public static void AccessoryArgs_INIT()
98 NotificationEventArgs.AccessoryArgs accessoryArgs = new NotificationEventArgs.AccessoryArgs();
99 Assert.IsInstanceOf<NotificationEventArgs.AccessoryArgs>(accessoryArgs, "AccessoryArgs object is not of correct instance");
104 [Description("Check whether SoundOption returns expected value or not")]
105 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.SoundOption A")]
106 [Property("SPEC_URL", "-")]
107 [Property("CRITERIA", "PRO,PRE")]
108 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
109 public static async Task SoundOption_GET_ENUM_OFF()
113 NotificationListenerManager.Added += ChangedEventForSoundOption;
115 Notification noti = new Notification
117 Title = "Notification"
120 Notification.AccessorySet accessory = new Notification.AccessorySet();
121 accessory.SoundOption = Notifications.AccessoryOption.Off;
122 accessory.SoundPath = "Test";
124 noti.Accessory = accessory;
126 NotificationManager.Post(noti);
127 await Task.Delay(1000);
129 Assert.AreEqual((int)_soundoption, (int)Notifications.AccessoryOption.Off, "the set value and the get value should be equal");
131 NotificationManager.Delete(noti);
133 NotificationListenerManager.Added -= ChangedEventForSoundOption;
137 Assert.True(false, e.Message);
143 [Description("Check whether SoundOption returns expected value or not")]
144 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.SoundOption A")]
145 [Property("SPEC_URL", "-")]
146 [Property("CRITERIA", "PRO,PRE")]
147 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
148 public static async Task SoundOption_GET_ENUM_ON()
152 NotificationListenerManager.Added += ChangedEventForSoundOption;
154 Notification noti = new Notification
156 Title = "Notification"
159 Notification.AccessorySet accessory = new Notification.AccessorySet();
160 accessory.SoundOption = Notifications.AccessoryOption.On;
161 accessory.SoundPath = "Test";
163 noti.Accessory = accessory;
165 NotificationManager.Post(noti);
166 await Task.Delay(1000);
168 Assert.AreEqual((int)_soundoption, (int)Notifications.AccessoryOption.On, "the set value and the get value should be equal");
170 NotificationManager.Delete(noti);
172 NotificationListenerManager.Added -= ChangedEventForSoundOption;
176 Assert.True(false, e.Message);
182 [Description("Check whether SoundOption returns expected value or not")]
183 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.SoundOption A")]
184 [Property("SPEC_URL", "-")]
185 [Property("CRITERIA", "PRO,PRE")]
186 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
187 public static async Task SoundOption_GET_ENUM_CUSTOM()
191 NotificationListenerManager.Added += ChangedEventForSoundOption;
193 Notification noti = new Notification
195 Title = "Notification"
198 Notification.AccessorySet accessory = new Notification.AccessorySet();
199 accessory.SoundOption = Notifications.AccessoryOption.Custom;
200 accessory.SoundPath = "Test";
202 noti.Accessory = accessory;
204 NotificationManager.Post(noti);
205 await Task.Delay(1000);
207 Assert.AreEqual((int)_soundoption, (int)Notifications.AccessoryOption.Custom, "the set value and the get value should be equal");
209 NotificationManager.Delete(noti);
211 NotificationListenerManager.Added -= ChangedEventForSoundOption;
215 Assert.True(false, e.Message);
221 [Description("Check whether SoundPath returns expected value or not")]
222 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.SoundPath A")]
223 [Property("SPEC_URL", "-")]
224 [Property("CRITERIA", "PRO")]
225 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
226 public static async Task SoundPath_PROPERTY_READ_ONLY()
230 NotificationListenerManager.Added += ChangedEventForSoundPath;
232 Notification noti = new Notification
234 Title = "Notification"
237 Notification.AccessorySet accessory = new Notification.AccessorySet();
238 accessory.SoundOption = Notifications.AccessoryOption.Custom;
239 accessory.SoundPath = "Test";
241 noti.Accessory = accessory;
243 NotificationManager.Post(noti);
244 await Task.Delay(1000);
246 Assert.AreEqual(_soundpath, "Test", "the set value and the get value should be equal");
248 NotificationManager.Delete(noti);
250 NotificationListenerManager.Added -= ChangedEventForSoundPath;
254 Assert.True(false, e.Message);
260 [Description("Check whether CanVibrate returns expected value or not")]
261 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.CanVibrate A")]
262 [Property("SPEC_URL", "-")]
263 [Property("CRITERIA", "PRO")]
264 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
265 public static async Task CanVibrate_PROPERTY_READ_ONLY()
269 NotificationListenerManager.Added += ChangedEventForCanVibrate;
271 Notification noti = new Notification
273 Title = "Notification"
276 Notification.AccessorySet accessory = new Notification.AccessorySet();
277 accessory.CanVibrate = true;
279 noti.Accessory = accessory;
281 NotificationManager.Post(noti);
282 await Task.Delay(1000);
284 Assert.AreEqual(_isvibration, true, "the set value and the get value should be equal");
286 NotificationManager.Delete(noti);
288 NotificationListenerManager.Added -= ChangedEventForCanVibrate;
292 Assert.True(false, e.Message);
298 [Description("Check whether LedOption returns expected value or not")]
299 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedOption A")]
300 [Property("SPEC_URL", "-")]
301 [Property("CRITERIA", "PRO,PRE")]
302 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
303 public static async Task LedOption_GET_ENUM_OFF()
307 NotificationListenerManager.Added += ChangedEventForLedOption;
309 Notification noti = new Notification
311 Title = "Notification"
314 Notification.AccessorySet accessory = new Notification.AccessorySet();
315 accessory.LedOption = Notifications.AccessoryOption.Off;
316 accessory.LedOnMillisecond = 100;
317 accessory.LedOffMillisecond = 100;
319 noti.Accessory = accessory;
321 NotificationManager.Post(noti);
322 await Task.Delay(1000);
324 Assert.AreEqual((int)_ledoption, (int)Notifications.AccessoryOption.Off, "the set value and the get value should be equal");
326 NotificationManager.Delete(noti);
328 NotificationListenerManager.Added -= ChangedEventForLedOption;
332 Assert.True(false, e.Message);
338 [Description("Check whether LedOption returns expected value or not")]
339 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedOption A")]
340 [Property("SPEC_URL", "-")]
341 [Property("CRITERIA", "PRO,PRE")]
342 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
343 public static async Task LedOption_GET_ENUM_ON()
347 NotificationListenerManager.Added += ChangedEventForLedOption;
349 Notification noti = new Notification
351 Title = "Notification"
354 Notification.AccessorySet accessory = new Notification.AccessorySet();
355 accessory.LedOption = Notifications.AccessoryOption.On;
356 accessory.LedOnMillisecond = 100;
357 accessory.LedOffMillisecond = 100;
359 noti.Accessory = accessory;
361 NotificationManager.Post(noti);
362 await Task.Delay(1000);
364 Assert.AreEqual((int)_ledoption, (int)Notifications.AccessoryOption.On, "the set value and the get value should be equal");
366 NotificationManager.Delete(noti);
368 NotificationListenerManager.Added -= ChangedEventForLedOption;
372 Assert.True(false, e.Message);
378 [Description("Check whether LedOption returns expected value or not")]
379 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedOption A")]
380 [Property("SPEC_URL", "-")]
381 [Property("CRITERIA", "PRO,PRE")]
382 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
383 public static async Task LedOption_GET_ENUM_CUSTOM()
387 NotificationListenerManager.Added += ChangedEventForLedOption;
389 Notification noti = new Notification
391 Title = "Notification"
394 Notification.AccessorySet accessory = new Notification.AccessorySet();
395 accessory.LedOption = Notifications.AccessoryOption.Custom;
396 accessory.LedOnMillisecond = 100;
397 accessory.LedOffMillisecond = 100;
399 noti.Accessory = accessory;
401 NotificationManager.Post(noti);
402 await Task.Delay(1000);
404 Assert.AreEqual((int)_ledoption, (int)Notifications.AccessoryOption.Custom, "the set value and the get value should be equal");
406 NotificationManager.Delete(noti);
408 NotificationListenerManager.Added -= ChangedEventForLedOption;
412 Assert.True(false, e.Message);
418 [Description("Check whether LedOnMillisecond returns expected value or not")]
419 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedOnMillisecond A")]
420 [Property("SPEC_URL", "-")]
421 [Property("CRITERIA", "PRO")]
422 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
423 public static async Task LedOnMillisecond_PROPERTY_READ_ONLY()
427 NotificationListenerManager.Added += ChangedEventForLedOnMs;
429 Notification noti = new Notification
431 Title = "Notification"
434 Notification.AccessorySet accessory = new Notification.AccessorySet();
435 accessory.LedOption = Notifications.AccessoryOption.On;
436 accessory.LedOnMillisecond = 100;
437 accessory.LedOffMillisecond = 100;
439 noti.Accessory = accessory;
441 NotificationManager.Post(noti);
442 await Task.Delay(1000);
444 Assert.AreEqual(_ledonms, 100, "the set value and the get value should be equal");
446 NotificationManager.Delete(noti);
448 NotificationListenerManager.Added -= ChangedEventForLedOnMs;
452 Assert.True(false, e.Message);
458 [Description("Check whether LedOffMillisecond returns expected value or not")]
459 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedOffMillisecond A")]
460 [Property("SPEC_URL", "-")]
461 [Property("CRITERIA", "PRO")]
462 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
463 public static async Task LedOffMillisecond_PROPERTY_READ_ONLY()
467 NotificationListenerManager.Added += ChangedEventForLedOffMs;
469 Notification noti = new Notification
471 Title = "Notification"
474 Notification.AccessorySet accessory = new Notification.AccessorySet();
475 accessory.LedOption = Notifications.AccessoryOption.On;
476 accessory.LedOnMillisecond = 100;
477 accessory.LedOffMillisecond = 100;
479 noti.Accessory = accessory;
481 NotificationManager.Post(noti);
482 await Task.Delay(1000);
484 Assert.AreEqual(_ledoffms, 100, "the set value and the get value should be equal");
486 NotificationManager.Delete(noti);
488 NotificationListenerManager.Added -= ChangedEventForLedOffMs;
492 Assert.True(false, e.Message);
498 [Description("Check whether LedColor returns expected value or not")]
499 [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.AccessoryArgs.LedColor A")]
500 [Property("SPEC_URL", "-")]
501 [Property("CRITERIA", "PRO")]
502 [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
503 public static async Task LedColor_PROPERTY_READ_ONLY()
507 NotificationListenerManager.Added += ChangedEventForLedColor;
509 Notification noti = new Notification
511 Title = "Notification"
514 Notification.AccessorySet accessory = new Notification.AccessorySet();
515 accessory.LedOption = Notifications.AccessoryOption.Custom;
516 accessory.LedOnMillisecond = 100;
517 accessory.LedOffMillisecond = 100;
518 accessory.LedColor = Color.Green;
520 noti.Accessory = accessory;
522 NotificationManager.Post(noti);
523 await Task.Delay(1000);
525 Assert.AreEqual(_ledcolor, Color.Green, "the set value and the get value should be equal");
527 NotificationManager.Delete(noti);
529 NotificationListenerManager.Added -= ChangedEventForLedColor;
533 Assert.True(false, e.Message);