[ElmSharp.Wearable] deprecate AngleRatio, fix incorrect default value of AngleRatio... 80/161380/10
authorHyunjin <hj.na.park@samsung.com>
Thu, 23 Nov 2017 05:35:49 +0000 (14:35 +0900)
committerHyunjin <hj.na.park@samsung.com>
Thu, 30 Nov 2017 00:03:58 +0000 (09:03 +0900)
Solution : add description for deprecation, change default value to 360/(Maximum - Minimum) and fix TC to test issue case

Change-Id: I106b6c051eec80920ede8b8a49d413ac8f1838d8

src/ElmSharp.Wearable/ElmSharp.Wearable/CircleSpinner.cs
test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs [changed mode: 0755->0644]
test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs [changed mode: 0755->0644]
test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs [changed mode: 0755->0644]
test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest4.cs [new file with mode: 0644]

index c0ca700..717ff3e 100644 (file)
@@ -29,7 +29,7 @@ namespace ElmSharp.Wearable
     public class CircleSpinner : Spinner, IRotaryActionWidget
     {
         IntPtr _circleHandle;
-        double _angleRatio = 1.0;
+        double _angleRatio = -1.0;
         CircleSurface _surface;
 
         /// <summary>
@@ -73,16 +73,36 @@ namespace ElmSharp.Wearable
         /// Sets or gets the circle spinner angle per each spinner value.
         /// </summary>
         /// <since_tizen> preview </since_tizen>
+        [Obsolete("Use Step")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public double AngleRatio
         {
             get
             {
+                if(_angleRatio <= 0)
+                {
+                    if(Maximum == Minimum)
+                    {
+                        return 0.0;
+                    }
+                    else
+                    {
+                        return 360/(Maximum - Minimum);
+                    }
+                }
+
                 return _angleRatio;
             }
             set
             {
-                _angleRatio = value;
-                Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
+                if(value > 0)
+                {
+                    if (_angleRatio == value) return;
+
+                    _angleRatio = value;
+
+                    Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
+                }
             }
         }
 
old mode 100755 (executable)
new mode 100644 (file)
index 87c6a0a..d068df4
@@ -21,7 +21,7 @@ namespace ElmSharp.Test.TC
     class CircleSpinnerTest1 : TestCaseBase
     {
         public override string TestName => "CircleSpinnerTest1";
-        public override string TestDescription => "To test basic operation of Circle Spinner";
+        public override string TestDescription => "To test basic operation of Circle Spinner with no AngleRatio";
 
         public override void Run(Window window)
         {
@@ -39,9 +39,8 @@ namespace ElmSharp.Test.TC
                 Text = "Spinner Test",
                 LabelFormat = "%d Value",
                 Style = "circle",
-                AngleRatio = 3.0,
                 Minimum = 0,
-                Maximum = 360,
+                Maximum = 100,
                 Value = 0,
                 Step = 10,
                 Interval = 0.5,
old mode 100755 (executable)
new mode 100644 (file)
index 80c5372..f32d951
@@ -21,7 +21,7 @@ namespace ElmSharp.Test.TC
     class CircleSpinnerTest2 : TestCaseBase
     {
         public override string TestName => "CircleSpinnerTest2";
-        public override string TestDescription => "To test basic operation of Circle Spinner";
+        public override string TestDescription => "To test basic operation of Circle Spinner with Marker";
 
         public override void Run(Window window)
         {
old mode 100755 (executable)
new mode 100644 (file)
index 57843c8..a6a9b31
@@ -21,7 +21,7 @@ namespace ElmSharp.Test.TC
     class CircleSpinnerTest3 : TestCaseBase
     {
         public override string TestName => "CircleSpinnerTest3";
-        public override string TestDescription => "To test basic operation of Circle Spinner";
+        public override string TestDescription => "To test basic operation of Circle Spinner with AngleRatio";
 
         public override void Run(Window window)
         {
@@ -42,9 +42,9 @@ namespace ElmSharp.Test.TC
                 Text = "Spinner Test",
                 LabelFormat = "%d Value",
                 Style = "circle",
-                AngleRatio = 3.0,
+                AngleRatio = 1.0,
                 Minimum = 0,
-                Maximum = 360,
+                Maximum = 100,
                 Value = 0,
                 Step = 10,
                 Interval = 0.5,
diff --git a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest4.cs b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest4.cs
new file mode 100644 (file)
index 0000000..11df391
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using ElmSharp.Wearable;
+
+namespace ElmSharp.Test.TC
+{
+    class CircleSpinnerTest4 : TestCaseBase
+    {
+        public override string TestName => "CircleSpinnerTest4";
+        public override string TestDescription => "To test advanced operation of Circle Spinner with AngleRatio";
+
+        CircleSpinner spn1;
+        CircleSpinner spn2;
+
+        public override void Run(Window window)
+        {
+            Log.Debug(TestName, "CircleSpinnerTest run");
+
+            Rect square = window.GetInnerSquare();
+
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+
+            var surface = new CircleSurface(conformant);
+            spn1 = new CircleSpinner(window, surface) {
+                Text = "Spinner Test",
+                LabelFormat = "%d Ratio",
+                Style = "circle",
+                Minimum = 0,
+                Maximum = 100,
+                Value = 0.0,
+                Step = 10,
+                Interval = 0.5,
+                AlignmentX = -1,
+                AlignmentY = 0.5,
+                WeightX = 1,
+                WeightY = 1
+            };
+            spn1.Geometry = new Rect(square.X, square.Y, square.Width, square.Height / 4);
+            spn1.Show();
+
+            spn2 = new CircleSpinner(window, surface) {
+                Text = "Spinner Test",
+                LabelFormat = "%d Value",
+                Style = "circle",
+                MarkerColor = Color.Red,
+                Minimum = 0,
+                Maximum = 100,
+                Value = 0,
+                Interval = 0.5,
+                AlignmentX = -1,
+                AlignmentY = 0.5,
+                WeightX = 1,
+                WeightY = 1
+            };
+            spn2.Geometry = new Rect(square.X, square.Y+ square.Width * 2 / 4, square.Width, square.Height / 4);
+            spn2.Show();
+
+            spn1.Focused += Spn1_Focused;
+            spn2.Focused += Spn2_Focused;
+            spn1.ValueChanged += Spn1_ValueChanged;
+        }
+
+        private void Spn1_ValueChanged(object sender, System.EventArgs e)
+        {
+            spn2.AngleRatio = spn1.Value;
+        }
+
+        private void Spn2_Focused(object sender, System.EventArgs e)
+        {
+            ((IRotaryActionWidget)spn2).Activate();
+        }
+
+        private void Spn1_Focused(object sender, System.EventArgs e)
+        {
+            ((IRotaryActionWidget)spn1).Activate();
+        }
+    }
+}