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/WebFormRepostPolicyDecisionMaker")]
14 public class InternalWebFormRepostPolicyDecisionMakerTest
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";
21 internal class MyWebFormRepostPolicyDecisionMaker : WebFormRepostPolicyDecisionMaker
23 public MyWebFormRepostPolicyDecisionMaker(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
26 public void OnReleaseSwigCPtr(global::System.Runtime.InteropServices.HandleRef swigCPtr)
28 base.ReleaseSwigCPtr(swigCPtr);
35 tlog.Info(tag, "Init() is called!");
41 tlog.Info(tag, "Destroy() is called!");
46 [Description("WebFormRepostPolicyDecisionMaker constructor.")]
47 [Property("SPEC", "Tizen.NUI.WebFormRepostPolicyDecisionMaker.WebFormRepostPolicyDecisionMaker C")]
48 [Property("SPEC_URL", "-")]
49 [Property("CRITERIA", "CONSTR")]
50 [Property("COVPARAM", "")]
51 [Property("AUTHOR", "guowei.wang@samsung.com")]
52 public void WebFormRepostPolicyDecisionMakerConstructor()
54 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerConstructor START");
56 using (Tizen.NUI.BaseComponents.WebView webview = new Tizen.NUI.BaseComponents.WebView("Shanghai", "Asia/Shanghai"))
58 var testingTarget = new WebFormRepostPolicyDecisionMaker(webview.SwigCPtr.Handle, false);
59 Assert.IsNotNull(testingTarget, "null handle");
60 Assert.IsInstanceOf<WebFormRepostPolicyDecisionMaker>(testingTarget, "Should return WebFormRepostPolicyDecisionMaker instance.");
62 testingTarget.Dispose();
65 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerConstructor END (OK)");
70 [Description("WebFormRepostPolicyDecisionMaker ReleaseSwigCPtr.")]
71 [Property("SPEC", "Tizen.NUI.WebFormRepostPolicyDecisionMaker.ReleaseSwigCPtr M")]
72 [Property("SPEC_URL", "-")]
73 [Property("CRITERIA", "MR")]
74 [Property("COVPARAM", "")]
75 [Property("AUTHOR", "guowei.wang@samsung.com")]
76 public void WebFormRepostPolicyDecisionMakerReleaseSwigCPtr()
78 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerReleaseSwigCPtr START");
80 using (Tizen.NUI.BaseComponents.WebView webview = new Tizen.NUI.BaseComponents.WebView("Shanghai", "Asia/Shanghai"))
82 var testingTarget = new MyWebFormRepostPolicyDecisionMaker(webview.SwigCPtr.Handle, false);
83 Assert.IsNotNull(testingTarget, "null handle");
84 Assert.IsInstanceOf<WebFormRepostPolicyDecisionMaker>(testingTarget, "Should return WebFormRepostPolicyDecisionMaker instance.");
88 testingTarget.OnReleaseSwigCPtr(testingTarget.SwigCPtr);
92 tlog.Debug(tag, e.Message.ToString());
93 Assert.Fail("Caught Exception : Failed!");
97 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerReleaseSwigCPtr END (OK)");
102 [Description("WebFormRepostPolicyDecisionMaker Reply.")]
103 [Property("SPEC", "Tizen.NUI.WebFormRepostPolicyDecisionMaker.Reply M")]
104 [Property("SPEC_URL", "-")]
105 [Property("CRITERIA", "MR")]
106 [Property("COVPARAM", "")]
107 [Property("AUTHOR", "guowei.wang@samsung.com")]
108 public async Task WebFormRepostPolicyDecisionMakerReply()
110 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerReply START");
112 var testingTarget = new Tizen.NUI.BaseComponents.WebView(runtimeArgs)
114 Size = new Size(500, 200),
115 UserAgent = USER_AGENT
117 Assert.IsNotNull(testingTarget, "null handle");
118 Assert.IsInstanceOf<Tizen.NUI.BaseComponents.WebView>(testingTarget, "Should return Tizen.NUI.BaseComponents.WebView instance.");
120 testingTarget.FormRepostPolicyDecided += OnFormRepostPolicyDecided;
121 NUIApplication.GetDefaultWindow().Add(testingTarget);
123 testingTarget.LoadUrl("http://www.163.com");
125 await Task.Delay(10000);
126 testingTarget.ClearCache();
127 testingTarget.ClearCookies();
128 NUIApplication.GetDefaultWindow().Remove(testingTarget);
130 testingTarget.Dispose();
131 tlog.Debug(tag, $"WebFormRepostPolicyDecisionMakerReply END (OK)");
134 private void OnFormRepostPolicyDecided(object sender, WebViewFormRepostPolicyDecidedEventArgs e)
136 tlog.Info(tag, $"form repost policy decided");
137 e.FormRepostPolicyDecisionMaker.Reply(false);