From a7a9ae520138d71d87d2096f78cc7d83ea884711 Mon Sep 17 00:00:00 2001 From: "yh106.jung" Date: Thu, 24 Sep 2020 10:04:08 +0900 Subject: [PATCH] [WebView][Non-ACR] Test form submit without using network Some web sites have been blocked by internal proxy during emulator test. e.g. http://jkorpela.fi/cgi-bin/echo.cgi To avoid network error, this patch tests form submit without using network. `Form Resubmitted` event can be generated by reloading the page that has a form. Change-Id: Iccad8a2048e8c2eb11056d705d51c55cb693a91e Signed-off-by: yh106.jung --- .../res/form_submit_sample.html | 22 +++-------- .../testcase/TSNavigationPolicyEventArgs.cs | 43 +++++++++------------- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/tct-suite-vs/Tizen.WebView.Tests/res/form_submit_sample.html b/tct-suite-vs/Tizen.WebView.Tests/res/form_submit_sample.html index 945f1e1..e385e28 100755 --- a/tct-suite-vs/Tizen.WebView.Tests/res/form_submit_sample.html +++ b/tct-suite-vs/Tizen.WebView.Tests/res/form_submit_sample.html @@ -6,26 +6,14 @@ This test file is common file and can be used by EWK APIs to load web pages. Testing Sample Page -

Sample HTML

-

This is sample html page to be used in test suite when loading of a page is required.

-
-

- Type something:
- -

- Check me! -

- - + + +

- \ No newline at end of file + diff --git a/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs b/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs index d14e97c..af3c43a 100755 --- a/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs +++ b/tct-suite-vs/Tizen.WebView.Tests/testcase/TSNavigationPolicyEventArgs.cs @@ -329,50 +329,41 @@ namespace Tizen.WebView.Tests Assert.IsTrue(result, "LoadUrl method failed"); - TaskCompletionSource tcsEval = new TaskCompletionSource(false); - EventHandler onLoadFinishedEval = (s, e) => { tcsEval.TrySetResult(true); }; - EventHandler onLoadErrorEval = (s, e) => { tcsEval.TrySetResult(false); }; + TaskCompletionSource tcsSubmit = new TaskCompletionSource(false); + EventHandler onNavigationPolicyDecide = (s, e) => + { + if (e.NavigationType == NavigationType.FormSubmitted) + { + tcsSubmit.TrySetResult(true); + return; + } + tcsSubmit.TrySetResult(false); + }; - _webView.LoadFinished += onLoadFinishedEval; - _webView.LoadError += onLoadErrorEval; + _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide; _webView.Eval("submitForm()"); - result = await tcsEval.Task; + result = await tcsSubmit.Task; - _webView.LoadFinished -= onLoadFinishedEval; - _webView.LoadError -= onLoadErrorEval; + _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide; 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); - EventHandler onNavigationPolicyDecide = (s, e) => + 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.GoForward(); + _webView.Reload(); result = await tcs.Task; _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide; -- 2.7.4