diff options
Diffstat (limited to 'ElmSharp.Test')
-rwxr-xr-x | ElmSharp.Test/ElmSharp.Test.csproj | 1 | ||||
-rw-r--r-- | ElmSharp.Test/TC/EcoreTimerTest1.cs | 86 |
2 files changed, 87 insertions, 0 deletions
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 @@ <Compile Include="TC\BackgroundTest1.cs" /> <Compile Include="TC\BackgroundTest2.cs" /> <Compile Include="TC\BackgroundTest3.cs" /> + <Compile Include="TC\EcoreTimerTest1.cs" /> <Compile Include="TC\GenListTest10.cs" /> <Compile Include="TC\LabelTest4.cs" /> <Compile Include="TC\Log.cs" /> 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<bool> 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(); + } + } +} |