Auto TCT for Tizen.WebView was applied on Tizen 5.5.
This patch adds again auto TCT for Tizen.WebView.
Tizen.WebView has been already added as API level 6
Change-Id: Ic13b66ce7eeac12e4193bbad7070af8bd083fb6a
Signed-off-by: basavarajps <basavaraj.ps@samsung.com>
--- /dev/null
+<html>\r
+<!--\r
+This test file is common file and can be used by EWK APIs to load web pages.\r
+-->\r
+<head>\r
+ <title>Testing Sample Page</title>\r
+ <script>\r
+ function submitForm() {\r
+ document.getElementById('formContent').submit();\r
+ }\r
+ </script>\r
+</head>\r
+<body>\r
+ <h1>Sample HTML</h1>\r
+ <p>This is sample html page to be used in test suite when loading of a page is required.</p>\r
+ <form id="formContent" action="http://jkorpela.fi/cgi-bin/echo.cgi" method="post">\r
+ <P>\r
+ Type something:<br>\r
+<textarea rows=5 cols=72 name=Comments>\r
+This is\r
+some text\r
+in several lines.\r
+</textarea>\r
+ <p>\r
+ <input type="checkbox" name="box" value="yes">Check me!\r
+ <P>\r
+ <input type="hidden" name="hidden field" value="something">\r
+ <input type="submit" value="Send">\r
+ </form>\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<!--\r
+This test file is common file and can be used by EWK APIs to load web pages.\r
+-->\r
+<head>\r
+ <title>Testing Sample Page</title>\r
+ <script>\r
+ function clickLink() {\r
+ document.getElementById('linkContent').click();\r
+ }\r
+ </script>\r
+</head>\r
+<body onload="clickLink()">\r
+ <h1>Sample HTML</h1>\r
+ <p>This is sample html page to be used in test suite when loading of a page is required.</p>\r
+ <a id="linkContent" href="http://www.google.com">link content</a>\r
+</body>\r
+</html>\r
--- /dev/null
+<html>
+<!--
+This test file is common file and can be used by EWK APIs to load web pages.
+-->
+<head>
+ <title>Testing Sample Page</title>
+ <script>
+ function windowOpen() {
+ window.open("http://www.google.com/");
+ }
+ </script>
+</head>
+<body onload="windowOpen()">
+ <h1>Sample HTML</h1>
+ <p>This is sample html page to be used in test suite when loading of a page is required.</p>
+ <p id="getParaContent">test content</p>
+</body>
+</html>
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.WebView.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.WebView.BackForwardList Tests")]
+ public class BackForwardListTests
+ {
+ private WebView _webView;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.WebView.BackForwardList Tests");
+ _webView = new WebView(WebViewCommon.GetMainWindow());
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.WebView.BackForwardList Tests");
+ _webView = null;
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Back Forward List Count")]
+ [Property("SPEC", "Tizen.WebView.BackForwardList.Count A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Count_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "Get BackForwardList method failed");
+
+ Assert.AreEqual(1, backforwardlist.Count, "Fail to get BackForwardList Count");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Current Item of Back Forward List")]
+ [Property("SPEC", "Tizen.WebView.BackForwardList.CurrentItem A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task CurrentItem_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var currentItem = backforwardlist.CurrentItem;
+ Assert.IsInstanceOf<BackForwardListItem>(currentItem, "Get Current BackForwardListItem property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml, currentItem.Url, "URL should be same");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets Previous Item of Back Forward List")]
+ [Property("SPEC", "Tizen.WebView.BackForwardList.PreviousItem A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task PreviousItem_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsFisrt = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedFirst = (s, e) => { tcsFisrt.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorFirst = (s, e) => { tcsFisrt.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedFirst;
+ _webView.LoadError += onLoadErrorFirst;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcsFisrt.Task;
+
+ _webView.LoadFinished -= onLoadFinishedFirst;
+ _webView.LoadError -= onLoadErrorFirst;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the first page");
+
+ TaskCompletionSource<bool> tcsSecond = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedSecond = (s, e) => { tcsSecond.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorSecond = (s, e) => { tcsSecond.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedSecond;
+ _webView.LoadError += onLoadErrorSecond;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml2);
+ result = await tcsSecond.Task;
+
+ _webView.LoadFinished -= onLoadFinishedSecond;
+ _webView.LoadError -= onLoadErrorSecond;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the second page");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var previousItem = backforwardlist.PreviousItem;
+ Assert.IsInstanceOf<BackForwardListItem>(previousItem, "Get Previous BackForwardList Item property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml1, previousItem.Url, "URL should be same with the first page");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the copy of Back Items")]
+ [Property("SPEC", "Tizen.WebView.BackForwardList.BackItems M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task BackItems_RETURN_VALUE()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsFisrt = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedFirst = (s, e) => { tcsFisrt.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorFirst = (s, e) => { tcsFisrt.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedFirst;
+ _webView.LoadError += onLoadErrorFirst;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcsFisrt.Task;
+
+ _webView.LoadFinished -= onLoadFinishedFirst;
+ _webView.LoadError -= onLoadErrorFirst;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the first page");
+
+ TaskCompletionSource<bool> tcsSecond = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedSecond = (s, e) => { tcsSecond.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorSecond = (s, e) => { tcsSecond.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedSecond;
+ _webView.LoadError += onLoadErrorSecond;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml2);
+ result = await tcsSecond.Task;
+
+ _webView.LoadFinished -= onLoadFinishedSecond;
+ _webView.LoadError -= onLoadErrorSecond;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the second page");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var backItems = backforwardlist.BackItems(-1);
+ Assert.AreEqual(1, backItems.Count, "The count of backItems should be 1");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the copy of Forward Items")]
+ [Property("SPEC", "Tizen.WebView.BackForwardList.ForwardItems M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ForwardItems_RETURN_VALUE()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsFisrt = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedFirst = (s, e) => { tcsFisrt.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorFirst = (s, e) => { tcsFisrt.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedFirst;
+ _webView.LoadError += onLoadErrorFirst;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcsFisrt.Task;
+
+ _webView.LoadFinished -= onLoadFinishedFirst;
+ _webView.LoadError -= onLoadErrorFirst;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the first page");
+
+ TaskCompletionSource<bool> tcsSecond = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedSecond = (s, e) => { tcsSecond.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorSecond = (s, e) => { tcsSecond.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedSecond;
+ _webView.LoadError += onLoadErrorSecond;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml2);
+ result = await tcsSecond.Task;
+
+ _webView.LoadFinished -= onLoadFinishedSecond;
+ _webView.LoadError -= onLoadErrorSecond;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the second page");
+
+ TaskCompletionSource<bool> tcsGoBack = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> 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 */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var forwardItems = backforwardlist.ForwardItems(-1);
+ Assert.AreEqual(1, forwardItems.Count, "The count of forwardItems should be 1");
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.WebView.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.WebView.BackForwardListItem Tests")]
+ class BackForwardListItemTests
+ {
+ private WebView _webView;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.WebView.BackForwardListItem Tests");
+ _webView = new WebView(WebViewCommon.GetMainWindow());
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.WebView.BackForwardListItem Tests");
+ _webView = null;
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the url of Current Back Forward List Item")]
+ [Property("SPEC", "Tizen.WebView.BackForwardListItem.Url A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Url_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var currentItem = backforwardlist.CurrentItem;
+ Assert.IsInstanceOf<BackForwardListItem>(currentItem, "Get Current BackForwardListItem property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml, currentItem.Url, "URL should be same");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the original url of Current Back Forward List Item")]
+ [Property("SPEC", "Tizen.WebView.BackForwardListItem.OriginalUrl A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task OriginalUrl_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var currentItem = backforwardlist.CurrentItem;
+ Assert.IsInstanceOf<BackForwardListItem>(currentItem, "Get Current BackForwardListItem property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml, currentItem.OriginalUrl, "Original URL should be same");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Title of Current Back Forward List Item")]
+ [Property("SPEC", "Tizen.WebView.BackForwardListItem.Title A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Title_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var currentItem = backforwardlist.CurrentItem;
+ Assert.IsInstanceOf<BackForwardListItem>(currentItem, "Get Current BackForwardListItem property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtmlTitle, currentItem.Title, "Title should be same");
+ }
+ }
+}
using NUnit.Framework;
using NUnit.Framework.TUnit;
+using System;
namespace Tizen.WebView.Tests
{
var cookieManager = context.GetCookieManager();
Assert.IsInstanceOf<CookieManager>(cookieManager, "GetCookieManager method failed");
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Clears the resource cache for the context")]
+ [Property("SPEC", "Tizen.WebView.Context.ClearResourceCache M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public void ClearResourceCache_CHANGE_STATUS()
+ {
+ /* TEST CODE */
+ var context = _webView.GetContext();
+ Assert.IsInstanceOf<Context>(context, "GetContext method failed");
+
+ try
+ {
+ context.ClearResourceCache();
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+
+ }
}
}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Tizen.WebView.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.WebView.NavigationPolicyEventArgs Tests")]
+ class NavigationPolicyEventArgsTests
+ {
+ private WebView _webView;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.WebView.NavigationPolicyEventArgs Tests");
+ _webView = new WebView(WebViewCommon.GetMainWindow());
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.WebView.NavigationPolicyEventArgs Tests");
+ _webView = null;
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Cookie of Navigation Policy event")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.Cookie A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Cookie_READ_ONLY()
+ {
+ /* TEST CODE */
+ string cookie = string.Empty;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ cookie = e.Cookie;
+ cookie = cookie.Replace(WebViewCommon.HeaderTerminator, "");
+ e.Use();
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ var httpHeaders = new Dictionary<string, string>();
+ httpHeaders.Add("Cookie", WebViewCommon.TestCookie);
+ _webView.SetUrlRequest(WebViewCommon.TestUrl, HttpMethod.Get, httpHeaders, null);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+ Assert.AreEqual(WebViewCommon.TestCookie, cookie, "Cookie should be valid string object");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.Other")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_OTHER()
+ {
+ /* TEST CODE */
+ NavigationType type = NavigationType.BackForward;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ type = e.NavigationType;
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+ Assert.AreEqual(NavigationType.Other, type, "NavigationType should be NavigationType.Other");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.BackForward")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_BACKFOWARD()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsFisrt = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedFirst = (s, e) => { tcsFisrt.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorFirst = (s, e) => { tcsFisrt.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedFirst;
+ _webView.LoadError += onLoadErrorFirst;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcsFisrt.Task;
+
+ _webView.LoadFinished -= onLoadFinishedFirst;
+ _webView.LoadError -= onLoadErrorFirst;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the first page");
+
+ TaskCompletionSource<bool> tcsSecond = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedSecond = (s, e) => { tcsSecond.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorSecond = (s, e) => { tcsSecond.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedSecond;
+ _webView.LoadError += onLoadErrorSecond;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml2);
+ result = await tcsSecond.Task;
+
+ _webView.LoadFinished -= onLoadFinishedSecond;
+ _webView.LoadError -= onLoadErrorSecond;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the second page");
+
+ /* TEST CODE */
+ NavigationType type = NavigationType.Other;
+ TaskCompletionSource<bool> tcsGoBack = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorGoBack = (s, e) => { tcsGoBack.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ type = e.NavigationType;
+ };
+
+ _webView.LoadFinished += onLoadFinishedGoBack;
+ _webView.LoadError += onLoadErrorGoBack;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.GoBack();
+ result = await tcsGoBack.Task;
+
+ _webView.LoadFinished -= onLoadFinishedGoBack;
+ _webView.LoadError -= onLoadErrorGoBack;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "GoBack method failed");
+ Assert.AreEqual(NavigationType.BackForward, type, "NavigationType should be NavigationType.BackForward");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.Reload")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_RELOAD()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ NavigationType type = NavigationType.Other;
+ TaskCompletionSource<bool> tcsReload = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedReload = (s, e) => { tcsReload.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorReload = (s, e) => { tcsReload.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ type = e.NavigationType;
+ };
+
+ _webView.LoadFinished += onLoadFinishedReload;
+ _webView.LoadError += onLoadErrorReload;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.Reload();
+ result = await tcsReload.Task;
+
+ _webView.LoadFinished -= onLoadFinishedReload;
+ _webView.LoadError -= onLoadErrorReload;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "Reload method failed");
+ Assert.AreEqual(NavigationType.Reload, type, "NavigationType should be NavigationType.Reload");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.LinkClicked")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_LINKCLICKED()
+ {
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ if (e.NavigationType == NavigationType.LinkClicked)
+ {
+ tcs.TrySetResult(true);
+ }
+ };
+
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.LinkClickSampleHtml);
+ var result = await tcs.Task;
+
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "NavigationType should be NavigationType.LinkClicked");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.FormSubmitted")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_FORMSUBMITTED()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsForm = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedForm = (s, e) => { tcsForm.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorForm = (s, e) => { tcsForm.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedForm;
+ _webView.LoadError += onLoadErrorForm;
+
+ _webView.LoadUrl(WebViewCommon.FormSubmitSampleHtml);
+ var result = await tcsForm.Task;
+
+ _webView.LoadFinished -= onLoadFinishedForm;
+ _webView.LoadError -= onLoadErrorForm;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ if (e.NavigationType == NavigationType.FormSubmitted)
+ {
+ tcs.TrySetResult(true);
+ }
+ };
+
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.Eval("submitForm()");
+ result = await tcs.Task;
+
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "NavigationType should be NavigationType.FormSubmitted");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Checks whether the NavigationType of Navigation Policy event is NavigationType.FormResubmitted")]
+ [Property("SPEC", "Tizen.WebView.NavigationPolicyEventArgs.NavigationType A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task NavigationType_GET_FORMRESUBMITTED()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsForm = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedForm = (s, e) => { tcsForm.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorForm = (s, e) => { tcsForm.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedForm;
+ _webView.LoadError += onLoadErrorForm;
+
+ _webView.LoadUrl(WebViewCommon.FormSubmitSampleHtml);
+ var result = await tcsForm.Task;
+
+ _webView.LoadFinished -= onLoadFinishedForm;
+ _webView.LoadError -= onLoadErrorForm;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ TaskCompletionSource<bool> tcsEval = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedEval = (s, e) => { tcsEval.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorEval = (s, e) => { tcsEval.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedEval;
+ _webView.LoadError += onLoadErrorEval;
+
+ _webView.Eval("submitForm()");
+ result = await tcsEval.Task;
+
+ _webView.LoadFinished -= onLoadFinishedEval;
+ _webView.LoadError -= onLoadErrorEval;
+
+ Assert.IsTrue(result, "Eval method failed");
+
+ TaskCompletionSource<bool> tcsGoBack = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedGoBack = (s, e) => { tcsGoBack.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> 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<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ Log.Debug("TCT", "NavigationType: " + e.NavigationType.ToString());
+ if (e.NavigationType == NavigationType.FormResubmitted)
+ {
+ tcs.TrySetResult(true);
+ }
+ };
+
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.GoForward();
+ result = await tcs.Task;
+
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "NavigationType should be NavigationType.FormResubmitted");
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.WebView.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.WebView.PolicyDecisionEventArgs Tests")]
+ public class PolicyDecisionEventArgsTests
+ {
+ private WebView _webView;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.WebView.PolicyDecisionEventArgs Tests");
+ _webView = new WebView(WebViewCommon.GetMainWindow());
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.WebView.PolicyDecisionEventArgs Tests");
+ _webView = null;
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Ask to ignore the current Policy Decision event")]
+ [Property("SPEC", "Tizen.WebView.PolicyDecisionEventArgs.Ignore M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Ignore_CHANGE_STATUS()
+ {
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ try
+ {
+ e.Ignore();
+ }
+ catch
+ {
+ tcs.TrySetResult(false);
+ }
+ tcs.TrySetResult(true);
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "Page loading should be finished without any error");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Ask to use the current Policy Decision event")]
+ [Property("SPEC", "Tizen.WebView.PolicyDecisionEventArgs.Use M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Use_CHANGE_STATUS()
+ {
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ try
+ {
+ e.Use();
+ }
+ catch
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "Page loading should be finished without any error");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Scheme of Policy Decision event")]
+ [Property("SPEC", "Tizen.WebView.PolicyDecisionEventArgs.Scheme A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Scheme_READ_ONLY()
+ {
+ /* TEST CODE */
+ string scheme = string.Empty;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ scheme = e.Scheme;
+ e.Use();
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+ Assert.AreEqual(WebViewCommon.FileScheme, scheme, "Scheme should be valid string object");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Url of Policy Decision event")]
+ [Property("SPEC", "Tizen.WebView.PolicyDecisionEventArgs.Url A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Url_READ_ONLY()
+ {
+ /* TEST CODE */
+ string url = string.Empty;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ url = e.Url;
+ e.Use();
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml, url, "Url should be valid string object");
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.WebView.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.WebView.ResponsePolicyEventArgs Tests")]
+ class ResponsePolicyEventArgsTests
+ {
+ private WebView _webView;
+
+ [SetUp]
+ public void Init()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.WebView.ResponsePolicyEventArgs Tests");
+ _webView = new WebView(WebViewCommon.GetMainWindow());
+ }
+
+ [TearDown]
+ public void Destroy()
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.WebView.ResponsePolicyEventArgs Tests");
+ _webView = null;
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Cookie of Response Policy event")]
+ [Property("SPEC", "Tizen.WebView.ResponsePolicyEventArgs.Cookie A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task Cookie_READ_ONLY()
+ {
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<ResponsePolicyEventArgs> onResponsePolicyDecide = (s, e) =>
+ {
+ var cookie = e.Cookie;
+ if (cookie.GetType() != typeof(string))
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.ResponsePolicyDecideRequested += onResponsePolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.TestUrl);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.ResponsePolicyDecideRequested -= onResponsePolicyDecide;
+
+ Assert.IsTrue(result, "Cookie should be valid string object");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the IsDownload of Response Policy event")]
+ [Property("SPEC", "Tizen.WebView.ResponsePolicyEventArgs.IsDownload A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task IsDownload_READ_ONLY()
+ {
+ /* TEST CODE */
+ bool isDownload = true;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<ResponsePolicyEventArgs> onResponsePolicyDecide = (s, e) =>
+ {
+ isDownload = e.IsDownload;
+ e.Use();
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.ResponsePolicyDecideRequested += onResponsePolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.ResponsePolicyDecideRequested -= onResponsePolicyDecide;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+ Assert.IsFalse(isDownload, "IsDownload should be false");
+
+ TaskCompletionSource<bool> tcsDownload = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedDownload = (s, e) => { tcsDownload.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorDownload = (s, e) => { tcsDownload.TrySetResult(false); };
+ EventHandler<ResponsePolicyEventArgs> onResponsePolicyDecideDownload = (s, e) =>
+ {
+ isDownload = e.IsDownload;
+ e.Use();
+ };
+
+ _webView.LoadFinished += onLoadFinishedDownload;
+ _webView.LoadError += onLoadErrorDownload;
+ _webView.ResponsePolicyDecideRequested += onResponsePolicyDecideDownload;
+
+ _webView.LoadUrl(WebViewCommon.TestUrlForDownload);
+ result = await tcsDownload.Task;
+
+ _webView.LoadFinished -= onLoadFinishedDownload;
+ _webView.LoadError -= onLoadErrorDownload;
+ _webView.ResponsePolicyDecideRequested -= onResponsePolicyDecideDownload;
+
+ Assert.IsFalse(result, "LoadUrl method should be failed for download");
+ Assert.IsTrue(isDownload, "IsDownload should be true");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the StatusCode of Response Policy event")]
+ [Property("SPEC", "Tizen.WebView.ResponsePolicyEventArgs.StatusCode A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task StatusCode_READ_ONLY()
+ {
+ /* TEST CODE */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<ResponsePolicyEventArgs> onResponsePolicyDecide = (s, e) =>
+ {
+ if (e.StatusCode != 200)
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.ResponsePolicyDecideRequested += onResponsePolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.TestUrl);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.ResponsePolicyDecideRequested -= onResponsePolicyDecide;
+
+ Assert.IsTrue(result, "StatusCode should be 200 OK");
+ }
+ }
+}
settings.DefaultFontSize = fontSize;
Assert.AreEqual(fontSize, settings.DefaultFontSize, "Fail to get/set DefaultFontSize");
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets and sets scripts can open windows")]
+ [Property("SPEC", "Tizen.WebView.Settings.ScriptsCanOpenWindows A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public void ScriptsCanOpenWindows_READ_WRITE()
+ {
+ /* TEST CODE */
+ var settings = _webView.GetSettings();
+ Assert.IsInstanceOf<Settings>(settings, "GetSettings method failed");
+
+ settings.ScriptsCanOpenWindows = true;
+ Assert.IsTrue(settings.ScriptsCanOpenWindows, "Fail to get/set ScriptCanOpenWindows");
+
+ settings.ScriptsCanOpenWindows = false;
+ Assert.IsFalse(settings.ScriptsCanOpenWindows, "Fail to get/set ScriptCanOpenWindows");
+ }
}
}
* limitations under the License
*/
+using ElmSharp;
using NUnit.Framework;
using NUnit.Framework.TUnit;
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
namespace Tizen.WebView.Tests
[Test]
[Category("P1")]
+ [Description("Event that occurs when navigation policy decide requested")]
+ [Property("SPEC", "Tizen.WebView.WebView.NavigationPolicyDecideRequested E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task NavigationPolicyDecideRequested_CHECK_EVENT()
+ {
+ /* TEST CODE */
+ bool occurred = false;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NavigationPolicyEventArgs> onNavigationPolicyDecide = (s, e) =>
+ {
+ try
+ {
+ occurred = true;
+ e.Use();
+ }
+ catch
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NavigationPolicyDecideRequested += onNavigationPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NavigationPolicyDecideRequested -= onNavigationPolicyDecide;
+
+ Assert.IsTrue(result, "Page loading should be finished without any error");
+ Assert.IsTrue(occurred, "Event should be occured");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Event that occurs when response policy decide requested")]
+ [Property("SPEC", "Tizen.WebView.WebView.ResponsePolicyDecideRequested E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ResponsePolicyDecideRequested_CHECK_EVENT()
+ {
+ /* TEST CODE */
+ bool occurred = false;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<ResponsePolicyEventArgs> onResponsePolicyDecide = (s, e) =>
+ {
+ try
+ {
+ occurred = true;
+ e.Use();
+ }
+ catch
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.ResponsePolicyDecideRequested += onResponsePolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.ResponsePolicyDecideRequested -= onResponsePolicyDecide;
+
+ Assert.IsTrue(result, "Page loading should be finished without any error");
+ Assert.IsTrue(occurred, "Event should be occured");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Event that occurs when new window policy decide requested")]
+ [Property("SPEC", "Tizen.WebView.WebView.NewWindowPolicyDecideRequested E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task NewWindowPolicyDecideRequested_CHECK_EVENT()
+ {
+ /* TEST CODE */
+ bool occurred = false;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+ EventHandler<NewWindowPolicyEventArgs> onNewWindowPolicyDecide = (s, e) =>
+ {
+ try
+ {
+ occurred = true;
+ e.Use();
+ }
+ catch
+ {
+ tcs.TrySetResult(false);
+ }
+ };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+ _webView.NewWindowPolicyDecideRequested += onNewWindowPolicyDecide;
+
+ _webView.LoadUrl(WebViewCommon.WindowOpenSampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+ _webView.NewWindowPolicyDecideRequested -= onNewWindowPolicyDecide;
+
+ Assert.IsTrue(result, "Page loading should be finished without any error");
+ Assert.IsTrue(occurred, "Event should be occured");
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Event that occurs when URL of main frame was changed")]
[Property("SPEC", "Tizen.WebView.WebView.UrlChanged E")]
[Property("SPEC_URL", "-")]
[Test]
[Category("P1")]
+ [Description("Gets the BackForwardList object of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.GetBackForwardList M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task GetBackForwardList_RETURN_VALUE()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ var backforwardlist = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backforwardlist, "GetBackForwardList method failed");
+
+ var currentItem = backforwardlist.CurrentItem;
+ Assert.IsInstanceOf<BackForwardListItem>(currentItem, "Get Current BackForwardListItem property failed");
+ Assert.AreEqual(WebViewCommon.SampleHtml, currentItem.Url, "URL should be same");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Clears the BackForwardList of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.ClearBackForwardList M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ClearBackForwardList_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcsFisrt = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedFirst = (s, e) => { tcsFisrt.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorFirst = (s, e) => { tcsFisrt.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedFirst;
+ _webView.LoadError += onLoadErrorFirst;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml1);
+ var result = await tcsFisrt.Task;
+
+ _webView.LoadFinished -= onLoadFinishedFirst;
+ _webView.LoadError -= onLoadErrorFirst;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the first page");
+
+ TaskCompletionSource<bool> tcsSecond = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinishedSecond = (s, e) => { tcsSecond.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadErrorSecond = (s, e) => { tcsSecond.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinishedSecond;
+ _webView.LoadError += onLoadErrorSecond;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml2);
+ result = await tcsSecond.Task;
+
+ _webView.LoadFinished -= onLoadFinishedSecond;
+ _webView.LoadError -= onLoadErrorSecond;
+
+ Assert.IsTrue(result, "LoadUrl method failed for the second page");
+
+ /* TEST CODE */
+ _webView.ClearBackForwardList();
+
+ var backForwardList = _webView.GetBackForwardList();
+ Assert.IsInstanceOf<BackForwardList>(backForwardList, "GetBackForwardList method failed");
+ Assert.AreEqual(1, backForwardList.Count, "Fail to Clear BackForwardList");
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Asks the object to load the given URL")]
[Property("SPEC", "Tizen.WebView.WebView.LoadUrl M")]
[Property("SPEC_URL", "-")]
_webView.SetFocus(false);
Assert.IsFalse(_webView.HasFocus, "Fail to set focus as false");
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Contents Size of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.ContentsSize A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ContentsSize_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ await Task.Delay(2000);
+
+ /* TEST CODE */
+ var contentSize = _webView.ContentsSize;
+ Assert.AreNotEqual(0, contentSize.Height, "Height of content size should be nonzero");
+ Assert.AreNotEqual(0, contentSize.Width, "Width of content size should be nonzero");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Exits the Full Screen of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.ExitFullscreen M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ExitFullscreen_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ try
+ {
+ _webView.ExitFullscreen();
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sends the orientation of the device")]
+ [Property("SPEC", "Tizen.WebView.WebView.SendOrientation M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MAE")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task SendOrientation_ENUM_ALL()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+
+ try
+ {
+ foreach(Orientation orientation in Enum.GetValues(typeof(Orientation)))
+ {
+ _webView.SendOrientation(orientation);
+ }
+
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Suspends the operation associated with the view")]
+ [Property("SPEC", "Tizen.WebView.WebView.Suspend M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Suspend_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ try
+ {
+ _webView.Suspend();
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Resumes the operation associated with the view")]
+ [Property("SPEC", "Tizen.WebView.WebView.Resume M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Resume_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ try
+ {
+ _webView.Resume();
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Load Progress of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.LoadProgress A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task LoadProgress_READ_ONLY()
+ {
+ /* TEST CODE */
+ double progress = 0;
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadStarted = (s, e) => { progress = _webView.LoadProgress; };
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadStarted += onLoadStarted;
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadStarted -= onLoadStarted;
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ Assert.AreNotEqual(0, progress, "Fail to get Load Progress");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets the Scale of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.Scale A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task Scale_READ_ONLY()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ Assert.AreNotEqual(0, _webView.Scale, "Fail to get scale");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets the Scale for this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.SetScale M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task SetScale_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ double scaleFactor = 2.0;
+ Point scrollTo;
+ scrollTo.X = 5;
+ scrollTo.Y = 5;
+
+ _webView.SetScale(scaleFactor, scrollTo);
+ await Task.Delay(1000);
+
+ Assert.AreEqual(2.0, _webView.Scale, "Fail to set scale");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Enables the visibility of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.SetViewVisibility M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task SetViewVisibility_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ try
+ {
+ _webView.SetViewVisibility(true);
+
+ _webView.SetViewVisibility(false);
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Gets and sets user agent string of this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.ScrollPosition A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRW")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ScrollPosition_READ_WRITE()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ Point scrollPos;
+ scrollPos.X = 5;
+ scrollPos.Y = 10;
+
+ _webView.ScrollPosition = scrollPos;
+ await Task.Delay(1000);
+
+ Assert.AreEqual(scrollPos, _webView.ScrollPosition, "Get ScrollPos should return valid scroll position");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets the Scroll By for this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.ScrollBy M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task ScrollBy_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ Point initialPos = _webView.ScrollPosition;
+ Point scrollBy;
+ scrollBy.X = 5;
+ scrollBy.Y = 10;
+
+ _webView.ScrollBy(scrollBy);
+ await Task.Delay(1000);
+
+ Point scrollPos = _webView.ScrollPosition;
+ Assert.AreEqual(initialPos.X + scrollBy.X, scrollPos.X, "X of scroll position should be valid");
+ Assert.AreEqual(initialPos.Y + scrollBy.Y, scrollPos.Y, "Y of scroll position should be valid");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Finds the text entered for this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.FindText M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MAE")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public async Task FindText_ENUM_ALL()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ try
+ {
+ foreach (FindOption option in Enum.GetValues(typeof(FindOption)))
+ {
+ _webView.FindText("sample", option, 0);
+ }
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets the url request for this view")]
+ [Property("SPEC", "Tizen.WebView.WebView.SetUrlRequest M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MAE")]
+ [Property("AUTHOR", "Basavaraj P S, basavaraj.ps@samsung.com")]
+ public void SetUrlRequest_ENUM_ALL()
+ {
+ /* TEST CODE */
+ var httpHeaders = new Dictionary<string, string>();
+ httpHeaders.Add("Accept", "*/*");
+ try
+ {
+ foreach(HttpMethod method in Enum.GetValues(typeof(HttpMethod)))
+ {
+ _webView.SetUrlRequest(WebViewCommon.TestUrl, method, httpHeaders, null);
+ }
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Sets the delegate for context menu customization")]
+ [Property("SPEC", "Tizen.WebView.WebView.SetContextMenuCustomizeDelegate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MCST")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task SetContextMenuCustomizeDelegate_CHANGE_STATUS()
+ {
+ /* PRECONDITION */
+ TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
+ EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); };
+ EventHandler<SmartCallbackLoadErrorArgs> onLoadError = (s, e) => { tcs.TrySetResult(false); };
+
+ _webView.LoadFinished += onLoadFinished;
+ _webView.LoadError += onLoadError;
+
+ _webView.LoadUrl(WebViewCommon.SampleHtml);
+ var result = await tcs.Task;
+
+ _webView.LoadFinished -= onLoadFinished;
+ _webView.LoadError -= onLoadError;
+
+ Assert.IsTrue(result, "LoadUrl method failed");
+
+ /* TEST CODE */
+ WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) =>
+ {
+ Assert.True(false, "Delegate must not be invoked in this testcase");
+ };
+ try
+ {
+ _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize);
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+
+ }
}
}
public const string SampleHtml1 = "file:///opt/usr/home/owner/share/res/sample_1.html";
public const string SampleHtml2 = "file:///opt/usr/home/owner/share/res/sample_2.html";
public const string AddJavaScriptInterfaceSampleHtml = "file:///opt/usr/home/owner/share/res/add_js_interface_sample.html";
+ public const string WindowOpenSampleHtml = "file:///opt/usr/home/owner/share/res/window_open_sample.html";
+ public const string LinkClickSampleHtml = "file:///opt/usr/home/owner/share/res/link_click_sample.html";
+ public const string FormSubmitSampleHtml = "file:///opt/usr/home/owner/share/res/form_submit_sample.html";
public const string SampleHtmlTitle = "Testing Sample Page";
+ public const string HeaderTerminator = "\r\r";
+ public const string FileScheme = "file";
public const string TestUrl = "https://www.tizen.org/";
public const string TestUrlForError = "http://page_that_does_not_exist/";
+ public const string TestUrlForDownload = "http://download.tizen.org/sdk/samples/online/Native/MN_account-sample/MN_account-sample.zip";
public const string TestUserAgent = "Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/538.1 (KHTML, like Gecko) Version/5.0 Safari/538.1";
public const string TestHtml = "<html><body onload='document.title=document.URL'></body></html>";
public const string TestScript = "document.getElementById('getParaContent').innerHTML";
+ public const string TestCookie = "foo=bar";
private static Window _instance;