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