Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / EventTest1.cs
1 using System.Diagnostics;
2
3 /*
4  * Copyright (c) 2016 Samsung Electronics Co. Ltd All Rights Reserved
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an AS IS BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 namespace ElmSharp.Test
20 {
21     class EventTest1 : TestCaseBase
22     {
23         public override string TestName => "EventTest1";
24         public override string TestDescription => "event propagation test";
25
26         Box gParent;
27         GestureLayer _gParentLayer, _parentLayer, childLayer, chLayer;
28
29         public override void Run(Window window)
30         {
31             Conformant conformant = new Conformant(window);
32             conformant.Show();
33             gParent = new Box(window)
34             {
35                 BackgroundColor = Color.Yellow,
36                 PassEvents = false,
37                 PropagateEvents = false,
38             };
39             conformant.SetContent(gParent);
40
41             Box parent = new Box(gParent)
42             {
43                 AlignmentX = -1,
44                 AlignmentY = -1,
45                 WeightX = 1,
46                 WeightY = 1,
47                 BackgroundColor = Color.Green,
48                 PassEvents = false,
49                 PropagateEvents = false,
50             };
51             Box child = new Box(parent)
52             {
53                 AlignmentX = -1,
54                 AlignmentY = -1,
55                 WeightX = 1,
56                 WeightY = 1,
57                 BackgroundColor = Color.Blue,
58                 PassEvents = false,
59                 PropagateEvents = false,
60             };
61
62             Check ch = new Check(child)
63             {
64                 AlignmentX = -1,
65                 AlignmentY = -1,
66                 WeightX = 1,
67                 WeightY = 1,
68                 BackgroundColor = Color.Silver,
69                 PassEvents = false,
70                 PropagateEvents = false,
71             };
72
73             gParent.PackEnd(parent);
74             parent.PackEnd(child);
75             child.PackEnd(ch);
76
77             gParent.Show();
78             parent.Show();
79             child.Show();
80             ch.Show();
81
82             _gParentLayer = new GestureLayer(gParent);
83             _gParentLayer.Attach(gParent);
84             _gParentLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
85             {
86                 Debug.WriteLine($"@@@ Grand Parent Tap : {gParent.PassEvents}, {gParent.PropagateEvents}, {gParent.RepeatEvents}");
87             });
88             _parentLayer = new GestureLayer(parent);
89             _parentLayer.Attach(parent);
90             _parentLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
91             {
92                 Debug.WriteLine($"@@@ Parent Tap : {parent.PassEvents}, {parent.PropagateEvents}, {parent.RepeatEvents}");
93             });
94             childLayer = new GestureLayer(child);
95             childLayer.Attach(child);
96             childLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
97             {
98                 Debug.WriteLine($"@@@ Child Tap : {child.PassEvents}, {child.PropagateEvents}, {child.RepeatEvents}");
99             });
100
101             chLayer = new GestureLayer(ch);
102             chLayer.Attach(ch);
103             chLayer.SetTapCallback(GestureLayer.GestureType.Tap, GestureLayer.GestureState.End, (info) =>
104             {
105                 Debug.WriteLine($"@@@ Check1 Tap : {ch.PassEvents}, {ch.PropagateEvents}, {ch.RepeatEvents}");
106             });
107
108             EvasObjectEvent eventGrand = new EvasObjectEvent(gParent, EvasObjectCallbackType.MouseDown);
109             eventGrand.On += (s, e) =>
110             {
111                 Debug.WriteLine($"@@@ Grand Parent down : {gParent.PassEvents}, {gParent.PropagateEvents}, {gParent.RepeatEvents}");
112             };
113             EvasObjectEvent evnetParent = new EvasObjectEvent(parent, EvasObjectCallbackType.MouseDown);
114             evnetParent.On += (s, e) =>
115             {
116                 Debug.WriteLine($"@@@ Parent down : {parent.PassEvents}, {parent.PropagateEvents}, {parent.RepeatEvents}");
117             };
118             EvasObjectEvent eventChild = new EvasObjectEvent(child, EvasObjectCallbackType.MouseDown);
119             eventChild.On += (s, e) =>
120             {
121                 Debug.WriteLine($"@@@ Child down : {child.PassEvents}, {child.PropagateEvents}, {child.RepeatEvents}");
122             };
123             EvasObjectEvent eventCh = new EvasObjectEvent(ch, ch.RealHandle, EvasObjectCallbackType.MouseDown);
124             eventCh.On += (s, e) =>
125             {
126                 Debug.WriteLine($"@@@ Check down : {ch.PassEvents}, {ch.PropagateEvents}, {ch.RepeatEvents}");
127             };
128         }
129     }
130 }