Add CircleSurface and Change Every circle object
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Wearable.Test / TC / CircleProgressBarTest4.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
18 using ElmSharp.Wearable;
19
20 namespace ElmSharp.Test.TC
21 {
22     public class CircleProgressBarTest4 : TestCaseBase
23     {
24         public override string TestName => "CircleProgressBarTest4";
25         public override string TestDescription => "To test Disabled property of CircleProgressBar";
26
27         public override void Run(Window window)
28         {
29             Log.Debug(TestName, "CircleProgressBar run");
30             Conformant conformant = new Conformant(window);
31             conformant.Show();
32
33             var surface = new CircleSurface(conformant);
34             CircleProgressBar pb1 = new CircleProgressBar(conformant, surface)
35             {
36                 AlignmentX = -1,
37                 AlignmentY = -1,
38                 WeightX = 1,
39                 WeightY = 1,
40
41                 // bar
42                 Value = 0,
43                 Maximum = 100,
44                 Minimum = 0,
45                 BarRadius = 100,
46                 BarLineWidth = 15,
47                 BarColor = Color.Green,
48
49                 // background
50                 BackgroundRadius = 100,
51                 BackgroundLineWidth = 15,
52                 BackgroundColor = Color.Aqua,
53             };
54             pb1.Show();
55             conformant.SetContent(pb1);
56             Label lb1 = new Label(window)
57             {
58                 Text = string.Format("S {0} %", pb1.Value),
59             };
60
61             lb1.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
62             lb1.Move(160, window.ScreenSize.Height / 2 - 40);
63             lb1.Show();
64
65             EcoreMainloop.AddTimer(0.05, () =>
66             {
67                 if (pb1.Value == pb1.Maximum/2)
68                 {
69                     // Test purpose : set disable
70                     pb1.IsEnabled = false;
71                 }
72
73                 if (pb1.Value == pb1.Maximum)
74                 {
75                     EcoreMainloop.RemoveTimer(pb1);
76                 }
77
78                 pb1.Value += 1;
79                 lb1.Text = string.Format("S {0} %", pb1.Value);
80
81                 return true;
82             });
83         }
84     }
85 }