Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / EvasImageTest1.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 System.IO;
19 using ElmSharp;
20 using System.Collections.Generic;
21
22 namespace ElmSharp.Test
23 {
24     public class EvasImageTest1 : TestCaseBase
25     {
26         public override string TestName => "EvasImageTest1";
27         public override string TestDescription => "To test EvasImage proxy feature";
28
29         public override void Run(Window window)
30         {
31             Conformant conformant = new Conformant(window);
32             conformant.Show();
33             Box box = new Box(window);
34             conformant.SetContent(box);
35             box.Show();
36
37             Box horizentalBox = new Box(window)
38             {
39                 IsHorizontal = true,
40                 AlignmentX = -1,
41                 AlignmentY = -1,
42                 WeightX = 1,
43                 WeightY = 1,
44             };
45             horizentalBox.Show();
46
47             Button realObject1 = new Button(window) {
48                 Text = "It is RealObject",
49                 AlignmentX = -1,
50                 AlignmentY = -1,
51                 WeightX = 1,
52                 WeightY = 1,
53             };
54             realObject1.Show();
55
56             Image realObject2 = new Image(window)
57             {
58                 AlignmentX = -1,
59                 AlignmentY = -1,
60                 WeightX = 1,
61                 WeightY = 1,
62             };
63             realObject2.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
64             realObject2.Show();
65
66             horizentalBox.PackEnd(realObject1);
67             horizentalBox.PackEnd(realObject2);
68
69             EvasImage proxyObject = new EvasImage(window)
70             {
71                 AlignmentX = -1,
72                 AlignmentY = -1,
73                 WeightX = 1,
74                 WeightY = 0.5,
75             };
76             Button toggle = new Button(window)
77             {
78                 Text = "Change Source",
79                 AlignmentX = -1,
80                 AlignmentY = -1,
81                 WeightX = 1,
82                 WeightY = 0.1,
83             };
84             toggle.Show();
85
86             EvasObject proxyedObject = realObject1;
87             toggle.Clicked += (s, e) =>
88             {
89                 if (proxyedObject == realObject1)
90                 {
91                     proxyedObject = realObject2;
92                 }
93                 else
94                 {
95                     proxyedObject = realObject1;
96                 }
97                 proxyObject.SetSource(proxyedObject);
98             };
99
100
101             proxyObject.IsFilled = true;
102             proxyObject.SetSource(realObject1);
103             proxyObject.Show();
104
105             box.PackEnd(horizentalBox);
106             box.PackEnd(proxyObject);
107             box.PackEnd(toggle);
108         }
109     }
110 }