From 8c17fb9e6cecd29f46562314ef7ef0865ac5ef52 Mon Sep 17 00:00:00 2001 From: ssabah Date: Tue, 15 Mar 2022 16:26:13 +0300 Subject: [PATCH] [NUI] Make PrimaryCursorPosition property public --- .../src/public/BaseComponents/TextEditor.cs | 8 ++++-- .../src/public/BaseComponents/TextField.cs | 8 ++++-- .../testcase/public/BaseComponents/TSTextEditor.cs | 31 +++++++++++++++++++--- .../testcase/public/BaseComponents/TSTextField.cs | 31 +++++++++++++++++++--- 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index ea57f6a..407ba48 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -1738,9 +1738,13 @@ namespace Tizen.NUI.BaseComponents } /// - /// Specify primary cursor (caret) position in text control. + /// PrimaryCursorPosition property.
+ /// Specify the position of the primary cursor (caret) in text control. ///
- [EditorBrowsable(EditorBrowsableState.Never)] + /// + /// If the value set is out of range (negative or greater than or equal the number of characters in Text) then the PrimaryCursorPosition is moved to the end of Text (the number of characters in Text). + /// + /// 10 public int PrimaryCursorPosition { get diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 42afe43..712d65d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -1872,9 +1872,13 @@ namespace Tizen.NUI.BaseComponents } /// - /// Specify primary cursor (caret) position in text control. + /// PrimaryCursorPosition property.
+ /// Specify the position of the primary cursor (caret) in text control. ///
- [EditorBrowsable(EditorBrowsableState.Never)] + /// + /// If the value set is out of range (negative or greater than or equal the number of characters in Text) then the PrimaryCursorPosition is moved to the end of Text (the number of characters in Text). + /// + /// 10 public int PrimaryCursorPosition { get diff --git a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextEditor.cs b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextEditor.cs index 1dec2da..0915bbb 100755 --- a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextEditor.cs +++ b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextEditor.cs @@ -626,7 +626,7 @@ namespace Tizen.NUI.Devel.Tests [Property("SPEC", "Tizen.NUI.TextEditor.PrimaryCursorPosition A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] - [Property("AUTHOR", "bowon.ryu@samsung.com")] + [Property("AUTHOR", "s.sabah@samsung.com")] public void TextEditorPrimaryCursorPosition() { tlog.Debug(tag, $"TextEditorPrimaryCursorPosition START"); @@ -635,14 +635,37 @@ namespace Tizen.NUI.Devel.Tests Assert.IsNotNull(testingTarget, "Can't create success object TextEditor"); Assert.IsInstanceOf(testingTarget, "Should be an instance of TextEditor type."); - testingTarget.Text = "0123456789"; - testingTarget.PrimaryCursorPosition = 5; - Assert.AreEqual(5, testingTarget.PrimaryCursorPosition, "Should be equal!"); + testingTarget.Text ="Hello World!"; + int textLen = testingTarget.Text.Length; + + int expectedValue = textLen; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 5; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 0; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = textLen ; + testingTarget.PrimaryCursorPosition = textLen + 1; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 6; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = textLen ; + testingTarget.PrimaryCursorPosition = -1; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"TextEditorPrimaryCursorPosition END (OK)"); } + [Test] [Category("P1")] [Description("TextEditor EnableSelection.")] diff --git a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextField.cs b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextField.cs index 61ca464..8cb02cb 100755 --- a/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextField.cs +++ b/test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextField.cs @@ -2280,13 +2280,14 @@ namespace Tizen.NUI.Devel.Tests tlog.Debug(tag, $"TextFieldEnableEditing END (OK)"); } + [Test] [Category("P1")] [Description("TextField PrimaryCursorPosition.")] [Property("SPEC", "Tizen.NUI.TextField.PrimaryCursorPosition A")] [Property("SPEC_URL", "-")] [Property("CRITERIA", "CONSTR")] - [Property("AUTHOR", "bowon.ryu@samsung.com")] + [Property("AUTHOR", "s.sabah@samsung.com")] public void TextFieldPrimaryCursorPosition() { tlog.Debug(tag, $"TextFieldPrimaryCursorPosition START"); @@ -2295,9 +2296,31 @@ namespace Tizen.NUI.Devel.Tests Assert.IsNotNull(testingTarget, "Can't create success object TextField"); Assert.IsInstanceOf(testingTarget, "Should be an instance of TextField type."); - testingTarget.Text = "0123456789"; - testingTarget.PrimaryCursorPosition = 5; - Assert.AreEqual(5, testingTarget.PrimaryCursorPosition, "Should be equal!"); + testingTarget.Text ="Hello World!"; + int textLen = testingTarget.Text.Length; + + int expectedValue = textLen; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 5; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 0; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = textLen ; + testingTarget.PrimaryCursorPosition = textLen + 1; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = 6; + testingTarget.PrimaryCursorPosition = expectedValue; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); + + expectedValue = textLen ; + testingTarget.PrimaryCursorPosition = -1; + Assert.AreEqual(expectedValue, testingTarget.PrimaryCursorPosition, "Should be equal!"); testingTarget.Dispose(); tlog.Debug(tag, $"TextFieldPrimaryCursorPosition END (OK)"); -- 2.7.4