[NUI][ACR-452] Add CursorPositionChanged Event 85/263385/6
authorabdullah <abdullahhasan10@gmail.com>
Wed, 1 Sep 2021 13:47:52 +0000 (16:47 +0300)
committerabdullah <abdullahhasan10@gmail.com>
Thu, 23 Sep 2021 10:24:47 +0000 (13:24 +0300)
Added test to check if CursorPositionChanged is called in TextEditor & TextField.

Change-Id: I358f00337e5cc4802be55929b92b14f551cff0a1

tct-suite-vs/Tizen.NUI.Tests/testcase/TSTextEditor.cs
tct-suite-vs/Tizen.NUI.Tests/testcase/TSTextField.cs

index c3c22f6..5224730 100755 (executable)
@@ -1113,7 +1113,7 @@ namespace Tizen.NUI.Tests
         [Property("SPEC", "Tizen.NUI.BaseComponents.TextEditor.ScrollStateChanged E")]
         [Property("SPEC_URL", "-")]
         [Property("CRITERIA", "EVL")]
-        [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]\r
+        [Property("AUTHOR", "Xianbing Teng, xb.teng@samsung.com")]
         public async Task ScrollStateChanged_CHECK_EVENT()
         {
             var textEditor = new TextEditor()
@@ -1202,5 +1202,32 @@ namespace Tizen.NUI.Tests
             textEditor.FontSizeScale = scale;
             Assert.AreEqual(scale, textEditor.FontSizeScale, "Retrieved FontSizeScale should be equal to set value");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test CursorPositionChanged.Check whether CursorPositionChanged defined in the spec is callable.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextEditor.CursorPositionChanged E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Abdullah Ghujeh, a.ghujeh@samsung.com")]
+        public async Task CursorPositionChanged_CHECK_EVENT()
+        {
+            var textEditor = new TextEditor();
+            textEditor.Text = "123456789";
+            Window.Instance.GetDefaultLayer().Add(textEditor);
+            bool flag = false;
+            EventHandler handler = (obj, e) =>
+            {
+                flag = true;
+            };
+
+            textEditor.CursorPositionChanged += handler;
+            textEditor.PrimaryCursorPosition = 4;
+            await Task.Delay(500);
+
+            Assert.IsTrue(flag, "CursorPositionChanged is not be called");
+
+            textEditor.CursorPositionChanged -= handler;
+        }
     }
 }
index 888d66c..48fbef3 100755 (executable)
@@ -3,6 +3,7 @@ using NUnit.Framework.TUnit;
 using System;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
+using System.Threading.Tasks;
 using Tizen.NUI.Test;
 
 namespace Tizen.NUI.Tests
@@ -1199,8 +1200,8 @@ namespace Tizen.NUI.Tests
             Assert.IsInstanceOf<TextField>(textField, "Should be an instance of TextField type.");
 
             textField.MatchSystemLanguageDirection = false;
-            Assert.AreEqual(false, textField.MatchSystemLanguageDirection, "should be same");\r
-\r
+            Assert.AreEqual(false, textField.MatchSystemLanguageDirection, "should be same");
+
             textField.MatchSystemLanguageDirection = true;
             Assert.AreEqual(true, textField.MatchSystemLanguageDirection, "should be same");
         }
@@ -1243,5 +1244,31 @@ namespace Tizen.NUI.Tests
             textField.FontSizeScale = scale;
             Assert.AreEqual(scale, textField.FontSizeScale, "Retrieved FontSizeScale should be equal to set value");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test CursorPositionChanged.Check whether CursorPositionChanged defined in the spec is callable.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextField.CursorPositionChanged E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Abdullah Ghujeh, a.ghujeh@samsung.com")]
+        public async Task CursorPositionChanged_CHECK_EVENT()
+        {
+            var textField = new TextField();
+            textField.Text = "123456789";
+            Window.Instance.GetDefaultLayer().Add(textField);
+            bool flag = false;
+            EventHandler handler = (obj, e) =>
+            {
+                flag = true;
+            };
+
+            textField.CursorPositionChanged += handler;
+            textField.PrimaryCursorPosition = 4;
+            await Task.Delay(500);
+
+            Assert.IsTrue(flag, "CursorPositionChanged is not be called");
+            textField.CursorPositionChanged -= handler;
+        }
     }
 }