3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Collections.Generic;
7 using System.Threading.Tasks;
9 namespace Tizen.NUI.Devel.Tests
11 using tlog = Tizen.Log;
14 [Description("public/BaseComponents/TextEditorEvent")]
15 public class PublicTextEditorEventTest
17 private const string tag = "NUITEST";
18 private bool selectionStartedFlag = false;
23 tlog.Info(tag, "Init() is called!");
29 tlog.Info(tag, "Destroy() is called!");
34 [Description("TextEditorEvent TextChanged.")]
35 [Property("SPEC", "Tizen.NUI.TextEditorEvent.TextChanged A")]
36 [Property("SPEC_URL", "-")]
37 [Property("CRITERIA", "PRW")]
38 [Property("AUTHOR", "guowei.wang@samsung.com")]
39 public void TextEditorEventEvents()
41 tlog.Debug(tag, $"TextEditorEventEvents START");
43 var testingTarget = new TextEditor(true);
44 Assert.IsNotNull(testingTarget, "Can't create success object TextEditor");
45 Assert.IsInstanceOf<TextEditor>(testingTarget, "Should be an instance of TextEditor type.");
47 testingTarget.TextChanged += OnTextChanged;
48 testingTarget.TextChanged -= OnTextChanged;
50 testingTarget.MaxLengthReached += OnMaxLengthReached;
51 testingTarget.MaxLengthReached -= OnMaxLengthReached;
53 testingTarget.AnchorClicked += OnAnchorClicked;
54 testingTarget.AnchorClicked -= OnAnchorClicked;
56 testingTarget.SelectionStarted += OnSelectionStarted;
57 testingTarget.SelectionStarted -= OnSelectionStarted;
59 testingTarget.Dispose();
60 tlog.Debug(tag, $"TextEditorEventEvents END (OK)");
65 [Description("TextEditorEvent SelectionStarted.")]
66 [Property("SPEC", "Tizen.NUI.TextEditor.SelectionStarted A")]
67 [Property("SPEC_URL", "-")]
68 [Property("CRITERIA", "PRW")]
69 [Property("AUTHOR", "a.ghujeh@samsung.com")]
70 async public Task TextEditorSelectionStarted()
72 tlog.Debug(tag, $"SelectionStarted START");
74 var testingTarget = new TextEditor()
79 Window.Instance.GetDefaultLayer().Add(testingTarget);
81 Assert.IsNotNull(testingTarget, "Can't create success object TextEditor");
82 Assert.IsInstanceOf<TextEditor>(testingTarget, "Should be an instance of TextEditor type.");
86 testingTarget.SelectionStarted += OnSelectionStarted;
88 testingTarget.SelectWholeText();
89 await Task.Delay(500);
91 testingTarget.SelectionStarted -= OnSelectionStarted;
95 tlog.Info(tag, e.Message.ToString());
96 Assert.Fail("Caught Exception : Failed!");
99 testingTarget.Dispose();
101 if(selectionStartedFlag == true)
102 tlog.Debug(tag, $"SelectionStarted END (OK)");
104 Assert.Fail("SelectionStarted : Failed!");
107 private void OnAnchorClicked(object sender, AnchorClickedEventArgs e)
111 private void OnMaxLengthReached(object sender, TextEditor.MaxLengthReachedEventArgs e)
115 private void OnTextChanged(object sender, TextEditor.TextChangedEventArgs e)
119 private void OnSelectionStarted(object sender, EventArgs e)
121 selectionStartedFlag = true;