d4593bf0126e88f96c9fd9df9e9bba19f60c59da
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Utility / TSPageFactory.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
7 namespace Tizen.NUI.Devel.Tests
8 {
9     using tlog = Tizen.Log;
10
11     [TestFixture]
12     [Description("Internal/Utility/PageFactory")]
13     public class InternalPageFactoryTest
14     {
15         private const string tag = "NUITEST";
16
17         internal class MyPageFactory : PageFactory
18         {
19             public MyPageFactory(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
20             { }
21         }
22
23         [SetUp]
24         public void Init()
25         {
26             tlog.Info(tag, "Init() is called!");
27         }
28
29         [TearDown]
30         public void Destroy()
31         {
32             tlog.Info(tag, "Destroy() is called!");
33         }
34
35         [Test]
36         [Category("P1")]
37         [Description("PageFactory constructor.")]
38         [Property("SPEC", "Tizen.NUI.PageFactory.PageFactory C")]
39         [Property("SPEC_URL", "-")]
40         [Property("CRITERIA", "CONSTR")]
41         [Property("AUTHOR", "guowei.wang@samsung.com")]
42         public void PageFactoryConstructor()
43         {
44             tlog.Debug(tag, $"PageFactoryConstructor START");
45
46             using (View view = new View())
47             {
48                 view.Size = new Size(20, 40);
49                 view.BackgroundColor = Color.Cyan;
50
51                 var testingTarget = new PageFactory(view.SwigCPtr.Handle, false);
52                 Assert.IsNotNull(testingTarget, "Should be not null!");
53                 Assert.IsInstanceOf<PageFactory>(testingTarget, "Should be an Instance of PageFactory!");
54
55                 testingTarget.Dispose();
56             }
57
58             tlog.Debug(tag, $"PageFactoryConstructor END (OK)");
59         }
60
61         [Test]
62         [Category("P1")]
63         [Description("PageFactory getCPtr.")]
64         [Property("SPEC", "Tizen.NUI.PageFactory.getCPtr M")]
65         [Property("SPEC_URL", "-")]
66         [Property("CRITERIA", "MR")]
67         [Property("AUTHOR", "guowei.wang@samsung.com")]
68         public void PageFactorygetCPtr()
69         {
70             tlog.Debug(tag, $"PageFactorygetCPtr START");
71
72             using (View view = new View())
73             {
74                 view.Size = new Size(20, 40);
75                 view.BackgroundColor = Color.Cyan;
76
77                 var testingTarget = new MyPageFactory(view.SwigCPtr.Handle, false);
78                 Assert.IsNotNull(testingTarget, "Should be not null!");
79                 Assert.IsInstanceOf<PageFactory>(testingTarget, "Should be an Instance of PageFactory!");
80
81                 try
82                 {
83                     MyPageFactory.getCPtr(testingTarget);
84                 }
85                 catch (Exception e)
86                 {
87                     tlog.Debug(tag, e.Message.ToString());
88                     Assert.Fail("Caught Exception: Failed!");
89                 }
90
91                 testingTarget.Dispose();
92             }
93
94             tlog.Debug(tag, $"PageFactorygetCPtr END (OK)");
95         }
96     }
97 }