From: yh106.jung Date: Tue, 30 Apr 2019 00:57:41 +0000 (+0900) Subject: [WebView][TCSACR-219] Adds manual TCT for Tizen.WebView X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3eefa1ce5251431591da751e261a7335d3e20204;p=test%2Ftct%2Fcsharp%2Fapi.git [WebView][TCSACR-219] Adds manual TCT for Tizen.WebView This patch adds manual TCT for Tizen.WebView. Change-Id: I29193b9d12352ae0f1d9f0b4b3abe07429e47e63 Signed-off-by: yh106.jung --- diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/Program.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/Program.cs new file mode 100755 index 0000000..d94f055 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/Program.cs @@ -0,0 +1,52 @@ +/* + * 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 System; +using NUnit.Framework; +using Xamarin.Forms; +using Tizen.WebView; + +namespace XamarinApplication.Tizen +{ + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + private Application _app; + protected override void OnCreate() + { + Console.WriteLine("TCT : OnCreate()"); + base.OnCreate(); + if (ManualTest.IsWearable()) + { + _app = new WearableTemplate.MainPage(); + } + else + { + _app = new ManualTemplate.MainPage(); + } + LoadApplication(_app); + } + + static void Main(string[] args) + { + Console.WriteLine("TCT : Main()"); + var app = new Program(); + global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); + Chromium.Initialize(); + app.Run(args); + Chromium.Shutdown(); + } + } +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.csproj b/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.csproj new file mode 100755 index 0000000..10ee118 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.csproj @@ -0,0 +1,39 @@ + + + + + Exe + tizen60 + + + + + true + + + + portable + + + None + + + + + + + + + + + Runtime + + + + + + + + + + diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.sln b/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.sln new file mode 100755 index 0000000..e1cac60 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/Tizen.WebView.Manual.Tests.sln @@ -0,0 +1,92 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.15 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.WebView.Manual.Tests", "Tizen.WebView.Manual.Tests.csproj", "{D92BEEAC-3B2A-45F8-8C53-53B92550404A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\nunit.framework\nunit.framework.csproj", "{B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\nunitlite.csproj", "{FDB8025A-C029-461F-895E-287B4C65939B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplate", "..\Template\ManualTemplate\ManualTemplate.csproj", "{269F89A7-E648-4811-8421-844E00ACF5F0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplateForWearable", "..\Template\ManualTemplateForWearable\ManualTemplateForWearable.csproj", "{D36CED01-29BD-4EB3-8903-62E0BF2A822D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x64.ActiveCfg = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x64.Build.0 = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x86.ActiveCfg = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Debug|x86.Build.0 = Debug|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|Any CPU.Build.0 = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x64.ActiveCfg = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x64.Build.0 = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x86.ActiveCfg = Release|Any CPU + {269F89A7-E648-4811-8421-844E00ACF5F0}.Release|x86.Build.0 = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x64.ActiveCfg = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x64.Build.0 = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x86.ActiveCfg = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|x86.Build.0 = Debug|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.Build.0 = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x64.ActiveCfg = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x64.Build.0 = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x86.ActiveCfg = Release|Any CPU + {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED382B91-9930-40B6-B3D7-362304C78680} + EndGlobalSection +EndGlobal diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/res/context_menu.html b/tct-suite-vs/Tizen.WebView.Manual.Tests/res/context_menu.html new file mode 100755 index 0000000..c829c2a --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/res/context_menu.html @@ -0,0 +1,17 @@ + + + Testing Context Menu + + + + +

Context Menu Test Page

+

Please long press below image.

+ Test image + + diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/res/tizen.png b/tct-suite-vs/Tizen.WebView.Manual.Tests/res/tizen.png new file mode 100644 index 0000000..46b80ab Binary files /dev/null and b/tct-suite-vs/Tizen.WebView.Manual.Tests/res/tizen.png differ diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/shared/res/Tizen.WebView.Manual.Tests.png b/tct-suite-vs/Tizen.WebView.Manual.Tests/shared/res/Tizen.WebView.Manual.Tests.png new file mode 100755 index 0000000..9765b1b Binary files /dev/null and b/tct-suite-vs/Tizen.WebView.Manual.Tests/shared/res/Tizen.WebView.Manual.Tests.png differ diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenu.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenu.cs new file mode 100755 index 0000000..2be1d7d --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenu.cs @@ -0,0 +1,267 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using NUnit.Framework.TUnit; + +namespace Tizen.WebView.Manual.Tests +{ + [TestFixture] + [Description("Tizen.WebView.ContextMenu test")] + class ContextMenuTests + { + private WebView _webView; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for Tizen.WebView.ContextMenu TEST"); + _webView = WebViewCommon.GetWebViewPage(); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Postconditions for Tizen.WebView.ContextMenu TEST"); + WebViewCommon.RemoveWebViewPage(); + _webView = null; + } + + [Test] + [Category("P1")] + [Description("Test: Append new item to context menu.")] + [Property("SPEC", "Tizen.WebView.ContextMenu.AppendItem M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MAE")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task AppendItem_ENUM_ALL() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + /* TEST CODE */ + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + bool isFailed = false; + foreach (ContextMenuItemTag tag in Enum.GetValues(typeof(ContextMenuItemTag))) + { + var count = menu.ItemCount; + var newItem = menu.AppendItem(tag, tag.ToString(), null, true); + + if (newItem == null || tag != newItem.ItemTag || menu.ItemCount - count != 1) + { + isFailed = true; + break; + } + } + + if (isFailed) + { + ManualTest.ConfirmFail("Failed to append item"); + } + else + { + ManualTest.Confirm(); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + + [Test] + [Category("P1")] + [Description("Test: Gets the item of the context menu.")] + [Property("SPEC", "Tizen.WebView.ContextMenu.GetItemAtIndex M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task GetItemAtIndex_RETURN_VALUE() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + 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.IsTrue(menu.ItemCount > 0, "ContextMenu has no item"); + var item = menu.GetItemAtIndex(0); + if (item != null && item.GetType() == typeof(ContextMenuItem)) + { + ManualTest.Confirm(); + } + else + { + ManualTest.ConfirmFail("Item is invalid object"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + + [Test] + [Category("P1")] + [Description("Test: Removes the item from the context menu.")] + [Property("SPEC", "Tizen.WebView.ContextMenu.RemoveItem M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MCST")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task RemoveItem_CHANGE_STATUS() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + /* TEST CODE */ + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + var count = menu.ItemCount; + Assert.IsTrue(count > 0, "There are no items in the context menu"); + menu.RemoveItem(menu.GetItemAtIndex(0)); + if (menu.ItemCount - count == -1) + { + ManualTest.Confirm(); + } + else + { + ManualTest.ConfirmFail("Failed to remove item"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + + [Test] + [Category("P1")] + [Description("Test: Gets the count of items in the context menu.")] + [Property("SPEC", "Tizen.WebView.ContextMenu.ItemCount A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task ItemCount_READ_ONLY() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + /* TEST CODE */ + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + if (menu.ItemCount > 0) + { + ManualTest.Confirm(); + } + else + { + ManualTest.ConfirmFail("There are no items in the context menu"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + }; +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItem.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItem.cs new file mode 100755 index 0000000..1463970 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItem.cs @@ -0,0 +1,86 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using NUnit.Framework.TUnit; + +namespace Tizen.WebView.Manual.Tests +{ + [TestFixture] + [Description("Tizen.WebView.ContextMenuItem test")] + class ContextMenuItemTests + { + private WebView _webView; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for Tizen.WebView.ContextMenuItem TEST"); + _webView = WebViewCommon.GetWebViewPage(); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Postconditions for Tizen.WebView.ContextMenuItem TEST"); + WebViewCommon.RemoveWebViewPage(); + _webView = null; + } + + [Test] + [Category("P1")] + [Description("Test: Gets ItemTag property of ContextMenuItem.")] + [Property("SPEC", "Tizen.WebView.ContextMenuItem.ItemTag A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task ItemTag_READ_ONLY() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + 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.IsTrue(menu.ItemCount > 0, "ContextMenu has no item"); + var item = menu.GetItemAtIndex(0); + if (item != null && item.ItemTag.GetType() == typeof(ContextMenuItemTag)) + { + ManualTest.Confirm(); + } + else + { + ManualTest.ConfirmFail("ItemTag is invalid object"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + } +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItemEventArgs.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItemEventArgs.cs new file mode 100755 index 0000000..db4e34d --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSContextMenuItemEventArgs.cs @@ -0,0 +1,103 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using NUnit.Framework.TUnit; + +namespace Tizen.WebView.Manual.Tests +{ + [TestFixture] + [Description("Tizen.WebView.ContextMenuItemEventArgs test")] + class ContextMenuItemEventArgsTests + { + private WebView _webView; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for Tizen.WebView.ContextMenuItemEventArgs TEST"); + _webView = WebViewCommon.GetWebViewPage(); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Postconditions for Tizen.WebView.ContextMenuItemEventArgs TEST"); + WebViewCommon.RemoveWebViewPage(); + _webView = null; + } + + [Test] + [Category("P1")] + [Description("Test: Gets Item property of ContextMenuItemEventArgs.")] + [Property("SPEC", "Tizen.WebView.ContextMenuItemEventArgs.Item A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "Select item of the context menu.")] + [Step(4, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task Item_READ_ONLY() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + var count = menu.ItemCount; + for (int i = 0; i < count; i++) + { + menu.RemoveItem(menu.GetItemAtIndex(0)); + } + + var newItem = menu.AppendItem(WebViewCommon.CustomItemTag, "Select me!!!", null, true); + if (newItem == null) + { + ManualTest.ConfirmFail("Failed to append item"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + /* TEST CODE */ + EventHandler onContextMenuItemSelected = (s, e) => + { + var item = e.Item; + if (item != null && item.GetType() == typeof(ContextMenuItem)) + { + ManualTest.Confirm(); + } + else + { + ManualTest.ConfirmFail("Seleted item is invalid object"); + } + }; + _webView.ContextMenuItemSelected += onContextMenuItemSelected; + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + _webView.ContextMenuItemSelected -= onContextMenuItemSelected; + } + } +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSWebView.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSWebView.cs new file mode 100755 index 0000000..dc07c46 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/TSWebView.cs @@ -0,0 +1,143 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using NUnit.Framework.TUnit; + +namespace Tizen.WebView.Manual.Tests +{ + [TestFixture] + [Description("Tizen.WebView.WebView test")] + class WebViewTests + { + private WebView _webView; + + [SetUp] + public void Init() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for Tizen.WebView.WebView TEST"); + _webView = WebViewCommon.GetWebViewPage(); + } + + [TearDown] + public void Destroy() + { + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Postconditions for Tizen.WebView.WebView TEST"); + WebViewCommon.RemoveWebViewPage(); + _webView = null; + } + + [Test] + [Category("P1")] + [Description("Test: 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")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task SetContextMenuCustomizeDelegate_CHANGE_STATUS() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + /* TEST CODE */ + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + ManualTest.Confirm(); + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + } + + [Test] + [Category("P1")] + [Description("Test: Checks event that occurs when customized item is selected.")] + [Property("SPEC", "Tizen.WebView.WebView.ContextMenuItemSelected E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Youngha Jung, yh106.jung@samsung.com")] + [Precondition(1, "Context menu is not supported on TV profile. So the testcase will be passed automatically after run if the profile is TV.")] + [Step(1, "Click run TC.")] + [Step(2, "Long press image of test page.")] + [Step(3, "Select item of the context menu.")] + [Step(4, "If there is no exception, test will be automatically passed.")] + [Postcondition(1, "NA")] + public async Task ContextMenuItemSelected_CHECK_EVENT() + { + /* PRECONDITION */ + if (WebViewCommon.IsTVProfile()) + { + Assert.Pass("Context menu is not supported on TV profile"); + } + + TaskCompletionSource tcs = new TaskCompletionSource(false); + EventHandler onLoadFinished = (s, e) => { tcs.TrySetResult(true); }; + EventHandler onLoadError = (s, e) => { tcs.TrySetResult(false); }; + + _webView.LoadFinished += onLoadFinished; + _webView.LoadError += onLoadError; + + _webView.LoadUrl(WebViewCommon.ContextMenuHtml); + var result = await tcs.Task; + + _webView.LoadFinished -= onLoadFinished; + _webView.LoadError -= onLoadError; + + Assert.IsTrue(result, "LoadUrl method failed"); + + WebView.ContextMenuCustomize contextMenuCustomize = (ContextMenu menu) => + { + var count = menu.ItemCount; + for (int i = 0; i < count; i++) + { + menu.RemoveItem(menu.GetItemAtIndex(0)); + } + + var newItem = menu.AppendItem(WebViewCommon.CustomItemTag, "Select me!!!", null, true); + if (newItem == null) + { + ManualTest.ConfirmFail("Failed to append item"); + } + }; + _webView.SetContextMenuCustomizeDelegate(contextMenuCustomize); + + /* TEST CODE */ + EventHandler onContextMenuItemSelected = (s, e) => + { + ManualTest.Confirm(); + }; + _webView.ContextMenuItemSelected += onContextMenuItemSelected; + + await ManualTest.WaitForConfirm(); + + /* POSTCONDITION */ + _webView.SetContextMenuCustomizeDelegate(null); + _webView.ContextMenuItemSelected -= onContextMenuItemSelected; + } + } +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/support/WebViewCommon.cs b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/support/WebViewCommon.cs new file mode 100755 index 0000000..71efc94 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/testcase/support/WebViewCommon.cs @@ -0,0 +1,112 @@ +using ElmSharp; +using Tizen.WebView; +using Tizen.System; + +namespace Tizen.WebView.Manual.Tests +{ + internal static class WebViewCommon + { + private static Window _window; + private static Box _box; + private static WebView _webView; + private static string _profile; + + public const string ContextMenuHtml = "file:///opt/usr/home/owner/share/res/context_menu.html"; + public const ContextMenuItemTag CustomItemTag = ContextMenuItemTag.BaseApplicationTag + 1; + + public static WebView GetWebViewPage() + { + if (_window == null) + { + Elementary.Initialize(); + + _window = new Window("Tizen.WebView.Test"); + _window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false); + _window.KeyUp += (s, e) => + { + if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName) + RemoveWebViewPage(); + + }; + _window.Show(); + + Background background = new Background(_window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = Color.White + }; + background.Show(); + _window.AddResizeObject(background); + + Conformant conformant = new Conformant(_window); + conformant.Show(); + + _box = new Box(_window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + _box.Show(); + conformant.SetContent(_box); + } + else + { + _window.Show(); + } + + _webView = new WebView(_window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + _webView.Show(); + + _box.PackEnd(_webView); + + return _webView; + } + + public static void RemoveWebViewPage() + { + if (_webView != null) + { + _box.UnPack(_webView); + _webView.Unrealize(); + _webView = null; + } + _window.Hide(); + } + + public static bool IsTVProfile() + { + return string.Compare("tv", GetProfile()) == 0 ? true : false; + } + + public static bool IsMobileProfile() + { + return string.Compare("mobile", GetProfile()) == 0 ? true : false; + } + + public static bool IsWearableProfile() + { + return string.Compare("wearable", GetProfile()) == 0 ? true : false; + } + + private static string GetProfile() + { + if (string.IsNullOrEmpty(_profile)) + { + Information.TryGetValue("http://tizen.org/feature/profile", out _profile); + } + + return _profile; + } + } +} diff --git a/tct-suite-vs/Tizen.WebView.Manual.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.WebView.Manual.Tests/tizen-manifest.xml new file mode 100755 index 0000000..e327787 --- /dev/null +++ b/tct-suite-vs/Tizen.WebView.Manual.Tests/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + Tizen.WebView.Manual.Tests.png + + + + http://tizen.org/privilege/appmanager.launch + +