[Applications][TCSACR-198][Add a new testcase] 31/194931/3
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 10 Dec 2018 00:20:06 +0000 (09:20 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 10 Dec 2018 08:49:50 +0000 (17:49 +0900)
Added:
 - SendLaunchRequestAsync_TO_UI_APP()

Change-Id: I06df5e25a09b0be2ed2986ce2558f914270df4b0
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply.sln [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.csproj [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/shared/res/Reply.png [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/tizen-manifest.xml [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.Tests/org.tizen.example.Reply-1.0.0.tpk [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.Tests/testcase/TSAppControl.cs

diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply.sln b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply.sln
new file mode 100755 (executable)
index 0000000..f9097d3
--- /dev/null
@@ -0,0 +1,25 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 15\r
+VisualStudioVersion = 15.0.28010.2050\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reply", "Reply\Reply.csproj", "{7ABD6289-AA0F-4268-A633-8B54C1759E4D}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {7ABD6289-AA0F-4268-A633-8B54C1759E4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {7ABD6289-AA0F-4268-A633-8B54C1759E4D}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {7ABD6289-AA0F-4268-A633-8B54C1759E4D}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {7ABD6289-AA0F-4268-A633-8B54C1759E4D}.Release|Any CPU.Build.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityGlobals) = postSolution\r
+               SolutionGuid = {297EF507-9B6A-48C8-BCA8-700F28D05D7D}\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.cs b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.cs
new file mode 100755 (executable)
index 0000000..86b1807
--- /dev/null
@@ -0,0 +1,84 @@
+using System;\r
+using Tizen;\r
+using Tizen.Applications;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+\r
+namespace Reply\r
+{\r
+    class Program : NUIApplication\r
+    {\r
+        static private string LogTag = "Reply";\r
+\r
+        protected override void OnCreate()\r
+        {\r
+            base.OnCreate();\r
+            Initialize();\r
+            Log.Info(LogTag, "OnCreate()");\r
+        }\r
+\r
+        protected override void OnAppControlReceived(AppControlReceivedEventArgs e)\r
+        {\r
+            base.OnAppControlReceived(e);\r
+            Log.Info(LogTag, "OnAppControlReceived()");\r
+            if (e.ReceivedAppControl.IsReplyRequest == true)\r
+            {\r
+                AppControl replyRequest = new AppControl();\r
+                e.ReceivedAppControl.ReplyToLaunchRequest(replyRequest, AppControlReplyResult.Succeeded);\r
+                Log.Info(LogTag, "ReplyToLaunchRequest()");\r
+            }\r
+        }\r
+\r
+        protected override void OnResume()\r
+        {\r
+            base.OnResume();\r
+            Log.Info(LogTag, "OnResume()");\r
+        }\r
+\r
+        protected override void OnPause()\r
+        {\r
+            base.OnPause();\r
+            Log.Info(LogTag, "OnPause()");\r
+        }\r
+\r
+        protected override void OnTerminate()\r
+        {\r
+            base.OnTerminate();\r
+            Log.Info(LogTag, "OnTerminte()");\r
+        }\r
+\r
+        void Initialize()\r
+        {\r
+            Window.Instance.KeyEvent += OnKeyEvent;\r
+\r
+            TextLabel text = new TextLabel("Hello Tizen NUI World");\r
+            text.HorizontalAlignment = HorizontalAlignment.Center;\r
+            text.VerticalAlignment = VerticalAlignment.Center;\r
+            text.TextColor = Color.Blue;\r
+            text.PointSize = 12.0f;\r
+            text.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+            text.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+            Window.Instance.GetDefaultLayer().Add(text);\r
+\r
+            Animation animation = new Animation(2000);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);\r
+            animation.Looping = true;\r
+            animation.Play();\r
+        }\r
+\r
+        public void OnKeyEvent(object sender, Window.KeyEventArgs e)\r
+        {\r
+            if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))\r
+            {\r
+                Exit();\r
+            }\r
+        }\r
+\r
+        static void Main(string[] args)\r
+        {\r
+            var app = new Program();\r
+            app.Run(args);\r
+        }\r
+    }\r
+}\r
diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.csproj b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/Reply.csproj
new file mode 100755 (executable)
index 0000000..5f980d9
--- /dev/null
@@ -0,0 +1,28 @@
+<Project Sdk="Microsoft.NET.Sdk">\r
+\r
+  <PropertyGroup>\r
+    <OutputType>Exe</OutputType>\r
+    <TargetFramework>netcoreapp2.0</TargetFramework>\r
+  </PropertyGroup>\r
+\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugType>portable</DebugType>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>None</DebugType>\r
+  </PropertyGroup>\r
+\r
+  <ItemGroup>\r
+    <Folder Include="lib\"/>\r
+    <Folder Include="res\"/>\r
+  </ItemGroup>\r
+\r
+  <ItemGroup>\r
+    <PackageReference Include="Tizen.NET" Version="5.0.0.14562" >\r
+      <ExcludeAssets>Runtime</ExcludeAssets>\r
+    </PackageReference>\r
+    <PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />\r
+  </ItemGroup>\r
+\r
+</Project>\r
+\r
diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/shared/res/Reply.png b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/shared/res/Reply.png
new file mode 100755 (executable)
index 0000000..9f3cb98
Binary files /dev/null and b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/shared/res/Reply.png differ
diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/tizen-manifest.xml b/tct-suite-vs/Resource/Tizen.Applications.Tests/code/Reply/Reply/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..a8ca162
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="5" package="org.tizen.example.Reply" version="1.0.0">\r
+  <profile name="common" />\r
+  <ui-application appid="org.tizen.example.Reply"\r
+                                       exec="Reply.dll"\r
+                                       type="dotnet"\r
+                                       multiple="false"\r
+                                       taskmanage="true"\r
+                                       nodisplay="false"\r
+                                       launch_mode="single">\r
+    <label>Reply</label>\r
+    <icon>Reply.png</icon>\r
+    <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />\r
+  </ui-application>\r
+</manifest>\r
diff --git a/tct-suite-vs/Resource/Tizen.Applications.Tests/org.tizen.example.Reply-1.0.0.tpk b/tct-suite-vs/Resource/Tizen.Applications.Tests/org.tizen.example.Reply-1.0.0.tpk
new file mode 100755 (executable)
index 0000000..8d4ceca
Binary files /dev/null and b/tct-suite-vs/Resource/Tizen.Applications.Tests/org.tizen.example.Reply-1.0.0.tpk differ
index 736fcc310bc3503e5bf1ffdfcc6781b501bc0223..afeb64bbcb85f74faddf9d0d037da5bc54cf21a9 100755 (executable)
@@ -18,6 +18,7 @@ namespace Tizen.Applications.Tests
         private const string MyAppId1 = "org.tizen.SampleServiceApp2.Tizen";
         private const string MyUIAppId = "org.tizen.example.UIApp.Tizen";
         private static bool _flag;
+        private static bool _replyFlag = false;
 
         [SetUp]
         public static void Init()
@@ -430,5 +431,52 @@ namespace Tizen.Applications.Tests
             AppControl MyAppControl = new AppControl();
             Assert.Throws<ArgumentException>(() => Tizen.Applications.AppControl.SendTerminateRequest(MyAppControl));
         }
+
+        static void ReplyReceivedCallback(Tizen.Applications.AppControl launchRequest, Tizen.Applications.AppControl replyRequest, AppControlReplyResult result)
+        {
+            if (result == AppControlReplyResult.Succeeded)
+                _replyFlag = true;
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Send Launch Request Asynchronously - UI app should be launched")]
+        [Property("SPEC", "Tizen.Applications.AppControl.SendLaunchRequestAsync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        [Property("COVPARAM", "Tizen.Applications.AppControl, Tizen.Applications.AppControlReplyCallback")]
+        public async Task SendLaunchRequestAsync_TO_UI_APP()
+        {
+
+            /* PRECONDITION
+             * Install org.tizen.example.Reply.tpk  <in folder res/>
+             * Privilege: http://tizen.org/privilege/appmanager.launch
+             * */
+
+            /* TEST CODE */
+            bool isRunning = false;
+            string appId = "org.tizen.example.Reply";
+
+            _appControl = new Tizen.Applications.AppControl();
+            Assert.IsNotNull(_appControl, "Object should not be null after initializing");
+
+            _appControl.Operation = AppControlOperations.Default;
+            _appControl.ApplicationId = appId;
+
+            AppControlResult result = await Tizen.Applications.AppControl.SendLaunchRequestAsync(_appControl, ReplyReceivedCallback);
+            Assert.AreEqual(result, AppControlResult.None, "The result should be None.");
+            _runningApps = ApplicationManager.GetRunningApplicationsAsync();
+            _list = await _runningApps;
+            foreach (var app in _list)
+            {
+                if (app.ApplicationId == appId)
+                    isRunning = true;
+            }
+            Assert.IsTrue(isRunning, appId + " should be running after launching request has sent");
+
+            await Task.Delay(5000);
+            Assert.IsTrue (_replyFlag, " The flag should be true");
+        }
     }
 }