3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7 using System.Threading.Tasks;
9 namespace Tizen.NUI.Devel.Tests
11 using tlog = Tizen.Log;
14 [Description("public/Utility/FontClient")]
17 private const string tag = "NUITEST";
18 private string ttf_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "TizenSansRegular.ttf";
23 tlog.Info(tag, "Init() is called!");
29 tlog.Info(tag, "Destroy() is called!");
32 internal class MySWIGTYPE_p_unsigned_int : SWIGTYPE_p_unsigned_int
34 public MySWIGTYPE_p_unsigned_int() : base()
40 [Description("FontClient constructor.")]
41 [Property("SPEC", "Tizen.NUI.FontClient.FontClient C")]
42 [Property("SPEC_URL", "-")]
43 [Property("CRITERIA", "CONSTR")]
44 [Property("AUTHOR", "guowei.wang@samsung.com")]
45 public void FontClientConstructor()
47 tlog.Debug(tag, $"FontClientConstructor START");
49 var testingTarget = new FontClient();
50 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
51 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
53 testingTarget.Dispose();
55 tlog.Debug(tag, $"FontClientConstructor END (OK)");
60 [Description("FontClient constructor. With FontClient")]
61 [Property("SPEC", "Tizen.NUI.FontClient.FontClient C")]
62 [Property("SPEC_URL", "-")]
63 [Property("CRITERIA", "CONSTR")]
64 [Property("AUTHOR", "guowei.wang@samsung.com")]
65 public void FontClientConstructorWithFontClient()
67 tlog.Debug(tag, $"FontClientConstructorWithFontClient START");
69 using (FontClient instance = FontClient.Instance)
71 var testingTarget = new FontClient(instance);
72 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
73 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
75 testingTarget.Dispose();
78 tlog.Debug(tag, $"FontClientConstructorWithFontClient END (OK)");
83 [Description("FontClient DefaultPointSize.")]
84 [Property("SPEC", "Tizen.NUI.FontClient.DefaultPointSize A")]
85 [Property("SPEC_URL", "-")]
86 [Property("CRITERIA", "PRO")]
87 [Property("AUTHOR", "guowei.wang@samsung.com")]
88 public void FontClientDefaultPointSize()
90 tlog.Debug(tag, $"FontClientDefaultPointSize START");
92 var testingTarget = FontClient.DefaultPointSize;
93 Assert.AreEqual(768, testingTarget, "Should be equal!");
95 tlog.Debug(tag, $"FontClientDefaultPointSize END (OK)");
100 [Description("FontClient Assign.")]
101 [Property("SPEC", "Tizen.NUI.FontClient.Assign M")]
102 [Property("SPEC_URL", "-")]
103 [Property("CRITERIA", "MR")]
104 [Property("AUTHOR", "guowei.wang@samsung.com")]
105 public void FontClientAssign()
107 tlog.Debug(tag, $"FontClientAssign START");
109 using (FontClient fontClient = FontClient.Instance)
113 var testingTarget = fontClient.Assign(fontClient);
114 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
115 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
117 testingTarget.Dispose();
121 tlog.Debug(tag, e.Message.ToString());
122 Assert.Fail("Caught Exception: Failed!");
126 tlog.Debug(tag, $"FontClientAssign END (OK)");
131 [Description("FontClient GetDpi.")]
132 [Property("SPEC", "Tizen.NUI.FontClient.GetDpi M")]
133 [Property("SPEC_URL", "-")]
134 [Property("CRITERIA", "MR")]
135 [Property("AUTHOR", "guowei.wang@samsung.com")]
136 public void FontClientGetDpi()
138 tlog.Debug(tag, $"FontClientGetDpi START");
140 var testingTarget = new FontClient(FontClient.Instance);
141 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
142 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
144 testingTarget.SetDpi(50, 60);
148 var horizontalDpi = new SWIGTYPE_p_unsigned_int(testingTarget.GetBaseHandleCPtrHandleRef.Handle);
149 var verticalDpi = new SWIGTYPE_p_unsigned_int(new FontClient().GetBaseHandleCPtrHandleRef.Handle);
150 testingTarget.GetDpi(horizontalDpi, verticalDpi);
154 tlog.Debug(tag, e.Message.ToString());
155 Assert.Fail("Caught Exception: Failed");
158 testingTarget.Dispose();
159 tlog.Debug(tag, $"FontClientGetDpi END (OK)");
164 [Description("FontClient GetDefaultFontSize.")]
165 [Property("SPEC", "Tizen.NUI.FontClient.GetDefaultFontSize M")]
166 [Property("SPEC_URL", "-")]
167 [Property("CRITERIA", "MR")]
168 [Property("AUTHOR", "guowei.wang@samsung.com")]
169 public void FontClientGetDefaultFontSize()
171 tlog.Debug(tag, $"FontClientGetDefaultFontSize START");
173 var testingTarget = new FontClient(FontClient.Instance);
174 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
175 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
177 Assert.IsNotNull(testingTarget.GetDefaultFontSize());
179 testingTarget.Dispose();
180 tlog.Debug(tag, $"FontClientGetDefaultFontSize END (OK)");
185 [Description("FontClient GetDefaultPlatformFontDescription.")]
186 [Property("SPEC", "Tizen.NUI.FontClient.GetDefaultPlatformFontDescription M")]
187 [Property("SPEC_URL", "-")]
188 [Property("CRITERIA", "MR")]
189 [Property("AUTHOR", "guowei.wang@samsung.com")]
190 public void FontClientGetDefaultPlatformFontDescription()
192 tlog.Debug(tag, $"FontClientGetDefaultPlatformFontDescription START");
194 using (FontDescription description = new FontDescription())
196 description.Path = ttf_path;
198 var testingTarget = new FontClient(FontClient.Instance);
199 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
200 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
204 testingTarget.GetDefaultPlatformFontDescription(description);
208 tlog.Debug(tag, e.Message.ToString());
209 Assert.Fail("Caught Exception: Failed");
212 testingTarget.Dispose();
215 tlog.Debug(tag, $"FontClientGetDefaultPlatformFontDescription END (OK)");
220 [Description("FontClient IsScalable.")]
221 [Property("SPEC", "Tizen.NUI.FontClient.IsScalable M")]
222 [Property("SPEC_URL", "-")]
223 [Property("CRITERIA", "MR")]
224 [Property("AUTHOR", "guowei.wang@samsung.com")]
225 public void FontClientIsScalable()
227 tlog.Debug(tag, $"FontClientIsScalable START");
229 using (FontDescription description = new FontDescription())
231 description.Path = ttf_path;
233 var testingTarget = new FontClient(FontClient.Instance);
234 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
235 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
237 var result = testingTarget.IsScalable(description);
238 Assert.IsNotNull(result);
240 testingTarget.Dispose();
243 tlog.Debug(tag, $"FontClientIsScalable END (OK)");
248 [Description("FontClient CreateVectorBlob.")]
249 [Property("SPEC", "Tizen.NUI.FontClient.CreateVectorBlob M")]
250 [Property("SPEC_URL", "-")]
251 [Property("CRITERIA", "MR")]
252 [Property("AUTHOR", "guowei.wang@samsung.com")]
253 public void FontClientCreateVectorBlob()
255 tlog.Debug(tag, $"FontClientCreateVectorBlob START");
257 using (FontClient fontClient = FontClient.Instance)
259 var testingTarget = new FontClient(fontClient);
261 using (Color color = new Color(0.4f, 1.0f, 0.3f, 0.0f))
263 var blob = new SWIGTYPE_p_p_Dali__TextAbstraction__VectorBlob(color.SwigCPtr.Handle);
264 var blobLegnth = new SWIGTYPE_p_unsigned_int(color.SwigCPtr.Handle);
266 var nominalWidth = new SWIGTYPE_p_unsigned_int(fontClient.SwigCPtr.Handle);
267 var nominalHeight = new SWIGTYPE_p_unsigned_int(testingTarget.SwigCPtr.Handle);
271 testingTarget.CreateVectorBlob(0, 0, blob, blobLegnth, nominalWidth, nominalHeight);
275 tlog.Debug(tag, e.Message.ToString());
276 Assert.Fail("Caught Exception: Failed!");
279 testingTarget.Dispose();
283 tlog.Debug(tag, $"FontClientCreateVectorBlob END (OK)");
288 [Description("FontClient GetEllipsisGlyph.")]
289 [Property("SPEC", "Tizen.NUI.FontClient.GetEllipsisGlyph M")]
290 [Property("SPEC_URL", "-")]
291 [Property("CRITERIA", "MR")]
292 [Property("AUTHOR", "guowei.wang@samsung.com")]
293 public void FontClientGetEllipsisGlyph()
295 tlog.Debug(tag, $"FontClientGetEllipsisGlyph START");
297 var testingTarget = new FontClient(FontClient.Instance);
298 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
299 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
301 var result = testingTarget.GetEllipsisGlyph(10);
302 Assert.IsInstanceOf<GlyphInfo>(result, "Should be an instance of GlyphInfo type.");
304 testingTarget.Dispose();
305 tlog.Debug(tag, $"FontClientGetEllipsisGlyph END (OK)");
310 [Description("FontClient IsColorGlyph.")]
311 [Property("SPEC", "Tizen.NUI.FontClient.IsColorGlyph M")]
312 [Property("SPEC_URL", "-")]
313 [Property("CRITERIA", "MR")]
314 [Property("AUTHOR", "guowei.wang@samsung.com")]
315 public void FontClientIsColorGlyph()
317 tlog.Debug(tag, $"FontClientIsColorGlyph START");
319 var testingTarget = new FontClient(FontClient.Instance);
320 Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
321 Assert.IsInstanceOf<FontClient>(testingTarget, "Should be an instance of FontClient type.");
325 testingTarget.IsColorGlyph(testingTarget.GetFontId(ttf_path), testingTarget.GetGlyphIndex(0, 0x0041));
329 tlog.Debug(tag, e.Message.ToString());
330 Assert.Fail("Caugth Exception: Failed!");
333 testingTarget.Dispose();
334 tlog.Debug(tag, $"FontClientIsColorGlyph END (OK)");
339 [Description("GlyphBufferData constructor.")]
340 [Property("SPEC", "Tizen.NUI.FontClient.GlyphBufferData.GlyphBufferData C")]
341 [Property("SPEC_URL", "-")]
342 [Property("CRITERIA", "MR")]
343 [Property("AUTHOR", "guowei.wang@samsung.com")]
344 public void FontClientGlyphBufferDataConstructor()
346 tlog.Debug(tag, $"FontClientGlyphBufferDataConstructor START");
348 using (FontClient.GlyphBufferData data = new FontClient.GlyphBufferData())
350 var testingTarget = new FontClient.GlyphBufferData(FontClient.GlyphBufferData.getCPtr(data).Handle, true);
351 Assert.IsNotNull(testingTarget, "Return a null object of GlyphBufferData");
352 Assert.IsInstanceOf<FontClient.GlyphBufferData>(testingTarget, "Should be an instance of GlyphBufferData type.");
354 testingTarget.Dispose();
357 tlog.Debug(tag, $"FontClientGlyphBufferDataConstructor END (OK)");
362 [Description("GlyphBufferData Width.")]
363 [Property("SPEC", "Tizen.NUI.FontClient.GlyphBufferData.Width A")]
364 [Property("SPEC_URL", "-")]
365 [Property("CRITERIA", "PRW")]
366 [Property("AUTHOR", "guowei.wang@samsung.com")]
367 public void FontClientGlyphBufferDataWidth()
369 tlog.Debug(tag, $"FontClientGlyphBufferDataWidth START");
371 var testingTarget = new FontClient.GlyphBufferData();
372 Assert.IsNotNull(testingTarget, "Return a null object of GlyphBufferData");
373 Assert.IsInstanceOf<FontClient.GlyphBufferData>(testingTarget, "Should be an instance of GlyphBufferData type.");
375 testingTarget.Width = 100;
376 Assert.AreEqual(100, testingTarget.Width, "Should be equal!");
378 testingTarget.Dispose();
379 tlog.Debug(tag, $"FontClientGlyphBufferDataWidth END (OK)");
384 [Description("GlyphBufferData Height.")]
385 [Property("SPEC", "Tizen.NUI.FontClient.GlyphBufferData.Height A")]
386 [Property("SPEC_URL", "-")]
387 [Property("CRITERIA", "PRW")]
388 [Property("AUTHOR", "guowei.wang@samsung.com")]
389 public void FontClientGlyphBufferDataHeight()
391 tlog.Debug(tag, $"FontClientGlyphBufferDataHeight START");
393 var testingTarget = new FontClient.GlyphBufferData(); ;
394 Assert.IsNotNull(testingTarget, "Return a null object of GlyphBufferData");
395 Assert.IsInstanceOf<FontClient.GlyphBufferData>(testingTarget, "Should be an instance of GlyphBufferData type.");
397 testingTarget.Height = 50;
398 Assert.AreEqual(50, testingTarget.Height, "Should be equal!");
400 testingTarget.Dispose();
401 tlog.Debug(tag, $"FontClientGlyphBufferDataHeight END (OK)");
406 [Description("GlyphBufferData Format.")]
407 [Property("SPEC", "Tizen.NUI.FontClient.GlyphBufferData.Format A")]
408 [Property("SPEC_URL", "-")]
409 [Property("CRITERIA", "PRW")]
410 [Property("AUTHOR", "guowei.wang@samsung.com")]
411 public void FontClientGlyphBufferDataFormat()
413 tlog.Debug(tag, $"FontClientGlyphBufferDataFormat START");
415 var testingTarget = new FontClient.GlyphBufferData();
416 Assert.IsNotNull(testingTarget, "Return a null object of GlyphBufferData");
417 Assert.IsInstanceOf<FontClient.GlyphBufferData>(testingTarget, "Should be an instance of GlyphBufferData type.");
419 testingTarget.Format = PixelFormat.BGR8888;
420 Assert.AreEqual(PixelFormat.BGR8888, testingTarget.Format, "Should be equal!");
422 testingTarget.Dispose();
423 tlog.Debug(tag, $"FontClientGlyphBufferDataFormat END (OK)");