From cdf88bad0f121a5baca323a1ae035f76f00642fe Mon Sep 17 00:00:00 2001 From: darkleem Date: Wed, 31 May 2017 20:13:34 +0900 Subject: Fixed that EcoreMainLoop timer does not repeat - TASK=TCAPI-2448 Change-Id: Ibec2316057c37f3090c3afa842b0b08a6d2a60e6 Signed-off-by: darkleem --- ElmSharp.Test/ElmSharp.Test.csproj | 1 + ElmSharp.Test/TC/EcoreTimerTest1.cs | 86 +++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 ElmSharp.Test/TC/EcoreTimerTest1.cs (limited to 'ElmSharp.Test') diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index 8457572..9e0b6cf 100755 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -45,6 +45,7 @@ + diff --git a/ElmSharp.Test/TC/EcoreTimerTest1.cs b/ElmSharp.Test/TC/EcoreTimerTest1.cs new file mode 100644 index 0000000..325f6a4 --- /dev/null +++ b/ElmSharp.Test/TC/EcoreTimerTest1.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace ElmSharp.Test +{ + class EcoreTimerTest1 : TestCaseBase + { + public override string TestName => "EcoreTimerTest1"; + public override string TestDescription => "To timer operation of EcoreMainLoop"; + + public override void Run(Window window) + { + Background bg = new Background(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + Color = Color.White + }; + bg.Show(); + window.AddResizeObject(bg); + + Conformant conformant = new Conformant(window); + conformant.Show(); + + + int number = 0; + bool bReturn = true; + Label label1 = new Label(window); + label1.Move(150, 150); + label1.Resize(300, 100); + + Button btnTimerSwitch = new Button(window); + btnTimerSwitch.Text = "Timer : On"; + btnTimerSwitch.Move(0, 300); + btnTimerSwitch.Resize(300, 100); + + Func handler = () => + { + label1.Text = (++number).ToString(); + label1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#000000 font_size=64 align=left valign=bottom wrap=word'"; + return bReturn; + }; + IntPtr prevId = EcoreMainloop.AddTimer(1.0, handler); + btnTimerSwitch.Clicked += (s, e) => + { + if(bReturn) + { + bReturn = false; + btnTimerSwitch.Text = "Timer : Off"; + } + else + { + bReturn = true; + btnTimerSwitch.Text = "Timer : On"; + EcoreMainloop.RemoveTimer(prevId); + prevId = EcoreMainloop.AddTimer(1.0, handler); + } + }; + + window.BackButtonPressed += (s, e) => + { + EcoreMainloop.RemoveTimer(prevId); + }; + + label1.Show(); + btnTimerSwitch.Show(); + } + } +} -- cgit v1.2.3