[NUI] add SelectText testcase
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 13 Apr 2022 08:06:38 +0000 (17:06 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 20 Apr 2022 08:38:08 +0000 (17:38 +0900)
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextEditor.cs
test/Tizen.NUI.Tests/Tizen.NUI.Devel.Tests/testcase/public/BaseComponents/TSTextField.cs

index f9cbb12..1dec2da 100755 (executable)
@@ -4,6 +4,7 @@ using NUnit.Framework.TUnit;
 using Tizen.NUI.Components;
 using Tizen.NUI.BaseComponents;
 using System.Collections.Generic;
+using System.Threading.Tasks;
 
 namespace Tizen.NUI.Devel.Tests
 {
@@ -740,5 +741,95 @@ namespace Tizen.NUI.Devel.Tests
             testingTarget.Dispose();
             tlog.Debug(tag, $"TextEditorGrabHandleColor END (OK)");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextEditor SelectText.")]
+        [Property("SPEC", "Tizen.NUI.TextEditor.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextEditorSelectText()
+        {
+            tlog.Debug(tag, $"TextEditorSelectText START");
+
+            var testingTarget = new TextEditor();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextEditor");
+            Assert.IsInstanceOf<TextEditor>(testingTarget, "Should be an instance of TextEditor type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            testingTarget.SelectText(2, 6);
+            await Task.Delay(500);
+            Assert.AreEqual(testingTarget.SelectedText, "2345", "Should be equal!");
+            Assert.AreEqual(testingTarget.SelectedTextStart, 2, "Should be equal!");
+            Assert.AreEqual(testingTarget.SelectedTextEnd, 6, "Should be equal!");
+
+            tlog.Debug(tag, $"TextEditorSelectText END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextEditor SelectText.StartIndexException")]
+        [Property("SPEC", "Tizen.NUI.TextEditor.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextEditorSelectTextStartIndexException()
+        {
+            tlog.Debug(tag, $"TextEditorSelectTextStartIndexException START");
+
+            var testingTarget = new TextEditor();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextEditor");
+            Assert.IsInstanceOf<TextEditor>(testingTarget, "Should be an instance of TextEditor type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            try
+            {
+                testingTarget.SelectText(-1, 6);
+            }
+            catch (ArgumentOutOfRangeException e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Pass("Caught ArgumentOutOfRangeException: Passed!");
+                tlog.Debug(tag, $"TextEditorSelectTextStartIndexException END (OK)");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextEditor SelectText.EndIndexException")]
+        [Property("SPEC", "Tizen.NUI.TextEditor.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextEditorSelectTextEndIndexException()
+        {
+            tlog.Debug(tag, $"TextEditorSelectTextEndIndexException START");
+
+            var testingTarget = new TextEditor();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextEditor");
+            Assert.IsInstanceOf<TextEditor>(testingTarget, "Should be an instance of TextEditor type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            try
+            {
+                testingTarget.SelectText(1, -1);
+            }
+            catch (ArgumentOutOfRangeException e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Pass("Caught ArgumentOutOfRangeException: Passed!");
+                tlog.Debug(tag, $"TextEditorSelectTextEndIndexException END (OK)");
+            }
+        }
     }
 }
index 0dbec04..61ca464 100755 (executable)
@@ -5,6 +5,7 @@ using Tizen.NUI.Components;
 using Tizen.NUI.BaseComponents;
 using System.Collections.Generic;
 using System.Runtime.InteropServices;
+using System.Threading.Tasks;
 
 namespace Tizen.NUI.Devel.Tests
 {
@@ -2301,5 +2302,95 @@ namespace Tizen.NUI.Devel.Tests
             testingTarget.Dispose();
             tlog.Debug(tag, $"TextFieldPrimaryCursorPosition END (OK)");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextField SelectText.")]
+        [Property("SPEC", "Tizen.NUI.TextField.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextFieldSelectText()
+        {
+            tlog.Debug(tag, $"TextFieldSelectText START");
+
+            var testingTarget = new TextField();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextField");
+            Assert.IsInstanceOf<TextField>(testingTarget, "Should be an instance of TextField type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            testingTarget.SelectText(2, 6);
+            await Task.Delay(500);
+            Assert.AreEqual(testingTarget.SelectedText, "2345", "Should be equal!");
+            Assert.AreEqual(testingTarget.SelectedTextStart, 2, "Should be equal!");
+            Assert.AreEqual(testingTarget.SelectedTextEnd, 6, "Should be equal!");
+
+            tlog.Debug(tag, $"TextFieldSelectText END (OK)");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextField SelectText.StartIndexException")]
+        [Property("SPEC", "Tizen.NUI.TextField.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextFieldSelectTextStartIndexException()
+        {
+            tlog.Debug(tag, $"TextFieldSelectTextStartIndexException START");
+
+            var testingTarget = new TextField();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextField");
+            Assert.IsInstanceOf<TextField>(testingTarget, "Should be an instance of TextField type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            try
+            {
+                testingTarget.SelectText(-1, 6);
+            }
+            catch (ArgumentOutOfRangeException e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Pass("Caught ArgumentOutOfRangeException: Passed!");
+                tlog.Debug(tag, $"TextFieldSelectTextStartIndexException END (OK)");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("TextField SelectText.EndIndexException")]
+        [Property("SPEC", "Tizen.NUI.TextField.SelectText M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "bowon.ryu@samsung.com")]
+        public async Task TextFieldSelectTextEndIndexException()
+        {
+            tlog.Debug(tag, $"TextFieldSelectTextEndIndexException START");
+
+            var testingTarget = new TextField();
+            Assert.IsNotNull(testingTarget, "Can't create success object TextField");
+            Assert.IsInstanceOf<TextField>(testingTarget, "Should be an instance of TextField type.");
+
+            testingTarget.Text = "0123456789";
+            testingTarget.EnableSelection = true;
+            Window.Instance.GetDefaultLayer().Add(testingTarget);
+
+            try
+            {
+                testingTarget.SelectText(1, -1);
+            }
+            catch (ArgumentOutOfRangeException e)
+            {
+                tlog.Debug(tag, e.Message.ToString());
+                Assert.Pass("Caught ArgumentOutOfRangeException: Passed!");
+                tlog.Debug(tag, $"TextFieldSelectTextEndIndexException END (OK)");
+            }
+        }
     }
 }