ff0b4453f45105489f5122d2163cf58cfc84768b
[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.IndicatorStyleArgs Api Tests")]
32     public class NotificationEventIndicatorStyleArgsTests
33     {
34         private static string _iconpath;
35         private static string _subtext;
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.IndicatorStyleArgs style = args.GetStyle<NotificationEventArgs.IndicatorStyleArgs>();
52             _iconpath = style.IconPath;
53         }
54
55         private static void ChangedEventForSubText(object sender, NotificationEventArgs args)
56         {
57             NotificationEventArgs.IndicatorStyleArgs style = args.GetStyle<NotificationEventArgs.IndicatorStyleArgs>();
58             _subtext = style.SubText;
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("IndicatorStyleArgs constructor")]
64         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.IndicatorStyleArgs.IndicatorStyleArgs C")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "CONSTR")]
67         [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
68         public static void IndicatorStyleArgs_INIT()
69         {
70             NotificationEventArgs.IndicatorStyleArgs indicatorStyle = new NotificationEventArgs.IndicatorStyleArgs();
71             Assert.IsInstanceOf<NotificationEventArgs.IndicatorStyleArgs>(indicatorStyle, "IndicatorStyleArgs object is not of correct instance");
72         }
73
74         [Test]
75         [Category("P1")]
76         [Description("Gets the path of the image file to display on the icon of Indicator style")]
77         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.IndicatorStyleArgs.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.IndicatorStyle style = new Notification.IndicatorStyle();
93                 style.IconPath = "IconPath";
94                 style.SubText = "SubText";
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("Gets the sub text to display Indicator style")]
116         [Property("SPEC", "Tizen.Applications.NotificationEventListener.NotificationEventArgs.IndicatorStyleArgs.SubText A")]
117         [Property("SPEC_URL", "-")]
118         [Property("CRITERIA", "PRO")]
119         [Property("AUTHOR", "MyungKi Lee, mk5004.lee@samsung.com")]
120         public static async Task SubText_PROPERTY_READ_ONLY()
121         {
122             try
123             {
124                 NotificationListenerManager.Added += ChangedEventForSubText;
125
126                 Notification noti = new Notification
127                 {
128                     Content = "Content"
129                 };
130
131                 Notification.IndicatorStyle style = new Notification.IndicatorStyle();
132                 style.IconPath = "IconPath";
133                 style.SubText = "SubText";
134
135                 noti.AddStyle(style);
136
137                 NotificationManager.Post(noti);
138                 await Task.Delay(1000);
139
140                 Assert.AreEqual(_subtext, "SubText", "the set value and the get value should be equal");
141
142                 NotificationManager.Delete(noti);
143
144                 NotificationListenerManager.Added -= ChangedEventForSubText;
145             }
146             catch (Exception e)
147             {
148                 Assert.True(false, e.Message);
149             }
150         }
151     }
152 }