2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 namespace ElmSharp.Test
21 class EcoreTimerTest1 : TestCaseBase
23 public override string TestName => "EcoreTimerTest1";
24 public override string TestDescription => "To timer operation of EcoreMainLoop";
26 public override void Run(Window window)
28 Background bg = new Background(window)
37 window.AddResizeObject(bg);
39 Conformant conformant = new Conformant(window);
45 Label label1 = new Label(window);
46 label1.Move(150, 150);
47 label1.Resize(300, 100);
49 Button btnTimerSwitch = new Button(window);
50 btnTimerSwitch.Text = "Timer : On";
51 btnTimerSwitch.Move(0, 300);
52 btnTimerSwitch.Resize(300, 100);
54 Func<bool> handler = () =>
56 label1.Text = (++number).ToString();
57 label1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#000000 font_size=64 align=left valign=bottom wrap=word'";
60 IntPtr prevId = EcoreMainloop.AddTimer(1.0, handler);
61 btnTimerSwitch.Clicked += (s, e) =>
66 btnTimerSwitch.Text = "Timer : Off";
71 btnTimerSwitch.Text = "Timer : On";
72 EcoreMainloop.RemoveTimer(prevId);
73 prevId = EcoreMainloop.AddTimer(1.0, handler);
77 window.BackButtonPressed += (s, e) =>
79 EcoreMainloop.RemoveTimer(prevId);
83 btnTimerSwitch.Show();