Add tpk packaging for ElmSharp.Test
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 22 Sep 2016 04:54:58 +0000 (13:54 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 22 Sep 2016 05:07:13 +0000 (14:07 +0900)
Change-Id: I15eb34230216a83be77ad2341d55b5f58e68ffc4

test/ElmSharp.Test/ElmSharp.Test.csproj
test/ElmSharp.Test/ElmSharp.Test.project.json
test/ElmSharp.Test/ElmSharpTest.Net45.csproj [deleted file]
test/ElmSharp.Test/ElmSharpTest.Net45.project.json [deleted file]
test/ElmSharp.Test/TC/ImageTest1.cs
test/ElmSharp.Test/TestRunner.cs
test/ElmSharp.Test/res/picture.png [new file with mode: 0644]
test/ElmSharp.Test/shared/res/ElmSharp.Test.png [new file with mode: 0644]
test/ElmSharp.Test/test.sh
test/ElmSharp.Test/tizen-manifest.xml [new file with mode: 0644]

index f6b7a55..e610825 100644 (file)
@@ -3,6 +3,7 @@
   <PropertyGroup>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProjectTypeGuids>{2F98DAC9-6F16-457B-AED7-D43CAC379341};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\r
     <ProjectGuid>{E901BB06-632D-489E-86AC-66AD2EF85BCC}</ProjectGuid>\r
     <OutputType>Exe</OutputType>\r
     <AppDesignerFolder>Properties</AppDesignerFolder>\r
@@ -58,8 +59,8 @@
     <Compile Include="TC\GenListTest4.cs" />\r
     <Compile Include="TC\PerformanceTest.cs" />\r
     <Compile Include="TC\GenListTest5.cs" />\r
-    <Compile Include="TC\ImageTest1.cs" />\r
     <Compile Include="TC\IconTest1.cs" />\r
+    <Compile Include="TC\ImageTest1.cs" />\r
     <Compile Include="TC\IndexTest1.cs" />\r
     <Compile Include="TC\IndexTest2.cs" />\r
     <Compile Include="TC\LabelTest1.cs" />\r
       <Name>ElmSharp</Name>\r
     </ProjectReference>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <Content Include="res\picture.png">\r
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\r
+    </Content>\r
+    <Content Include="shared\res\ElmSharp.Test.png" />\r
+    <Content Include="tizen-manifest.xml" />\r
+  </ItemGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
        Other similar extension points exist, see Microsoft.Common.targets.\r
index f9a9620..33302d8 100644 (file)
@@ -1,11 +1,12 @@
-{
-  "dependencies": {
-    "Microsoft.NETCore.App": "1.0.0"
-  },
-  "frameworks": {
-    "netcoreapp1.0": {}
-  },
-  "runtimes": {
-    "win": {}
-  }
-}
+{\r
+  "dependencies": {\r
+    "Microsoft.NETCore.App": "1.0.0",\r
+    "Tizen.Applications": "1.0.0"\r
+  },\r
+  "frameworks": {\r
+    "netcoreapp1.0": {}\r
+  },\r
+  "runtimes": {\r
+    "win": {}\r
+  }\r
+}
\ No newline at end of file
diff --git a/test/ElmSharp.Test/ElmSharpTest.Net45.csproj b/test/ElmSharp.Test/ElmSharpTest.Net45.csproj
deleted file mode 100644 (file)
index bb68b0d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <PropertyGroup>\r
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
-    <ProjectGuid>{0D01D989-E4C1-400C-BF05-8FD79EF828A8}</ProjectGuid>\r
-    <OutputType>Exe</OutputType>\r
-    <AppDesignerFolder>Properties</AppDesignerFolder>\r
-    <RootNamespace>ElmSharpTest</RootNamespace>\r
-    <AssemblyName>ElmSharpTest</AssemblyName>\r
-    <FileAlignment>512</FileAlignment>\r
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
-    <DebugSymbols>true</DebugSymbols>\r
-    <DebugType>full</DebugType>\r
-    <Optimize>true</Optimize>\r
-    <OutputPath>bin\Debug\</OutputPath>\r
-    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
-    <ErrorReport>prompt</ErrorReport>\r
-    <WarningLevel>4</WarningLevel>\r
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
-    <DebugType>pdbonly</DebugType>\r
-    <Optimize>true</Optimize>\r
-    <OutputPath>bin\Release\</OutputPath>\r
-    <DefineConstants>TRACE</DefineConstants>\r
-    <ErrorReport>prompt</ErrorReport>\r
-    <WarningLevel>4</WarningLevel>\r
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
-  </PropertyGroup>\r
-  <ItemGroup>\r
-    <Reference Include="System" />\r
-    <Reference Include="System.Core" />\r
-    <Reference Include="System.Xml.Linq" />\r
-    <Reference Include="System.Data.DataSetExtensions" />\r
-    <Reference Include="Microsoft.CSharp" />\r
-    <Reference Include="System.Data" />\r
-    <Reference Include="System.Net.Http" />\r
-    <Reference Include="System.Xml" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <Compile Include="Properties\AssemblyInfo.cs" />\r
-    <Compile Include="TC\BackgroundTest1.cs" />\r
-    <Compile Include="TC\BackgroundTest2.cs" />\r
-    <Compile Include="TC\BackgroundTest3.cs" />\r
-    <Compile Include="TC\BoxTest1.cs" />\r
-    <Compile Include="TC\ButtonTest1.cs" />\r
-    <Compile Include="TC\CalendarTest1.cs" />\r
-    <Compile Include="TC\CheckTest1.cs" />\r
-    <Compile Include="TC\ColorSelectorTest1.cs" />\r
-    <Compile Include="TC\ContextPopupTest1.cs" />\r
-    <Compile Include="TC\DateTimeSelectorTest1.cs" />\r
-    <Compile Include="TC\EntryTest1.cs" />\r
-    <Compile Include="TC\GenGridTest1.cs" />\r
-    <Compile Include="TC\GenGridTest2.cs" />\r
-    <Compile Include="TC\GenListTest1.cs" />\r
-    <Compile Include="TC\GenListTest2.cs" />\r
-    <Compile Include="TC\GenListTest3.cs" />\r
-    <Compile Include="TC\GenListTest4.cs" />\r
-    <Compile Include="TC\GenListTest5.cs" />\r
-    <Compile Include="TC\IconTest1.cs" />\r
-    <Compile Include="TC\IndexTest1.cs" />\r
-    <Compile Include="TC\IndexTest2.cs" />\r
-    <Compile Include="TC\LabelTest1.cs" />\r
-    <Compile Include="TC\ListTest1.cs" />\r
-    <Compile Include="TC\NaviframeTest1.cs" />\r
-    <Compile Include="TC\NaviframeTest2.cs" />\r
-    <Compile Include="TC\PanelTest1.cs" />\r
-    <Compile Include="TC\PanelTest2.cs" />\r
-    <Compile Include="TC\PanesTest1.cs" />\r
-    <Compile Include="TC\PopupTest1.cs" />\r
-    <Compile Include="TC\ProgressBarTest1.cs" />\r
-    <Compile Include="TC\RadioTest1.cs" />\r
-    <Compile Include="TC\RectangleTest1.cs" />\r
-    <Compile Include="TC\ScrollerTest1.cs" />\r
-    <Compile Include="TC\ScrollerTest2.cs" />\r
-    <Compile Include="TC\SliderTest1.cs" />\r
-    <Compile Include="TC\SpinnerTest1.cs" />\r
-    <Compile Include="TC\ToolbarTest1.cs" />\r
-    <Compile Include="TestCaseBase.cs" />\r
-    <Compile Include="TestRunner.cs" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="ElmSharpTest.Net45.project.json" />\r
-    <None Include="test.sh" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ProjectReference Include="..\ElmSharp\ElmSharp.Net45.csproj">\r
-      <Project>{657e0754-faf0-42b9-b9f5-45868826758e}</Project>\r
-      <Name>ElmSharp.Net45</Name>\r
-    </ProjectReference>\r
-  </ItemGroup>\r
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.\r
-       Other similar extension points exist, see Microsoft.Common.targets.\r
-  <Target Name="BeforeBuild">\r
-  </Target>\r
-  <Target Name="AfterBuild">\r
-  </Target>\r
-  -->\r
-</Project>
\ No newline at end of file
diff --git a/test/ElmSharp.Test/ElmSharpTest.Net45.project.json b/test/ElmSharp.Test/ElmSharpTest.Net45.project.json
deleted file mode 100644 (file)
index 5e1948a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "frameworks": {
-    "net45": {}
-  },
-  "runtimes": {
-    "win": {}
-  }
-}
index 82ee3c2..de8f72b 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 using ElmSharp;
 using System.Collections.Generic;
 
@@ -15,7 +16,7 @@ namespace ElmSharp.Test
             {
                 IsFixedAspect = false
             };
-            image.Load("/home/owner/res/picture.png");
+            image.Load(Path.Combine(TestRunner.ResourceDir,  "picture.png"));
             image.Clicked += (e, o) =>
             {
                 Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect);
index 47b5d8c..f0992ce 100644 (file)
@@ -7,35 +7,42 @@
 // you entered into with Samsung.
 
 using System;
+using System.IO;
 using System.Linq;
 using System.Reflection;
 using System.Collections.Generic;
 
+using Tizen.Applications;
+
 namespace ElmSharp.Test
 {
-    public class TestRunner
+    public class TestRunner : CoreUIApplication
     {
+        private Window _firstPageWindow;
+
+        public static string ResourceDir { get; private set; }
+
         public TestRunner()
         {
         }
 
-        public void Run(string[] args)
+        protected override void OnCreate()
+        {
+            ResourceDir = DirectoryInfo.Resource;
+
+            var testCases = GetTestCases();
+            CreateFirstPage(testCases);
+            base.OnCreate();
+        }
+
+        public void RunStandalone(string[] args)
         {
+            ResourceDir = Path.Combine(Path.GetDirectoryName(typeof(TestRunner).GetTypeInfo().Assembly.Location), "res");
+
             Elementary.Initialize();
 
             EcoreSynchronizationContext.Initialize();
 
-            Window window = new Window("TestWindow");
-            window.Show();
-            window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false);
-            window.KeyUp += (s, e) =>
-            {
-                if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
-                {
-                    EcoreMainloop.Quit();
-                }
-            };
-
             var testCases = GetTestCases();
             TestCaseBase theTest = null;
 
@@ -46,14 +53,13 @@ namespace ElmSharp.Test
 
             if (theTest != null)
             {
-                theTest.Run(window);
+                StartTC(theTest);
                 EcoreMainloop.Begin();
-            } else
+            }
+            else
             {
-                foreach (var test in testCases)
-                {
-                    Console.WriteLine("{0}", test.TestName);
-                }
+                CreateFirstPage(testCases);
+                EcoreMainloop.Begin();
             }
 
             Elementary.Shutdown();
@@ -78,10 +84,100 @@ namespace ElmSharp.Test
             EcoreMainloop.Quit();
         }
 
+        private Window CreateWindow(bool isSecond = false)
+        {
+            Window window = new Window("ElmSharp UI Tests");
+            window.Show();
+            if (isSecond)
+            {
+                window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true);
+                window.KeyUp += (s, e) =>
+                {
+                    if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
+                    {
+                        window.Hide();
+                    }
+                };
+            }
+            else
+            {
+                window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false);
+                window.KeyUp += (s, e) =>
+                {
+                    if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
+                    {
+                        UIExit();
+                    }
+                };
+            }
+            return window;
+        }
+
+        private void CreateFirstPage(IEnumerable<TestCaseBase> testCases)
+        {
+            _firstPageWindow = CreateWindow();
+            Conformant conformant = new Conformant(_firstPageWindow);
+            conformant.Show();
+            Box box = new Box(_firstPageWindow)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            box.Show();
+            conformant.SetContent(box);
+
+            List list = new List(_firstPageWindow)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1
+            };
+
+            foreach (var tc in testCases)
+            {
+                list.Append(tc.TestName);
+            }
+
+            list.ItemSelected += (s, e) =>
+            {
+                foreach (var tc in testCases)
+                {
+                    if (tc.TestName == e.Item.Text)
+                    {
+                        StartTCFromList(tc);
+                        break;
+                    }
+                }
+            };
+
+            list.Update();
+            list.Show();
+
+            box.PackEnd(list);
+        }
+
+        private void StartTC(TestCaseBase tc)
+        {
+            Window window = CreateWindow();
+            tc.Run(window);
+        }
+
+        private void StartTCFromList(TestCaseBase tc)
+        {
+            Window window = CreateWindow(true);
+            tc.Run(window);
+        }
+
         static void Main(string[] args)
         {
             TestRunner testRunner = new TestRunner();
             testRunner.Run(args);
+
+            // if running with appfw is failed, below line will be executed.
+            testRunner.RunStandalone(args);
         }
     }
 }
diff --git a/test/ElmSharp.Test/res/picture.png b/test/ElmSharp.Test/res/picture.png
new file mode 100644 (file)
index 0000000..7522362
Binary files /dev/null and b/test/ElmSharp.Test/res/picture.png differ
diff --git a/test/ElmSharp.Test/shared/res/ElmSharp.Test.png b/test/ElmSharp.Test/shared/res/ElmSharp.Test.png
new file mode 100644 (file)
index 0000000..9765b1b
Binary files /dev/null and b/test/ElmSharp.Test/shared/res/ElmSharp.Test.png differ
index 976dfd2..d50694f 100755 (executable)
@@ -2,7 +2,7 @@
 
 TARGET_USER=owner
 TARGET_DIR=/home/$TARGET_USER/elmsharp_test
-TARGET_RES_DIR=/home/$TARGET_USER/res
+TARGET_RES_DIR=$TARGET_DIR/res
 
 TO_COPY_FILES="bin/Debug"
 
@@ -21,24 +21,17 @@ usage() {
   echo "Usage: $0 [options] [testcase]"
   echo "    Options:"
   echo "        -h, --help         Show this usages message"
-  echo "        -b, --build        Build test cases"
   echo "        -i, --install      Install test cases to target device"
   echo "        -r, --install-res  Install resource files for test cases to target device"
-  echo "        -r, --install-res  Install resource files for test cases to target device"
-  echo "        -s, --install-lib  Install System libraries to target device"
   echo "        -m, --use-mono     Execute test case by using mono instead of corerun"
 }
 
-build() {
-  xbuild ElmSharpTest.csproj
-  exit_on_error $?
-}
-
 install() {
   echo "install"
   sdb root on
   sdb_cmd "rm -fr $TARGET_DIR"
   sdb_cmd "mkdir -p $TARGET_DIR"
+  sdb push $TO_COPY_FILES/Tizen*.dll $TARGET_DIR
   sdb push $TO_COPY_FILES/ElmSharp*.dll $TARGET_DIR
   sdb push $TO_COPY_FILES/ElmSharp*.exe $TARGET_DIR
   exit_on_error $?
@@ -52,15 +45,6 @@ install_res() {
   exit_on_error $?
 }
 
-install_lib() {
-  sdb root on
-  sdb_cmd "rm -fr $TARGET_DIR"
-  sdb_cmd "mkdir -p $TARGET_DIR"
-  sdb push $TO_COPY_FILES/System*.dll $TARGET_DIR
-  sdb push $TO_COPY_FILES/Microsoft*.dll $TARGET_DIR
-  exit_on_error $?
-}
-
 run() {
   sdb root on
   sdb_cmd "/opt/usr/share/tizen.net/corerun $TARGET_DIR/ElmSharp.Test.exe $1"
@@ -73,24 +57,20 @@ run_mono() {
   exit_on_error $?
 }
 
-OPTS=`getopt -o hbirsm --long help,build,install,install-res,install-lib,use-mono -n 'test' -- "$@"`
+OPTS=`getopt -o hirm --long help,install,install-res,use-mono -n 'test' -- "$@"`
 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
 eval set -- "$OPTS"
 
 FLAG_HELP=false
-FLAG_BUILD=false
 FLAG_INSTALL=false
 FLAG_INSTALL_RES=false
-FLAG_INSTALL_LIB=false
 FLAG_USE_MONO=false
 
 while true; do
   case "$1" in
     -h|--help) FLAG_HELP=true; shift ;;
-    -b|--build) FLAG_BUILD=true; shift ;;
     -i|--install) FLAG_INSTALL=true; shift ;;
     -r|--install-res) FLAG_INSTALL_RES=true; shift ;;
-    -r|--install-lib) FLAG_INSTALL_LIB=true; shift ;;
     -m|--use-mono) FLAG_USE_MONO=true; shift ;;
     --) shift; break ;;
     *) break ;;
@@ -99,7 +79,6 @@ done
 
 if $FLAG_HELP; then usage; exit 1; fi
 
-if $FLAG_BUILD; then build; fi
 if $FLAG_INSTALL; then install; fi
 if $FLAG_INSTALL_RES; then install_res; fi
 if $FLAG_USE_MONO; then run_mono $@; else run $@; fi
diff --git a/test/ElmSharp.Test/tizen-manifest.xml b/test/ElmSharp.Test/tizen-manifest.xml
new file mode 100644 (file)
index 0000000..5067a8f
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="ElmSharpTest" version="1.0.0">
+       <profile name="common" />
+       <ui-application appid="org.tizen.ElmSharp.Test"
+                                       exec="ElmSharp.Test.exe"
+                                       type="dotnet"
+                                       multiple="false"
+                                       taskmanage="true"
+                                       launch_mode="single">
+       <icon>ElmSharp.Test.png</icon>
+       <label>ElmSharp.Test</label>
+       </ui-application>
+</manifest>