[WebView][Non-ACR] Test form resubmit using back-forward instead reload 68/251868/2
authoryh106.jung <yh106.jung@samsung.com>
Wed, 20 Jan 2021 06:00:49 +0000 (15:00 +0900)
committerYoungha Jung <yh106.jung@samsung.com>
Wed, 20 Jan 2021 06:43:42 +0000 (06:43 +0000)
Form resubmit test has used reload function instead of back-forward
since [1], But the latest Chromium makes a reload event instead
resubmitted in the same situation. So this patch uses back-forward
instead reload again.

[1] https://review.tizen.org/gerrit/c/test/tct/csharp/api/+/244740

Change-Id: Icb651147fd9ee85b6b1a1d2a898617c4af48d627
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs

index af3c43a..d14e97c 100755 (executable)
@@ -329,41 +329,50 @@ namespace Tizen.WebView.Tests
 
             Assert.IsTrue(result, "LoadUrl method failed");
 
-            TaskCompletionSource<bool> tcsSubmit = new TaskCompletionSource<bool>(false);
-            EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
-            {
-                if (e.NavigationType == NavigationType.FormSubmitted)
-                {
-                    tcsSubmit.TrySetResult(true);
-                    return;
-                }
-                tcsSubmit.TrySetResult(false);
-            };
+            TaskCompletionSource<bool> tcsEval = new TaskCompletionSource<bool>(false);
+            EventHandler onLoadFinishedEval = (s, e) => { tcsEval.TrySetResult(true); };
+            EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorEval = (s, e) => { tcsEval.TrySetResult(false); };
 
-            _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+            _webView.LoadFinished += onLoadFinishedEval;
+            _webView.LoadError += onLoadErrorEval;
 
             _webView.Eval("submitForm()");
-            result = await tcsSubmit.Task;
+            result = await tcsEval.Task;
 
-            _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+            _webView.LoadFinished -= onLoadFinishedEval;
+            _webView.LoadError -= onLoadErrorEval;
 
             Assert.IsTrue(result, "Eval method failed");
 
+            TaskCompletionSource<bool> tcsGoBack = new TaskCompletionSource<bool>(false);
+            EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); };
+            EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorGoBack = (s, e) => { tcsGoBack.TrySetResult(false); };
+
+            _webView.LoadFinished += onLoadFinishedGoBack;
+            _webView.LoadError += onLoadErrorGoBack;
+
+            _webView.GoBack();
+            result = await tcsGoBack.Task;
+
+            _webView.LoadFinished -= onLoadFinishedGoBack;
+            _webView.LoadError -= onLoadErrorGoBack;
+
+            Assert.IsTrue(result, "GoBack method failed");
+
             /* TEST CODE */
             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
-            onNavigationPolicyDecide = (s, e) =>
+            EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
             {
+                Log.Debug("TCT", "NavigationType: " + e.NavigationType.ToString());
                 if (e.NavigationType == NavigationType.FormResubmitted)
                 {
                     tcs.TrySetResult(true);
-                    return;
                 }
-                tcs.TrySetResult(false);
             };
 
             _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
 
-            _webView.Reload();
+            _webView.GoForward();
             result = await tcs.Task;
 
             _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;