[NUI] Fix fail issues of NUI.Devel.Test .
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Utility / TSCapture.cs
1 using global::System;
2 using NUnit.Framework;
3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7
8
9 namespace Tizen.NUI.Devel.Tests
10 {
11     using tlog = Tizen.Log;
12
13     [TestFixture]
14     [Description("public/Utility/Capture")]
15     class PublicCaptureTest
16     {
17         private const string tag = "NUITEST";
18         private string path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
19         private string jpg_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "arrow.jpg";
20
21         private delegate bool dummyCallback(IntPtr captureSignal);
22         private bool OnDummyCallback(IntPtr data)
23         {
24             return false;
25         }
26
27
28         internal class MyCapture : Capture
29         {
30             public MyCapture() : base()
31             { }
32
33             public void OnDispose(DisposeTypes type)
34             {
35                 base.Dispose(type);
36             }
37         }
38
39         [SetUp]
40         public void Init()
41         {
42             tlog.Info(tag, "Init() is called!");
43         }
44
45         [TearDown]
46         public void Destroy()
47         {
48             tlog.Info(tag, "Destroy() is called!");
49         }
50
51         [Test]
52         [Category("P1")]
53         [Description("Capture constructor.")]
54         [Property("SPEC", "Tizen.NUI.Capture.Capture C")]
55         [Property("SPEC_URL", "-")]
56         [Property("CRITERIA", "CONSTR")]
57         [Property("AUTHOR", "guowei.wang@samsung.com")]
58         public void CaptureConstructor()
59         {
60             tlog.Debug(tag, $"CaptureConstructor START");
61
62             var testingTarget = new Capture();
63             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
64             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
65
66             testingTarget.Dispose();
67             tlog.Debug(tag, $"CaptureConstructor END (OK)");
68         }
69
70         [Test]
71         [Category("P1")]
72         [Description("Capture Dispose.")]
73         [Property("SPEC", "Tizen.NUI.Capture.Dispose M")]
74         [Property("SPEC_URL", "-")]
75         [Property("CRITERIA", "MR")]
76         [Property("AUTHOR", "guowei.wang@samsung.com")]
77         public void CaptureDispose()
78         {
79             tlog.Debug(tag, $"CaptureDispose START");
80
81             var testingTarget = new Capture();
82             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
83             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
84
85             try
86             {
87                 testingTarget.Dispose();
88             }
89             catch (Exception e)
90             {
91                 tlog.Debug(tag, e.Message.ToString());
92                 Assert.Fail("Caught Exception: Failed!");
93             }
94
95             /** disposed is true */
96             try
97             {
98                 testingTarget.Dispose();
99             }
100             catch (Exception e)
101             {
102                 tlog.Debug(tag, e.Message.ToString());
103                 Assert.Fail("Caught Exception: Failed!");
104             }
105
106             tlog.Debug(tag, $"CaptureDispose END (OK)");
107         }
108
109         [Test]
110         [Category("P1")]
111         [Description("Capture SetImageQuality.")]
112         [Property("SPEC", "Tizen.NUI.Capture.SetImageQuality M")]
113         [Property("SPEC_URL", "-")]
114         [Property("CRITERIA", "MR")]
115         [Property("AUTHOR", "guowei.wang@samsung.com")]
116         public void CaptureSetImageQuality()
117         {
118             tlog.Debug(tag, $"CaptureSetImageQuality START");
119
120             var testingTarget = new Capture();
121             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
122             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
123
124             try
125             {
126                 testingTarget.SetImageQuality(30);
127             }
128             catch (Exception e)
129             {
130                 tlog.Debug(tag, e.Message.ToString());
131                 Assert.Fail("Caught Exception: Failed!");
132             }
133
134             testingTarget.Dispose();
135             tlog.Debug(tag, $"CaptureSetImageQuality END (OK)");
136         }
137
138         [Test]
139         [Category("P2")]
140         [Description("Capture SetImageQuality. With invalid operation.")]
141         [Property("SPEC", "Tizen.NUI.Capture.SetImageQuality M")]
142         [Property("SPEC_URL", "-")]
143         [Property("CRITERIA", "MR")]
144         [Property("AUTHOR", "guowei.wang@samsung.com")]
145         public void CaptureSetImageQualityWithInvalidOperation()
146         {
147             tlog.Debug(tag, $"CaptureSetImageQualityWithInvalidOperation START");
148
149             var testingTarget = new Capture();
150             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
151             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
152
153             try
154             {
155                 testingTarget.SetImageQuality(120);
156             }
157             catch (InvalidOperationException)
158             {
159                 testingTarget.Dispose();
160                 tlog.Debug(tag, $"CaptureSetImageQualityWithInvalidOperation END (OK)");
161                 Assert.Pass("Caught InvalidOperationException: Passed!");
162             }
163         }
164
165         [Test]
166         [Category("P2")]
167         [Description("Capture Dispose. Capture is disposed.")]
168         [Property("SPEC", "Tizen.NUI.Capture.Dispose M")]
169         [Property("SPEC_URL", "-")]
170         [Property("CRITERIA", "MR")]
171         [Property("AUTHOR", "guowei.wang@samsung.com")]
172         public void CaptureDisposeWithDisposedInstance()
173         {
174             tlog.Debug(tag, $"CaptureDisposeWithDisposedInstance START");
175
176             var testingTarget = new MyCapture();
177             Assert.IsNotNull(testingTarget, "Can't create success object MyCapture");
178             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of MyCapture type.");
179
180             testingTarget.OnDispose(DisposeTypes.Explicit);
181
182             try
183             {
184                 testingTarget.OnDispose(DisposeTypes.Explicit);
185             }
186             catch (Exception e)
187             {
188                 tlog.Debug(tag, e.Message.ToString());
189                 Assert.Fail("Caught Exception: Failed!");
190             }
191
192             tlog.Debug(tag, $"CaptureDisposeWithDisposedInstance END (OK)");
193         }
194
195         [Test]
196         [Category("P1")]
197         [Description("Capture Start.")]
198         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
199         [Property("SPEC_URL", "-")]
200         [Property("CRITERIA", "MR")]
201         [Property("AUTHOR", "guowei.wang@samsung.com")]
202         public void CaptureStart()
203         {
204             tlog.Debug(tag, $"CaptureStart START");
205
206             var testingTarget = new Capture();
207             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
208             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
209
210             using (Container container = new View())
211             {
212                 using (Size size = new Size(100, 80))
213                 {
214                     try
215                     {
216                         testingTarget.Start(container, size, path);
217                     }
218                     catch (Exception e)
219                     {
220                         tlog.Debug(tag, e.Message.ToString());
221                         Assert.Fail("Caught Exception: Failed!");
222                     }
223                 }
224             }
225
226             testingTarget.Dispose();
227             tlog.Debug(tag, $"CaptureStart END (OK)");
228         }
229
230         [Test]
231         [Category("P2")]
232         [Description("Capture Start. Size is null.")]
233         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
234         [Property("SPEC_URL", "-")]
235         [Property("CRITERIA", "MR")]
236         [Property("AUTHOR", "guowei.wang@samsung.com")]
237         public void CaptureStartWithNullSize()
238         {
239             tlog.Debug(tag, $"CaptureStartWithNullSize START");
240
241             var testingTarget = new Capture();
242             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
243             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
244
245             using (Container container = new View())
246             {
247                 try
248                 {
249                     testingTarget.Start(container, null, path);
250                 }
251                 catch (ArgumentNullException e)
252                 {
253                     testingTarget.Dispose();
254                     tlog.Debug(tag, e.Message.ToString());
255                     tlog.Debug(tag, $"CaptureStartWithNullSize END (OK)");
256                     Assert.Pass("Caught ArgumentNullException: Passed!");
257                 }
258             }
259         }
260
261         [Test]
262         [Category("P2")]
263         [Description("Capture Start. Size is invalid.")]
264         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
265         [Property("SPEC_URL", "-")]
266         [Property("CRITERIA", "MR")]
267         [Property("AUTHOR", "guowei.wang@samsung.com")]
268         public void CaptureStartWithInvalidSize()
269         {
270             tlog.Debug(tag, $"CaptureStartWithInvalidSize START");
271
272             var testingTarget = new Capture();
273             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
274             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
275
276             using (Container container = new View())
277             {
278                 using (Size size = new Size(0, 0))
279                 {
280                     try
281                     {
282                         testingTarget.Start(container, size, path);
283                     }
284                     catch (InvalidOperationException e)
285                     {
286                         testingTarget.Dispose();
287                         tlog.Debug(tag, e.Message.ToString());
288                         tlog.Debug(tag, $"CaptureStartWithInvalidSize END (OK)");
289                         Assert.Pass("Caught InvalidOperationException: Passed!");
290                     }
291                 }
292             }
293         }
294
295         [Test]
296         [Category("P2")]
297         [Description("Capture Start. path is null.")]
298         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
299         [Property("SPEC_URL", "-")]
300         [Property("CRITERIA", "MR")]
301         [Property("AUTHOR", "guowei.wang@samsung.com")]
302         public void CaptureStartWithNullPath()
303         {
304             tlog.Debug(tag, $"CaptureStartWithNullPath START");
305
306             var testingTarget = new Capture();
307             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
308             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
309
310             using (Container container = new View())
311             {
312                 using (Size size = new Size(100, 80))
313                 {
314                     try
315                     {
316                         testingTarget.Start(container, size, null);
317                     }
318                     catch (ArgumentNullException e)
319                     {
320                         testingTarget.Dispose();
321                         tlog.Debug(tag, e.Message.ToString());
322                         tlog.Debug(tag, $"CaptureStartWithNullPath END (OK)");
323                         Assert.Pass("Caught ArgumentNullException: Passed!");
324                     }
325                 }
326             }
327         }
328
329         [Test]
330         [Category("P1")]
331         [Description("Capture Start include Color.")]
332         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
333         [Property("SPEC_URL", "-")]
334         [Property("CRITERIA", "MR")]
335         [Property("AUTHOR", "guowei.wang@samsung.com")]
336         public void CaptureStartIncludeColor()
337         {
338             tlog.Debug(tag, $"CaptureStartIncludeColor START");
339
340             var testingTarget = new Capture();
341             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
342             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
343
344             using (Container container = new View())
345             {
346                 using (Size size = new Size(100, 80))
347                 {
348                     using (Color color = Color.Cyan)
349                     {
350                         try
351                         {
352                             testingTarget.Start(container, size, path, color);
353                         }
354                         catch (Exception e)
355                         {
356                             tlog.Debug(tag, e.Message.ToString());
357                             Assert.Fail("Caught Exception: Failed!");
358                         }
359                     }
360                 }
361             }
362
363             testingTarget.Dispose();
364             tlog.Debug(tag, $"CaptureStartIncludeColor END (OK)");
365         }
366
367         [Test]
368         [Category("P2")]
369         [Description("Capture Start include Color. Color is null.")]
370         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
371         [Property("SPEC_URL", "-")]
372         [Property("CRITERIA", "MR")]
373         [Property("AUTHOR", "guowei.wang@samsung.com")]
374         public void CaptureStartIncludeColorWithNullColor()
375         {
376             tlog.Debug(tag, $"CaptureStartIncludeColorWithNullColor START");
377
378             var testingTarget = new Capture();
379             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
380             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
381
382             using (Container container = new View())
383             {
384                 using (Size size = new Size(100, 80))
385                 {
386                     try
387                     {
388                         testingTarget.Start(container, size, path, null);
389                     }
390                     catch (ArgumentNullException e)
391                     {
392                         testingTarget.Dispose();
393                         tlog.Debug(tag, e.Message.ToString());
394                         tlog.Debug(tag, $"CaptureStartIncludeColorWithNullColor END (OK)");
395                         Assert.Pass("Caught ArgumentNullException: Passed!");
396                     }
397                 }
398             }
399         }
400
401         [Test]
402         [Category("P2")]
403         [Description("Capture Start include color. Size is null.")]
404         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
405         [Property("SPEC_URL", "-")]
406         [Property("CRITERIA", "MR")]
407         [Property("AUTHOR", "guowei.wang@samsung.com")]
408         public void CaptureStartIncludeColorWithNullSize()
409         {
410             tlog.Debug(tag, $"CaptureStartIncludeColorWithNullSize START");
411
412             var testingTarget = new Capture();
413             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
414             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
415
416             using (Container container = new View())
417             {
418                 using (Color color = Color.Cyan)
419                 {
420                     try
421                     {
422                         testingTarget.Start(container, null, path, color);
423                     }
424                     catch (ArgumentNullException e)
425                     {
426                         testingTarget.Dispose();
427                         tlog.Debug(tag, e.Message.ToString());
428                         tlog.Debug(tag, $"CaptureStartIncludeColorWithNullSize END (OK)");
429                         Assert.Pass("Caught ArgumentNullException: Passed!");
430                     }
431                 }
432             }
433         }
434
435         [Test]
436         [Category("P2")]
437         [Description("Capture Start include color. Path is null.")]
438         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
439         [Property("SPEC_URL", "-")]
440         [Property("CRITERIA", "MR")]
441         [Property("AUTHOR", "guowei.wang@samsung.com")]
442         public void CaptureStartIncludeColorWithNullPath()
443         {
444             tlog.Debug(tag, $"CaptureStartIncludeColorWithNullPath START");
445
446             var testingTarget = new Capture();
447             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
448             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
449
450             using (Container container = new View())
451             {
452                 using (Size size = new Size(100, 80))
453                 {
454                     using (Color color = Color.Cyan)
455                     {
456                         try
457                         {
458                             testingTarget.Start(container, size, null, color);
459                         }
460                         catch (ArgumentNullException e)
461                         {
462                             testingTarget.Dispose();
463                             tlog.Debug(tag, e.Message.ToString());
464                             tlog.Debug(tag, $"CaptureStartIncludeColorWithNullPath END (OK)");
465                             Assert.Pass("Caught ArgumentNullException: Passed!");
466                         }
467                     }
468                 }
469             }
470         }
471
472         [Test]
473         [Category("P2")]
474         [Description("Capture Start include color. Size is invalid.")]
475         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
476         [Property("SPEC_URL", "-")]
477         [Property("CRITERIA", "MR")]
478         [Property("AUTHOR", "guowei.wang@samsung.com")]
479         public void CaptureStartIncludeColorWithInvalidSize()
480         {
481             tlog.Debug(tag, $"CaptureStartIncludeColorWithInvalidSize START");
482
483             var testingTarget = new Capture();
484             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
485             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
486
487             using (Container container = new View())
488             {
489                 using (Size size = new Size(0, 0))
490                 {
491                     using (Color color = Color.Cyan)
492                     {
493                         try
494                         {
495                             testingTarget.Start(container, size, path, color);
496                         }
497                         catch (InvalidOperationException e)
498                         {
499                             testingTarget.Dispose();
500                             tlog.Debug(tag, e.Message.ToString());
501                             tlog.Debug(tag, $"CaptureStartIncludeColorWithInvalidSize END (OK)");
502                             Assert.Pass("Caught InvalidOperationException: Passed!");
503                         }
504                     }
505                 }
506             }
507         }
508
509         //[Test]
510         //[Category("P1")]
511         //[Description("Capture Start include quality.")]
512         //[Property("SPEC", "Tizen.NUI.Capture.Start M")]
513         //[Property("SPEC_URL", "-")]
514         //[Property("CRITERIA", "MR")]
515         //[Property("AUTHOR", "guowei.wang@samsung.com")]
516         //public void CaptureStartIncludeQuality()
517         //{
518         //    tlog.Debug(tag, $"CaptureStartIncludeQuality START");
519
520         //    var testingTarget = new Capture();
521         //    Assert.IsNotNull(testingTarget, "Can't create success object Capture");
522         //    Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
523
524         //    using (Container container = new View())
525         //    {
526         //        using (Size size = new Size(100, 80))
527         //        {
528         //            using (Color color = Color.Cyan)
529         //            {
530         //                try
531         //                {
532         //                    testingTarget.Start(container, size, jpg_path, color, 30);
533         //                }
534         //                catch (Exception e)
535         //                {
536         //                    tlog.Debug(tag, e.Message.ToString());
537         //                    Assert.Fail("Caught Exception: Failed!");
538         //                }
539         //            }
540         //        }
541         //    }
542
543         //    testingTarget.Dispose();
544         //    tlog.Debug(tag, $"CaptureStartIncludeQuality END (OK)");
545         //}
546
547         [Test]
548         [Category("P2")]
549         [Description("Capture Start include quality. Color is null.")]
550         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
551         [Property("SPEC_URL", "-")]
552         [Property("CRITERIA", "MR")]
553         [Property("AUTHOR", "guowei.wang@samsung.com")]
554         public void CaptureStartIncludeQualityWithNullColor()
555         {
556             tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullColor START");
557
558             var testingTarget = new Capture();
559             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
560             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
561
562             using (Container container = new View())
563             {
564                 using (Size size = new Size(100, 80))
565                 {
566                     try
567                     {
568                         testingTarget.Start(container, size, jpg_path, null, 30);
569                     }
570                     catch (ArgumentNullException e)
571                     {
572                         testingTarget.Dispose();
573                         tlog.Debug(tag, e.Message.ToString());
574                         tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullColor END (OK)");
575                         Assert.Pass("Caught ArgumentNullException: Passed!");
576                     }
577                 }
578             }
579         }
580
581         [Test]
582         [Category("P2")]
583         [Description("Capture Start include quality. Size is null.")]
584         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
585         [Property("SPEC_URL", "-")]
586         [Property("CRITERIA", "MR")]
587         [Property("AUTHOR", "guowei.wang@samsung.com")]
588         public void CaptureStartIncludeQualityWithNullSize()
589         {
590             tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullSize START");
591
592             var testingTarget = new Capture();
593             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
594             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
595
596             using (Container container = new View())
597             {
598                 using (Color color = Color.Cyan)
599                 {
600                     try
601                     {
602                         testingTarget.Start(container, null, jpg_path, color, 30);
603                     }
604                     catch (ArgumentNullException e)
605                     {
606                         testingTarget.Dispose();
607                         tlog.Debug(tag, e.Message.ToString());
608                         tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullSize END (OK)");
609                         Assert.Pass("Caught ArgumentNullException: Passed!");
610                     }
611                 }
612             }
613         }
614
615         [Test]
616         [Category("P2")]
617         [Description("Capture Start include quality. Path is null.")]
618         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
619         [Property("SPEC_URL", "-")]
620         [Property("CRITERIA", "MR")]
621         [Property("AUTHOR", "guowei.wang@samsung.com")]
622         public void CaptureStartIncludeQualityWithNullPath()
623         {
624             tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullPath START");
625
626             var testingTarget = new Capture();
627             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
628             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
629
630             using (Container container = new View())
631             {
632                 using (Size size = new Size(100, 80))
633                 {
634                     using (Color color = Color.Cyan)
635                     {
636                         try
637                         {
638                             testingTarget.Start(container, size, null, color, 30);
639                         }
640                         catch (ArgumentNullException e)
641                         {
642                             testingTarget.Dispose();
643                             tlog.Debug(tag, e.Message.ToString());
644                             tlog.Debug(tag, $"CaptureStartIncludeQualityWithNullPath END (OK)");
645                             Assert.Pass("Caught ArgumentNullException: Passed!");
646                         }
647                     }
648                 }
649             }
650         }
651
652         [Test]
653         [Category("P2")]
654         [Description("Capture Start include quality. Quality is invalid.")]
655         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
656         [Property("SPEC_URL", "-")]
657         [Property("CRITERIA", "MR")]
658         [Property("AUTHOR", "guowei.wang@samsung.com")]
659         public void CaptureStartIncludeQualityWithInvalidQuality()
660         {
661             tlog.Debug(tag, $"CaptureStartIncludeQualityWithInvalidQuality START");
662
663             var testingTarget = new Capture();
664             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
665             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
666
667             using (Container container = new View())
668             {
669                 using (Size size = new Size(100, 80))
670                 {
671                     using (Color color = Color.Cyan)
672                     {
673                         try
674                         {
675                             testingTarget.Start(container, size, jpg_path, color, 130);
676                         }
677                         catch (InvalidOperationException e)
678                         {
679                             testingTarget.Dispose();
680                             tlog.Debug(tag, e.Message.ToString());
681                             tlog.Debug(tag, $"CaptureStartIncludeQualityWithInvalidQuality END (OK)");
682                             Assert.Pass("Caught InvalidOperationException: Passed!");
683                         }
684                     }
685                 }
686             }
687         }
688
689         [Test]
690         [Category("P2")]
691         [Description("Capture Start include quality. Size is invalid.")]
692         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
693         [Property("SPEC_URL", "-")]
694         [Property("CRITERIA", "MR")]
695         [Property("AUTHOR", "guowei.wang@samsung.com")]
696         public void CaptureStartIncludeQualityWithInvalidSize()
697         {
698             tlog.Debug(tag, $"CaptureStartIncludeQualityWithInvalidSize START");
699
700             var testingTarget = new Capture();
701             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
702             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
703
704             using (Container container = new View())
705             {
706                 using (Size size = new Size(0, 0))
707                 {
708                     using (Color color = Color.Cyan)
709                     {
710                         try
711                         {
712                             testingTarget.Start(container, size, path, color, 30);
713                         }
714                         catch (InvalidOperationException e)
715                         {
716                             testingTarget.Dispose();
717                             tlog.Debug(tag, e.Message.ToString());
718                             tlog.Debug(tag, $"CaptureStartIncludeQualityWithInvalidSize END (OK)");
719                             Assert.Pass("Caught InvalidOperationException: Passed!");
720                         }
721                     }
722                 }
723             }
724         }
725
726         //[Test]
727         //[Category("P1")]
728         //[Description("Capture Start include position.")]
729         //[Property("SPEC", "Tizen.NUI.Capture.Start M")]
730         //[Property("SPEC_URL", "-")]
731         //[Property("CRITERIA", "MR")]
732         //[Property("AUTHOR", "guowei.wang@samsung.com")]
733         //public void CaptureStartIncludePosition()
734         //{
735         //    tlog.Debug(tag, $"CaptureStartIncludePosition START");
736
737         //    var testingTarget = new Capture();
738         //    Assert.IsNotNull(testingTarget, "Can't create success object Capture");
739         //    Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
740
741         //    using (Container container = new View())
742         //    {
743         //        using (Position position = new Position(50, 100))
744         //        {
745         //            using (Size size = new Size(100, 80))
746         //            {
747         //                using (Color color = Color.Cyan)
748         //                {
749         //                    try
750         //                    {
751         //                        testingTarget.Start(container, position, size, path, color);
752         //                    }
753         //                    catch (Exception e)
754         //                    {
755         //                        tlog.Debug(tag, e.Message.ToString());
756         //                        Assert.Fail("Caught Exception: Failed!");
757         //                    }
758         //                }
759         //            }
760         //        }
761         //    }
762
763         //    testingTarget.Dispose();
764         //    tlog.Debug(tag, $"CaptureStartIncludePosition END (OK)");
765         //}
766
767         [Test]
768         [Category("P2")]
769         [Description("Capture Start include position. Position is null.")]
770         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
771         [Property("SPEC_URL", "-")]
772         [Property("CRITERIA", "MR")]
773         [Property("AUTHOR", "guowei.wang@samsung.com")]
774         public void CaptureStartIncludePositionWithNullPosition()
775         {
776             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullPosition START");
777
778             var testingTarget = new Capture();
779             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
780             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
781
782             using (Container container = new View())
783             {
784                 using (Size size = new Size(100, 80))
785                 {
786                     using (Color color = Color.Cyan)
787                     {
788                         try
789                         {
790                             testingTarget.Start(container, null, size, path, color);
791                         }
792                         catch (ArgumentNullException e)
793                         {
794                             testingTarget.Dispose();
795                             tlog.Debug(tag, e.Message.ToString());
796                             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullPosition END (OK)");
797                             Assert.Pass("Caught ArgumentNullException: Passed!");
798                         }
799                     }
800                 }
801             }
802         }
803
804         [Test]
805         [Category("P2")]
806         [Description("Capture Start include position. Size is null.")]
807         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
808         [Property("SPEC_URL", "-")]
809         [Property("CRITERIA", "MR")]
810         [Property("AUTHOR", "guowei.wang@samsung.com")]
811         public void CaptureStartIncludePositionWithNullSize()
812         {
813             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullSize START");
814
815             var testingTarget = new Capture();
816             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
817             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
818
819             using (Container container = new View())
820             {
821                 using (Position position = new Position(100, 80))
822                 {
823                     using (Color color = Color.Cyan)
824                     {
825                         try
826                         {
827                             testingTarget.Start(container, position, null, path, color);
828                         }
829                         catch (ArgumentNullException e)
830                         {
831                             testingTarget.Dispose();
832                             tlog.Debug(tag, e.Message.ToString());
833                             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullSize END (OK)");
834                             Assert.Pass("Caught ArgumentNullException: Passed!");
835                         }
836                     }
837                 }
838             }
839         }
840
841         [Test]
842         [Category("P2")]
843         [Description("Capture Start include position. Color is null.")]
844         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
845         [Property("SPEC_URL", "-")]
846         [Property("CRITERIA", "MR")]
847         [Property("AUTHOR", "guowei.wang@samsung.com")]
848         public void CaptureStartIncludePositionWithNullColor()
849         {
850             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullColor START");
851
852             var testingTarget = new Capture();
853             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
854             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
855
856             using (Container container = new View())
857             {
858                 using (Position position = new Position(50, 100))
859                 {
860                     using (Size size = new Size(100, 80))
861                     {
862                         try
863                         {
864                             testingTarget.Start(container, position, size, path, null);
865                         }
866                         catch (ArgumentNullException e)
867                         {
868                             testingTarget.Dispose();
869                             tlog.Debug(tag, e.Message.ToString());
870                             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullColor END (OK)");
871                             Assert.Pass("Caught ArgumentNullException: Passed!");
872                         }
873                     }
874                 }
875             }
876         }
877
878         [Test]
879         [Category("P2")]
880         [Description("Capture Start include position. Color is null.")]
881         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
882         [Property("SPEC_URL", "-")]
883         [Property("CRITERIA", "MR")]
884         [Property("AUTHOR", "guowei.wang@samsung.com")]
885         public void CaptureStartIncludePositionWithNullPath()
886         {
887             tlog.Debug(tag, $"CaptureStartIncludePositionWithNullPath START");
888
889             var testingTarget = new Capture();
890             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
891             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
892
893             using (Container container = new View())
894             {
895                 using (Position position = new Position(50, 100))
896                 {
897                     using (Size size = new Size(100, 80))
898                     {
899                         using (Color color = Color.Cyan)
900                         {
901                             try
902                             {
903                                 testingTarget.Start(container, position, size, null, color);
904                             }
905                             catch (ArgumentNullException e)
906                             {
907                                 testingTarget.Dispose();
908                                 tlog.Debug(tag, e.Message.ToString());
909                                 tlog.Debug(tag, $"CaptureStartIncludePositionWithNullPath END (OK)");
910                                 Assert.Pass("Caught ArgumentNullException: Passed!");
911                             }
912                         }
913                     }
914                 }
915             }
916         }
917
918         [Test]
919         [Category("P2")]
920         [Description("Capture Start include position. Size is invalid.")]
921         [Property("SPEC", "Tizen.NUI.Capture.Start M")]
922         [Property("SPEC_URL", "-")]
923         [Property("CRITERIA", "MR")]
924         [Property("AUTHOR", "guowei.wang@samsung.com")]
925         public void CaptureStartIncludePositionWithInvalidSize()
926         {
927             tlog.Debug(tag, $"CaptureStartIncludePositionWithInvalidSize START");
928
929             var testingTarget = new Capture();
930             Assert.IsNotNull(testingTarget, "Can't create success object Capture");
931             Assert.IsInstanceOf<Capture>(testingTarget, "Should be an instance of Capture type.");
932
933             using (Container container = new View())
934             {
935                 using (Position position = new Position(50, 100))
936                 {
937                     using (Size size = new Size(0, 0))
938                     {
939                         using (Color color = Color.Cyan)
940                         {
941                             try
942                             {
943                                 testingTarget.Start(container, position, size, path, color);
944                             }
945                             catch (InvalidOperationException e)
946                             {
947                                 testingTarget.Dispose();
948                                 tlog.Debug(tag, e.Message.ToString());
949                                 tlog.Debug(tag, $"CaptureStartIncludePositionWithInvalidSize END (OK)");
950                                 Assert.Pass("Caught InvalidOperationException: Passed!");
951                             }
952                         }
953                     }
954                 }
955             }
956         }
957
958         [Test]
959         [Category("P1")]
960         [Description("Capture Finished.")]
961         [Property("SPEC", "Tizen.NUI.Capture.Finished M")]
962         [Property("SPEC_URL", "-")]
963         [Property("CRITERIA", "MR")]
964         [Property("AUTHOR", "guowei.wang@samsung.com")]
965         public void CaptureFinished()
966         {
967             tlog.Debug(tag, $"CaptureFinished START");
968
969             var testingTarget = new MyCapture();
970             Assert.IsNotNull(testingTarget, "Can't create success object MyCapture");
971             Assert.IsInstanceOf<MyCapture>(testingTarget, "Should be an instance of MyCapture type.");
972
973             testingTarget.Finished += OnFinishedEvent;
974             testingTarget.Finished -= OnFinishedEvent;
975
976             testingTarget.Dispose();
977             tlog.Debug(tag, $"CaptureFinished END (OK)");
978         }
979
980         [Test]
981         [Category("P1")]
982         [Description("Capture GetNativeImageSource.")]
983         [Property("SPEC", "Tizen.NUI.Capture.GetNativeImageSource M")]
984         [Property("SPEC_URL", "-")]
985         [Property("CRITERIA", "MR")]
986         [Property("AUTHOR", "guowei.wang@samsung.com")]
987         public void CaptureGetNativeImageSource()
988         {
989             tlog.Debug(tag, $"CaptureGetNativeImageSource START");
990
991             var testingTarget = new MyCapture();
992             Assert.IsNotNull(testingTarget, "Can't create success object MyCapture");
993             Assert.IsInstanceOf<MyCapture>(testingTarget, "Should be an instance of MyCapture type.");
994
995             var result = testingTarget.GetNativeImageSource();
996             Assert.IsNotNull(result, "Can't create success object NativeImageSource ");
997             Assert.IsInstanceOf<NativeImageSource>(result, "Should be an instance of NativeImageSource  type.");
998
999             testingTarget.Dispose();
1000             tlog.Debug(tag, $"CaptureGetNativeImageSource END (OK)");
1001         }
1002
1003         [Test]
1004         [Category("P1")]
1005         [Description("Capture.CaptureFinishedEventArgs  Success.")]
1006         [Property("SPEC", "Tizen.NUI.Capture.CaptureFinishedEventArgs.Success A")]
1007         [Property("SPEC_URL", "-")]
1008         [Property("CRITERIA", "PRW")]
1009         [Property("AUTHOR", "guowei.wang@samsung.com")]
1010         public void CaptureCaptureFinishedEventArgsSuccess()
1011         {
1012             tlog.Debug(tag, $"CaptureCaptureFinishedEventArgsSuccess START");
1013
1014             var testingTarget = new CaptureFinishedEventArgs();
1015             Assert.IsNotNull(testingTarget, "Can't create success object CaptureFinishedEventArgs");
1016             Assert.IsInstanceOf<CaptureFinishedEventArgs>(testingTarget, "Should be an instance of CaptureFinishedEventArgs type.");
1017
1018             Assert.AreEqual(false, testingTarget.Success, "Should be equal!");
1019
1020             testingTarget.Success = true;
1021             Assert.AreEqual(true, testingTarget.Success, "Should be equal!");
1022
1023             tlog.Debug(tag, $"CaptureCaptureFinishedEventArgsSuccess END (OK)");
1024         }
1025
1026         [Test]
1027         [Category("P1")]
1028         [Description("Capture.CaptureSignal constructor.")]
1029         [Property("SPEC", "Tizen.NUI.Capture.CaptureSignal.CaptureSignal M")]
1030         [Property("SPEC_URL", "-")]
1031         [Property("CRITERIA", "MR")]
1032         [Property("AUTHOR", "guowei.wang@samsung.com")]
1033         public void CaptureCaptureSignalConstructor()
1034         {
1035             tlog.Debug(tag, $"CaptureCaptureSignalConstructor START");
1036
1037             using (Capture capture = new Capture())
1038             {
1039                 var testingTarget = new CaptureSignal(capture.SwigCPtr.Handle, true);
1040                 Assert.IsNotNull(testingTarget, "Can't create success object CaptureSignal");
1041                 Assert.IsInstanceOf<CaptureSignal>(testingTarget, "Should be an instance of CaptureSignal type.");
1042
1043                 testingTarget.Dispose();
1044             }
1045
1046             tlog.Debug(tag, $"CaptureCaptureSignalConstructor END (OK)");
1047         }
1048
1049         [Test]
1050         [Category("P1")]
1051         [Description("Capture.CaptureSignal Empty.")]
1052         [Property("SPEC", "Tizen.NUI.Capture.CaptureSignal.Empty M")]
1053         [Property("SPEC_URL", "-")]
1054         [Property("CRITERIA", "MR")]
1055         [Property("AUTHOR", "guowei.wang@samsung.com")]
1056         public void CaptureCaptureSignalEmpty()
1057         {
1058             tlog.Debug(tag, $"CaptureCaptureSignalEmpty START");
1059
1060             using (Capture capture = new Capture())
1061             {
1062                 var testingTarget = new CaptureSignal(capture.SwigCPtr.Handle, true);
1063                 Assert.IsNotNull(testingTarget, "Can't create success object CaptureSignal");
1064                 Assert.IsInstanceOf<CaptureSignal>(testingTarget, "Should be an instance of CaptureSignal type.");
1065
1066                 try
1067                 {
1068                     var result = testingTarget.Empty();
1069                     tlog.Debug(tag, "Empty : " +  result);
1070                 }
1071                 catch (Exception e)
1072                 {
1073                     tlog.Debug(tag, e.Message.ToString());
1074                     Assert.Fail("Caught Exception : Failed!");
1075                 }
1076
1077                 testingTarget.Dispose();
1078             }
1079
1080             tlog.Debug(tag, $"CaptureCaptureSignalEmpty END (OK)");
1081         }
1082
1083         [Test]
1084         [Category("P1")]
1085         [Description("Capture.CaptureSignal GetConnectionCount.")]
1086         [Property("SPEC", "Tizen.NUI.Capture.CaptureSignal.GetConnectionCount M")]
1087         [Property("SPEC_URL", "-")]
1088         [Property("CRITERIA", "MR")]
1089         [Property("AUTHOR", "guowei.wang@samsung.com")]
1090         public void CaptureCaptureSignalGetConnectionCount()
1091         {
1092             tlog.Debug(tag, $"CaptureCaptureSignalGetConnectionCount START");
1093
1094             using (Capture capture = new Capture())
1095             {
1096                 var testingTarget = new CaptureSignal(capture.SwigCPtr.Handle, true);
1097                 Assert.IsNotNull(testingTarget, "Can't create success object CaptureSignal");
1098                 Assert.IsInstanceOf<CaptureSignal>(testingTarget, "Should be an instance of CaptureSignal type.");
1099
1100                 var result = testingTarget.GetConnectionCount();
1101                 Assert.AreEqual(0, result, "Should be equal!");
1102
1103                 testingTarget.Dispose();
1104             }
1105
1106             tlog.Debug(tag, $"CaptureCaptureSignalGetConnectionCount END (OK)");
1107         }
1108
1109         [Test]
1110         [Category("P1")]
1111         [Description("Capture.CaptureSignal Emit.")]
1112         [Property("SPEC", "Tizen.NUI.Capture.CaptureSignal.Emit M")]
1113         [Property("SPEC_URL", "-")]
1114         [Property("CRITERIA", "MR")]
1115         [Property("AUTHOR", "guowei.wang@samsung.com")]
1116         public void CaptureCaptureSignalEmit()
1117         {
1118             tlog.Debug(tag, $"CaptureCaptureSignalEmit START");
1119
1120             var currentPid = global::System.Diagnostics.Process.GetCurrentProcess().Id;
1121             var currentTid = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
1122
1123             tlog.Debug(tag, $"thread check! main pid={App.mainPid}, current pid={currentPid}, main tid={App.mainTid}, current tid={currentTid}");
1124
1125             using (Capture capture = new Capture())
1126             {
1127                 var testingTarget = new CaptureSignal(capture.SwigCPtr.Handle, true);
1128                 Assert.IsNotNull(testingTarget, "Can't create success object CaptureSignal");
1129                 Assert.IsInstanceOf<CaptureSignal>(testingTarget, "Should be an instance of CaptureSignal type.");
1130
1131                 testingTarget.Emit(capture, true);
1132                 
1133                 testingTarget.Dispose();
1134             }
1135
1136             tlog.Debug(tag, $"CaptureCaptureSignalEmit END (OK)");
1137         }
1138
1139         private void OnFinishedEvent(object sender, CaptureFinishedEventArgs e)
1140         {
1141             // Do not implementation
1142         }
1143     }
1144 }