From 1ff21f30093c067576b8d05486efdb336981e828 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 24 Mar 2021 11:19:44 +0900 Subject: [PATCH] [NUI] VectorGraphics: Add exception handling for Drawable.Transform() --- .../BaseComponents/VectorGraphcis/Drawable.cs | 11 ++++++++ .../Tizen.NUI.Samples/Samples/CanvasViewSamsple.cs | 33 +++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphcis/Drawable.cs b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphcis/Drawable.cs index 1d2a94a..e03d5bf 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphcis/Drawable.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphcis/Drawable.cs @@ -14,6 +14,7 @@ * limitations under the License. * */ +using System; using System.ComponentModel; namespace Tizen.NUI.BaseComponents.VectorGraphics @@ -80,9 +81,19 @@ namespace Tizen.NUI.BaseComponents.VectorGraphics /// /// The float type array of 3x3 matrix. /// True when it's successful. False otherwise. + /// Thrown when matrix is null. + /// Thrown when matrix array length is not 9. [EditorBrowsable(EditorBrowsableState.Never)] public bool Transform(float[] matrix) { + if (matrix == null) + { + throw new ArgumentNullException(nameof(matrix)); + } + if (matrix.Length != 9) + { + throw new ArgumentException("matrix array length is not 9.", nameof(matrix)); + } bool ret = Interop.Drawable.Transform(BaseHandle.getCPtr(this), matrix); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CanvasViewSamsple.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CanvasViewSamsple.cs index f8c343a..23165ed 100644 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CanvasViewSamsple.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/CanvasViewSamsple.cs @@ -1,8 +1,7 @@ +using System; +using System.Collections.Generic; using Tizen.NUI.BaseComponents; using Tizen.NUI.BaseComponents.VectorGraphics; -using System.Collections.Generic; -using System.Collections.ObjectModel; - namespace Tizen.NUI.Samples { @@ -61,7 +60,7 @@ namespace Tizen.NUI.Samples StrokeDash = new List(){15.0f, 30.0f}.AsReadOnly(), }; shape2.AddCircle(0.0f, 0.0f, 150.0f, 100.0f); - shape2.Transform(new float[] {0.6f, 0.0f, 350.0f, 0.0f, 0.6f, 100.0f, 0.0f, 0.0f, 1.0f}); + shape2.Transform(new float[] {0.6f, 0.0f, 350.0f, 0.0f, 0.6f, 100.0f, 0.0f, 0.0f, 1.0f}); canvasView.AddDrawable(shape2); @@ -135,6 +134,32 @@ namespace Tizen.NUI.Samples { log.Debug(tag, "Shape4 StrokeDash : " + shape2.StrokeDash[i] + "\n"); } + + // Exception test. + try + { + shape2.Transform(new float[] {0.6f, 0.0f}); + } + catch (ArgumentException e) + { + log.Debug(tag, "Transform : " + e.Message + "\n"); + } + try + { + shape2.Transform(null); + } + catch (ArgumentException e) + { + log.Debug(tag, "Transform : " + e.Message + "\n"); + } + try + { + shape2.StrokeDash = null; + } + catch (ArgumentException e) + { + log.Debug(tag, "StrokeDash setter : " + e.Message + "\n"); + } root.Add(canvasView); -- 2.7.4