[NUI] Fix failed TCs of NUI.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Devel.Tests / testcase / public / Utility / TSGraphicsTypeConverter.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 namespace Tizen.NUI.Devel.Tests
9 {
10     using tlog = Tizen.Log;
11
12     [TestFixture]
13     [Description("public/Utility/GraphicsTypeConverter")]
14     public class PublicGraphicsTypeConverterTest
15     {
16         private const string tag = "NUITEST";
17
18         [SetUp]
19         public void Init()
20         {
21             tlog.Info(tag, "Init() is called!");
22         }
23
24         [TearDown]
25         public void Destroy()
26         {
27             tlog.Info(tag, "Destroy() is called!");
28         }
29
30         internal class MyGraphicsTypeConverter : GraphicsTypeConverter
31         {
32             public MyGraphicsTypeConverter() : base()
33             { }
34
35             public override float ConvertScriptToPixel(string scriptValue)
36             {
37                 return base.ConvertScriptToPixel(scriptValue);
38             }
39
40             public override float ConvertFromPixel(float scriptValue)
41             {
42                 return base.ConvertFromPixel(scriptValue);
43             }
44         }
45
46         [Test]
47         [Category("P1")]
48         [Description("GraphicsTypeConverter ConvertScriptToPixel.")]
49         [Property("SPEC", "Tizen.NUI.GraphicsTypeConverter.ConvertScriptToPixel M")]
50         [Property("SPEC_URL", "-")]
51         [Property("CRITERIA", "MR")]
52         [Property("AUTHOR", "guowei.wang@samsung.com")]
53         public void GraphicsTypeConverterConvertScriptToPixel()
54         {
55             tlog.Debug(tag, $"GraphicsTypeConverterConvertScriptToPixel START");
56
57             var testingTarget = new MyGraphicsTypeConverter();
58             Assert.IsNotNull(testingTarget, "Can't create success object GraphicsTypeConverter");
59             Assert.IsInstanceOf<GraphicsTypeConverter>(testingTarget, "Should be an instance of GraphicsTypeConverter type.");
60
61             var result = testingTarget.ConvertScriptToPixel("160dp");
62             tlog.Debug(tag, "ConvertScriptToPixel : " + result);
63
64             result = testingTarget.ConvertScriptToPixel("160px");
65             tlog.Debug(tag, "ConvertScriptToPixel : " + result);
66
67             result = testingTarget.ConvertScriptToPixel("160.0f");
68             tlog.Debug(tag, "ConvertScriptToPixel : " + result);
69
70             tlog.Debug(tag, $"GraphicsTypeConverterConvertScriptToPixel END (OK)");
71         }
72
73         [Test]
74         [Category("P1")]
75         [Description("GraphicsTypeConverter ConvertFromPixel.")]
76         [Property("SPEC", "Tizen.NUI.GraphicsTypeConverter.ConvertFromPixel M")]
77         [Property("SPEC_URL", "-")]
78         [Property("CRITERIA", "MR")]
79         [Property("AUTHOR", "guowei.wang@samsung.com")]
80         public void GraphicsTypeConverterConvertFromPixel()
81         {
82             tlog.Debug(tag, $"GraphicsTypeConverterConvertFromPixel START");
83
84             var testingTarget = new MyGraphicsTypeConverter();
85             Assert.IsNotNull(testingTarget, "Can't create success object GraphicsTypeConverter");
86             Assert.IsInstanceOf<GraphicsTypeConverter>(testingTarget, "Should be an instance of GraphicsTypeConverter type.");
87
88             var result = testingTarget.ConvertFromPixel(160.0f);
89             Assert.IsNotNull(result);
90
91             tlog.Debug(tag, $"GraphicsTypeConverterConvertFromPixel END (OK)");
92         }
93     }
94 }