--- /dev/null
+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");
+ }
+ }
+}