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/WebBackForwardList")]
14 public class InternalWebBackForwardListTest
16 private const string tag = "NUITEST";
17 private string url = $"file://{Applications.Application.Current.DirectoryInfo.Resource}webview/index.html";
18 private string secondUrl = $"file://{Applications.Application.Current.DirectoryInfo.Resource}webview/second.html";
19 private BaseComponents.WebView webView = null;
24 webView = new BaseComponents.WebView()
26 Size = new Size(150, 100),
28 tlog.Info(tag, "Init() is called!");
34 tlog.Info(tag, "Destroy() is being called!");
36 tlog.Info(tag, "Destroy() is called!");
41 [Description("WebBackForwardList ItemCount.")]
42 [Property("SPEC", "Tizen.NUI.WebBackForwardList.ItemCount A")]
43 [Property("SPEC_URL", "-")]
44 [Property("CRITERIA", "PRO")]
45 [Property("COVPARAM", "")]
46 [Property("AUTHOR", "guowei.wang@samsung.com")]
47 public async Task WebBackForwardListConstructor()
49 tlog.Debug(tag, $"WebBackForwardListConstructor START");
51 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
52 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
54 tlog.Info(tag, "onLoadFinished is called!");
55 tcs.TrySetResult(true);
57 webView.PageLoadFinished += onLoadFinished;
60 var result = await tcs.Task;
61 Assert.IsTrue(result, "PageLoadFinished event should be invoked.");
63 Assert.IsNotNull(webView.BackForwardList, "null handle");
64 Assert.IsInstanceOf<WebBackForwardList>(webView.BackForwardList, "Should return WebBackForwardList instance.");
65 Assert.Greater(webView.BackForwardList.ItemCount, 0, "ItemCount should be greater than 0.");
67 webView.PageLoadFinished -= onLoadFinished;
69 tlog.Debug(tag, $"WebBackForwardListConstructor END (OK)");
74 [Description("WebBackForwardList GetCurrentItem.")]
75 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetCurrentItem M")]
76 [Property("SPEC_URL", "-")]
77 [Property("CRITERIA", "MR")]
78 [Property("COVPARAM", "")]
79 [Property("AUTHOR", "guowei.wang@samsung.com")]
80 public async Task WebBackForwardListGetCurrentItem()
82 tlog.Debug(tag, $"WebBackForwardListGetCurrentItem START");
84 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
85 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
87 tlog.Info(tag, "onLoadFinished is called!");
88 tcs.TrySetResult(true);
90 webView.PageLoadFinished += onLoadFinished;
93 var result = await tcs.Task;
94 Assert.IsTrue(result, "PageLoadFinished event should be invoked.");
95 Assert.IsNotNull(webView.BackForwardList.GetCurrentItem(), "handle should not be null.");
97 webView.PageLoadFinished -= onLoadFinished;
99 tlog.Debug(tag, $"WebBackForwardListGetCurrentItem END (OK)");
104 [Description("WebBackForwardList GetPreviousItem.")]
105 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetPreviousItem M")]
106 [Property("SPEC_URL", "-")]
107 [Property("CRITERIA", "MR")]
108 [Property("COVPARAM", "")]
109 [Property("AUTHOR", "guowei.wang@samsung.com")]
110 public async Task WebBackForwardListGetPreviousItem()
112 tlog.Debug(tag, $"WebBackForwardListGetPreviousItem START");
114 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
115 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
117 if (webView.Url.Contains("index.html"))
119 tlog.Info(tag, "onLoadFinished is called!");
120 webView.LoadUrl(secondUrl);
124 tlog.Info(tag, "onLoadFinished is called!");
125 tcs.TrySetResult(true);
128 webView.PageLoadFinished += onLoadFinished;
130 webView.LoadUrl(url);
131 var result = await tcs.Task;
132 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
133 Assert.IsNotNull(webView.BackForwardList.GetPreviousItem(), "handle should not be null.");
135 webView.PageLoadFinished -= onLoadFinished;
137 tlog.Debug(tag, $"WebBackForwardListGetPreviousItem END (OK)");
142 [Description("WebBackForwardList GetNextItem.")]
143 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetNextItem M")]
144 [Property("SPEC_URL", "-")]
145 [Property("CRITERIA", "MR")]
146 [Property("COVPARAM", "")]
147 [Property("AUTHOR", "guowei.wang@samsung.com")]
148 public async Task WebBackForwardListGetNextItem()
150 tlog.Debug(tag, $"WebBackForwardListGetNextItem START");
152 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
153 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
155 if (webView.Url.Contains("index.html"))
157 tlog.Info(tag, "onLoadFinished is called!");
158 webView.LoadUrl(secondUrl);
162 tlog.Info(tag, "onLoadFinished is called!");
164 tcs.TrySetResult(true);
167 webView.PageLoadFinished += onLoadFinished;
169 webView.LoadUrl(url);
170 var result = await tcs.Task;
171 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
172 Assert.IsNotNull(webView.BackForwardList.GetNextItem(), "handle should not be null.");
174 webView.PageLoadFinished -= onLoadFinished;
176 tlog.Debug(tag, $"WebBackForwardListGetNextItem END (OK)");
181 [Description("WebBackForwardList GetItemAtIndex.")]
182 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetItemAtIndex M")]
183 [Property("SPEC_URL", "-")]
184 [Property("CRITERIA", "MR")]
185 [Property("COVPARAM", "")]
186 [Property("AUTHOR", "guowei.wang@samsung.com")]
187 public async Task WebBackForwardListGetItemAtIndex()
189 tlog.Debug(tag, $"WebBackForwardListGetItemAtIndex START");
191 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
192 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
194 if (webView.Url.Contains("index.html"))
196 tlog.Info(tag, "onLoadFinished is called!");
197 webView.LoadUrl(secondUrl);
201 tlog.Info(tag, "onLoadFinished is called!");
202 tcs.TrySetResult(true);
205 webView.PageLoadFinished += onLoadFinished;
207 webView.LoadUrl(url);
208 var result = await tcs.Task;
209 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
210 Assert.IsNotNull(webView.BackForwardList.GetItemAtIndex(0), "handle should not be null.");
212 webView.PageLoadFinished -= onLoadFinished;
214 tlog.Debug(tag, $"WebBackForwardListGetItemAtIndex END (OK)");
219 [Description("WebBackForwardList GetBackwardItems.")]
220 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetBackwardItems M")]
221 [Property("SPEC_URL", "-")]
222 [Property("CRITERIA", "MR")]
223 [Property("COVPARAM", "")]
224 [Property("AUTHOR", "guowei.wang@samsung.com")]
225 public async Task WebBackForwardListGetBackwardItems()
227 tlog.Debug(tag, $"WebBackForwardListGetBackwardItems START");
229 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
230 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
232 if (webView.Url.Contains("index.html"))
234 tlog.Info(tag, "onLoadFinished is called!");
235 webView.LoadUrl(secondUrl);
239 tlog.Info(tag, "onLoadFinished is called!");
240 tcs.TrySetResult(true);
243 webView.PageLoadFinished += onLoadFinished;
245 webView.LoadUrl(url);
246 var result = await tcs.Task;
247 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
248 Assert.IsNotNull(webView.BackForwardList.GetBackwardItems(2), "handle should not be null.");
250 webView.PageLoadFinished -= onLoadFinished;
252 tlog.Debug(tag, $"WebBackForwardListGetBackwardItems END (OK)");
257 [Description("WebBackForwardList GetForwardItems.")]
258 [Property("SPEC", "Tizen.NUI.WebBackForwardList.GetForwardItems M")]
259 [Property("SPEC_URL", "-")]
260 [Property("CRITERIA", "MR")]
261 [Property("COVPARAM", "")]
262 [Property("AUTHOR", "guowei.wang@samsung.com")]
263 public async Task WebBackForwardListGetForwardItems()
265 tlog.Debug(tag, $"WebBackForwardListGetForwardItems START");
267 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
268 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
270 if (webView.Url.Contains("index.html"))
272 tlog.Info(tag, "onLoadFinished is called!");
273 webView.LoadUrl(secondUrl);
277 tlog.Info(tag, "onLoadFinished is called!");
279 tcs.TrySetResult(true);
282 webView.PageLoadFinished += onLoadFinished;
284 webView.LoadUrl(url);
285 var result = await tcs.Task;
286 Assert.IsTrue(result, "PageLoadFinished event should be invoked");
287 Assert.IsNotNull(webView.BackForwardList.GetForwardItems(2), "handle should not be null.");
289 webView.PageLoadFinished -= onLoadFinished;
291 tlog.Debug(tag, $"WebBackForwardListGetForwardItems END (OK)");
296 [Description("WebBackForwardListItem Url.")]
297 [Property("SPEC", "Tizen.NUI.WebBackForwardListItem.Url A")]
298 [Property("SPEC_URL", "-")]
299 [Property("CRITERIA", "PRO")]
300 [Property("COVPARAM", "")]
301 [Property("AUTHOR", "guowei.wang@samsung.com")]
302 public async Task WebBackForwardListItemUrl()
304 tlog.Debug(tag, $"WebBackForwardListItemUrl START");
306 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
307 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
309 tlog.Info(tag, "onLoadFinished is called!");
310 tcs.TrySetResult(true);
312 webView.PageLoadFinished += onLoadFinished;
314 webView.LoadUrl(url);
315 var result = await tcs.Task;
316 Assert.IsTrue(result, "PageLoadFinished event should be invoked.");
318 var testingTarget = webView.BackForwardList.GetCurrentItem();
319 Assert.IsNotNull(testingTarget, "Handle should not be null.");
320 Assert.IsNotNull(testingTarget.Url, "Url should not be null.");
321 Assert.IsTrue(testingTarget.Url.Contains("index.html"), "Url of current item should contain a correct string.");
323 tlog.Debug(tag, $"WebBackForwardListItemUrl END (OK)");
328 [Description("WebBackForwardListItem Title.")]
329 [Property("SPEC", "Tizen.NUI.WebBackForwardListItem.Title A")]
330 [Property("SPEC_URL", "-")]
331 [Property("CRITERIA", "PRO")]
332 [Property("COVPARAM", "")]
333 [Property("AUTHOR", "guowei.wang@samsung.com")]
334 public async Task WebBackForwardListItemTitle()
336 tlog.Debug(tag, $"WebBackForwardListItemTitle START");
338 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
339 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
341 tlog.Info(tag, "onLoadFinished is called!");
342 tcs.TrySetResult(true);
344 webView.PageLoadFinished += onLoadFinished;
346 webView.LoadUrl(url);
347 var result = await tcs.Task;
348 Assert.IsTrue(result, "PageLoadFinished event should be invoked.");
350 var testingTarget = webView.BackForwardList.GetCurrentItem();
351 Assert.IsNotNull(testingTarget, "handle should not be null.");
352 Assert.IsNotNull(testingTarget.Title, "Title should not be null.");
353 Assert.IsTrue(testingTarget.Title.Contains("Title"), "Title of current item should contain a correct string.");
355 tlog.Debug(tag, $"WebBackForwardListItemTitle END (OK)");
360 [Description("WebBackForwardListItem OriginalUrl.")]
361 [Property("SPEC", "Tizen.NUI.WebBackForwardListItem.OriginalUrl A")]
362 [Property("SPEC_URL", "-")]
363 [Property("CRITERIA", "PRO")]
364 [Property("COVPARAM", "")]
365 [Property("AUTHOR", "guowei.wang@samsung.com")]
366 public async Task WebBackForwardListItemOriginalUrl()
368 tlog.Debug(tag, $"WebBackForwardListItemOriginalUrl START");
370 TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
371 EventHandler<WebViewPageLoadEventArgs> onLoadFinished = (s, e) =>
373 tlog.Info(tag, "onLoadFinished is called!");
374 tcs.TrySetResult(true);
376 webView.PageLoadFinished += onLoadFinished;
378 webView.LoadUrl(url);
379 var result = await tcs.Task;
380 Assert.IsTrue(result, "PageLoadFinished event should be invoked.");
382 var testingTarget = webView.BackForwardList.GetCurrentItem();
383 Assert.IsNotNull(testingTarget, "Handle should not be null.");
384 Assert.IsNotNull(testingTarget.OriginalUrl, "Url should not be null.");
385 Assert.IsTrue(testingTarget.OriginalUrl.Contains("index.html"), "Url of current item should contain a correct string.");
387 tlog.Debug(tag, $"WebBackForwardListItemOriginalUrl END (OK)");