3 using System.Reflection;
4 using System.Collections;
5 using System.Collections.Generic;
6 using System.Threading;
7 using System.Threading.Tasks;
8 using System.Runtime.CompilerServices;
9 using System.Diagnostics;
12 using Tizen.Applications;
14 using Tizen.Messaging.Push;
15 using System.Collections.ObjectModel;
16 using System.Collections.Specialized;
17 using System.Runtime.InteropServices;
20 namespace TizenTest.PushT {
23 [Description("Tizen.Messaging.Push Tests")]
24 public class PushTest {
26 private static string appID = "7c58a4ac98388bba";
27 private static string TAG = "TCT";
28 private static string _message;
31 public static void Init() {
32 //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
36 public static void Destroy() {
37 //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
42 [Description("Return Type of PushServiceConnect ...")]
43 [Property("SPEC", " Tizen.Messaging.Push.PushServiceConnect M")]
44 [Property("SPEC_URL", "-")]
45 [Property("CRITERIA", "MR")]
46 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
47 public static void PushServiceConnect_RETURN_VALUE() {
51 Tizen.Log.Info(TAG,"Executing TC:PushServiceConnect_RETURN_VALUE");
52 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceConnect_RETURN_VALUE");
53 Push.PushServiceConnect(appID);
58 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
59 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
66 [Description("Return Type of PushServiceDisconnect ...")]
67 [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
68 [Property("SPEC_URL", "-")]
69 [Property("CRITERIA", "MR")]
70 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
71 public static void PushServiceDisconnect_RETURN_VALUE() {
73 * 1. Connect to Push Service
75 Push.PushServiceConnect(appID);
80 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE");
81 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE");
82 Push.PushServiceDisconnect();
83 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
84 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
89 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
90 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
97 [Description("Calling Multiple PushServiceConnect PushServiceDisconnect ...")]
98 [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
99 [Property("SPEC_URL", "-")]
100 [Property("CRITERIA", "MR")]
101 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
102 public static void PushServiceConnect_PushServiceDisconnect_RETURN_VALUE() {
104 * 1. Connect to Push Service
111 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE");
112 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE");
113 for(int i=0;i<4;i++){
114 Push.PushServiceConnect(appID);
115 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE after Connect");
116 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE after Connect");
117 Push.PushServiceDisconnect();
118 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE after Disconnect");
119 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE after Disconnect");}
120 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
121 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_RETURN_VALUE completed");
126 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
127 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
134 [Description("Calling PushServiceDisconnect Multiple times...")]
135 [Property("SPEC", " Tizen.Messaging.Push.PushServiceDisconnect M")]
136 [Property("SPEC_URL", "-")]
137 [Property("CRITERIA", "MR")]
138 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
139 public static void PushServiceDisconnect_MULTIPLE() {
141 * 1. Connect to Push Service
148 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE");
149 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE");
150 for(int i=0;i<4;i++){
151 Push.PushServiceConnect(appID);
152 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Connect");
153 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Connect");
154 Push.PushServiceDisconnect();
155 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
156 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");}
157 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE completed");
158 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE completed");
159 Push.PushServiceDisconnect();
160 Tizen.Log.Info(TAG,"Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
161 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServiceDisconnect_MULTIPLE after Disconnect");
166 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
167 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
174 [Description("Return Type of PushServerRegister ...")]
175 [Property("SPEC", " Tizen.Messaging.Push.PushServerRegister M")]
176 [Property("SPEC_URL", "-")]
177 [Property("CRITERIA", "MR")]
178 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
179 public static async Task PushServerRegister_RETURN_VALUE() {
181 * 1. Connect to Push Service
183 Push.PushServiceConnect(appID);
188 Tizen.Log.Info(TAG,"Executing TC:PushServerRegister_RETURN_VALUE");
189 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE");
190 ServerResponse res = await Push.PushServerRegister();
191 await Task.Delay(5000);
192 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
193 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
194 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
195 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
200 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
201 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
206 * 1. Disconnect from Push Service
208 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE before disconnect");
209 Push.PushServiceDisconnect();
210 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerRegister_RETURN_VALUE after disconnect");
215 [Description("Return Type of PushServerUnregister ...")]
216 [Property("SPEC", " Tizen.Messaging.Push.PushServerUnregister M")]
217 [Property("SPEC_URL", "-")]
218 [Property("CRITERIA", "MR")]
219 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
220 public static async Task PushServerUnregister_RETURN_VALUE() {
222 * 1. Connect to Push Service
223 * 2. Register with Push Service
225 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:PushServerUnregister_RETURN_VALUE before connect");
226 Push.PushServiceConnect(appID);
227 ServerResponse res = await Push.PushServerRegister();
228 await Task.Delay(5000);
229 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
230 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
231 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
232 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
233 Tizen.Log.Info(TAG,"Executing TC:PushServerRegister_RETURN_VALUE before pass");
238 ServerResponse resUnreg = await Push.PushServerUnregister();
239 await Task.Delay(5000);
240 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
241 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
242 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
243 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
248 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
249 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
254 * 1. Disconnect from Push Service
256 Push.PushServiceDisconnect();
261 [Description("Return Type of GetRegistrationId ...")]
262 [Property("SPEC", " Tizen.Messaging.Push.GetRegistrationId M")]
263 [Property("SPEC_URL", "-")]
264 [Property("CRITERIA", "MR")]
265 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
266 public static async Task GetRegistrationId_RETURN_VALUE() {
268 * 1. Connect to Push Service
269 * 2. Register with Push Service
271 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE before connect");
272 Push.PushServiceConnect(appID);
273 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE after connect");
274 ServerResponse resReg = await Push.PushServerRegister();
275 await Task.Delay(5000);
276 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
277 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
278 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
279 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
284 Tizen.Log.Info(TAG,"Executing TC:GetRegistrationId_RETURN_VALUE");
285 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE");
286 string id = Push.GetRegistrationId();
287 Tizen.Log.Info(TAG,"Executing TC:GetRegistrationId_RETURN_VALUE Reg Id: "+id);
288 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetRegistrationId_RETURN_VALUE Reg Id: "+id);
300 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
301 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
306 * 1. Unregister from Push Service
307 * 2. Disconnect from Push Service
309 ServerResponse resUnreg = await Push.PushServerUnregister();
310 await Task.Delay(5000);
311 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
312 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
313 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
314 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
315 Push.PushServiceDisconnect();
320 [Description("Return Type of GetUnreadNotifications ...")]
321 [Property("SPEC", " Tizen.Messaging.Push.GetUnreadNotifications M")]
322 [Property("SPEC_URL", "-")]
323 [Property("CRITERIA", "MR")]
324 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
325 public static async Task GetUnreadNotifications_RETURN_VALUE() {
327 * 1. Connect to Push Service
328 * 2. Register with Push Service
330 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetUnreadNotifications_RETURN_VALUE before connect");
331 Push.PushServiceConnect(appID);
332 ServerResponse resReg = await Push.PushServerRegister();
333 await Task.Delay(5000);
334 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
335 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
336 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
337 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
342 Tizen.Log.Info(TAG,"Executing TC:GetUnreadNotifications_RETURN_VALUE");
343 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:GetUnreadNotifications_RETURN_VALUE");
344 Push.GetUnreadNotifications();
349 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
350 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
355 * 1. Unregister from Push Service
356 * 2. Disconnect from Push Service
358 ServerResponse resUnreg = await Push.PushServerUnregister();
359 await Task.Delay(5000);
360 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
361 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
362 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
363 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
364 Push.PushServiceDisconnect();
369 [Description("Getting NotificationReceived Event ...")]
370 [Property("SPEC", " Tizen.Messaging.Push.NotificationReceived E")]
371 [Property("SPEC_URL", "-")]
372 [Property("CRITERIA", "EVL")]
373 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
374 public static async Task NotificationReceived_EVENT() {
376 * 1. Connect to Push Service
377 * 2. Register with Push Service
379 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT before connect");
380 Push.PushServiceConnect(appID);
381 ServerResponse resReg = await Push.PushServerRegister();
382 await Task.Delay(5000);
383 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
384 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resReg.ServerResult);
385 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
386 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resReg.ServerMessage);
392 EventHandler<PushMessageEventArgs> handler = (object sender, PushMessageEventArgs e) =>
394 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event AppData"+e.AppData);
395 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Message"+e.Message);
396 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event ReceivedAt"+e.ReceivedAt);
397 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Sender"+e.Sender);
398 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event SessionInfo"+e.SessionInfo);
399 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event RequestID"+e.RequestId);
400 Tizen.Log.Info(TAG, "Executing TC:NotificationReceived_EVENT got event Type"+e.Type);
401 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event AppData"+e.AppData);
402 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Message"+e.Message);
403 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event ReceivedAt"+e.ReceivedAt);
404 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Sender"+e.Sender);
405 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event SessionInfo"+e.SessionInfo);
406 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event RequestID"+e.RequestId);
407 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT got event Type"+e.Type);
410 Push.NotificationReceived += handler;
411 Tizen.Log.Info(TAG,"Executing TC:NotificationReceived_EVENT");
412 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT");
413 Push.GetUnreadNotifications();
414 Tizen.Log.Info(TAG,"Executing TC:NotificationReceived_EVENT Waiting ................");
415 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:NotificationReceived_EVENT Waiting ................");
416 await Task.Delay(10000);
417 Assert.True(caught, "Did not recieve NotificationReceived Event");
421 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
422 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
427 * 1. Unregister from Push Service
428 * 2. Disconnect from Push Service
430 ServerResponse resUnreg = await Push.PushServerUnregister();
431 await Task.Delay(5000);
432 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
433 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
434 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
435 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
436 Push.PushServiceDisconnect();
441 [Description("Getting StateChanged Event ...")]
442 [Property("SPEC", " Tizen.Messaging.Push.StateChanged E")]
443 [Property("SPEC_URL", "-")]
444 [Property("CRITERIA", "EVL")]
445 [Property("AUTHOR", "Manish Rathod, manish.r@samsung.com")]
446 public static async Task StateChanged_EVENT() {
448 * 1. Connect to Push Service
450 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT before connect");
451 Push.PushServiceConnect(appID);
452 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT after connect");
456 * 1. Register StateChanged Event
457 * 2. Register with Push Service
462 EventHandler<PushConnectionStateEventArgs> handler = (object sender, PushConnectionStateEventArgs e) =>
464 Tizen.Log.Info(TAG, "Executing TC:StateChanged_EVENT got event"+e.State);
465 Tizen.Log.Info(TAG, "Executing TC:StateChanged_EVENT got event"+e.Error);
466 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT got event"+e.State);
467 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Executing TC:StateChanged_EVENT got event"+e.Error);
470 Push.StateChanged += handler;
471 ServerResponse res = await Push.PushServerRegister();
472 await Task.Delay(5000);
473 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+res.ServerResult);
474 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+res.ServerResult);
475 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
476 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+res.ServerMessage);
477 Assert.True(caught, "Did not recieve StateChanged Event");
481 Tizen.Log.Error(TAG, "Caught Exception" + e.ToString());
482 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
487 * 1. Unregister from Push Service
488 * 2. Disconnect from Push Service
490 ServerResponse resUnreg = await Push.PushServerUnregister();
491 await Task.Delay(5000);
492 Tizen.Log.Info(TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
493 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerResult:"+resUnreg.ServerResult);
494 Tizen.Log.Info(TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
495 LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "ServerResponse.ServerMessage:"+resUnreg.ServerMessage);
496 Push.PushServiceDisconnect();