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/WebPolicyDecisionMaker")]
14 public class InternalWebPolicyDecisionMakerTest
16 private const string tag = "NUITEST";
17 private string url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
18 private static string[] runtimeArgs = { "Tizen.NUI.Devel.Tests", "--enable-dali-window", "--enable-spatial-navigation" };
19 private const string USER_AGENT = "Mozilla/5.0 (SMART-TV; Linux; Tizen 6.0) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/76.0.3809.146 TV Safari/537.36";
24 tlog.Info(tag, "Init() is called!");
30 tlog.Info(tag, "Destroy() is called!");
35 [Description("WebPolicyDecisionMaker Url.")]
36 [Property("SPEC", "Tizen.NUI.WebPolicyDecisionMaker.Url A")]
37 [Property("SPEC_URL", "-")]
38 [Property("CRITERIA", "PRO")]
39 [Property("COVPARAM", "")]
40 [Property("AUTHOR", "guowei.wang@samsung.com")]
41 public async Task WebPolicyDecisionMakerUrl()
43 tlog.Debug(tag, $"WebViewResponsePolicyDecidedEventArgsConstructor START");
45 var testingTarget = new Tizen.NUI.BaseComponents.WebView(runtimeArgs)
47 Size = new Size(500, 200),
48 UserAgent = USER_AGENT
50 Assert.IsNotNull(testingTarget, "null handle");
51 Assert.IsInstanceOf<Tizen.NUI.BaseComponents.WebView>(testingTarget, "Should return Tizen.NUI.BaseComponents.WebView instance.");
53 testingTarget.ResponsePolicyDecided += OnResponsePolicyDecided;
54 NUIApplication.GetDefaultWindow().Add(testingTarget);
56 testingTarget.LoadUrl("https://www.youtube.com");
58 await Task.Delay(30000);
59 testingTarget.ClearCache();
60 testingTarget.ClearCookies();
61 NUIApplication.GetDefaultWindow().Remove(testingTarget);
63 testingTarget.Dispose();
64 tlog.Debug(tag, $"WebPolicyDecisionMakerUrl END (OK)");
67 private void OnResponsePolicyDecided(object sender, WebViewResponsePolicyDecidedEventArgs e)
69 tlog.Info(tag, $"response policy decided, Url: {e.ResponsePolicyDecisionMaker.Url}");
70 tlog.Info(tag, $"response policy decided, Cookie: {e.ResponsePolicyDecisionMaker.Cookie}");
71 tlog.Info(tag, $"response policy decided, PolicyDecisionType: {e.ResponsePolicyDecisionMaker.PolicyDecisionType}");
72 tlog.Info(tag, $"response policy decided, ResponseMime: {e.ResponsePolicyDecisionMaker.ResponseMime}");
73 tlog.Info(tag, $"response policy decided, ResponseStatusCode: {e.ResponsePolicyDecisionMaker.ResponseStatusCode}");
74 tlog.Info(tag, $"response policy decided, DecisionNavigationType: {e.ResponsePolicyDecisionMaker.DecisionNavigationType}");
75 tlog.Info(tag, $"response policy decided, Scheme: {e.ResponsePolicyDecisionMaker.Scheme}");
76 if (e.ResponsePolicyDecisionMaker.Frame != null)
78 tlog.Info(tag, $"response policy decided, Frame.IsMainFrame: {e.ResponsePolicyDecisionMaker.Frame.IsMainFrame}");
80 e.ResponsePolicyDecisionMaker.Ignore();
81 e.ResponsePolicyDecisionMaker.Suspend();
82 e.ResponsePolicyDecisionMaker.Use();