[Test]
[Category("P1")]
+ [Description("Requests the execution of the given script and gets the result of evaluation")]
+ [Property("SPEC", "Tizen.WebView.WebView.EvalAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task EvalAsync_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 */
+ string returnValue = "";
+ try
+ {
+ returnValue = await _webView.EvalAsync(WebViewCommon.TestScript);
+ }
+ catch (Exception e)
+ {
+ Assert.True(false, e.Message);
+ }
+
+ Assert.AreEqual("test content", returnValue, WebViewCommon.ReturnOfTestScript);
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Checks whether EvalAsync throws ArgumentException when script is null")]
+ [Property("SPEC", "Tizen.WebView.WebView.EvalAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task EvalAsync_ARGUMENT_EXCEPTION_NULL_SCRIPT()
+ {
+ /* 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.ThrowsAsync<ArgumentException>(async () => await _webView.EvalAsync(null), "ArgumentException should be thrown");
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Checks whether EvalAsync throws ArgumentException when script is empty")]
+ [Property("SPEC", "Tizen.WebView.WebView.EvalAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")]
+ public async Task EvalAsync_ARGUMENT_EXCEPTION_EMPTY_SCRIPT()
+ {
+ /* 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.ThrowsAsync<ArgumentException>(async () => await _webView.EvalAsync(""), "ArgumentException should be thrown");
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Requests to set or unset a view as the currently focused one")]
[Property("SPEC", "Tizen.WebView.WebView.SetFocus M")]
[Property("SPEC_URL", "-")]