3 using NUnit.Framework.TUnit;
5 using Tizen.NUI.Components;
6 using Tizen.NUI.BaseComponents;
7 using Tizen.NUI.Binding;
9 namespace Tizen.NUI.Components.Devel.Tests
11 using static Tizen.NUI.Components.ScrollOutOfBoundEventArgs;
12 using tlog = Tizen.Log;
15 [Description("Controls/ScrollableBase")]
16 public class ScrollableBaseTest
18 private const string tag = "NUITEST";
20 internal class MyScrollableBase : ScrollableBase
22 public MyScrollableBase() : base()
25 public void MyAccessibilityIsScrollable()
27 base.AccessibilityIsScrollable();
30 public void OnGetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
32 base.GetNextFocusableView(currentFocusedView, direction, loopEnabled);
35 public void MyDecelerating(float velocity, Animation animation)
37 base.Decelerating(velocity, animation);
40 public bool MyAccessibilityScrollToChild(View child)
42 return base.AccessibilityScrollToChild(child);
49 tlog.Info(tag, "Init() is called!");
55 tlog.Info(tag, "Destroy() is called!");
60 [Description("ScrollableBase constructor.")]
61 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollableBase C")]
62 [Property("SPEC_URL", "-")]
63 [Property("CRITERIA", "CONSTR")]
64 [Property("COVPARAM", "")]
65 [Property("AUTHOR", "guowei.wang@samsung.com")]
66 public void ScrollableBaseConstructor()
68 tlog.Debug(tag, $"ScrollableBaseConstructor START");
70 var testingTarget = new ScrollableBase();
71 Assert.IsNotNull(testingTarget, "null handle");
72 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
74 tlog.Debug(tag, "ScrollPosition : " + testingTarget.ScrollPosition);
76 testingTarget.ScrollingEventThreshold = 0.3f;
77 tlog.Debug(tag, "ScrollingEventThreshold : " + testingTarget.ScrollingEventThreshold);
79 testingTarget.NoticeAnimationEndBeforePosition = 0.5f;
80 tlog.Debug(tag, "NoticeAnimationEndBeforePosition : " + testingTarget.NoticeAnimationEndBeforePosition);
82 testingTarget.Padding = new Extents(2, 2, 2, 2);
83 tlog.Debug(tag, "Padding : " + testingTarget.Padding);
85 testingTarget.Dispose();
86 tlog.Debug(tag, $"ScrollableBaseConstructor END (OK)");
91 [Description("ScrollEventArgs ScrollPosition")]
92 [Property("SPEC", "Tizen.NUI.Components.ScrollEventArgs.ScrollPosition A")]
93 [Property("SPEC_URL", "-")]
94 [Property("CRITERIA", "PRW")]
95 [Property("COVPARAM", "")]
96 [Property("AUTHOR", "guowei.wang@samsung.com")]
97 public void ScrollEventArgsScrollPosition()
99 tlog.Debug(tag, $"ScrollEventArgsScrollPosition START");
101 using (Position position = new Position(10, 20))
103 var testingTarget = new ScrollEventArgs(position);
104 Assert.IsNotNull(testingTarget, "null handle");
105 Assert.IsInstanceOf<ScrollEventArgs>(testingTarget, "Should return ScrollEventArgs instance.");
107 tlog.Debug(tag, "ScrollPosition : " + testingTarget.ScrollPosition);
110 tlog.Debug(tag, $"ScrollEventArgsScrollPosition END (OK)");
115 [Description("ScrollOutOfBoundEventArgs constructor")]
116 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollOutOfBoundEventArgs C")]
117 [Property("SPEC_URL", "-")]
118 [Property("CRITERIA", "MR")]
119 [Property("COVPARAM", "")]
120 [Property("AUTHOR", "guowei.wang@samsung.com")]
121 public void ScrollOutOfBoundEventArgsConstructor()
123 tlog.Debug(tag, $"ScrollOutOfBoundEventArgsConstructor START");
125 var testingTarget = new ScrollOutOfBoundEventArgs(ScrollOutOfBoundEventArgs.Direction.Up, 0.3f);
126 Assert.IsNotNull(testingTarget, "null handle");
127 Assert.IsInstanceOf<ScrollOutOfBoundEventArgs>(testingTarget, "Should return ScrollOutOfBoundEventArgs instance.");
129 tlog.Debug(tag, "PanDirection : " + testingTarget.PanDirection);
130 tlog.Debug(tag, "Displacement : " + testingTarget.Displacement);
132 tlog.Debug(tag, $"ScrollOutOfBoundEventArgsConstructor END (OK)");
137 [Description("ScrollableBase ScrollEnabled")]
138 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollEnabled A")]
139 [Property("SPEC_URL", "-")]
140 [Property("CRITERIA", "PRW")]
141 [Property("COVPARAM", "")]
142 [Property("AUTHOR", "guowei.wang@samsung.com")]
143 public void ScrollableBaseScrollEnabled()
145 tlog.Debug(tag, $"ScrollableBaseScrollEnabled START");
147 var testingTarget = new ScrollableBase();
148 Assert.IsNotNull(testingTarget, "null handle");
149 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
151 testingTarget.ScrollEnabled = true;
152 tlog.Debug(tag, "ScrollEnabled : " + testingTarget.ScrollEnabled);
154 testingTarget.ScrollEnabled = false;
155 tlog.Debug(tag, "ScrollEnabled : " + testingTarget.ScrollEnabled);
157 testingTarget.ScrollEnabled = true;
158 tlog.Debug(tag, "ScrollEnabled : " + testingTarget.ScrollEnabled);
160 testingTarget.Dispose();
161 tlog.Debug(tag, $"ScrollableBaseScrollEnabled END (OK)");
166 [Description("ScrollableBase Scrollbar")]
167 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.Scrollbar A")]
168 [Property("SPEC_URL", "-")]
169 [Property("CRITERIA", "PRW")]
170 [Property("COVPARAM", "")]
171 [Property("AUTHOR", "guowei.wang@samsung.com")]
172 public void ScrollableBaseScrollbar()
174 tlog.Debug(tag, $"ScrollableBaseScrollbar START");
176 var testingTarget = new ScrollableBase();
177 Assert.IsNotNull(testingTarget, "null handle");
178 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
180 testingTarget.ScrollEnabled = true;
181 tlog.Debug(tag, "ScrollEnabled : " + testingTarget.ScrollEnabled);
183 testingTarget.HideScrollbar = false;
185 Scrollbar bar = new Scrollbar()
187 Size = new Size(50, 2),
189 testingTarget.Scrollbar = bar;
191 testingTarget.Dispose();
192 tlog.Debug(tag, $"ScrollableBaseScrollbar END (OK)");
197 [Description("ScrollableBase ScrollableBaseAccessibilityIsScrollable")]
198 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollableBaseAccessibilityIsScrollable M")]
199 [Property("SPEC_URL", "-")]
200 [Property("CRITERIA", "PRW")]
201 [Property("COVPARAM", "")]
202 [Property("AUTHOR", "guowei.wang@samsung.com")]
203 public void ScrollableBaseAccessibilityIsScrollable()
205 tlog.Debug(tag, $"ScrollableBaseAccessibilityIsScrollable START");
207 var testingTarget = new MyScrollableBase();
208 Assert.IsNotNull(testingTarget, "null handle");
209 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
213 testingTarget.MyAccessibilityIsScrollable();
217 tlog.Debug(tag, e.Message.ToString());
218 Assert.Fail("Caught Exception : Failed!");
221 testingTarget.Dispose();
222 tlog.Debug(tag, $"ScrollableBaseAccessibilityIsScrollable END (OK)");
227 [Description("ScrollableBase GetNextFocusableView")]
228 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.GetNextFocusableView M")]
229 [Property("SPEC_URL", "-")]
230 [Property("CRITERIA", "PRW")]
231 [Property("COVPARAM", "")]
232 [Property("AUTHOR", "guowei.wang@samsung.com")]
233 public void ScrollableBaseGetNextFocusableView()
235 tlog.Debug(tag, $"ScrollableBaseGetNextFocusableView START");
237 var testingTarget = new MyScrollableBase();
238 Assert.IsNotNull(testingTarget, "null handle");
239 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
241 View view1 = new View()
243 Size = new Size(100, 200),
244 Position = new Position(0, 0),
245 BackgroundColor = Color.Cyan
248 View view2 = new View()
250 Size = new Size(100, 200),
251 Position = new Position(150, 0),
252 BackgroundColor = Color.Green
255 View view3 = new View()
257 Size = new Size(100, 200),
258 Position = new Position(300, 200),
259 BackgroundColor = Color.Green
262 FocusManager.Instance.SetCurrentFocusView(view1);
266 testingTarget.OnGetNextFocusableView(view1, View.FocusDirection.Right, true);
267 testingTarget.OnGetNextFocusableView(view2, View.FocusDirection.Right, true);
268 testingTarget.OnGetNextFocusableView(view3, View.FocusDirection.Left, true);
272 tlog.Debug(tag, e.Message.ToString());
273 Assert.Fail("Caught Exception : Failed!");
276 FocusManager.Instance.ClearFocus();
278 testingTarget.Dispose();
279 tlog.Debug(tag, $"ScrollableBaseGetNextFocusableView END (OK)");
284 [Description("ScrollableBase ScrollTo")]
285 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollTo M")]
286 [Property("SPEC_URL", "-")]
287 [Property("CRITERIA", "PRW")]
288 [Property("COVPARAM", "")]
289 [Property("AUTHOR", "guowei.wang@samsung.com")]
290 public void ScrollableBaseScrollTo()
292 tlog.Debug(tag, $"ScrollableBaseScrollTo START");
294 var testingTarget = new ScrollableBase()
296 Size = new Size(100, 2),
297 BackgroundColor = Color.Cyan,
298 ScrollingDirection = ScrollableBase.Direction.Horizontal,
300 Assert.IsNotNull(testingTarget, "null handle");
301 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
305 testingTarget.ScrollTo(0.3f, true);
309 tlog.Debug(tag, e.Message.ToString());
310 Assert.Fail("Caught Exception : Failed!");
313 testingTarget.Dispose();
314 tlog.Debug(tag, $"ScrollableBaseScrollTo END (OK)");
319 [Description("ScrollableBase OnAccessibilityPan")]
320 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.OnAccessibilityPan M")]
321 [Property("SPEC_URL", "-")]
322 [Property("CRITERIA", "PRW")]
323 [Property("COVPARAM", "")]
324 [Property("AUTHOR", "guowei.wang@samsung.com")]
325 public void ScrollableBaseOnAccessibilityPan()
327 tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan START");
329 var testingTarget = new ScrollableBase()
331 Size = new Size(100, 2),
332 BackgroundColor = Color.Cyan,
333 ScrollingDirection = ScrollableBase.Direction.Vertical,
335 Assert.IsNotNull(testingTarget, "null handle");
336 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
338 using (PanGesture gesture = new PanGesture())
342 testingTarget.OnAccessibilityPan(gesture);
346 tlog.Debug(tag, e.Message.ToString());
347 Assert.Fail("Caught Exception : Failed!");
351 testingTarget.Dispose();
352 tlog.Debug(tag, $"ScrollableBaseOnAccessibilityPan END (OK)");
357 [Description("ScrollableBase Decelerating")]
358 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.Decelerating M")]
359 [Property("SPEC_URL", "-")]
360 [Property("CRITERIA", "PRW")]
361 [Property("COVPARAM", "")]
362 [Property("AUTHOR", "guowei.wang@samsung.com")]
363 public void ScrollableBaseDecelerating()
365 tlog.Debug(tag, $"ScrollableBaseDecelerating START");
367 var testingTarget = new MyScrollableBase()
369 Size = new Size(100, 2),
370 BackgroundColor = Color.Cyan,
371 ScrollingDirection = ScrollableBase.Direction.Vertical,
373 Assert.IsNotNull(testingTarget, "null handle");
374 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
378 using (Animation ani = new Animation(300))
380 ani.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce);
381 testingTarget.MyDecelerating(0.3f, ani);
386 tlog.Debug(tag, e.Message.ToString());
387 Assert.Fail("Caught Exception : Failed!");
390 testingTarget.Dispose();
391 tlog.Debug(tag, $"ScrollableBaseDecelerating END (OK)");
396 [Description("ScrollableBase DecelerationThreshold")]
397 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.DecelerationThreshold A")]
398 [Property("SPEC_URL", "-")]
399 [Property("CRITERIA", "PRW")]
400 [Property("COVPARAM", "")]
401 [Property("AUTHOR", "guowei.wang@samsung.com")]
402 public void ScrollableBaseDecelerationThreshold()
404 tlog.Debug(tag, $"ScrollableBaseDecelerationThreshold START");
406 var testingTarget = new MyScrollableBase()
408 Size = new Size(100, 2),
409 BackgroundColor = Color.Cyan,
410 ScrollingDirection = ScrollableBase.Direction.Vertical,
412 Assert.IsNotNull(testingTarget, "null handle");
413 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
415 testingTarget.DecelerationThreshold = 0.8f;
416 tlog.Debug(tag, "DecelerationThreshold : " + testingTarget.DecelerationThreshold);
418 testingTarget.Dispose();
419 tlog.Debug(tag, $"ScrollableBaseDecelerationThreshold END (OK)");
424 [Description("ScrollableBase ScrollAlphaFunction")]
425 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.ScrollAlphaFunction A")]
426 [Property("SPEC_URL", "-")]
427 [Property("CRITERIA", "PRW")]
428 [Property("COVPARAM", "")]
429 [Property("AUTHOR", "guowei.wang@samsung.com")]
430 public void ScrollableBaseScrollAlphaFunction()
432 tlog.Debug(tag, $"ScrollableBaseScrollAlphaFunction START");
434 var testingTarget = new MyScrollableBase()
436 Size = new Size(100, 2),
437 BackgroundColor = Color.Cyan,
438 ScrollingDirection = ScrollableBase.Direction.Vertical,
440 Assert.IsNotNull(testingTarget, "null handle");
441 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
443 testingTarget.ScrollAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseIn);
444 tlog.Debug(tag, "ScrollAlphaFunction : " + testingTarget.ScrollAlphaFunction);
446 testingTarget.Dispose();
447 tlog.Debug(tag, $"ScrollableBaseScrollAlphaFunction END (OK)");
452 [Description("ScrollableBase AccessibilityScrollToChild")]
453 [Property("SPEC", "Tizen.NUI.Components.ScrollableBase.AccessibilityScrollToChild M")]
454 [Property("SPEC_URL", "-")]
455 [Property("CRITERIA", "MR")]
456 [Property("COVPARAM", "")]
457 [Property("AUTHOR", "guowei.wang@samsung.com")]
458 public void ScrollableBaseAccessibilityScrollToChild()
460 tlog.Debug(tag, $"ScrollableBaseAccessibilityScrollToChild START");
462 var testingTarget = new MyScrollableBase()
464 Size = new Size(2000, 200),
465 BackgroundColor = Color.Cyan,
466 ScrollingDirection = ScrollableBase.Direction.Horizontal,
468 Assert.IsNotNull(testingTarget, "null handle");
469 Assert.IsInstanceOf<ScrollableBase>(testingTarget, "Should return ScrollableBase instance.");
471 testingTarget.ScrollAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseIn);
472 tlog.Debug(tag, "ScrollAlphaFunction : " + testingTarget.ScrollAlphaFunction);
474 View[] views = new View[10];
475 for (int i = 0; i < 10; i++)
477 views[i] = new View();
478 views[i].Size = new Size(200, 200);
479 testingTarget.Add(views[i]);
482 var result = testingTarget.MyAccessibilityScrollToChild(views[9]);
483 tlog.Debug(tag, "AccessibilityScrollToChild : " + result);
487 testingTarget.RemoveAllChildren(true);
491 tlog.Debug(tag, e.Message.ToString());
492 Assert.Fail("Caught Exception : Failed!");
495 testingTarget.Dispose();
496 tlog.Debug(tag, $"ScrollableBaseAccessibilityScrollToChild END (OK)");