f49a985bd3c9fc1301a48f7ded388d0f428ae978
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / internal / Xaml / TSApplyPropertiesVisitor.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections.Generic;
4 using System.Reflection;
5 using System.Xml;
6 using Tizen.NUI.Xaml;
7
8 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("internal/Xaml/ApplyPropertiesVisitor")]
14     public class InternalXamlApplyPropertiesVisitorTest
15     {
16         private const string tag = "NUITEST";
17         public const string NUI2018Uri = "http://tizen.org/Tizen.NUI/2018/XAML";
18         private string xaml_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "simpleXaml.xaml";
19         private ApplyPropertiesVisitor visitor;
20         [SetUp]
21         public void Init()
22         {
23             tlog.Info(tag, "Init() is called!");
24             HydrationContext context = new HydrationContext();
25             visitor = new ApplyPropertiesVisitor(context, false);
26         }
27
28         [TearDown]
29         public void Destroy()
30         {
31             visitor = null;
32             tlog.Info(tag, "Destroy() is called!");
33         }
34
35         [Test]
36         [Category("P1")]
37         [Description("ApplyPropertiesVisitor ApplyPropertiesVisitor")]
38         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.ApplyPropertiesVisitor C")]
39         [Property("SPEC_URL", "-")]
40         [Property("CRITERIA", "CONSTR")]
41         [Property("AUTHOR", "guowei.wang@samsung.com")]
42         public void ApplyPropertiesVisitorConstructor()
43         {
44             tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor START");
45
46             var testingTarget = new ApplyPropertiesVisitor(new HydrationContext(), false);
47             Assert.IsNotNull(testingTarget, "Can't create success object ApplyPropertiesVisitor");
48             Assert.IsInstanceOf<ApplyPropertiesVisitor>(testingTarget, "Should be an instance of ApplyPropertiesVisitor type.");
49
50             tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor END (OK)");
51         }
52
53         [Test]
54         [Category("P1")]
55         [Description("ApplyPropertiesVisitor Skips.")]
56         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.Skips M")]
57         [Property("SPEC_URL", "-")]
58         [Property("CRITERIA", "MR")]
59         [Property("AUTHOR", "guowei.wang@samsung.com")]
60         public void ApplyPropertiesVisitorSkips()
61         {
62             tlog.Debug(tag, $"ApplyPropertiesVisitorSkips START");
63
64             var testingTarget = ApplyPropertiesVisitor.Skips;
65             Assert.IsNotNull(testingTarget, "Can't create success object ApplyPropertiesVisitor");
66             Assert.IsInstanceOf<IList<XmlName>>(testingTarget, "Should be an instance of IList<XmlName> type.");
67
68             tlog.Debug(tag, $"ApplyPropertiesVisitorSkips END (OK)");
69         }
70
71         [Test]
72         [Category("P1")]
73         [Description("ApplyPropertiesVisitor VisitingMode")]
74         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.VisitingMode M")]
75         [Property("SPEC_URL", "-")]
76         [Property("CRITERIA", "MR")]
77         [Property("AUTHOR", "guowei.wang@samsung.com")]
78         public void ApplyPropertiesVisitorVisitingMode()
79         {
80             tlog.Debug(tag, $"ApplyPropertiesVisitorVisitingMode START");
81
82             try
83             {
84                 var result = visitor.VisitingMode;
85                 tlog.Debug(tag, "VisitingMode : " + result);
86             }
87             catch (Exception e)
88             {
89                 tlog.Debug(tag, e.Message.ToString());
90                 Assert.Fail("Caught Exception : Failed!");
91             }
92
93             tlog.Debug(tag, $"ApplyPropertiesVisitorVisitingMode END (OK)");
94         }
95
96         [Test]
97         [Category("P1")]
98         [Description("ApplyPropertiesVisitor StopOnDataTemplate")]
99         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.StopOnDataTemplate M")]
100         [Property("SPEC_URL", "-")]
101         [Property("CRITERIA", "MR")]
102         [Property("AUTHOR", "guowei.wang@samsung.com")]
103         public void ApplyPropertiesVisitorStopOnDataTemplate()
104         {
105             tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnDataTemplate START");
106
107             try
108             {
109                 var result = visitor.StopOnDataTemplate;
110                 tlog.Debug(tag, "StopOnDataTemplate : " + result);
111             }
112             catch (Exception e)
113             {
114                 tlog.Debug(tag, e.Message.ToString());
115                 Assert.Fail("Caught Exception : Failed!");
116             }
117
118             tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnDataTemplate END (OK)");
119         }
120
121         [Test]
122         [Category("P1")]
123         [Description("ApplyPropertiesVisitor StopOnResourceDictionary ")]
124         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.StopOnResourceDictionary A")]
125         [Property("SPEC_URL", "-")]
126         [Property("CRITERIA", "PRW")]
127         [Property("AUTHOR", "guowei.wang@samsung.com")]
128         public void ApplyPropertiesVisitorStopOnResourceDictionary()
129         {
130             tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnResourceDictionary START");
131
132             try
133             {
134                 var result = visitor.StopOnResourceDictionary;
135                 tlog.Debug(tag, "StopOnResourceDictionary : " + result);
136             }
137             catch (Exception e)
138             {
139                 tlog.Debug(tag, e.Message.ToString());
140                 Assert.Fail("Caught Exception : Failed!");
141             }
142
143             tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnResourceDictionary END (OK)");
144         }
145
146         [Test]
147         [Category("P1")]
148         [Description("ApplyPropertiesVisitor VisitNodeOnDataTemplate ")]
149         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.VisitNodeOnDataTemplate M")]
150         [Property("SPEC_URL", "-")]
151         [Property("CRITERIA", "MR")]
152         [Property("AUTHOR", "guowei.wang@samsung.com")]
153         public void ApplyPropertiesVisitorVisitNodeOnDataTemplate()
154         {
155             tlog.Debug(tag, $"ApplyPropertiesVisitorVisitNodeOnDataTemplate START");
156
157             try
158             {
159                 var result = visitor.VisitNodeOnDataTemplate;
160                 tlog.Debug(tag, "VisitNodeOnDataTemplate : " + result);
161             }
162             catch (Exception e)
163             {
164                 tlog.Debug(tag, e.Message.ToString());
165                 Assert.Fail("Caught Exception : Failed!");
166             }
167
168             tlog.Debug(tag, $"ApplyPropertiesVisitorVisitNodeOnDataTemplate END (OK)");
169         }
170
171         internal class INodeImplement : INode
172         {
173             public global::System.Collections.Generic.List<string> IgnorablePrefixes { get; set; }
174
175             public global::System.Xml.IXmlNamespaceResolver NamespaceResolver => new XmlNamespaceResolver();
176
177             public INode Parent { get; set; }
178
179             public void Accept(IXamlNodeVisitor visitor, INode parentNode) { }
180
181             public INode Clone()
182             {
183                 return null;
184             }
185         }
186
187         [Test]
188         [Category("P1")]
189         [Description("ApplyPropertiesVisitor SkipChildren")]
190         [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.SkipChildren M")]
191         [Property("SPEC_URL", "-")]
192         [Property("CRITERIA", "MR")]
193         public void ApplyPropertiesVisitorSkipChildren()
194         {
195             tlog.Debug(tag, $"ApplyPropertiesVisitorSkipChildren START");
196
197             try
198             {
199                 INodeImplement n1 = new INodeImplement();
200                 INodeImplement n2 = new INodeImplement();
201                 bool b1 = visitor.SkipChildren(n1, n2);
202             }
203             catch (Exception e)
204             {
205                 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
206                 Assert.Fail("Caught Exception" + e.ToString());
207             }
208
209             tlog.Debug(tag, $"ApplyPropertiesVisitorSkipChildren END (OK)");
210             Assert.Pass("ApplyPropertiesVisitorSkipChildren");
211         }
212
213         public class IXmlNamespaceResolverImplement : IXmlNamespaceResolver
214         {
215             public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
216             {
217                 throw new NotImplementedException();
218             }
219
220             public string LookupNamespace(string prefix)
221             {
222                 throw new NotImplementedException();
223             }
224
225             public string LookupPrefix(string namespaceName)
226             {
227                 throw new NotImplementedException();
228             }
229         }
230
231         //[Test]
232         //[Category("P1")]
233         //[Description("ApplyPropertiesVisitor IsResourceDictionary")]
234         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.IsResourceDictionary M")]
235         //[Property("SPEC_URL", "-")]
236         //[Property("CRITERIA", "MR")]
237         //public void ApplyPropertiesVisitorIsResourceDictionary()
238         //{
239         //    tlog.Debug(tag, $"ApplyPropertiesVisitorIsResourceDictionary START");
240
241         //    try
242         //    {
243         //        IList<XmlType> list = null;
244         //        XmlType xmlType = new XmlType("myNameSpace", "myName", list);
245
246         //        IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
247         //        ElementNode n1 = new ElementNode(xmlType, "myNameSpace", i1);
248         //        bool b1 = visitor.IsResourceDictionary(n1);
249         //    }
250         //    catch (Exception e)
251         //    {
252         //        tlog.Debug(tag, e.Message.ToString());
253         //        tlog.Debug(tag, $"ApplyPropertiesVisitorIsResourceDictionary END (OK)");
254         //        Assert.Pass("Caught Exception : passed!");
255         //    }
256
257         //}
258
259         //[Test]
260         //[Category("P1")]
261         //[Description("ApplyPropertiesVisitor Visit. With ValueNode.")]
262         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.Visit M")]
263         //[Property("SPEC_URL", "-")]
264         //[Property("CRITERIA", "MR")]
265         //public void ApplyPropertiesVisitorVisitWithValueNode()
266         //{
267         //    tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithValueNode START");
268
269         //    try
270         //    {
271         //        object o1 = new object();
272         //        IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
273         //        ValueNode valueNode = new ValueNode(o1, i1);
274
275         //        INodeImplement nodeImplement = new INodeImplement();
276         //        visitor.Visit(valueNode, nodeImplement);
277         //    }
278         //    catch (Exception e)
279         //    {
280         //        tlog.Debug(tag, e.Message.ToString());
281         //        tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithValueNode END (OK)");
282         //        Assert.Pass("Caught Exception : passed!");
283         //    }
284         //}
285
286         //[Test]
287         //[Category("P1")]
288         //[Description("ApplyPropertiesVisitor Visit. With ElementNode.")]
289         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.Visit M")]
290         //[Property("SPEC_URL", "-")]
291         //[Property("CRITERIA", "MR")]
292         //public void ApplyPropertiesVisitorVisitWithElementNode()
293         //{
294         //    tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithElementNode START");
295
296         //    try
297         //    {
298         //        INodeImplement nodeImplement = new INodeImplement();
299
300         //        IList<XmlType> list = null;
301         //        XmlType xmlType = new XmlType("myNameSpace", "myName", list);
302
303         //        IXmlNamespaceResolverImplement ix1 = new IXmlNamespaceResolverImplement();
304         //        ElementNode n1 = new ElementNode(xmlType, "myNameSpace", ix1);
305
306         //        visitor.Visit(n1, nodeImplement);
307         //    }
308         //    catch (Exception e)
309         //    {
310         //        tlog.Debug(tag, e.Message.ToString());
311         //        tlog.Debug(tag, $"ApplyPropertiesVisitorVisit END (OK)");
312         //        Assert.Pass("Caught Exception : passed!");
313         //    }
314         //}
315
316         //[Test]
317         //[Category("P1")]
318         //[Description("ApplyPropertiesVisitor TryGetPropertyName")]
319         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.TryGetPropertyName M")]
320         //[Property("SPEC_URL", "-")]
321         //[Property("CRITERIA", "MR")]
322         //public void ApplyPropertiesVisitorTryGetPropertyName()
323         //{
324         //    tlog.Debug(tag, $"ApplyPropertiesVisitorTryGetPropertyName START");
325
326         //    try
327         //    {
328         //        INodeImplement n1 = new INodeImplement();
329         //        INodeImplement n2 = new INodeImplement();
330         //        XmlName xmlName = new XmlName();
331         //        ApplyPropertiesVisitor.TryGetPropertyName(n1, n2, out xmlName);
332         //    }
333         //    catch (Exception e)
334         //    {
335         //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
336         //        Assert.Fail("Caught Exception" + e.ToString());
337         //    }
338
339         //    tlog.Debug(tag, $"ApplyPropertiesVisitorTryGetPropertyName END (OK)");
340         //    Assert.Pass("ApplyPropertiesVisitorTryGetPropertyName");
341         //}
342
343         //[Test]
344         //[Category("P1")]
345         //[Description("ApplyPropertiesVisitor IsCollectionItem")]
346         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.IsCollectionItem M")]
347         //[Property("SPEC_URL", "-")]
348         //[Property("CRITERIA", "MR")]
349         //public void ApplyPropertiesVisitorIsCollectionItem()
350         //{
351         //    tlog.Debug(tag, $"ApplyPropertiesVisitorIsCollectionItem START");
352
353         //    try
354         //    {
355         //        INodeImplement n1 = new INodeImplement();
356         //        INodeImplement n2 = new INodeImplement();
357
358         //        ApplyPropertiesVisitor.IsCollectionItem(n1, n2);
359         //    }
360         //    catch (Exception e)
361         //    {
362         //        Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
363         //        Assert.Fail("Caught Exception" + e.ToString());
364         //    }
365
366         //    tlog.Debug(tag, $"ApplyPropertiesVisitorIsCollectionItem END (OK)");
367         //    Assert.Pass("ApplyPropertiesVisitorIsCollectionItem");
368         //}
369
370         //[Test]
371         //[Category("P1")]
372         //[Description("ApplyPropertiesVisitor GetContentPropertyName")]
373         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.GetContentPropertyName M")]
374         //[Property("SPEC_URL", "-")]
375         //[Property("CRITERIA", "MR")]
376         //[Property("AUTHOR", "guowei.wang@samsung.com")]
377         //public void ApplyPropertiesVisitorGetContentPropertyName()
378         //{
379         //    tlog.Debug(tag, $"ApplyPropertiesVisitorGetContentPropertyName START");
380
381         //    try
382         //    {
383         //        var typeInfo = new BindingExtension().GetType().GetTypeInfo();
384         //        ApplyPropertiesVisitor.GetContentPropertyName(typeInfo);
385         //    }
386         //    catch (Exception e)
387         //    {
388         //        tlog.Debug(tag, e.Message.ToString());
389         //        Assert.Fail("Caught Exception : Failed!");
390         //    }
391
392         //    tlog.Debug(tag, $"ApplyPropertiesVisitorGetContentPropertyName END (OK)");
393         //}
394
395         //public class IXmlLineInfoImplement : IXmlLineInfo
396         //{
397         //    public int LineNumber => throw new NotImplementedException();
398
399         //    public int LinePosition => throw new NotImplementedException();
400
401         //    public bool HasLineInfo()
402         //    {
403         //        throw new NotImplementedException();
404         //    }
405         //}
406
407         //[Test]
408         //[Category("P1")]
409         //[Description("ApplyPropertiesVisitor SetPropertyValue")]
410         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.SetPropertyValue M")]
411         //[Property("SPEC_URL", "-")]
412         //[Property("CRITERIA", "MR")]
413         //public void ApplyPropertiesVisitorProvideValue()
414         //{
415         //    tlog.Debug(tag, $"ApplyPropertiesVisitorSetPropertyValue START");
416
417         //    try
418         //    {
419         //        object o1 = new object();
420         //        XmlName xmlName = new XmlName();
421         //        object value = new object();
422         //        object rootElement = new object();
423         //        INodeImplement nodeImplement = new INodeImplement();
424         //        HydrationContext context = new HydrationContext();
425         //        IXmlLineInfoImplement xmlLineInfoImplement = new IXmlLineInfoImplement();
426
427         //        ApplyPropertiesVisitor.SetPropertyValue(o1, xmlName, value, rootElement, nodeImplement, context, xmlLineInfoImplement);
428         //    }
429         //    catch (Exception e)
430         //    {
431         //        tlog.Debug(tag, e.Message.ToString());
432         //        tlog.Debug(tag, $"ApplyPropertiesVisitorSetPropertyValue END (OK)");
433         //        Assert.Pass("Caught Exception : passed!");
434         //    }
435         //}
436
437         //[Test]
438         //[Category("P1")]
439         //[Description("ApplyPropertiesVisitor GetPropertyValue")]
440         //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.GetPropertyValue M")]
441         //[Property("SPEC_URL", "-")]
442         //[Property("CRITERIA", "MR")]
443         //public void ApplyPropertiesVisitorGetPropertyValue()
444         //{
445         //    tlog.Debug(tag, $"ApplyPropertiesVisitorGetPropertyValue START");
446
447         //    try
448         //    {
449         //        object o1 = new object();
450         //        XmlName xmlName = new XmlName();
451         //        object value = new object();
452         //        INodeImplement nodeImplement = new INodeImplement();
453         //        HydrationContext context = new HydrationContext();
454         //        IXmlLineInfoImplement xmlLineInfoImplement = new IXmlLineInfoImplement();
455
456         //        ApplyPropertiesVisitor.GetPropertyValue(o1, xmlName, context, xmlLineInfoImplement, out value);
457         //    }
458         //    catch (Exception e)
459         //    {
460         //        tlog.Debug(tag, e.Message.ToString());
461         //        tlog.Debug(tag, $"ApplyPropertiesVisitorGetPropertyValue END (OK)");
462         //        Assert.Pass("Caught Exception : passed!");
463         //    }
464         //}
465     }
466 }