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.
20 namespace ElmSharp.Test
22 public class PerformanceTest : TestCaseBase
24 public override string TestName => "PerformanceTest";
25 public override string TestDescription => "To test Performance of GenList";
27 const int TestItemMax = 2000;
28 const double TimeSet = 5.0;
31 "Time Warner Cable(Cable)",
34 "DirecTV (Satellite)",
35 "Tata Sky (Satellite)",
36 "Nextra Cable(Cable)",
38 "Tikona Cable(Cable)",
39 "True Provider (Cable)",
40 "Vodafone (Satellite)",
47 GenListItem ItemTarget = null;
48 double _enteringSpeed = 0;
52 IntPtr _anim = IntPtr.Zero;
54 double AnimatorFPS = 0;
56 public override void Run(Window window)
58 Conformant conformant = new Conformant(window);
61 Naviframe navi = new Naviframe(window)
63 PreserveContentOnPop = true,
64 DefaultBackButtonEnabled = true
77 //elm_box_padding_set(box2, ELM_SCALE_SIZE(10), ELM_SCALE_SIZE(10)); ºÎºÐ ºüÁü.
81 list = new GenList(window)
88 Style = "solid/default"
91 navi.Push(box, "Performance");
95 list.Changed += List_Changed;
96 list.ScrollAnimationStarted += List_ScrollAnimationStarted;
97 list.ScrollAnimationStopped += List_ScrollAnimationStopped;
101 conformant.SetContent(navi);
104 private void InitializeListItem()
106 GenItemClass defaultClass = new GenItemClass("default")
108 GetTextHandler = (obj, part) =>
114 for (int i = 0; i < TestItemMax; ++i)
117 ItemTarget = list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray()));
119 list.Append(defaultClass, new string(arrLabel[i % 10].ToCharArray()));
123 private void List_ScrollAnimationStopped(object sender, EventArgs e)
125 list.RenderPost -= List_RenderPostFrame;
126 list.ScrollAnimationStarted -= List_ScrollAnimationStarted;
127 list.ScrollAnimationStopped -= List_ScrollAnimationStopped;
129 EcoreAnimator.RemoveAnimator(_anim);
130 Elementary.BringInScrollFriction = _frameSet;
132 FrameFPS = _frameCount / TimeSet;
133 AnimatorFPS = _ecoreCount / TimeSet;
135 Button btn1 = new Button(box2)
142 btn1.Text = string.Format("Entering Speed : {0:f1} msec", _enteringSpeed);
145 Button btn2 = new Button(box2)
152 btn2.Text = string.Format("Animator FPS : {0:f1} fps", AnimatorFPS);
155 Button btn3 = new Button(box2)
162 btn3.Text = string.Format("Evas FPS : {0:f1} fps", FrameFPS);
165 box2.SetAlignment(-1, -1);
166 box2.SetWeight(1, 0.07);
169 private void List_RenderPost(object sender, EventArgs e)
171 list.RenderPost -= List_RenderPost;
172 _enteringSpeed = (EcoreAnimator.GetCurrentTime() - _enteringSpeed) * 1000;
174 _frameSet = Elementary.BringInScrollFriction;
175 Elementary.BringInScrollFriction = TimeSet;
176 list.ScrollTo(ItemTarget, ScrollToPosition.In, true);
179 private void List_ScrollAnimationStarted(object sender, EventArgs e)
182 _anim = EcoreAnimator.AddAnimator(OnEcoreCheck);
183 list.RenderPost += List_RenderPostFrame;
186 private bool OnEcoreCheck()
192 private void List_RenderPostFrame(object sender, EventArgs e)
197 private void List_Changed(object sender, EventArgs e)
199 _enteringSpeed = EcoreAnimator.GetCurrentTime();
200 list.Changed -= List_Changed;
201 list.RenderPost += List_RenderPost;