[NUI] Change parent class of Hover, Key, Wheel and Gesture to BaseHandle (#2001)
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TestRunner.cs
index 267e9a8..08c3b8f 100644 (file)
@@ -26,11 +26,13 @@ namespace ElmSharp.Test
 {
     public class TestRunner : CoreUIApplication
     {
-        private Window _firstPageWindow;
+        internal Window _firstPageWindow;
         private static bool s_terminated;
 
         public static string ResourceDir { get; private set; }
 
+        public string Profile { get; set; }
+
         public TestRunner()
         {
             s_terminated = false;
@@ -100,31 +102,26 @@ namespace ElmSharp.Test
 
         private Window CreateWindow(bool isSecond = false)
         {
-            Window window = new Window("ElmSharp UI Tests");
+            Window window = new Window("ElmSharp UI Tests")
+            {
+                AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90
+            };
             window.Show();
             if (isSecond)
             {
-                window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true);
-                window.KeyUp += (s, e) =>
+                window.BackButtonPressed += (s, e) =>
                 {
-                    if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
-                    {
-                        window.Hide();
-                        window.Unrealize();
-                        GC.Collect();
-                        GC.WaitForPendingFinalizers();
-                    }
+                    window.Hide();
+                    window.Unrealize();
+                    GC.Collect();
+                    GC.WaitForPendingFinalizers();
                 };
             }
             else
             {
-                window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, false);
-                window.KeyUp += (s, e) =>
+                window.BackButtonPressed += (s, e) =>
                 {
-                    if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
-                    {
-                        UIExit();
-                    }
+                    UIExit();
                 };
             }
             return window;
@@ -144,7 +141,10 @@ namespace ElmSharp.Test
                 WeightY = 1,
             };
             box.Show();
-            conformant.SetContent(box);
+            var bg = new Background(_firstPageWindow);
+            bg.Color = Color.White;
+            bg.SetContent(box);
+            conformant.SetContent(bg);
 
             GenList list = new GenList(_firstPageWindow)
             {
@@ -159,25 +159,26 @@ namespace ElmSharp.Test
             {
                 GetTextHandler = (data, part) =>
                 {
-                    return string.Format("{0}",(string)data);
+                    TestCaseBase tc = data as TestCaseBase;
+                    return tc == null ? "" : tc.TestName;
                 }
             };
 
-            foreach (var tc in testCases)
+            foreach (var tc in testCases.Where<TestCaseBase>((tc) => tc.TargetProfile.HasFlag(GetTargetProfile())))
             {
-                list.Append(defaultClass, tc.TestName);
+                list.Append(defaultClass, tc);
+            }
+
+            if (Profile == "wearable")
+            {
+                list.Prepend(defaultClass, null);
+                list.Append(defaultClass, null);
             }
 
             list.ItemSelected += (s, e) =>
             {
-                foreach (var tc in testCases)
-                {
-                    if (tc.TestName == (string)(e.Item.Data))
-                    {
-                        StartTCFromList(tc);
-                        break;
-                    }
-                }
+                TestCaseBase tc = e.Item.Data as TestCaseBase;
+                StartTCFromList(tc);
             };
             list.Show();
 
@@ -196,15 +197,43 @@ namespace ElmSharp.Test
             tc.Run(window);
         }
 
+        private TargetProfile GetTargetProfile()
+        {
+            switch (Profile)
+            {
+                case "wearable" :
+                    return TargetProfile.Wearable;
+                case "mobile" :
+                    return TargetProfile.Mobile;
+                case "tv":
+                    return TargetProfile.Tv;
+            }
+            return TargetProfile.Mobile;
+        }
+
         static void Main(string[] args)
         {
             Elementary.Initialize();
             Elementary.ThemeOverlay();
 
-            Console.WriteLine("ELM_PROFILE : {0}", Elementary.GetProfile());
+            var profile = Elementary.GetProfile();
+            Console.WriteLine("ELM_PROFILE : {0}", profile);
             Console.WriteLine("ELM_SCALE : {0}", Elementary.GetScale());
 
+            /*Elementary.EvasObjectRealized += (s, e) =>
+            {
+                var obj = (EvasObject)s;
+                Console.WriteLine("EvasObject Realized : {0}", obj.GetType());
+            };
+
+            Elementary.ItemObjectRealized += (s, e) =>
+            {
+                var obj = (ItemObject)s;
+                Console.WriteLine("ItemObject Realized : {0} (Parent : {1})", obj.GetType(), obj.Parent != null? obj.Parent.GetType() : null);
+            };*/
+
             TestRunner testRunner = new TestRunner();
+            testRunner.Profile = profile;
             testRunner.Run(args);
 
             // if running with appfw is failed, below line will be executed.