From: Junghoon Park Date: Fri, 14 Dec 2018 04:50:44 +0000 (+0900) Subject: [WidgetApplication][TCSACR-200] Add a testcase X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F195501%2F3;p=test%2Ftct%2Fcsharp%2Fapi.git [WidgetApplication][TCSACR-200] Add a testcase Change-Id: I5e2f4fe085e34a6c5bd1499cdd8cd4459bcbab4c Signed-off-by: Junghoon Park --- diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker-1.0.0.tpk b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker-1.0.0.tpk new file mode 100755 index 000000000..7c32a2828 Binary files /dev/null and b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker-1.0.0.tpk differ diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker.sln b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker.sln new file mode 100755 index 000000000..05d9bb867 --- /dev/null +++ b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.10 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WidgetAppInstChecker", "WidgetAppInstChecker\WidgetAppInstChecker.csproj", "{DE51BB9C-25EF-45B4-A0D1-035CFB94FAFE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE51BB9C-25EF-45B4-A0D1-035CFB94FAFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE51BB9C-25EF-45B4-A0D1-035CFB94FAFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE51BB9C-25EF-45B4-A0D1-035CFB94FAFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE51BB9C-25EF-45B4-A0D1-035CFB94FAFE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {378BEAC8-BE3D-498A-89E9-BB502CE5133F} + EndGlobalSection +EndGlobal diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetAppInstChecker.csproj b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetAppInstChecker.csproj new file mode 100755 index 000000000..fb4c08b0b --- /dev/null +++ b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetAppInstChecker.csproj @@ -0,0 +1,45 @@ + + + + + + $(MSBuildExtensionsPath)\Tizen\VisualStudio\ + + + + + + + + Exe + netcoreapp2.0 + + + + portable + + + None + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetApp_App.cs b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetApp_App.cs new file mode 100755 index 000000000..3d00a6c1a --- /dev/null +++ b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/WidgetApp_App.cs @@ -0,0 +1,93 @@ +using System; +using ElmSharp; +using Tizen; +using Tizen.Applications; + +namespace WidgetApp +{ + class MyWidget : WidgetBase + { + private static string _logTag = Application.Current.ApplicationInfo.ApplicationId; + + public override void OnCreate(Bundle content, int w, int h) + { + Log.Warn(_logTag, "OnCreate - w(" + w + "), h(" + h + ")"); + + try + { + base.OnCreate(content, w, h); + + Conformant conformant = new Conformant(Window); + conformant.Show(); + + Label label = new Label(Window); + label.Color = Color.White; + label.Text = "WidgetApp"; + label.Resize(w, h); + label.Show(); + + Box box = new Box(Window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + box.Show(); + + box.PackEnd(label); + + conformant.SetContent(box); + } + catch (Exception e) + { + Log.Warn(_logTag, "exception " + e); + } + + Log.Debug(_logTag, "ID:" + Id); + Bundle b = new Bundle(); + b.AddItem("InstID", Id); + SetContent(b); + } + + public override void OnPause() + { + base.OnPause(); + Log.Debug(_logTag, "OnPause"); + } + + public override void OnResume() + { + base.OnResume(); + Log.Debug(_logTag, "OnResume"); + } + + public override void OnResize(int w, int h) + { + base.OnResize(w, h); + Log.Debug(_logTag, "OnResize - w(" + w + "), h(" + h + ")"); + } + + public override void OnUpdate(Bundle content, bool isForce) + { + base.OnUpdate(content, isForce); + Log.Debug(_logTag, "OnUpdate - isForce(" + isForce + ")"); + } + + public override void OnDestroy(WidgetDestroyType reason, Bundle content) + { + base.OnDestroy(reason, content); + Log.Debug(_logTag, "OnDestroy"); + } + } + + class Program + { + static void Main(string[] args) + { + WidgetApplication app = new WidgetApplication(typeof(MyWidget)); + + app.Run(args); + } + } +} diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/shared/res/WidgetAppInstChecker.png b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/shared/res/WidgetAppInstChecker.png new file mode 100755 index 000000000..9f3cb9860 Binary files /dev/null and b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/shared/res/WidgetAppInstChecker.png differ diff --git a/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/tizen-manifest.xml b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/tizen-manifest.xml new file mode 100755 index 000000000..982bc628a --- /dev/null +++ b/tct-suite-vs/Resource/Tizen.WidgetApplication.Tests/WidgetAppInstChecker/WidgetAppInstChecker/tizen-manifest.xml @@ -0,0 +1,18 @@ + + + + + + WidgetAppInstChecker.png + 4x2 + + WidgetAppInstChecker.png + + 2x2 + + + diff --git a/tct-suite-vs/Tizen.WidgetApplication.Tests/testcase/TSWidgetBase.cs b/tct-suite-vs/Tizen.WidgetApplication.Tests/testcase/TSWidgetBase.cs index b38e692b0..3be7ae4e7 100755 --- a/tct-suite-vs/Tizen.WidgetApplication.Tests/testcase/TSWidgetBase.cs +++ b/tct-suite-vs/Tizen.WidgetApplication.Tests/testcase/TSWidgetBase.cs @@ -1,7 +1,9 @@ using NUnit.Framework; using NUnit.Framework.TUnit; +using ElmSharp; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Tizen.Applications.Tests { @@ -33,6 +35,49 @@ namespace Tizen.Applications.Tests { [TestFixture] [Description("Testing Tizen.Applications.WidgetBase class")] public class WidgetBaseTests { + private Tizen.Applications.WidgetControl _widgetControl; + private string _widgetId = "org.tizen.WidgetAppInstChecker"; + private Window _window; + private Background _background; + private RemoteView _remoteView; + private bool _created; + + private void LaunchWidget() + { + if (_window == null) + { + _window = new Window(Application.Current.ApplicationInfo.ApplicationId); + _window.Show(); + _background = new Background(_window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = Color.Black + }; + _background.Show(); + _window.AddResizeObject(_background); + + RemoteViewFactory.Init(_window); + _remoteView = RemoteViewFactory.Create(_window, _widgetId, "", 0, true, true, true); + _remoteView.Layout.Resize(712, 712); + _remoteView.Layout.Show(); + } + } + + private void ShutdownWidget() + { + _window = null; + _background = null; + _remoteView = null; + _created = false; + } + + private void OnCreated(object sender, Tizen.Applications.WidgetLifecycleEventArgs args) + { + _created = true; + } [SetUp] public static void Init() @@ -60,5 +105,40 @@ namespace Tizen.Applications.Tests { Assert.NotNull(bWidget, "Should not return NULL"); Assert.IsInstanceOf(bWidget, "Should return WidgetBase instance."); } + + [Test] + [Category("P1")] + [Description("Create a widget with default value")] + [Property("SPEC", "Tizen.Applications.WidgetBase.Id A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Junghoon Park, jh9216.park@samsung.com")] + public async Task Id_PROPERTY_GET() + { + /* PRECONDITION + * */ + ShutdownWidget(); + _widgetControl = new Tizen.Applications.WidgetControl(_widgetId); + _widgetControl.Created += OnCreated; + LaunchWidget(); + await Task.Delay(4000); + Assert.True(_created); + string content = _remoteView.Content; + Assert.NotNull(content); + + /* TEST CODE */ + Bundle b = Bundle.Decode(content); + b.TryGetItem("InstID", out string val); + Assert.NotNull(val); + Assert.AreEqual(val, _widgetId); + + /* POSTCONDITION + * */ + b.Dispose(); + ShutdownWidget(); + _widgetControl.Created -= OnCreated; + _widgetControl.Dispose(); + _widgetControl = null; + } } } diff --git a/tct-suite-vs/Tizen.WidgetApplication.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.WidgetApplication.Tests/tizen-manifest.xml index 671e45893..933eec8f5 100644 --- a/tct-suite-vs/Tizen.WidgetApplication.Tests/tizen-manifest.xml +++ b/tct-suite-vs/Tizen.WidgetApplication.Tests/tizen-manifest.xml @@ -12,5 +12,6 @@ http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/widget.viewer