[ComponentBased][TCSACR-398][Add new testcases for ComponentPort] 57/253057/12
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 9 Feb 2021 03:37:51 +0000 (12:37 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 9 Feb 2021 03:37:51 +0000 (12:37 +0900)
Adds:
 - ComponentPort_INIT
 - ComponentPort_INIT_WITH_NULL_AND_CHECK_ARGUMENTEXCEPTION
 - ComponentPort_INIT_WITH_EMPTYSTRING_AND_CHECK_ARGUMENTEXCEPTION
 - ComponentPort_INIT_AND_CHECK_IOEXCEPTION
 - PortName_GET
 - AddPrivilege_CHECK_WITHOUT_ARGUMENTEXCEPTION
 - AddPrivilege_CHECK_WITH_NULL_AND_CHECK_ARGUMENTEXCEPTION
 - AddPrivilege_CHECK_WITH_EMPTYSTRING_AND_CHECK_ARGUMENTEXCEPTION
 - WaitForEvent_CHECK_COUNT
 - Cancel_CHECK_COUNT
 - Send_CHECK_WITHOUT_EXCEPTION
 - Send_CHECK_WITH_ARUMENTEXCEPTION
 - Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION
 - SendSync_CHECK_WITHOUT_EXCEPTION
 - SendSync_CHECK_WITH_ARUMENTEXCEPTION
 - SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION
 - OnSyncRequestEvent_CHECK
 - OnRequestEvent_CHECK

Change-Id: I75b8f4e95808eb7ae27695a98b70caab623cf2fe
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
14 files changed:
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest.sln [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/App.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/ComponentPortTest.csproj [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Log.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Port.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Request.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Response.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Service.cs [new file with mode: 0755]
tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/tizen-manifest.xml [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Program.cs [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.csproj [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.sln [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/testcase/TSComponentPort.cs [new file with mode: 0755]
tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/tizen-manifest.xml [new file with mode: 0755]

diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest.sln b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest.sln
new file mode 100755 (executable)
index 0000000..8aef488
--- /dev/null
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30517.126
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentPortTest", "ComponentPortTest\ComponentPortTest.csproj", "{8A33B7D5-0548-4BFD-96F8-DFAAB0B799BE}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {8A33B7D5-0548-4BFD-96F8-DFAAB0B799BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {8A33B7D5-0548-4BFD-96F8-DFAAB0B799BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {8A33B7D5-0548-4BFD-96F8-DFAAB0B799BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {8A33B7D5-0548-4BFD-96F8-DFAAB0B799BE}.Release|Any CPU.Build.0 = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+       GlobalSection(ExtensibilityGlobals) = postSolution
+               SolutionGuid = {B96E82DA-8CC5-410A-BC1F-F38A154C3705}
+       EndGlobalSection
+EndGlobal
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/App.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/App.cs
new file mode 100755 (executable)
index 0000000..ac210be
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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 System.Collections.Generic;
+using Tizen.Applications;
+using Tizen.Applications.ComponentBased.Default;
+
+namespace ServicePort
+{
+    class App
+    {
+        static void Main(string[] args)
+        {
+            Log.Info("Main()");
+            Dictionary<Type, string> typeInfo = new Dictionary<Type, string>();
+            typeInfo.Add(typeof(Service), "Service");
+            var app = new EFLComponentBasedApplication(typeInfo);
+            app.Run(args);
+        }
+    }
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/ComponentPortTest.csproj b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/ComponentPortTest.csproj
new file mode 100755 (executable)
index 0000000..0da868b
--- /dev/null
@@ -0,0 +1,28 @@
+<Project Sdk="Tizen.NET.Sdk/1.1.6">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>tizen90</TargetFramework>
+      <AssemblyName>ComponentPortTest</AssemblyName>
+  </PropertyGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugType>portable</DebugType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>None</DebugType>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Folder Include="lib\" />
+    <Folder Include="res\" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen.NET" Version="9.0.0.15923">
+      <ExcludeAssets>Runtime</ExcludeAssets>
+    </PackageReference>
+  </ItemGroup>
+
+</Project>
+
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Log.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Log.cs
new file mode 100755 (executable)
index 0000000..ac298d0
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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.Runtime.CompilerServices;
+
+namespace ServicePort
+{
+    public class Log
+    {
+        private static string LogTag = "ServicePort";
+
+        public static void Info(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            Tizen.Log.Info(LogTag, message, file, func, line);
+        }
+
+        public static void Error(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            Tizen.Log.Error(LogTag, message, file, func, line);
+        }
+
+        public static void Warn(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            Tizen.Log.Warn(LogTag, message, file, func, line);
+        }
+
+        public static void Debug(string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
+        {
+            Tizen.Log.Debug(LogTag, message, file, func, line);
+        }
+    }
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Port.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Port.cs
new file mode 100755 (executable)
index 0000000..dbe9e2f
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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 Tizen.Applications.ComponentBased;
+
+namespace ServicePort
+{
+    public sealed class Port : ComponentPort
+    {
+        public Port(string name) : base(name)
+        {
+            Log.Info("Port(): " + PortName);
+        }
+
+        protected override void OnRequestEvent(string sender, object request)
+        {
+            Log.Info("OnRequestEvent() sender: " + sender);
+            if (request.GetType() == typeof(Request))
+            {
+                var req = (Request)request;
+                Log.Info("Command: " + req.Command + " Sequence: " + req.Sequence + " Message: " + req.Message);
+
+                if (req.Command == "OnRequestEvent_CHECK")
+                {
+                    Service.SendMessage(0);
+                }
+            }
+            else if (request.GetType() == typeof(Response))
+            {
+                var res = (Response)request;
+                Log.Info("Command: " + res.Command + " Sequence: " + res.Sequence + " Result: " + res.Result);
+            }
+        }
+
+        protected override object OnSyncRequestEvent(string sender, object request)
+        {
+            Log.Info("OnSyncRequestEvent() sender: " + sender);
+            Response res;
+            if (request.GetType() == typeof(Request))
+            {
+                var req = (Request)request;
+                Log.Info("Command: " + req.Command + " Sequence: " + req.Sequence + " Message: " + req.Message);
+
+                if (req.Command == "OnSyncRequestEvent_CHECK")
+                {
+                    Service.SendMessage(0);
+                }
+
+                res = new Response(req.Command, req.Sequence, 0);
+            }
+            else
+            {
+                Log.Error("Invalid request");
+                res = new Response("Unknown", -1, -1);
+            }
+
+            return res;
+        }
+    }
+
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Request.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Request.cs
new file mode 100755 (executable)
index 0000000..b4ae902
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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;
+
+namespace ServicePort
+{
+    [Serializable]
+    public class Request
+    {
+        public Request(string command, int sequence, string message)
+        {
+            Command = command;
+            Sequence = sequence;
+            Message = message;
+        }
+
+        public string Command
+        {
+            get; set;
+        }
+
+        public string Message
+        {
+            get; set;
+        }
+
+        public int Sequence
+        {
+            get; set;
+        }
+    }
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Response.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Response.cs
new file mode 100755 (executable)
index 0000000..fccf5b4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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;
+
+namespace ServicePort
+{
+    [Serializable]
+    public class Response
+    {
+        public Response(string command, int sequence, int result)
+        {
+            Command = command;
+            Sequence = sequence;
+            Result = result;
+        }
+
+        public string Command
+        {
+            get; set;
+        }
+
+        public int Sequence
+        {
+            get; set;
+        }
+
+        public int Result
+        {
+            get; set;
+        }
+    }
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Service.cs b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/Service.cs
new file mode 100755 (executable)
index 0000000..fe7a201
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * 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 System.Threading;
+using Tizen.Applications;
+using Tizen.Applications.ComponentBased.Common;
+using Tizen.Applications.Messages;
+
+namespace ServicePort
+{
+    public class Service : ServiceComponent
+    {
+        private Thread _thread;
+        private Port _port;
+        private Port _dummyPort;
+        private Thread _dummyThread;
+        private int _sequence = 0;
+        private static string _command = string.Empty;
+        private static string _caller = string.Empty;
+        private static string _remotePortName = string.Empty;
+        private static MessagePort _messagePort;
+
+        private void ThreadMethod()
+        {
+            Log.Info("ThreadMethod()");
+            _port.WaitForEvent();
+        }
+
+        private void DummyThreadMethod()
+        {
+            Log.Info("DummyThreadMethod()");
+            _dummyPort.WaitForEvent();
+        }
+
+        private void OnMessageRecevied(object sender, MessageReceivedEventArgs args)
+        {
+            Log.Info("");
+        }
+
+        public override bool OnCreate()
+        {
+            Log.Info("OnCreate()");
+            _port = new Port("ServicePort");
+            _port.AddPrivilege("http://tizen.org/privilege/appmanager.launch");
+            _thread = new Thread(new ThreadStart(ThreadMethod));
+            _thread.Start();
+
+            _dummyPort = new Port("DummyPort");
+            _dummyPort.AddPrivilege("http://tizen.org/privilege/datasharing");
+            _dummyThread = new Thread(new ThreadStart(DummyThreadMethod));
+            _dummyThread.Start();
+
+            _messagePort = new MessagePort("ServicePort", false);
+            _messagePort.MessageReceived += OnMessageRecevied;
+            _messagePort.Listen();
+
+            return true;
+        }
+
+        public static void SendMessage(int result)
+        {
+            Log.Info("START");
+            using (var message = new Bundle())
+            {
+                message.AddItem("command", _command);
+                message.AddItem("result", result.ToString());
+                try
+                {
+                    _messagePort.Send(message, _caller, _remotePortName);
+                    Log.Info("remoteAppId: " + _caller + "remotePortName: " + _remotePortName + " result: " + result);
+                }
+                catch (System.InvalidOperationException)
+                {
+                    Log.Error("InvalidOperationException occurs");
+                }
+                catch (System.OutOfMemoryException)
+                {
+                    Log.Error("OutOfMemoryException occurs");
+                }
+                catch (System.ArgumentOutOfRangeException)
+                {
+                    Log.Error("ArgumentOutOfRangeException occurs");
+                }
+            }
+            Log.Info("END");
+        }
+
+        private void HandleCommand()
+        {
+            Log.Info("START");
+            if (_command == "Send_CHECK_WITHOUT_EXCEPTION")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    _port.Send(_port.PortName, 5000, request);
+                    SendMessage(0);
+                }
+                catch
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(-1);
+                }
+            }
+            else if (_command == "SendSync_CHECK_WITHOUT_EXCEPTION")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    var response = (Response)_port.SendSync(_port.PortName, 5000, request);
+                    SendMessage(0);
+                }
+                catch
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(-1);
+                }
+            }
+            else if (_command == "OnSyncRequestEvent_CHECK")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    var response = (Response)_port.SendSync(_port.PortName, 5000, request);
+                }
+                catch
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(-1);
+                }
+            }
+            else if (_command == "OnRequestEvent_CHECK")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    _port.Send(_port.PortName, 5000, request);
+                }
+                catch
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(-1);
+                }
+            }
+            else if (_command == "Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    _port.Send(_dummyPort.PortName, 5000, request);
+                    SendMessage(-1);
+                }
+                catch (UnauthorizedAccessException)
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(0);
+                }
+            }
+            else if (_command == "SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION")
+            {
+                try
+                {
+                    var request = new Request(_command, _sequence++, _caller);
+                    var response = (Response)_port.SendSync(_dummyPort.PortName, 5000, request);
+                    SendMessage(-1);
+                }
+                catch (UnauthorizedAccessException)
+                {
+                    Log.Error("Failed to send request");
+                    SendMessage(0);
+                }
+            }
+            Log.Info("END");
+        }
+
+        public override void OnStartCommand(AppControl appControl, bool restarted)
+        {
+            Log.Info("OnStartCommand()");
+            base.OnStartCommand(appControl, restarted);
+
+            try
+            {
+                _caller = appControl.ExtraData.Get<string>("caller");
+                _remotePortName = appControl.ExtraData.Get<string>("message-port");
+                _command = appControl.ExtraData.Get<string>("command");
+                Log.Info("caller: " + _caller);
+                Log.Info("message-port: " + _remotePortName);
+                Log.Info("command: " + _command);
+            }
+            catch
+            {
+                Log.Warn("Failed to get extra data");
+            }
+
+            if (!string.IsNullOrEmpty(_command))
+                HandleCommand();
+        }
+
+        public override void OnDestroy()
+        {
+            Log.Info("OnDestroy()");
+            base.OnDestroy();
+            _port.Cancel();
+            _thread.Join();
+            _dummyPort.Cancel();
+            _dummyThread.Join();
+        }
+    }
+}
diff --git a/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/tizen-manifest.xml b/tct-suite-vs/Resource/Tizen.Applications.ComponentBased.ComponentPort.Tests/code/ComponentPortTest/ComponentPortTest/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..ec9cee8
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="9" package="org.tizen.example.ComponentPortTest" version="1.0.0">
+  <profile name="common" />
+  <component-based-application appid="org.tizen.example.ComponentPortTest"
+      exec="ComponentPortTest.dll"
+      type="dotnet"
+      multiple="false"
+      taskmanage="false"
+      nodisplay="ture"
+      launch_mode="single">
+    <label>ComponentPortTest</label>
+    <icon>ComponentPortTest.png</icon>
+    <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+
+    <background-category value="background-network" />
+    <background-category value="iot-communication" />
+    <background-category value="location" />
+    <background-category value="media" />
+    <background-category value="sensor" />
+
+    <service-component id="Service" main="true">
+      <label>Service</label>
+    </service-component>
+  </component-based-application>
+  <privileges>
+    <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  </privileges>
+</manifest>
diff --git a/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Program.cs b/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Program.cs
new file mode 100755 (executable)
index 0000000..071f453
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ *  Copyright (c) 2021 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 NUnitLite.TUnit;
+using AutoTemplate;
+
+namespace XamarinForTizen.Tizen
+{
+
+    class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication
+    {
+        private static App _app;
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+
+            Console.WriteLine("TCT : OnCreate()");
+            _app = new App();
+            LoadApplication(_app);
+
+            TRunner t = new TRunner();
+            t.LoadTestsuite();
+            t.Execute();
+        }
+
+        public static App getApp()
+        {
+            return _app;
+        }
+        static void Main(string[] args)
+        {
+            Console.WriteLine("TCT : Main()");
+            var app = new Program();
+            global::Xamarin.Forms.Forms.Init(app);
+            app.Run(args);
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.csproj b/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.csproj
new file mode 100755 (executable)
index 0000000..717469e
--- /dev/null
@@ -0,0 +1,41 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <!-- Property Group for .NET Core Project -->
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>tizen90</TargetFramework>
+    <TargetFrameworkIdentifier>Tizen</TargetFrameworkIdentifier>
+  </PropertyGroup>
+
+  <!-- Property Group for Tizen Project -->
+  <PropertyGroup>
+    <TizenCreateTpkOnBuild>true</TizenCreateTpkOnBuild>
+  </PropertyGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugType>None</DebugType>
+    <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>None</DebugType>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Folder Include="lib\" />
+  </ItemGroup>
+
+  <Import Project="..\Common\dependencies.props" />
+
+  <ItemGroup>
+    <PackageReference Include="Tizen.NET" Version="$(TizenNETVersion)">
+      <ExcludeAssets>Runtime</ExcludeAssets>
+    </PackageReference>
+    <PackageReference Include="Tizen.NET.Sdk" Version="$(TizenNETSdkVersion)" />
+  </ItemGroup>
+
+  <!-- Include Nuget Package for Tizen Project building -->
+  <ItemGroup>
+    <ProjectReference Include="..\Template\AutoTemplate\AutoTemplate.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.sln b/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/Tizen.Applications.ComponentBased.ComponentPort.Tests.sln
new file mode 100755 (executable)
index 0000000..dec092b
--- /dev/null
@@ -0,0 +1,78 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30517.126
+MinimumVisualStudioVersion = 15.0.26124.0
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased.ComponentPort.Tests", "Tizen.Applications.ComponentBased.ComponentPort.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}") = "AutoTemplate", "..\Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}"
+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
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.ActiveCfg = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.Build.0 = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.ActiveCfg = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.Build.0 = Debug|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.ActiveCfg = Release|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.Build.0 = Release|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.ActiveCfg = Release|Any CPU
+               {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.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.Applications.ComponentBased.ComponentPort.Tests/testcase/TSComponentPort.cs b/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/testcase/TSComponentPort.cs
new file mode 100755 (executable)
index 0000000..f4f1948
--- /dev/null
@@ -0,0 +1,563 @@
+/*
+ *  Copyright (c) 2021 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 NUnit.Framework;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Timers;
+using Tizen.Applications;
+using Tizen.Applications.Messages;
+using Timer = System.Timers.Timer;
+
+namespace Tizen.Applications.ComponentBased.Tests {
+
+    [TestFixture]
+    [Description("Tizen.Applications.ComponentBased.ComponentPort Tests")]
+    public class ComponentPortTests
+    {
+        private const string LogTag = "ComponentPort.Tests";
+        private MessagePort _messagePort;
+        private TestPort _port;
+        private Timer _timer;
+        private Thread _thread;
+        private uint _count;
+        private string _receivedCommand;
+        private int _receivedResult;
+        private bool _received;
+
+        public class TestPort : ComponentPort
+        {
+            public TestPort(string portName) : base(portName)
+            {
+            }
+
+            protected override void OnRequestEvent(string sender, object request)
+            {
+            }
+
+            protected override object OnSyncRequestEvent(string sender, object request)
+            {
+                return null;
+            }
+        }
+
+        void OnMessageReceived(object sender, MessageReceivedEventArgs e)
+        {
+            Log.Info(LogTag, "START sender: " + sender);
+            try
+            {
+                _receivedCommand = e.Message.GetItem<string>("command");
+                _receivedResult = int.Parse(e.Message.GetItem<string>("result"));
+                Log.Info(LogTag, "Command: " + _receivedCommand + " Result: " + _receivedResult);
+                _received = true;
+            }
+            catch (ArgumentException)
+            {
+                Log.Error(LogTag, "ArgumentException occurs");
+            }
+            catch (InvalidOperationException)
+            {
+                Log.Error(LogTag, "InvalidOperationException occurs");
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [SetUp]
+        public void Init()
+        {
+            Log.Info(LogTag, "Preconditions for each TEST");
+            SendLaunchRequest("wakeup");
+
+            _messagePort = new MessagePort("ComponentPort.Tests", false);
+            _messagePort.MessageReceived += OnMessageReceived;
+            _messagePort.Listen();
+
+            _receivedCommand = string.Empty;
+            _receivedResult = -1;
+            _received = false;
+
+            _port = new TestPort("Test");
+            _count = 0;
+        }
+
+        [TearDown]
+        public void Destroy()
+        {
+            Log.Info(LogTag, "Postconditions for each TEST");
+            _timer = null;
+            _thread = null;
+
+            _port?.Dispose();
+            _port = null;
+
+            _messagePort?.StopListening();
+            _messagePort?.Dispose();
+            _messagePort = null;
+        }
+
+        private void SendLaunchRequest(string command)
+        {
+            Log.Info(LogTag, "START command: " + command);
+            AppControl appControl = new AppControl();
+            appControl.ApplicationId = "org.tizen.example.ComponentPortTest";
+            appControl.ComponentId = "Service";
+            appControl.ExtraData.Add("command", command);
+            appControl.ExtraData.Add("caller", Application.Current.ApplicationInfo.ApplicationId);
+            appControl.ExtraData.Add("message-port", "ComponentPort.Tests");
+            try
+            {
+                AppControl.SendLaunchRequest(appControl);
+            }
+            catch (ArgumentNullException)
+            {
+                Log.Error(LogTag, "ArgumentNullException occurs");
+            }
+            catch (InvalidOperationException)
+            {
+                Log.Error(LogTag, "InvalidOperationException occurs");
+            }
+            catch (TimeoutException)
+            {
+                Log.Error(LogTag, "TimeoutException occurs");
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : ComponentPort method initialization")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.ComponentPort C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void ComponentPort_INIT()
+        {
+            Log.Info(LogTag, "START");
+            var testPort = new TestPort("Test2");
+            Assert.IsInstanceOf<ComponentPort>(testPort, "Should be an instance of ComponentPort");
+            Assert.IsNotNull(testPort, "testPort should not be null");
+            testPort?.Dispose();
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : ComponentPort method initialization with null argument")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.ComponentPort C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTN")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void ComponentPort_INIT_WITH_NULL_AND_CHECK_ARGUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try\r
+            {\r
+                var testPort = new TestPort(null);\r
+                Assert.Fail("Should throw ArgumentException");\r
+            }
+            catch (ArgumentException)
+            {\r
+                Assert.Pass("ArgumentException: Pass");\r
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : ComponentPort method initialization with null argument")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.ComponentPort C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTN")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void ComponentPort_INIT_WITH_EMPTYSTRING_AND_CHECK_ARGUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try\r
+            {\r
+                var testPort = new TestPort("");\r
+                Assert.Fail("Should throw ArgumentException");\r
+            }
+            catch (ArgumentException)
+            {\r
+                Assert.Pass("ArgumentException: Pass");\r
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : ComponentPort method initialization with the existed port name")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.ComponentPort C")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "CONSTX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void ComponentPort_INIT_AND_CHECK_IOEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try\r
+            {\r
+                var testPort = new TestPort("Test");\r
+                Assert.Fail("Should throw IOException");\r
+            }
+            catch (global::System.IO.IOException)\r
+            {\r
+                Assert.Pass("IOException: Pass");\r
+            }\r
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : property PortName of ComponentPort")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.PortName A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void PortName_GET()
+        {
+            Log.Info(LogTag, "START");
+            Assert.AreEqual(_port.PortName, "Test", "PortName(" + _port.PortName + ") is not equal");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Add privilege to port object")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.AddPrivilege M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void AddPrivilege_CHECK_WITHOUT_ARGUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try
+            {
+                _port.AddPrivilege("http://tizen.org/privilege/appmanager.launch");
+                Assert.Pass("Pass");
+            }
+            catch (ArgumentException)
+            {
+                Assert.Fail("Should not throw ArgumentException");
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : Add privilege with null argument")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.AddPrivilege M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void AddPrivilege_CHECK_WITH_NULL_AND_CHECK_ARGUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try
+            {
+                _port.AddPrivilege(null);
+                Assert.Fail("Should throw ArgumentException");
+            }
+            catch (ArgumentException)
+            {
+                Log.Error(LogTag, "ArgumentException occurs");
+                Assert.Pass("ArgumentException: Pass");
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : Add privilege with null argument")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.AddPrivilege M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void AddPrivilege_CHECK_WITH_EMPTYSTRING_AND_CHECK_ARGUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try\r
+            {\r
+                _port.AddPrivilege("");
+                Assert.Fail("Should throw ArgumentException");\r
+            }
+            catch (ArgumentException)
+            {\r
+                Log.Error(LogTag, "ArgumentException occurs");
+                Assert.Pass("ArgumentException: Pass");\r
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        private void Timeout(object sender, ElapsedEventArgs args)
+        {
+            _count++;
+            Log.Info(LogTag, "count: " + _count);
+
+            if (_count == 5)
+            {
+                Log.Warn(LogTag, "Cancel()");
+                _port.Cancel();
+            }
+        }
+
+        private void SetTimer(ElapsedEventHandler handler)
+        {
+            Log.Info(LogTag, "SetTimer()");
+            _timer = new Timer(5 * 100);
+            _timer.Elapsed += handler;
+            _timer.Start();
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Wait for events")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.WaitForEvent M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void WaitForEvent_CHECK_COUNT()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(Timeout)));
+            _thread.Start();
+
+            _port.WaitForEvent();
+            _timer.Stop();
+            _thread.Join();
+            Assert.AreEqual(_count, 5, "count should be '5'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Cancel waiting for events")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.Cancel M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void Cancel_CHECK_COUNT()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(Timeout)));
+            _thread.Start();
+
+            _port.WaitForEvent();
+            _timer.Stop();
+            _thread.Join();
+            Assert.AreEqual(_count, 5, "count should be '5'");
+            Log.Info(LogTag, "END");
+        }
+
+        private void CheckReceivedMessage(object sender, ElapsedEventArgs args)
+        {
+            Log.Info(LogTag, "START");
+            if (_received)
+            {
+                Log.Info(LogTag, "MessageReceived");
+                _timer.Stop();
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Send a request asynchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.Send M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task Send_CHECK_WITHOUT_EXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("Send_CHECK_WITHOUT_EXCEPTION");
+            await Task.Delay(4000);
+
+            _timer.Stop();
+            _thread.Join();
+            Assert.AreEqual(_receivedCommand, "Send_CHECK_WITHOUT_EXCEPTION", "Recevied Command should be 'Send_CHECK_WITHOUT_EXCEPTION'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : Send a request asynchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.Send M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void Send_CHECK_WITH_ARUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try
+            {
+                _port.Send("ServicePort", 5000, null);
+                Assert.Fail("Should throw ARGUMENTEXCEPTION");
+            }
+            catch (ArgumentException)
+            {
+                Assert.Pass("ArgumentException: Pass");
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : Send a request asynchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.Send M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION");
+            await Task.Delay(4000);
+
+            _timer.Stop();
+            _thread.Join();
+
+            Assert.AreEqual(_receivedCommand, "Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION", "Recevied Command should be 'Send_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Send a request synchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.SendSync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task SendSync_CHECK_WITHOUT_EXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("SendSync_CHECK_WITHOUT_EXCEPTION");
+            await Task.Delay(8000);
+
+            _timer.Stop();
+            _thread.Join();
+
+            Assert.AreEqual(_receivedCommand, "SendSync_CHECK_WITHOUT_EXCEPTION", "Recevied Command should be 'SendSync_CHECK_WITHOUT_EXCEPTION'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : Send a request synchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.SendSync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public void SendSync_CHECK_WITH_ARUMENTEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            try
+            {
+                var res = _port.SendSync("ServicePort", 5000, null);
+                Assert.Fail();
+            }
+            catch (ArgumentException)
+            {
+                Assert.Pass();
+            }
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Test : Send a request synchronously")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.SendSync M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MEX")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION");
+            await Task.Delay(4000);
+
+            _timer.Stop();
+            _thread.Join();
+
+            Assert.AreEqual(_receivedCommand, "SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION", "Recevied Command should be 'SendSync_CHECK_WITH_UNAUTHORIZEDACCESSEXCEPTION'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : OnSyncRequestEvent")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.OnSyncRequestEvent E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task OnSyncRequestEvent_CHECK()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("OnSyncRequestEvent_CHECK");
+            await Task.Delay(4000);
+
+            _timer.Stop();
+            _thread.Join();
+
+            Assert.AreEqual(_receivedCommand, "OnSyncRequestEvent_CHECK", "Recevied Command should be 'OnSyncRequestEvent_CHECK'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test : OnRequestEvent")]
+        [Property("SPEC", "Tizen.Applications.ComponentBased.ComponentPort.OnRequestEvent E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
+        public async Task OnRequestEvent_CHECK()
+        {
+            Log.Info(LogTag, "START");
+            _thread = new Thread(() => SetTimer(new ElapsedEventHandler(CheckReceivedMessage)));
+            _thread.Start();
+
+            SendLaunchRequest("OnRequestEvent_CHECK");
+            await Task.Delay(4000);
+
+            _timer.Stop();
+            _thread.Join();
+
+            Assert.AreEqual(_receivedCommand, "OnRequestEvent_CHECK", "Recevied Command should be 'OnRequestEvent_CHECK'");
+            Assert.AreEqual(_receivedResult, 0, "Recevied Result should be '0'");
+            Log.Info(LogTag, "END");
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.Applications.ComponentBased.ComponentPort.Tests/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..5f38f3f
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="Tizen.Applications.ComponentBased.ComponentPort.Tests" version="1.0.0" api-version="9" xmlns="http://tizen.org/ns/packages">
+    <profile name="common" />
+    <ui-application appid="Tizen.Applications.ComponentBased.ComponentPort.Tests" exec="Tizen.Applications.ComponentBased.ComponentPort.Tests.dll" multiple="false" taskmanage="true" type="dotnet" launch_mode="single">
+        <icon>Tizen.Applications.ComponentBased.ComponentPort.Tests.png</icon>
+        <label>Tizen.Applications.ComponentBased.ComponentPort.Tests</label>
+        <background-category value="background-network" />
+        <background-category value="iot-communication" />
+        <background-category value="location" />
+        <background-category value="media" />
+        <background-category value="sensor" />
+        <splash-screens />
+    </ui-application>
+    <shortcut-list />
+    <privileges>
+        <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+    </privileges>
+    <dependencies />
+    <provides-appdefined-privileges />
+</manifest>