3 using NUnit.Framework.TUnit;
4 using Tizen.NUI.Components;
5 using Tizen.NUI.BaseComponents;
6 using System.Threading.Tasks;
8 namespace Tizen.NUI.Devel.Tests
10 using tlog = Tizen.Log;
13 [Description("internal/WebView/WebCertificate")]
14 public class InternalWebCertificateTest
16 private const string tag = "NUITEST";
17 private string url = $"file://{Applications.Application.Current.DirectoryInfo.Resource}webview/index.html";
18 private BaseComponents.WebView webView = null;
23 webView = new BaseComponents.WebView()
25 Size = new Size(150, 100),
27 tlog.Info(tag, "Init() is called!");
33 tlog.Info(tag, "Destroy() is being called!");
35 tlog.Info(tag, "Destroy() is called!");
40 [Description("WebCertificate constructor.")]
41 [Property("SPEC", "Tizen.NUI.WebCertificate.WebCertificate C")]
42 [Property("SPEC_URL", "-")]
43 [Property("CRITERIA", "CONSTR")]
44 [Property("COVPARAM", "")]
45 [Property("AUTHOR", "guowei.wang@samsung.com")]
46 public async Task WebCertificateConstructor()
48 tlog.Debug(tag, $"WebCertificateConstructor START");
50 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
51 EventHandler<WebViewCertificateReceivedEventArgs> onSslCertificateChange = (s, e) =>
53 Assert.IsNotNull(e.Certificate, "null handle");
54 Assert.IsInstanceOf<WebCertificate>(e.Certificate, "Should return WebCertificate instance.");
55 tcs.TrySetResult(true);
57 webView.SslCertificateChanged += onSslCertificateChange;
60 var result = await tcs.Task;
61 Assert.IsTrue(result, "SslCertificateChanged event should be invoked");
63 webView.SslCertificateChanged -= onSslCertificateChange;
65 tlog.Debug(tag, $"WebCertificateConstructor END (OK)");
70 [Description("WebCertificate IsFromMainFrame.")]
71 [Property("SPEC", "Tizen.NUI.WebCertificate.IsFromMainFrame A")]
72 [Property("SPEC_URL", "-")]
73 [Property("CRITERIA", "PRO")]
74 [Property("COVPARAM", "")]
75 [Property("AUTHOR", "guowei.wang@samsung.com")]
76 public async Task WebCertificateIsFromMainFrame()
78 tlog.Debug(tag, $"WebCertificateIsFromMainFrame START");
80 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
81 EventHandler<WebViewCertificateReceivedEventArgs> onSslCertificateChange = (s, e) =>
83 Assert.IsTrue(e.Certificate.PemData == null || e.Certificate.PemData.Length == 0, "Certificate has no pem data.");
84 Assert.IsFalse(e.Certificate.IsFromMainFrame, "Certificate is not from main frame.");
85 Assert.IsFalse(e.Certificate.IsContextSecure, "Certificate is not context secure.");
86 e.Certificate.Allow(false);
87 tcs.TrySetResult(true);
89 webView.SslCertificateChanged += onSslCertificateChange;
92 var result = await tcs.Task;
93 Assert.IsTrue(result, "SslCertificateChanged event should be invoked");
95 webView.SslCertificateChanged -= onSslCertificateChange;
97 tlog.Debug(tag, $"WebCertificateIsFromMainFrame END (OK)");