From: huayong.xu Date: Thu, 29 Jun 2023 05:51:09 +0000 (+0800) Subject: [Non-ACR][NUI]Add a delay to make sure that WebView TC exits fully. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2007ed57bd7cc434c3887b2c99981802c096d727;p=test%2Ftct%2Fcsharp%2Fapi.git [Non-ACR][NUI]Add a delay to make sure that WebView TC exits fully. Meanwhile remove some unnecessary event listener in WebView TCs. Change-Id: I87d30327c1236b5c7e5d3db49a62b866e32b3211 --- diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebPageLoadError.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebPageLoadError.cs index 60ec670..421ef5e 100755 --- a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebPageLoadError.cs +++ b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebPageLoadError.cs @@ -58,7 +58,6 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebPageLoadErrorUrl START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadError = (s, e) => { var url = e.PageLoadError.Url; @@ -68,14 +67,15 @@ namespace Tizen.NUI.Tests } }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "Url should be valid value"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; tlog.Debug(tag, $"WebPageLoadErrorUrl END (OK)"); } @@ -93,26 +93,24 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebPageLoadErrorCode START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadError = (s, e) => { var code = e.PageLoadError.Code; - if (code.GetType() == typeof(WebPageLoadError.ErrorCode) - && (code.Equals(WebPageLoadError.ErrorCode.CannotLookupHost) - || code.Equals(WebPageLoadError.ErrorCode.Unknown))) + if (code.GetType() == typeof(WebPageLoadError.ErrorCode)) { tcs.TrySetResult(true); } }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "Code should be valid value."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; tlog.Debug(tag, $"WebPageLoadErrorCode END (OK)"); } @@ -130,25 +128,24 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebPageLoadErrorType START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadError = (s, e) => { var type = e.PageLoadError.Type; - if (type.GetType() == typeof(WebPageLoadError.ErrorType) - && type.Equals(WebPageLoadError.ErrorType.Network)) + if (type.GetType() == typeof(WebPageLoadError.ErrorType) && type.Equals(WebPageLoadError.ErrorType.Network)) { tcs.TrySetResult(true); } }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "Type should be valid value."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; tlog.Debug(tag, $"WebPageLoadErrorType END (OK)"); } @@ -166,7 +163,6 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebPageLoadErrorDescription START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadError = (s, e) => { var description = e.PageLoadError.Description; @@ -176,14 +172,15 @@ namespace Tizen.NUI.Tests } }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "Description should be valid value."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; tlog.Debug(tag, $"WebPageLoadErrorDescription END (OK)"); } diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebView.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebView.cs index 780d613..a4f9148 100755 --- a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebView.cs +++ b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebView.cs @@ -103,7 +103,7 @@ namespace Tizen.NUI.Tests { tlog.Debug(tag, $"WebViewConstructorWithArray START"); - string[] arr = new string[1] { "Tizen.NUI.Devel.Tests" }; + string[] arr = new string[1] { "--enable-features=NativeScrollbar" }; var testingTarget = new BaseComponents.WebView(arr); Assert.IsNotNull(testingTarget, "null handle"); @@ -126,16 +126,16 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadStarted = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadStarted += onLoadStarted; _webview.LoadUrl(SampleUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadStarted event should be invoked"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadStarted -= onLoadStarted; tlog.Debug(tag, $"WebViewPageLoadStarted END (OK)"); } @@ -155,13 +155,14 @@ namespace Tizen.NUI.Tests EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; _webview.PageLoading += onLoading; - _webview.PageLoading += onLoading; _webview.LoadUrl(SampleUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoading event should be invoked"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoading -= onLoading; tlog.Debug(tag, $"WebViewPageLoading END (OK)"); } @@ -179,16 +180,16 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; _webview.LoadUrl(SampleUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadFinished event should be invoked"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewPageLoadFinished END (OK)"); } @@ -206,16 +207,16 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadError = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadError event should be invoked"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; tlog.Debug(tag, $"WebViewPageLoadError END (OK)"); } @@ -233,9 +234,7 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; _webview.Url = SampleUrl; @@ -243,7 +242,9 @@ namespace Tizen.NUI.Tests Assert.IsTrue(result, "PageLoadFinished event should be invoked"); Assert.AreEqual(_webview.Url, SampleUrl, "Url should be the same as before."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewUrl END (OK)"); } @@ -277,19 +278,19 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebViewTitle START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; _webview.PageLoading += onLoading; - _webview.PageLoadFinished += onLoadFinished; _webview.LoadUrl(SampleUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadFinished event should be invoked"); Assert.IsEmpty(_webview.Title, "Title should be null in some case."); + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoading -= onLoading; - _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewTitle END (OK)"); } @@ -306,9 +307,7 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; _webview.LoadUrl(SampleUrl); @@ -316,7 +315,9 @@ namespace Tizen.NUI.Tests Assert.IsTrue(result, "PageLoadFinished event should be invoked"); Assert.AreEqual(_webview.Favicon, null, "Favicon should be the same as before."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewFavicon END (OK)"); } @@ -334,9 +335,7 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; _webview.LoadUrl(SampleUrl); @@ -344,7 +343,9 @@ namespace Tizen.NUI.Tests Assert.IsTrue(result, "PageLoadFinished event should be invoked"); Assert.AreEqual(_webview.LoadProgressPercentage, 1.0f, 1.0f, "Loading should be finished."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewLoadProgressPercentage END (OK)"); } @@ -363,16 +364,16 @@ namespace Tizen.NUI.Tests TaskCompletionSource tcs = new TaskCompletionSource(false); EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; _webview.LoadUrl(SampleUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadFinished event should be invoked"); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewLoadUrl END (OK)"); } @@ -390,19 +391,19 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebViewLoadHtmlString START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; _webview.PageLoading += onLoading; - _webview.PageLoadFinished += onLoadFinished; _webview.LoadHtmlString(TestHtml); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadFinished event should be invoked"); Assert.IsEmpty(_webview.Title, "Title should be empty in some case."); + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoading -= onLoading; - _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewLoadHtmlString END (OK)"); } } diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadErrorEventArgs.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadErrorEventArgs.cs index 8b7c379..34228ac 100755 --- a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadErrorEventArgs.cs +++ b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadErrorEventArgs.cs @@ -57,7 +57,6 @@ namespace Tizen.NUI.Tests tlog.Debug(tag, $"WebViewPageLoadErrorEventArgsPageLoadError START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadError = (s, e) => { var error = e.PageLoadError; @@ -67,15 +66,16 @@ namespace Tizen.NUI.Tests } }; - _webview.PageLoading += onLoading; _webview.PageLoadError += onLoadError; _webview.LoadUrl(SampleErrorUrl); var result = await tcs.Task; Assert.IsTrue(result, "PageLoadError should be valid value"); + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadError -= onLoadError; - _webview.PageLoading -= onLoading; tlog.Debug(tag, $"WebViewPageLoadErrorEventArgsPageLoadError END (OK)"); } } diff --git a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadEventArgs.cs b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadEventArgs.cs index c4d1135..7bc3bfb 100755 --- a/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadEventArgs.cs +++ b/tct-suite-vs/Tizen.NUI.Tests/testcase/TSWebViewPageLoadEventArgs.cs @@ -57,14 +57,12 @@ namespace Tizen.NUI.Devel.Tests tlog.Debug(tag, $"WebViewPageLoadEventArgs_CHECK START"); TaskCompletionSource tcs = new TaskCompletionSource(false); - EventHandler onLoading = (s, e) => { tcs.TrySetResult(true); }; EventHandler onLoadFinished = (s, e) => { Assert.IsNotNull(e, "It should not be null handle."); tcs.TrySetResult(true); }; - _webview.PageLoading += onLoading; _webview.PageLoadFinished += onLoadFinished; var testingTarget = new WebViewPageLoadEventArgs(); @@ -75,7 +73,9 @@ namespace Tizen.NUI.Devel.Tests var result = await tcs.Task; Assert.IsTrue(result, "WebViewPageLoadEventArgs should be a valid value."); - _webview.PageLoading -= onLoading; + // Make current thread (CPU) sleep... + await Task.Delay(1); + _webview.PageLoadFinished -= onLoadFinished; tlog.Debug(tag, $"WebViewPageLoadEventArgs_CHECK END (OK)"); }