[NUI] Fix TCT fail issues by adding null check (#1558)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 22 Apr 2020 01:28:06 +0000 (10:28 +0900)
committerGitHub <noreply@github.com>
Wed, 22 Apr 2020 01:28:06 +0000 (10:28 +0900)
src/Tizen.NUI.Components/Controls/Button.cs
src/Tizen.NUI.Components/Controls/Slider.cs
src/Tizen.NUI.Components/Controls/Tab.cs

index e150f44..aa397c0 100755 (executable)
@@ -453,7 +453,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                textSelector.Clone(value);
+                if (value == null || textSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Button.TextSelector is null");
+                    throw new NullReferenceException("Button.TextSelector is null");
+                }
+                else
+                {
+                    textSelector.Clone(value);
+                }
             }
         }
 
@@ -470,7 +478,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                translatableTextSelector.Clone(value);
+                if (value == null || translatableTextSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Button.TranslatableTextSelector is null");
+                    throw new NullReferenceException("Button.TranslatableTextSelector is null");
+                }
+                else
+                {
+                    translatableTextSelector.Clone(value);
+                }
             }
         }
 
@@ -487,7 +503,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                textColorSelector.Clone(value);
+                if (value == null || textColorSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Button.textColorSelector is null");
+                    throw new NullReferenceException("Button.textColorSelector is null");
+                }
+                else
+                {
+                    textColorSelector.Clone(value);
+                }
             }
         }
 
@@ -504,7 +528,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                pointSizeSelector.Clone(value);
+                if (value == null || pointSizeSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Button.pointSizeSelector is null");
+                    throw new NullReferenceException("Button.pointSizeSelector is null");
+                }
+                else
+                {
+                    pointSizeSelector.Clone(value);
+                }
             }
         }
 
@@ -521,7 +553,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                iconURLSelector.Clone(value);
+                if (value == null || iconURLSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Button.iconURLSelector is null");
+                    throw new NullReferenceException("Button.iconURLSelector is null");
+                }
+                else
+                {
+                    iconURLSelector.Clone(value);
+                }
             }
         }
 
@@ -609,7 +649,7 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                if(Style != null && Style.IconRelativeOrientation != value)
+                if (Style != null && Style.IconRelativeOrientation != value)
                 {
                     Style.IconRelativeOrientation = value;
                     UpdateUIContent();
@@ -633,7 +673,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public Extents TextPadding
         {
-            get => (Extents) GetValue(TextPaddingProperty);
+            get => (Extents)GetValue(TextPaddingProperty);
             set => SetValue(TextPaddingProperty, value);
         }
 
@@ -751,7 +791,7 @@ namespace Tizen.NUI.Components
             if (null == touch) return false;
             PointStateType state = touch.GetState(0);
 
-            switch(state)
+            switch (state)
             {
                 case PointStateType.Down:
                     isPressed = true;
@@ -762,29 +802,29 @@ namespace Tizen.NUI.Components
                     UpdateState();
                     return true;
                 case PointStateType.Up:
-                {
-                    bool clicked = isPressed && isEnabled;
-
-                    isPressed = false;
-
-                    if (Style.IsSelectable != null && Style.IsSelectable == true)
-                    {
-                        SelectionChangedByTouch = touch;
-                        IsSelected = !IsSelected;
-                    }
-                    else
                     {
-                        UpdateState(touch);
+                        bool clicked = isPressed && isEnabled;
+
+                        isPressed = false;
+
+                        if (Style.IsSelectable != null && Style.IsSelectable == true)
+                        {
+                            SelectionChangedByTouch = touch;
+                            IsSelected = !IsSelected;
+                        }
+                        else
+                        {
+                            UpdateState(touch);
+                        }
+
+                        if (clicked)
+                        {
+                            ClickEventArgs eventArgs = new ClickEventArgs();
+                            OnClickInternal(eventArgs);
+                        }
+
+                        return true;
                     }
-
-                    if (clicked)
-                    {
-                        ClickEventArgs eventArgs = new ClickEventArgs();
-                        OnClickInternal(eventArgs);
-                    }
-
-                    return true;
-                }
                 default:
                     break;
             }
index fc46ae7..2973c1c 100755 (executable)
@@ -428,7 +428,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                thumbImageURLSelector.Clone(value);
+                if (value == null || thumbImageURLSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Slider.ThumbImageURLSelector is null");
+                    throw new NullReferenceException("Slider.ThumbImageURLSelector is null");
+                }
+                else
+                {
+                    thumbImageURLSelector.Clone(value);
+                }
             }
         }
 
index 3606a82..892be3e 100755 (executable)
@@ -301,7 +301,15 @@ namespace Tizen.NUI.Components
             }
             set
             {
-                textColorSelector.Clone(value);
+                if (value == null || textColorSelector == null)
+                {
+                    Tizen.Log.Fatal("NUI", "[Exception] Tab.TextColorSelector is null");
+                    throw new NullReferenceException("Tab.TextColorSelector is null");
+                }
+                else
+                {
+                    textColorSelector.Clone(value);
+                }
             }
         }