Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / WindowInternalTest.cs
1 using Tizen.Applications;
2 /*
3  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 using System;
19 using ElmSharp;
20 using System.Diagnostics;
21
22 namespace ElmSharp.Test
23 {
24     class WindowInternalTest : TestCaseBase
25     {
26         public override string TestName => "WindowInternalTest";
27         public override string TestDescription => "Window Test";
28
29         public override void Run(Window window)
30         {
31             var firstWindow = (Application.Current as TestRunner)?._firstPageWindow;
32             firstWindow.Hide();
33             firstWindow.Unrealize();
34
35             Button button1 = new Button(window) {
36                 Text = "Iconified",
37             };
38             button1.Resize(window.ScreenSize.Width, 100);
39             button1.Move(0, 0);
40             button1.Show();
41
42             button1.Clicked += (e, o) =>
43             {
44                 window.Iconified = true;
45             };
46
47             Button button2 = new Button(window)
48             {
49                 Text = "WinKeyGrab",
50             };
51             button2.Resize(window.ScreenSize.Width, 100);
52             button2.Move(0, 100);
53             button2.Show();
54
55             button2.Clicked += (e, o) =>
56             {
57                 Debug.WriteLine("@@KeyGrab");
58                 window.KeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, true);
59                 window.WinKeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, KeyGrabMode.Exclusive);
60             };
61
62             Button button3 = new Button(window)
63             {
64                 Text = "WinUnKeyGrab",
65             };
66             button3.Resize(window.ScreenSize.Width, 100);
67             button3.Move(0, 200);
68             button3.Show();
69
70             button3.Clicked += (e, o) =>
71             {
72                 Debug.WriteLine("@@UnKeyGrab");
73                 window.WinKeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName);
74                 window.KeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName);
75
76             };
77             window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true);
78             EventHandler<EvasKeyEventArgs> handler = (s, e) =>
79             {
80                 Debug.WriteLine("@@KeyDown start" + e.KeyName);
81
82                 if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
83                 {
84                     Application.Current.Exit();
85                 }
86                 if (e.KeyName == EvasKeyEventArgs.PlatformHomeButtonName)
87                 {
88                     Debug.WriteLine("@@KeyDown OK : " + window.Iconified);
89                     window.Iconified = !window.Iconified;
90                 }
91             };
92
93             window.KeyUp += handler;
94         }
95
96     }
97 }