[NUI][ACR-455] Add public APIs: Copy, Cut and Paste for Text on TextEditor and TextField 35/263335/13
authorShrouq Sabah <s.sabah@samsung.com>
Tue, 31 Aug 2021 15:21:29 +0000 (18:21 +0300)
committershrouq Sabah <s.sabah@samsung.com>
Wed, 5 Jan 2022 13:58:17 +0000 (13:58 +0000)
Added 14 test-cases for the below APIs:
public static string CopyToClipboard(TextEditor textEditor) //API
public static string CopyToClipboard(TextField textField) //API
public static string CutToClipboard(TextEditor textEditor) //API
public static string CutToClipboard(TextField textField) //API
public static void PasteTo(TextEditor textEditor) //API
public static void PasteTo(TextField textField) //API

Test-cases for both TextEditor and TextField:
- Tested only call for each API: Expected no exception.
- Tested CopyToClipboard API that retrieve copied text and keep selected text.
- Tested CutToClipboard API that retrieve cut text and remove selected text.
- Tested PasteTo after calling CopyToClipboard that paste the copied text.
- Tested PasteTo after calling CutToClipboard that paste the cut text.

Change-Id: Ic58203fabe8e9ec4d18766c3b5c04b3dbb7988f8

tct-suite-vs/Tizen.NUI.Tests/testcase/TSTextUtils.cs [new file with mode: 0644]

diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSTextUtils.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSTextUtils.cs
new file mode 100644 (file)
index 0000000..f499b09
--- /dev/null
@@ -0,0 +1,389 @@
+using NUnit.Framework;
+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
+{
+    [TestFixture]
+    [Description("Tizen.NUI.BaseComponents.TSTextUtils Tests")]
+    public class TextUtilsTests
+    {
+        private string TAG = "NUI";
+        private bool _flagScrollStateChanged = false;
+        private string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "Tizen.NUI.Tests.png";
+
+        [SetUp]
+        public void Init()
+        {
+            Tizen.Log.Info(TAG, "Init() is called!");
+            App.MainTitleChangeText("TextUtilsTests");
+            App.MainTitleChangeBackgroundColor(null);
+        }
+
+        [TearDown]
+        public void Destroy()
+        {
+            Tizen.Log.Info(TAG, "Destroy() is called!");
+        }
+
+        private void OnScrollStateChanged(object sender, EventArgs e)
+        {
+            _flagScrollStateChanged = true;
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check CopyToClipboard method with TextEditor. Check whether CopyToClipboard is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CopyToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        [Property("COVPARAM", "TextEditor")]
+        public void CopyToClipboard_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            var textEditor = new TextEditor();
+            try
+            {
+                TextUtils.CopyToClipboard(textEditor);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.CopyToClipboard(textEditor) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check CutToClipboard method with TextEditor. Check whether CutToClipboard is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CutToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public void CutToClipboard_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            var textEditor = new TextEditor();
+            try
+            {
+                TextUtils.CutToClipboard(textEditor);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.CutToClipboard(textEditor) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check PasteTo method with TextEditor. Check whether PasteTo is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public void PasteTo_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            var textEditor = new TextEditor();
+            try
+            {
+                TextUtils.PasteTo(textEditor);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.PasteTo(textEditor) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check the returned value from CopyToClipboard with TextEditor. Check whether the returned value is equal to the copied text and whether the original text in TextEditor is as is.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CopyToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task CopyToClipboard_RETURN_VALUE_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textEditor = new TextEditor();
+            Window.Instance.GetDefaultLayer().Add(textEditor);
+
+            textEditor.Text = text;
+
+            textEditor.SelectWholeText();
+            await Task.Delay(500);
+
+            Assert.AreEqual(text, textEditor.Text, "Text of TextEditor should not be changed");
+            Assert.AreEqual(text, textEditor.SelectedText, "Check selected text");
+
+            var copiedText = TextUtils.CopyToClipboard(textEditor);
+            Assert.AreEqual(text, copiedText, "CopyToClipboard returns the copied text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check CopyToClipboard and PasteTo methods with TextEditor. Check whether text is copied from textEditorOne and is pasted into textEditorTwo.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task PasteTo_PASTE_COPIED_TEXT_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textEditorOne = new TextEditor();
+            var textEditorTwo = new TextEditor();
+            Window.Instance.GetDefaultLayer().Add(textEditorOne);
+            Window.Instance.GetDefaultLayer().Add(textEditorTwo);
+
+            textEditorOne.Text = text;
+            textEditorTwo.Text = "";
+
+            textEditorOne.SelectWholeText();
+            await Task.Delay(500);
+
+            TextUtils.CopyToClipboard(textEditorOne);
+
+            TextUtils.PasteTo(textEditorTwo);
+
+            Assert.AreEqual(text, textEditorTwo.Text, "Text of TextEditorTwo should be equal to the copied text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check the returned value from CutToClipboard with TextEditor. Check whether the returned value is equal to the cut text and whether the original text in TextEditor is removed.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CutToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task CutToClipboard_RETURN_VALUE_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textEditor = new TextEditor();
+            Window.Instance.GetDefaultLayer().Add(textEditor);
+
+            textEditor.Text = text;
+
+            textEditor.SelectWholeText();
+            await Task.Delay(500);
+
+            var cutText = TextUtils.CutToClipboard(textEditor);
+
+            Assert.AreEqual("", textEditor.Text, "Text of TextEditor should be removed");
+            Assert.AreEqual(text, cutText, "CutToClipboard returns the cut text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check CutToClipboard and PasteTo methods with TextEditor. Check whether text is cut from textEditorOne and is pasted into textEditorTwo.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextEditor")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task PasteTo_PASTE_CUT_TEXT_WITH_TEXTEDITOR()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textEditorOne = new TextEditor();
+            var textEditorTwo = new TextEditor();
+            Window.Instance.GetDefaultLayer().Add(textEditorOne);
+            Window.Instance.GetDefaultLayer().Add(textEditorTwo);
+
+            textEditorOne.Text = text;
+            textEditorTwo.Text = "";
+
+            textEditorOne.SelectWholeText();
+            await Task.Delay(500);
+
+            TextUtils.CutToClipboard(textEditorOne);
+            TextUtils.PasteTo(textEditorTwo);
+
+            Assert.AreEqual(text, textEditorTwo.Text, "Text of TextEditorTwo should be equal to the cut text");
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check CopyToClipboard method with TextField. Check whether CopyToClipboard is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CopyToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        [Property("COVPARAM", "TextField")]
+        public void CopyToClipboard_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            var textField = new TextField();
+            try
+            {
+                TextUtils.CopyToClipboard(textField);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.CopyToClipboard(textField) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check PasteTo method with TextField. Check whether PasteTo is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public void PasteTo_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            var textField = new TextField();
+            try
+            {
+                TextUtils.PasteTo(textField);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.PasteTo(textField) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P0")]
+        [Description("Check CutToClipboard method with TextField. Check whether CutToClipboard is successfully invoked or not.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CutToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public void CutToClipboard_CALL_API_WITHOUT_EXCEPTION_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            var textField = new TextField();
+            try
+            {
+                TextUtils.CutToClipboard(textField);
+            }
+            catch (Exception ex)
+            {
+                Assert.Fail("Expected no exception when call TextUtils.CutToClipboard(textField) , but got: %s", ex.Message);
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check the returned value from CopyToClipboard with TextField. Check whether the returned value is equal to the copied text and the original text in TextField is as is.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CopyToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task CopyToClipboard_RETURN_VALUE_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textField = new TextField();
+            textField.Text = text;
+            Window.Instance.GetDefaultLayer().Add(textField);
+
+            textField.SelectWholeText();
+            await Task.Delay(500);
+
+            var copiedText = TextUtils.CopyToClipboard(textField);
+            Assert.AreEqual(text, textField.Text, "Text of TextField should not be changed");
+            Assert.AreEqual(text, copiedText, "CopyToClipboard returns the copied text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check CopyToClipboard and PasteTo methods with TextField. Check whether text is copied from textFieldOne and is pasted into textFieldTwo.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task PasteTo_PASTE_COPIED_TEXT_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textFieldOne = new TextField();
+            var textFieldTwo = new TextField();
+            Window.Instance.GetDefaultLayer().Add(textFieldOne);
+            Window.Instance.GetDefaultLayer().Add(textFieldTwo);
+
+            textFieldOne.Text = text;
+            textFieldTwo.Text = "";
+
+            textFieldOne.SelectWholeText();
+            await Task.Delay(500);
+
+            TextUtils.CopyToClipboard(textFieldOne);
+            TextUtils.PasteTo(textFieldTwo);
+
+            Assert.AreEqual(text, textFieldTwo.Text, "Text of TextFieldTwo should be equal to the copied text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check the returned value from CutToClipboard with TextField. Check whether the returned value is equal to the cut text and whether the original text in TextField is removed.")]
+        [Property("SPEC", "Tizen.NUI.BaseComponents.TextUtils.CutToClipboard M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task CutToClipboard_RETURN_VALUE_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textField = new TextField();
+            textField.Text = text;
+            Window.Instance.GetDefaultLayer().Add(textField);
+
+            textField.SelectWholeText();
+            await Task.Delay(500);
+
+            var cutText = TextUtils.CutToClipboard(textField);
+
+            Assert.AreEqual("", textField.Text, "Text of TextField should be removed");
+            Assert.AreEqual(text, cutText, "CutToClipboard returns the cut text");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check CutToClipboard and PasteTo methods with TextField. Check whether text is cut from textFieldOne and is pasted into textFieldTwo.")]
+        [Property("SPEC", "TTizen.NUI.BaseComponents.TextUtils.PasteTo M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("COVPARAM", "TextField")]
+        [Property("AUTHOR", "Shrouq Sabah, s.sabah@samsung.com")]
+        public async Task PasteTo_PASTE_CUT_TEXT_WITH_TEXTFIELD()
+        {
+            /* TEST CODE */
+            String text = "Hello World";
+            var textFieldOne = new TextField();
+            var textFieldTwo = new TextField();
+            Window.Instance.GetDefaultLayer().Add(textFieldOne);
+            Window.Instance.GetDefaultLayer().Add(textFieldTwo);
+
+            textFieldOne.Text = text;
+            textFieldTwo.Text = "";
+
+            textFieldOne.SelectWholeText();
+            await Task.Delay(500);
+
+            TextUtils.CutToClipboard(textFieldOne);
+            TextUtils.PasteTo(textFieldTwo);
+
+            Assert.AreEqual(text, textFieldTwo.Text, "Text of TextFieldTwo should be equal to cut text");
+        }
+    }
+}