1 using NUnit.Framework;
3 using System.Collections.Generic;
4 using System.Reflection;
8 namespace Tizen.NUI.Devel.Tests
10 using tlog = Tizen.Log;
13 [Description("internal/Xaml/ApplyPropertiesVisitor")]
14 public class InternalXamlApplyPropertiesVisitorTest
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;
23 tlog.Info(tag, "Init() is called!");
24 HydrationContext context = new HydrationContext();
25 visitor = new ApplyPropertiesVisitor(context, false);
32 tlog.Info(tag, "Destroy() is called!");
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()
44 tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor START");
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.");
50 tlog.Debug(tag, $"ApplyPropertiesVisitorConstructor END (OK)");
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()
62 tlog.Debug(tag, $"ApplyPropertiesVisitorSkips START");
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.");
68 tlog.Debug(tag, $"ApplyPropertiesVisitorSkips END (OK)");
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()
80 tlog.Debug(tag, $"ApplyPropertiesVisitorVisitingMode START");
84 var result = visitor.VisitingMode;
85 tlog.Debug(tag, "VisitingMode : " + result);
89 tlog.Debug(tag, e.Message.ToString());
90 Assert.Fail("Caught Exception : Failed!");
93 tlog.Debug(tag, $"ApplyPropertiesVisitorVisitingMode END (OK)");
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()
105 tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnDataTemplate START");
109 var result = visitor.StopOnDataTemplate;
110 tlog.Debug(tag, "StopOnDataTemplate : " + result);
114 tlog.Debug(tag, e.Message.ToString());
115 Assert.Fail("Caught Exception : Failed!");
118 tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnDataTemplate END (OK)");
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()
130 tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnResourceDictionary START");
134 var result = visitor.StopOnResourceDictionary;
135 tlog.Debug(tag, "StopOnResourceDictionary : " + result);
139 tlog.Debug(tag, e.Message.ToString());
140 Assert.Fail("Caught Exception : Failed!");
143 tlog.Debug(tag, $"ApplyPropertiesVisitorStopOnResourceDictionary END (OK)");
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()
155 tlog.Debug(tag, $"ApplyPropertiesVisitorVisitNodeOnDataTemplate START");
159 var result = visitor.VisitNodeOnDataTemplate;
160 tlog.Debug(tag, "VisitNodeOnDataTemplate : " + result);
164 tlog.Debug(tag, e.Message.ToString());
165 Assert.Fail("Caught Exception : Failed!");
168 tlog.Debug(tag, $"ApplyPropertiesVisitorVisitNodeOnDataTemplate END (OK)");
171 internal class INodeImplement : INode
173 public global::System.Collections.Generic.List<string> IgnorablePrefixes { get; set; }
175 public global::System.Xml.IXmlNamespaceResolver NamespaceResolver => new XmlNamespaceResolver();
177 public INode Parent { get; set; }
179 public void Accept(IXamlNodeVisitor visitor, INode parentNode) { }
189 [Description("ApplyPropertiesVisitor SkipChildren")]
190 [Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.SkipChildren M")]
191 [Property("SPEC_URL", "-")]
192 [Property("CRITERIA", "MR")]
193 public void ApplyPropertiesVisitorSkipChildren()
195 tlog.Debug(tag, $"ApplyPropertiesVisitorSkipChildren START");
199 INodeImplement n1 = new INodeImplement();
200 INodeImplement n2 = new INodeImplement();
201 bool b1 = visitor.SkipChildren(n1, n2);
205 Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
206 Assert.Fail("Caught Exception" + e.ToString());
209 tlog.Debug(tag, $"ApplyPropertiesVisitorSkipChildren END (OK)");
210 Assert.Pass("ApplyPropertiesVisitorSkipChildren");
213 public class IXmlNamespaceResolverImplement : IXmlNamespaceResolver
215 public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
217 throw new NotImplementedException();
220 public string LookupNamespace(string prefix)
222 throw new NotImplementedException();
225 public string LookupPrefix(string namespaceName)
227 throw new NotImplementedException();
233 //[Description("ApplyPropertiesVisitor IsResourceDictionary")]
234 //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.IsResourceDictionary M")]
235 //[Property("SPEC_URL", "-")]
236 //[Property("CRITERIA", "MR")]
237 //public void ApplyPropertiesVisitorIsResourceDictionary()
239 // tlog.Debug(tag, $"ApplyPropertiesVisitorIsResourceDictionary START");
243 // IList<XmlType> list = null;
244 // XmlType xmlType = new XmlType("myNameSpace", "myName", list);
246 // IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
247 // ElementNode n1 = new ElementNode(xmlType, "myNameSpace", i1);
248 // bool b1 = visitor.IsResourceDictionary(n1);
250 // catch (Exception e)
252 // tlog.Debug(tag, e.Message.ToString());
253 // tlog.Debug(tag, $"ApplyPropertiesVisitorIsResourceDictionary END (OK)");
254 // Assert.Pass("Caught Exception : passed!");
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()
267 // tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithValueNode START");
271 // object o1 = new object();
272 // IXmlNamespaceResolverImplement i1 = new IXmlNamespaceResolverImplement();
273 // ValueNode valueNode = new ValueNode(o1, i1);
275 // INodeImplement nodeImplement = new INodeImplement();
276 // visitor.Visit(valueNode, nodeImplement);
278 // catch (Exception e)
280 // tlog.Debug(tag, e.Message.ToString());
281 // tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithValueNode END (OK)");
282 // Assert.Pass("Caught Exception : passed!");
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()
294 // tlog.Debug(tag, $"ApplyPropertiesVisitorVisitWithElementNode START");
298 // INodeImplement nodeImplement = new INodeImplement();
300 // IList<XmlType> list = null;
301 // XmlType xmlType = new XmlType("myNameSpace", "myName", list);
303 // IXmlNamespaceResolverImplement ix1 = new IXmlNamespaceResolverImplement();
304 // ElementNode n1 = new ElementNode(xmlType, "myNameSpace", ix1);
306 // visitor.Visit(n1, nodeImplement);
308 // catch (Exception e)
310 // tlog.Debug(tag, e.Message.ToString());
311 // tlog.Debug(tag, $"ApplyPropertiesVisitorVisit END (OK)");
312 // Assert.Pass("Caught Exception : passed!");
318 //[Description("ApplyPropertiesVisitor TryGetPropertyName")]
319 //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.TryGetPropertyName M")]
320 //[Property("SPEC_URL", "-")]
321 //[Property("CRITERIA", "MR")]
322 //public void ApplyPropertiesVisitorTryGetPropertyName()
324 // tlog.Debug(tag, $"ApplyPropertiesVisitorTryGetPropertyName START");
328 // INodeImplement n1 = new INodeImplement();
329 // INodeImplement n2 = new INodeImplement();
330 // XmlName xmlName = new XmlName();
331 // ApplyPropertiesVisitor.TryGetPropertyName(n1, n2, out xmlName);
333 // catch (Exception e)
335 // Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
336 // Assert.Fail("Caught Exception" + e.ToString());
339 // tlog.Debug(tag, $"ApplyPropertiesVisitorTryGetPropertyName END (OK)");
340 // Assert.Pass("ApplyPropertiesVisitorTryGetPropertyName");
345 //[Description("ApplyPropertiesVisitor IsCollectionItem")]
346 //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.IsCollectionItem M")]
347 //[Property("SPEC_URL", "-")]
348 //[Property("CRITERIA", "MR")]
349 //public void ApplyPropertiesVisitorIsCollectionItem()
351 // tlog.Debug(tag, $"ApplyPropertiesVisitorIsCollectionItem START");
355 // INodeImplement n1 = new INodeImplement();
356 // INodeImplement n2 = new INodeImplement();
358 // ApplyPropertiesVisitor.IsCollectionItem(n1, n2);
360 // catch (Exception e)
362 // Tizen.Log.Error(tag, "Caught Exception" + e.ToString());
363 // Assert.Fail("Caught Exception" + e.ToString());
366 // tlog.Debug(tag, $"ApplyPropertiesVisitorIsCollectionItem END (OK)");
367 // Assert.Pass("ApplyPropertiesVisitorIsCollectionItem");
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()
379 // tlog.Debug(tag, $"ApplyPropertiesVisitorGetContentPropertyName START");
383 // var typeInfo = new BindingExtension().GetType().GetTypeInfo();
384 // ApplyPropertiesVisitor.GetContentPropertyName(typeInfo);
386 // catch (Exception e)
388 // tlog.Debug(tag, e.Message.ToString());
389 // Assert.Fail("Caught Exception : Failed!");
392 // tlog.Debug(tag, $"ApplyPropertiesVisitorGetContentPropertyName END (OK)");
395 //public class IXmlLineInfoImplement : IXmlLineInfo
397 // public int LineNumber => throw new NotImplementedException();
399 // public int LinePosition => throw new NotImplementedException();
401 // public bool HasLineInfo()
403 // throw new NotImplementedException();
409 //[Description("ApplyPropertiesVisitor SetPropertyValue")]
410 //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.SetPropertyValue M")]
411 //[Property("SPEC_URL", "-")]
412 //[Property("CRITERIA", "MR")]
413 //public void ApplyPropertiesVisitorProvideValue()
415 // tlog.Debug(tag, $"ApplyPropertiesVisitorSetPropertyValue START");
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();
427 // ApplyPropertiesVisitor.SetPropertyValue(o1, xmlName, value, rootElement, nodeImplement, context, xmlLineInfoImplement);
429 // catch (Exception e)
431 // tlog.Debug(tag, e.Message.ToString());
432 // tlog.Debug(tag, $"ApplyPropertiesVisitorSetPropertyValue END (OK)");
433 // Assert.Pass("Caught Exception : passed!");
439 //[Description("ApplyPropertiesVisitor GetPropertyValue")]
440 //[Property("SPEC", "Tizen.NUI.ApplyPropertiesVisitor.GetPropertyValue M")]
441 //[Property("SPEC_URL", "-")]
442 //[Property("CRITERIA", "MR")]
443 //public void ApplyPropertiesVisitorGetPropertyValue()
445 // tlog.Debug(tag, $"ApplyPropertiesVisitorGetPropertyValue START");
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();
456 // ApplyPropertiesVisitor.GetPropertyValue(o1, xmlName, context, xmlLineInfoImplement, out value);
458 // catch (Exception e)
460 // tlog.Debug(tag, e.Message.ToString());
461 // tlog.Debug(tag, $"ApplyPropertiesVisitorGetPropertyValue END (OK)");
462 // Assert.Pass("Caught Exception : passed!");