Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / EntryTest3.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 EntryTest3 : TestCaseBase
23     {
24         public override string TestName => "EntryTest3";
25         public override string TestDescription => "To test basic operation of Entry";
26
27         public override void Run(Window window)
28         {
29             Background bg = new Background(window)
30             {
31                 AlignmentX = -1,
32                 AlignmentY = -1,
33                 WeightX = 1,
34                 WeightY = 1,
35                 Color = Color.Yellow
36             };
37             bg.Show();
38             window.AddResizeObject(bg);
39
40             Conformant conformant = new Conformant(window);
41             conformant.Show();
42             Box box = new Box(window);
43             conformant.SetContent(box);
44             box.Show();
45
46             Entry entry = new Entry(window)
47             {
48                 AlignmentX = -1,
49                 AlignmentY = 1,
50                 WeightX = 1,
51                 WeightY = 1,
52                 IsSingleLine = true,
53                 Text = "Hello, Tizen"
54             };
55
56             var btn = new Button(window)
57             {
58                 AlignmentX = -1,
59                 AlignmentY = 1,
60                 WeightX = 1,
61                 WeightY = 1,
62                 Text = "Set Filter"
63             };
64             btn.Show();
65
66             //var filter = new Entry.TextFilter(SetFilter);
67             btn.Clicked += (s, e) =>
68             {
69                 entry.AppendMarkUpFilter(SetFilter);
70             };
71
72             var btn1 = new Button(window)
73             {
74                 AlignmentX = -1,
75                 AlignmentY = 1,
76                 WeightX = 1,
77                 WeightY = 1,
78                 Text = "Remove Filter"
79             };
80             btn1.Show();
81             btn1.Clicked += (s, e) =>
82             {
83                 entry.RemoveMarkUpFilter(SetFilter);
84             };
85
86             //entry.AppendMarkUpFilter(new Entry.Filter(SetFilter));
87
88             entry.Show();
89             box.PackEnd(entry);
90             box.PackEnd(btn);
91             box.PackEnd(btn1);
92         }
93
94         public string SetFilter(Entry entry, string text)
95         {
96             if (text.Equals("a") || text.Equals("b") || text.Equals("c") || text.Equals("d"))
97                 return text;
98             else
99                 return "Tizen";
100         }
101     }
102 }