3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
7 namespace Tizen.NUI.Devel.Tests
9 using tlog = Tizen.Log;
12 [Description("Internal/Utility/ColorCutQuantizer")]
13 public class InternalColorCutQuantizerTest
15 private const string tag = "NUITEST";
20 tlog.Info(tag, "Init() is called!");
26 tlog.Info(tag, "Destroy() is called!");
31 [Description("ColorCutQuantizer FromBitmap .")]
32 [Property("SPEC", "Tizen.NUI.ColorCutQuantizer.FromBitmap M")]
33 [Property("SPEC_URL", "-")]
34 [Property("CRITERIA", "MR")]
35 [Property("AUTHOR", "guowei.wang@samsung.com")]
36 public void ColorCutQuantizerFromBitmap()
38 tlog.Debug(tag, $"ColorCutQuantizerFromBitmap START");
40 using (PixelBuffer pixelBuffer = new PixelBuffer(100, 200, PixelFormat.RGBA8888))
42 using (Rectangle region = new Rectangle())
44 var testingTarget = ColorCutQuantizer.FromBitmap(pixelBuffer, region, 255);
45 Assert.IsNotNull(testingTarget, "Should be not null!");
46 Assert.IsInstanceOf<ColorCutQuantizer>(testingTarget, "Should be an Instance of ColorCutQuantizer!");
50 tlog.Debug(tag, $"ColorCutQuantizerFromBitmap END (OK)");
55 [Description("ColorCutQuantizer FromBitmap. MaxColor < 1.")]
56 [Property("SPEC", "Tizen.NUI.ColorCutQuantizer.FromBitmap M")]
57 [Property("SPEC_URL", "-")]
58 [Property("CRITERIA", "MR")]
59 [Property("AUTHOR", "guowei.wang@samsung.com")]
60 public void ColorCutQuantizerFromBitmapWithMaxColorLessThan1()
62 tlog.Debug(tag, $"ColorCutQuantizerFromBitmapWithMaxColorLessThan1 START");
64 using (PixelBuffer pixelBuffer = new PixelBuffer(100, 200, PixelFormat.RGBA8888))
66 using (Rectangle region = new Rectangle())
70 ColorCutQuantizer.FromBitmap(pixelBuffer, region, 0);
72 catch (ArgumentNullException e)
74 tlog.Debug(tag, e.Message.ToString());
75 tlog.Debug(tag, $"ColorCutQuantizerFromBitmapWithMaxColorLessThan1 END (OK)");
76 Assert.Pass("Caught ArgumentNullException : Passed!");
84 [Description("ColorCutQuantizer FromBitmap. Region is null.")]
85 [Property("SPEC", "Tizen.NUI.ColorCutQuantizer.FromBitmap M")]
86 [Property("SPEC_URL", "-")]
87 [Property("CRITERIA", "MR")]
88 [Property("AUTHOR", "guowei.wang@samsung.com")]
89 public void ColorCutQuantizerFromBitmapWithNullRegion()
91 tlog.Debug(tag, $"ColorCutQuantizerFromBitmapWithNullRegion START");
93 using (PixelBuffer pixelBuffer = new PixelBuffer(1, 2, PixelFormat.A8))
95 using (Rectangle region = null)
97 var testingTarget = ColorCutQuantizer.FromBitmap(pixelBuffer, region, 255);
98 Assert.IsNotNull(testingTarget, "Should be not null!");
99 Assert.IsInstanceOf<ColorCutQuantizer>(testingTarget, "Should be an Instance of ColorCutQuantizer!");
103 tlog.Debug(tag, $"ColorCutQuantizerFromBitmapWithNullRegion END (OK)");
108 [Description("ColorCutQuantizer GetQuantizedColors .")]
109 [Property("SPEC", "Tizen.NUI.ColorCutQuantizer.GetQuantizedColors M")]
110 [Property("SPEC_URL", "-")]
111 [Property("CRITERIA", "MR")]
112 [Property("AUTHOR", "guowei.wang@samsung.com")]
113 public void ColorCutQuantizerGetQuantizedColors()
115 tlog.Debug(tag, $"ColorCutQuantizerGetQuantizedColors START");
117 using (PixelBuffer pixelBuffer = new PixelBuffer(100, 200, PixelFormat.A8))
119 using (Rectangle region = new Rectangle())
121 var testingTarget = ColorCutQuantizer.FromBitmap(pixelBuffer, region, 255);
122 Assert.IsNotNull(testingTarget, "Should be not null!");
123 Assert.IsInstanceOf<ColorCutQuantizer>(testingTarget, "Should be an Instance of ColorCutQuantizer!");
127 testingTarget.GetQuantizedColors();
128 tlog.Debug(tag, "quantizedColors : " + testingTarget.GetQuantizedColors());
132 tlog.Debug(tag, e.Message.ToString());
133 Assert.Fail("Caught Exception: Failed!");
138 tlog.Debug(tag, $"ColorCutQuantizerGetQuantizedColors END (OK)");