From de661f3471c0bf9743261e461902bb4c3b5179b3 Mon Sep 17 00:00:00 2001 From: Hyunjin Date: Thu, 23 Nov 2017 14:35:49 +0900 Subject: [PATCH] [ElmSharp.Wearable] deprecate AngleRatio, fix incorrect default value of AngleRatio of CircleSpinner Solution : add description for deprecation, change default value to 360/(Maximum - Minimum) and fix TC to test issue case Change-Id: I106b6c051eec80920ede8b8a49d413ac8f1838d8 --- .../ElmSharp.Wearable/CircleSpinner.cs | 26 +++++- .../TC/CircleSpinnerTest1.cs | 5 +- .../TC/CircleSpinnerTest2.cs | 2 +- .../TC/CircleSpinnerTest3.cs | 6 +- .../TC/CircleSpinnerTest4.cs | 93 +++++++++++++++++++ 5 files changed, 122 insertions(+), 10 deletions(-) mode change 100755 => 100644 test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs mode change 100755 => 100644 test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs mode change 100755 => 100644 test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs create mode 100644 test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest4.cs diff --git a/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleSpinner.cs b/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleSpinner.cs index c0ca7009d..717ff3ed9 100644 --- a/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleSpinner.cs +++ b/src/ElmSharp.Wearable/ElmSharp.Wearable/CircleSpinner.cs @@ -29,7 +29,7 @@ namespace ElmSharp.Wearable public class CircleSpinner : Spinner, IRotaryActionWidget { IntPtr _circleHandle; - double _angleRatio = 1.0; + double _angleRatio = -1.0; CircleSurface _surface; /// @@ -73,16 +73,36 @@ namespace ElmSharp.Wearable /// Sets or gets the circle spinner angle per each spinner value. /// /// preview + [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); + } } } diff --git a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs old mode 100755 new mode 100644 index 87c6a0a00..d068df41b --- a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs +++ b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest1.cs @@ -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, diff --git a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs old mode 100755 new mode 100644 index 80c537223..f32d951fb --- a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs +++ b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest2.cs @@ -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) { diff --git a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs old mode 100755 new mode 100644 index 57843c816..a6a9b31ae --- a/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs +++ b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest3.cs @@ -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 index 000000000..11df391cf --- /dev/null +++ b/test/ElmSharp.Wearable.Test/TC/CircleSpinnerTest4.cs @@ -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(); + } + } +} -- 2.34.1