[NUI][Non-ACR][Fix some test case fails] 60/242560/3
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 28 Aug 2020 01:53:12 +0000 (10:53 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Mon, 31 Aug 2020 02:06:34 +0000 (11:06 +0900)
- Some InputMethodContext APIs need to show IME (input panel).
- This patch is to fix the defects of the patch,
  : [NUI][ACR-306]Update TCs related InputMethodContext().
    07fcd26f605e8cb3d19e443f003b83ecc812064f
- To add TextEditor instance and get InputMethodContext instance from it,
 there should show IME to get focus or do activated.

Change-Id: Iebb8c716c85a089dd47a27f59c035666902d7c0d
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
tct-suite-vs/Tizen.NUI.Tests/testcase/TSInputMethodContext.cs

index a8ae4e1d97e716e47ccfcb38b9565e3c429a0728..7320395a4f2914572d799fbfef2c0c5c4d8169b5 100755 (executable)
@@ -342,15 +342,38 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", " - ")]
         [Property("CRITERIA", "PRW")]
         [Property("AUTHOR", "Wenfeng Ge, wenfeng.ge@samsung.com")]
-        public void TextPrediction_SET_GET_VALUE()
+        public async Task TextPrediction_SET_GET_VALUE()
         {
             /* TEST CODE */
-            var _editor = new TextEditor();
-            var inputMethodContext = _editor.GetInputMethodContext();
-            inputMethodContext.TextPrediction = true;
-            Assert.AreEqual(true, inputMethodContext.TextPrediction, "Should be true but error");
-            inputMethodContext.TextPrediction = false;
-            Assert.AreEqual(false, inputMethodContext.TextPrediction, "should be false but error");
+            TextEditor editor = new TextEditor()
+            {
+                Size2D = new Size2D(500, 300),
+                Position2D = new Position2D(10, 550),
+                BackgroundColor = Color.Magenta,
+                Focusable = true,
+            };
+            NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(editor);
+            var inputMethodContext = editor.GetInputMethodContext();
+            FocusManager.Instance.SetCurrentFocusView(editor);
+            inputMethodContext.Activate();
+            inputMethodContext.ShowInputPanel();
+
+            await Task.Delay(300);
+
+            if (inputMethodContext)
+            {
+                editor.Text = "text";
+                inputMethodContext.TextPrediction = true;
+                Assert.AreEqual(true, inputMethodContext.TextPrediction, "Should be true but error");
+                inputMethodContext.TextPrediction = false;
+                Assert.AreEqual(false, inputMethodContext.TextPrediction, "should be false but error");
+            }
+            inputMethodContext.HideInputPanel();
+            await Task.Delay(30);
+            FocusManager.Instance.ClearFocus();
+            editor.Unparent();
+            editor.Dispose();
+            editor = null;
         }
 
         [Test]
@@ -435,9 +458,20 @@ namespace Tizen.NUI.Tests
         [Property("AUTHOR", "Wenfeng Ge, wenfeng.ge@samsung.com")]
         public async Task GetInputPanelState_RETURN_VALUE()
         {
-            var _editor = new TextEditor();
-            var inputMethodContext = _editor.GetInputMethodContext();
+            TextEditor editor = new TextEditor()
+            {
+                Size2D = new Size2D(500, 300),
+                Position2D = new Position2D(10, 550),
+                BackgroundColor = Color.Magenta,
+                Focusable = true,
+            };
+            NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(editor);
+            var inputMethodContext = editor.GetInputMethodContext();
             Assert.IsNotNull(inputMethodContext, "InputMethodContext should not be null");
+            FocusManager.Instance.SetCurrentFocusView(editor);
+            inputMethodContext.Activate();
+            inputMethodContext.ShowInputPanel();
+            await Task.Delay(300);
             if (inputMethodContext.RestoreAfterFocusLost())
             {
                 inputMethodContext.SetRestoreAfterFocusLost(false);
@@ -446,6 +480,10 @@ namespace Tizen.NUI.Tests
             inputMethodContext.HideInputPanel();
             await Task.Delay(300);
             Assert.AreEqual(InputMethodContext.State.Hide, inputMethodContext.GetInputPanelState(), "Should be equal");
+            FocusManager.Instance.ClearFocus();
+            editor.Unparent();
+            editor.Dispose();
+            editor = null;
         }
 
         [Test]
@@ -602,6 +640,12 @@ namespace Tizen.NUI.Tests
                     }
                 }
             }
+            inputMethodContext.HideInputPanel();
+            await Task.Delay(30);
+            FocusManager.Instance.ClearFocus();
+            _editor.Unparent();
+            _editor.Dispose();
+            _editor = null;
         }
 
         [Test]
@@ -655,10 +699,20 @@ namespace Tizen.NUI.Tests
         [Property("SPEC_URL", " - ")]
         [Property("CRITERIA", "MR")]
         [Property("AUTHOR", "Seoyeon Kim, seoyeon2.kim@samsung.com")]
-        public void SetInputPanelLanguage_NO_RETURN_VALUE()
+        public async Task SetInputPanelLanguage_NO_RETURN_VALUE()
         {
-            var _editor = new TextEditor();
-            var inputMethodContext = _editor.GetInputMethodContext();
+            TextEditor editor = new TextEditor()
+            {
+                Size2D = new Size2D(500, 300),
+                Position2D = new Position2D(10, 550),
+                BackgroundColor = Color.Magenta,
+                Focusable = true,
+            };
+            NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(editor);
+            var inputMethodContext = editor.GetInputMethodContext();
+            FocusManager.Instance.SetCurrentFocusView(editor);
+            inputMethodContext.Activate();
+            inputMethodContext.ShowInputPanel();
             InputMethodContext.InputPanelLanguage language = InputMethodContext.InputPanelLanguage.Alphabet;
             try
             {
@@ -674,6 +728,12 @@ namespace Tizen.NUI.Tests
             {
                 Assert.Fail("Caught Exception" + e.ToString());
             }
+            inputMethodContext.HideInputPanel();
+            await Task.Delay(30);
+            FocusManager.Instance.ClearFocus();
+            editor.Unparent();
+            editor.Dispose();
+            editor = null;
         }
 
         [Test]
@@ -703,17 +763,33 @@ namespace Tizen.NUI.Tests
         [Property("AUTHOR", "Wenfeng Ge, wenfeng.ge@samsung.com")]
         public async Task Activated_EVENT()
         {
-            var _editor = new TextEditor();
-            var inputMethodContext = _editor.GetInputMethodContext();
+            TextEditor editor = new TextEditor()
+            {
+                Size2D = new Size2D(500, 300),
+                Position2D = new Position2D(10, 550),
+                BackgroundColor = Color.Magenta,
+                Focusable = true,
+            };
+            NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(editor);
+            var inputMethodContext = editor.GetInputMethodContext();
+            FocusManager.Instance.SetCurrentFocusView(editor);
+            await Task.Delay(500);
             if (inputMethodContext)
             {
                 _temp = 0;
                 inputMethodContext.Activated += OnInputMethodContextEvent;
                 inputMethodContext.Activate();
-                await Task.Delay(20);
+                inputMethodContext.ShowInputPanel();
+                await Task.Delay(500);
                 Assert.AreEqual(10, _temp, "Should be 10");
                 inputMethodContext.Activated -= OnInputMethodContextEvent;
             }
+            inputMethodContext.HideInputPanel();
+            await Task.Delay(30);
+            FocusManager.Instance.ClearFocus();
+            editor.Unparent();
+            editor.Dispose();
+            editor = null;
         }
 
         [Test]