Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / TransitTest.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using ElmSharp;
19
20 namespace ElmSharp.Test
21 {
22     class TransitTest : TestCaseBase
23     {
24         public override string TestName => "TransitTest";
25         public override string TestDescription => "To test basic operation of Transit";
26
27         Transit CreateTransit()
28         {
29             Transit transit = new Transit();
30             transit.Deleted += (s, e) => { Console.WriteLine("Transit Deleted"); };
31             transit.Repeat = 1;
32             transit.AutoReverse = true;
33             transit.Duration = 1;
34             return transit;
35         }
36
37         public override void Run(Window window)
38         {
39             Button button1 = new Button(window) {
40                 Text = "Effect",
41             };
42             button1.Move(0, 0);
43             button1.Resize(270, 200);
44             button1.Show();
45
46             Button button2 = new Button(window)
47             {
48                 Text = "Chain Effect",
49             };
50             button2.Move(270, 200);
51             button2.Resize(270, 200);
52             button2.Show();
53
54             Point begin = new Point();
55             begin.X = begin.Y = 0;
56             Point end = new Point();
57             end.X = end.Y = 200;
58             TranslationEffect translation = new TranslationEffect(begin, end);
59             translation.EffectEnded += (s, e) => { Console.WriteLine("Translation Effect Ended"); };
60
61             RotationEffect rotation = new RotationEffect(0, 180);
62             rotation.EffectEnded += (s, e) => { Console.WriteLine("Rotation Effect Ended"); };
63
64             button1.Clicked += (s, e) => {
65                 Transit transit1 = CreateTransit();
66                 transit1.Objects.Add(button1);
67                 transit1.Objects.Add(button2);
68                 transit1.AddEffect(translation);
69                 transit1.AddEffect(rotation);
70                 transit1.Go();
71             };
72
73             button2.Clicked += (s, e) => {
74                 Transit transit1 = CreateTransit();
75                 transit1.Objects.Add(button1);
76                 transit1.AddEffect(translation);
77                 transit1.AddEffect(rotation);
78
79                 Transit transit2 = CreateTransit();
80                 transit2.Objects.Add(button2);
81                 transit2.AddEffect(translation);
82                 transit2.AddEffect(rotation);
83
84                 transit1.Chains.Add(transit2);
85                 transit1.Go();
86             };
87         }
88     }
89 }