From: yh106.jung Date: Wed, 20 Jan 2021 06:00:49 +0000 (+0900) Subject: [WebView][Non-ACR] Test form resubmit using back-forward instead reload X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F68%2F251868%2F2;p=test%2Ftct%2Fcsharp%2Fapi.git [WebView][Non-ACR] Test form resubmit using back-forward instead reload 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 --- diff --git a/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs b/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs index af3c43a..d14e97c 100755 --- a/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs +++ b/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs @@ -329,41 +329,50 @@ namespace Tizen.WebView.Tests Assert.IsTrue(result, "LoadUrl method failed"); - TaskCompletionSource tcsSubmit = new TaskCompletionSource(false); - EventHandler onNavigationPolicyDecide = (s, e) => - { - if (e.NavigationType == NavigationType.FormSubmitted) - { - tcsSubmit.TrySetResult(true); - return; - } - tcsSubmit.TrySetResult(false); - }; + TaskCompletionSource tcsEval = new TaskCompletionSource(false); + EventHandler onLoadFinishedEval = (s, e) => { tcsEval.TrySetResult(true); }; + EventHandler 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 tcsGoBack = new TaskCompletionSource(false); + EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); }; + EventHandler 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 tcs = new TaskCompletionSource(false); - onNavigationPolicyDecide = (s, e) => + EventHandler 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;