2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali/integration-api/events/touch-event-integ.h>
21 #include <dali/integration-api/events/wheel-event-integ.h>
26 using namespace Toolkit;
28 void scroll_view_startup(void)
30 test_return_value = TET_UNDEF;
33 void scroll_view_cleanup(void)
35 test_return_value = TET_PASS;
40 static bool gObjectCreatedCallBackCalled;
42 static void TestCallback(BaseHandle handle)
44 gObjectCreatedCallBackCalled = true;
47 struct CallbackFunctor
49 CallbackFunctor(bool* callbackFlag)
50 : mCallbackFlag(callbackFlag)
56 *mCallbackFlag = true;
61 const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS)
63 const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete.
65 // For Clamp Signal testing...
66 const float CLAMP_EXCESS_WIDTH = 200.0f; ///< Amount of width that can be panned outside scrollview
67 const float CLAMP_EXCESS_HEIGHT = 200.0f; ///< Amount of height that can be panned outside scrollview
68 const Vector2 CLAMP_START_SCROLL_POSITION(30.0f, 100.0f); ///< Scroll start position for the Clamping tests.
69 const Vector2 CLAMP_TOUCH_START(100.0f, 100.0f); ///< Start point to touch from for the Clamping tests.
70 const Vector2 CLAMP_TOUCH_MOVEMENT(5.0f, -5.0f); ///< Amount to move touch for each frame for the Clamping tests.
71 const int CLAMP_GESTURE_FRAMES = 100; ///< Number of Frames to synthesize a gesture for the Clamping tests.
72 const Vector3 TEST_ACTOR_POSITION(100.0f, 100.0f, 0.0f); ///< A Test actor position offset (arbitrary value)
73 const Vector3 TEST_CONSTRAINT_OFFSET(1.0f, 2.0f, 0.0f); ///< A Test constraint offset (arbitrary value to test effects)
75 const float DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f); ///< Default overshoot snapping animation time.
76 const float DEFAULT_MAX_OVERSHOOT(100.0f); ///< Default maximum allowed overshoot in pixels
78 const int MAX_FRAMES_TO_TEST_OVERSHOOT = 600; ///< 10 seconds (at 60 frames per second).
79 const Vector2 OVERSHOOT_START_SCROLL_POSITION(100.0f, 100.0f); ///< Scroll start position for the Overshoot tests.
80 const float SCROLL_ANIMATION_DURATION(0.33f); ///< Duration of scroll animation in Overshoot tests (i.e. 100 pixels of overshoot in the speed of 500 pixels per 100 frames, 100/(500/(100/60)) = 0.33)
81 const Vector2 SNAP_POSITION_WITH_DECELERATED_VELOCITY(74.0f, 74.0f); ///< the snap position for Overshoot tests with the decelerated velocity (i.e. Decelerated from 500 pixels per 100 frames).
82 const float TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION = 0.05f; ///< a Test duration
83 const float TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION = 1.5f; ///< another Test duration
84 const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * 0.5f; // Same as above, but different alpha function.
85 const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames)
88 * Simulate time passed by.
90 * @note this will always process at least 1 frame (1/60 sec)
92 * @param application Test application instance
93 * @param duration Time to pass in milliseconds.
94 * @return The actual time passed in milliseconds
96 int Wait(ToolkitTestApplication& application, int duration = 0)
100 for(int i = 0; i <= (duration / RENDER_FRAME_INTERVAL); i++)
102 application.SendNotification();
103 application.Render(RENDER_FRAME_INTERVAL);
104 time += RENDER_FRAME_INTERVAL;
112 static bool gOnScrollStartCalled; ///< Whether the OnScrollStart signal was invoked.
113 static bool gOnScrollUpdateCalled; ///< Whether the OnScrollUpdate signal was invoked.
114 static bool gOnScrollCompleteCalled; ///< Whether the OnScrollComplete signal was invoked.
115 static bool gOnSnapStartCalled; ///< Whether the OnSnapStart signal was invoked.
116 static bool gOnWheelEventCalled; ///< Whether the WheelEventSignal signal was invoked.
117 static SnapType gLastSnapType; ///< Snaping information from SnapEvent.
118 static Vector3 gConstraintResult; ///< Result from constraint.
121 * Invoked when scrolling starts.
123 * @param[in] position The current scroll position.
125 static void OnScrollStart(const Vector2& position)
127 gOnScrollStartCalled = true;
131 * Invoked when scrolling updates (via dragging)
133 * @param[in] position The current scroll position.
135 static void OnScrollUpdate(const Vector2& position)
137 gOnScrollUpdateCalled = true;
141 * Invoked when scrolling finishes
143 * @param[in] position The current scroll position.
145 static void OnScrollComplete(const Vector2& position)
147 gOnScrollCompleteCalled = true;
151 * Invoked when a snap or flick started.
153 * @param[in] event The type of snap and the target position/scale/rotation.
155 static void OnSnapStart(const ScrollView::SnapEvent& event)
157 gOnSnapStartCalled = true;
158 gLastSnapType = event.type;
162 * Invoked after a wheel-event is received
164 * @param[in] actor The owing actor
165 * @param[in] event The wheel event
166 * @return True if the event should be consumed
168 static bool OnWheelEvent(Actor actor, const Dali::WheelEvent& wheelEvent)
170 gOnWheelEventCalled = true;
177 * Summation of current value, property, and offset.
179 * current' = current + mOffset + property;
181 struct TestSumConstraint
184 * @param[in] offset The offset to be added to current.
186 TestSumConstraint(const Vector3& offset)
192 * @param[in] current The current base value
193 * @param[in] inputs Contains the property to be added to current.
194 * @return The new current Vector.
196 void operator()(Vector3& current, const PropertyInputContainer& inputs)
198 gConstraintResult = current + Vector3(inputs[0]->GetVector2()) + mOffset;
199 current = gConstraintResult;
206 * @param[in] application The application instance
207 * @param[in] scrollView The scrollView instance
208 * @return The time taken for the overshoot to reach origin (zero)
210 static float TestOvershootSnapDuration(ToolkitTestApplication& application, ScrollView scrollView)
212 int timeToReachOrigin = -1;
213 for(int i = 0; i < MAX_FRAMES_TO_TEST_OVERSHOOT; i++)
215 float overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
216 float overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
217 if(overshootXValue == 0.0f && overshootYValue == 0.0f)
222 timeToReachOrigin += Wait(application);
225 return static_cast<float>(timeToReachOrigin) * 0.001f; // return in seconds not ms.
229 * y = 2x alpha function, which is clamped between 0.0f - 1.0f
231 * Animations should appear to finish (reach 100% point)
232 * at just half the time of a regular Linear AlphaFunction.
234 * @param[in] progress value (ranges from 0.0f - 1.0f)
235 * @return interpolation value (ranges from 0.0f - 1.0f)
237 float TestAlphaFunction(float progress)
239 return std::min(progress * 2.0f, 1.0f);
243 * Generate a complete pan gesture
244 * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches
246 static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true)
248 gOnScrollStartCalled = false;
249 gOnScrollUpdateCalled = false;
250 gOnScrollCompleteCalled = false;
251 gOnSnapStartCalled = false;
255 // This is created to ensure a pan is started
256 Vector2 pos_start_jump(start + Vector2(11.0f, 11.0f));
257 TestStartPan(application, start, pos_start_jump, time);
258 pos = pos_start_jump;
262 for(int i = 0; i < frames; i++)
264 pos += direction; // Move in this direction
265 TestMovePan(application, pos, time);
266 time += Wait(application);
271 pos += direction; // Move in this direction.
272 TestEndPan(application, pos, time);
273 time += Wait(application, RENDER_DELAY_SCROLL);
279 } // unnamed namespace
281 int UtcDaliToolkitScrollViewConstructorP(void)
283 ToolkitTestApplication application;
285 ScrollView scrollView;
286 DALI_TEST_CHECK(!scrollView);
290 int UtcDaliToolkitScrollViewCopyConstructorP(void)
292 ToolkitTestApplication application;
294 ScrollView scrollView = ScrollView::New();
295 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f));
297 ScrollView copy(scrollView);
298 DALI_TEST_CHECK(copy);
299 DALI_TEST_CHECK(copy.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION) == scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION));
303 int UtcDaliScrollViewMoveConstructor(void)
305 ToolkitTestApplication application;
307 ScrollView scrollView = ScrollView::New();
308 DALI_TEST_EQUALS(1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
309 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f));
310 DALI_TEST_EQUALS(scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION), Vector2(10.0f, 10.0f), TEST_LOCATION);
312 ScrollView moved = std::move(scrollView);
313 DALI_TEST_CHECK(moved);
314 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
315 DALI_TEST_EQUALS(moved.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION), Vector2(10.0f, 10.0f), TEST_LOCATION);
316 DALI_TEST_CHECK(!scrollView);
321 int UtcDaliToolkitScrollViewAssignmentOperatorP(void)
323 ToolkitTestApplication application;
325 ScrollView scrollView = ScrollView::New();
326 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f));
330 DALI_TEST_CHECK(copy);
331 DALI_TEST_CHECK(copy.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION) == scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION));
335 int UtcDaliScrollViewMoveAssignment(void)
337 ToolkitTestApplication application;
339 ScrollView scrollView = ScrollView::New();
340 DALI_TEST_EQUALS(1, scrollView.GetBaseObject().ReferenceCount(), TEST_LOCATION);
341 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION, Vector2(10.0f, 10.0f));
342 DALI_TEST_EQUALS(scrollView.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION), Vector2(10.0f, 10.0f), TEST_LOCATION);
345 moved = std::move(scrollView);
346 DALI_TEST_CHECK(moved);
347 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
348 DALI_TEST_EQUALS(moved.GetProperty<Vector2>(ScrollView::Property::SCROLL_POSITION), Vector2(10.0f, 10.0f), TEST_LOCATION);
349 DALI_TEST_CHECK(!scrollView);
354 int UtcDaliScrollViewDestructorP(void)
356 ToolkitTestApplication application;
358 ScrollView* scrollView = new ScrollView();
361 DALI_TEST_CHECK(true);
365 int UtcDaliToolkitScrollViewNewP1(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitScrollViewNewP1");
370 ScrollView scrollView;
372 DALI_TEST_CHECK(!scrollView);
374 scrollView = ScrollView::New();
376 DALI_TEST_CHECK(scrollView);
378 ScrollView scrollView2(scrollView);
380 DALI_TEST_CHECK(scrollView2 == scrollView);
382 //Additional check to ensure object is created by checking if it's registered
383 ObjectRegistry registry = application.GetCore().GetObjectRegistry();
384 DALI_TEST_CHECK(registry);
386 gObjectCreatedCallBackCalled = false;
387 registry.ObjectCreatedSignal().Connect(&TestCallback);
389 ScrollView scrollView = ScrollView::New();
391 DALI_TEST_CHECK(gObjectCreatedCallBackCalled);
395 int UtcDaliToolkitScrollViewNewP2(void)
397 ToolkitTestApplication application;
398 tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry");
400 ScrollView scrollView;
401 DALI_TEST_CHECK(!scrollView);
403 TypeRegistry typeRegistry = TypeRegistry::Get();
404 TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView");
405 BaseHandle handle = scrollViewType.CreateInstance();
406 DALI_TEST_CHECK(handle);
408 scrollView = ScrollView::DownCast(handle);
409 DALI_TEST_CHECK(scrollView);
414 int UtcDaliToolkitScrollViewDownCastP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitScrollViewDownCastP");
419 ScrollView scrollView = ScrollView::New();
420 BaseHandle handle(scrollView);
422 ScrollView newScrollView = ScrollView::DownCast(handle);
423 DALI_TEST_CHECK(scrollView);
424 DALI_TEST_CHECK(newScrollView == scrollView);
428 int UtcDaliToolkitScrollViewScrollToPositionP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionP");
433 // Create the ScrollView actor
434 ScrollView scrollView = ScrollView::New();
435 application.GetScene().Add(scrollView);
437 const Vector2 target = Vector2(100.0f, 200.0f);
438 const Vector2 target2 = Vector2(300.0f, 100.0f);
440 scrollView.ScrollTo(target, 0.0f);
442 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
443 scrollView.ScrollTo(target2);
444 Wait(application, RENDER_DELAY_SCROLL);
445 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
450 int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP");
455 ScrollView scrollView = ScrollView::New();
456 application.GetScene().Add(scrollView);
457 RulerPtr rulerX = new FixedRuler(100.0f);
458 rulerX->SetDomain(RulerDomain(0.0f, 200.0f, true));
459 RulerPtr rulerY = new FixedRuler(100.0f);
460 rulerY->SetDomain(RulerDomain(0.0f, 200.0f, true));
462 scrollView.SetRulerX(rulerX);
463 scrollView.SetRulerY(rulerY);
465 scrollView.SetWrapMode(true);
467 Property::Value wrapMode = scrollView.GetProperty(Toolkit::ScrollView::Property::WRAP_ENABLED);
468 DALI_TEST_EQUALS(wrapMode.Get<bool>(), true, TEST_LOCATION);
470 const Vector2 target = Vector2(50.0f, 50.0f);
471 const Vector2 target2 = Vector2(150.0f, 150.0f);
473 scrollView.ScrollTo(target, 0.0f);
474 Wait(application, RENDER_DELAY_SCROLL);
475 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
477 scrollView.ScrollTo(target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT);
478 Wait(application, RENDER_DELAY_SCROLL);
479 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
481 scrollView.ScrollTo(target, 0.0f);
482 Wait(application, RENDER_DELAY_SCROLL);
483 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
485 scrollView.ScrollTo(target2, 0.25f, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT);
486 Wait(application, RENDER_DELAY_SCROLL);
487 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
492 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP(void)
494 ToolkitTestApplication application;
495 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionP");
497 // Create the ScrollView actor
498 ScrollView scrollView = ScrollView::New();
499 application.GetScene().Add(scrollView);
501 const Vector2 target = Vector2(100.0f, 200.0f);
502 const Vector2 target2 = Vector2(300.0f, 100.0f);
504 scrollView.ScrollTo(target, 0.5f, TestAlphaFunction);
505 Wait(application, 250);
506 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
507 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
509 scrollView.ScrollTo(target2, 0.5f, AlphaFunction::LINEAR);
510 Wait(application, 250);
511 // Check that the scroll animation has not finished within half of the specified duration with the linear alpha function
512 DALI_TEST_CHECK(scrollView.GetCurrentScrollPosition() != target2);
514 // Wait till the end of the specified duration
515 Wait(application, 250);
516 // Check that the scroll animation has finished
517 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
522 int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(void)
524 ToolkitTestApplication application;
525 tet_infoline(" UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP");
527 ScrollView scrollView = ScrollView::New();
528 application.GetScene().Add(scrollView);
529 RulerPtr rulerX = new FixedRuler(100.0f);
530 rulerX->SetDomain(RulerDomain(0.0f, 200.0f, true));
531 RulerPtr rulerY = new FixedRuler(100.0f);
532 rulerY->SetDomain(RulerDomain(0.0f, 200.0f, true));
534 scrollView.SetRulerX(rulerX);
535 scrollView.SetRulerY(rulerY);
537 scrollView.SetWrapMode(true);
539 const Vector2 target = Vector2(50.0f, 50.0f);
540 const Vector2 target2 = Vector2(150.0f, 150.0f);
542 scrollView.ScrollTo(target, 0.0f);
543 Wait(application, RENDER_DELAY_SCROLL);
544 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
546 scrollView.ScrollTo(target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_LEFT, Dali::Toolkit::DIRECTION_BIAS_LEFT);
547 Wait(application, RENDER_DELAY_SCROLL);
548 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
550 scrollView.ScrollTo(target, 0.0f);
551 Wait(application, RENDER_DELAY_SCROLL);
552 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
554 scrollView.ScrollTo(target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT);
555 Wait(application, RENDER_DELAY_SCROLL);
556 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
558 scrollView.ScrollTo(target, 0.0f);
559 Wait(application, RENDER_DELAY_SCROLL);
560 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
562 scrollView.ScrollTo(target2, 0.25f, TestAlphaFunction, Dali::Toolkit::DIRECTION_BIAS_RIGHT, Dali::Toolkit::DIRECTION_BIAS_RIGHT);
563 Wait(application, 125);
564 // Check that the scroll animation should finish within just half of the specified duration with the above alpha function
565 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
570 int UtcDaliToolkitScrollViewScrollToPageP(void)
572 ToolkitTestApplication application;
573 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageP");
575 ScrollView scrollView = ScrollView::New();
576 application.GetScene().Add(scrollView);
577 RulerPtr rulerX = new FixedRuler(100.0f);
578 rulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
579 RulerPtr rulerY = new FixedRuler(100.0f);
580 rulerY->SetDomain(RulerDomain(0.0f, 400.0f, true));
582 scrollView.SetRulerX(rulerX);
583 scrollView.SetRulerY(rulerY);
585 scrollView.ScrollTo(1, 0.0f);
587 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION);
589 scrollView.ScrollTo(5, 0.0f);
591 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(500.0f, 0.0f), TEST_LOCATION);
593 scrollView.ScrollTo(10, 0.0f);
595 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 100.0f), TEST_LOCATION);
597 scrollView.ScrollTo(15, 0.0f);
599 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(700.0f, 100.0f), TEST_LOCATION);
600 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION);
602 scrollView.ScrollTo(3);
603 Wait(application, RENDER_DELAY_SCROLL);
604 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(300.0f, 0.0f), TEST_LOCATION);
605 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION);
607 scrollView.ScrollTo(9);
608 Wait(application, RENDER_DELAY_SCROLL);
609 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 100.0f), TEST_LOCATION);
610 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION);
612 // Apply DefaultRulers instead and see what happens.
613 rulerX = new DefaultRuler();
614 rulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
615 rulerY = new DefaultRuler();
616 rulerY->SetDomain(RulerDomain(0.0f, 400.0f, true));
618 scrollView.SetRulerX(rulerX);
619 scrollView.SetRulerY(rulerY);
621 // This time should always scroll to origin (0.0f, 0.0f)
622 scrollView.ScrollTo(1, 0.0f);
624 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION);
625 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION);
630 int UtcDaliToolkitScrollModeP1(void)
632 ToolkitTestApplication application;
633 tet_infoline(" UtcDaliToolkitScrollView ScrollMode property");
635 // Set up a scrollView.
636 ScrollView scrollView = ScrollView::New();
638 // Do not rely on stage size for UTC tests.
639 Vector2 viewPageSize(720.0f, 1280.0f);
640 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
641 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
642 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
643 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
644 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
647 Property::Map rulerMap;
648 rulerMap.Add(ScrollMode::X_AXIS_SCROLL_ENABLED, true);
649 rulerMap.Add(ScrollMode::X_AXIS_SNAP_TO_INTERVAL, viewPageSize.width);
650 rulerMap.Add(ScrollMode::X_AXIS_SCROLL_BOUNDARY, viewPageSize.width * 3);
651 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_ENABLED, false);
652 scrollView.SetProperty(ScrollView::Property::SCROLL_MODE, rulerMap);
654 scrollView.SetWrapMode(false);
655 scrollView.SetScrollSensitive(true);
657 application.GetScene().Add(scrollView);
659 // Set up a gesture to perform.
660 Vector2 startPos(50.0f, 0.0f);
661 Vector2 direction(-5.0f, 0.0f);
665 // Force starting position.
666 scrollView.ScrollTo(startPos, 0.0f);
667 time += Wait(application);
669 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
670 Vector2 currentPos(PerformGestureSwipe(application, startPos, direction, frames - 1, time, false));
672 // Confirm the final X coord has not moved more than one page from the start X position.
673 DALI_TEST_GREATER((startPos.x + viewPageSize.width), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION);
675 // Finish the gesture and wait for the snap.
676 currentPos += direction;
677 TestEndPan(application, currentPos, time);
678 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
679 time += Wait(application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL);
681 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
682 DALI_TEST_EQUALS(viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION);
684 // Change scroll mode during pan, should not crash
685 PerformGestureSwipe(application, startPos, direction, frames - 1, time, false);
688 scrollView.SetScrollSensitive(false);
689 DALI_TEST_CHECK(true);
693 DALI_TEST_CHECK(false);
699 int UtcDaliToolkitScrollModeP2(void)
701 ToolkitTestApplication application;
702 tet_infoline(" UtcDaliToolkitScrollView ScrollMode property");
704 // Set up a scrollView.
705 ScrollView scrollView = ScrollView::New();
707 // Do not rely on stage size for UTC tests.
708 Vector2 viewPageSize(720.0f, 1280.0f);
709 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
710 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
711 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
712 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
713 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
716 Property::Map rulerMap;
717 rulerMap.Add(ScrollMode::X_AXIS_SCROLL_ENABLED, false);
718 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_ENABLED, true);
719 rulerMap.Add(ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height);
720 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height * 3);
721 scrollView.SetProperty(ScrollView::Property::SCROLL_MODE, rulerMap);
723 scrollView.SetWrapMode(false);
724 scrollView.SetScrollSensitive(true);
726 application.GetScene().Add(scrollView);
728 // Set up a gesture to perform.
729 Vector2 startPos(0.0f, 50.0f);
730 Vector2 direction(0.0f, -6.0f);
734 // Force starting position.
735 scrollView.ScrollTo(startPos, 0.0f);
736 time += Wait(application);
738 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
739 Vector2 currentPos(PerformGestureSwipe(application, startPos, direction, frames - 1, time, false));
741 // Confirm the final X coord has not moved more than one page from the start X position.
742 DALI_TEST_GREATER((startPos.y + viewPageSize.height), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION);
744 // Finish the gesture and wait for the snap.
745 currentPos += direction;
746 time += Wait(application);
747 TestEndPan(application, currentPos, time);
748 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
749 Wait(application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL);
751 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
752 DALI_TEST_EQUALS(viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION);
757 int UtcDaliToolkitScrollModeP3(void)
759 ToolkitTestApplication application;
760 tet_infoline(" UtcDaliToolkitScrollView ScrollMode property");
762 // Set up a scrollView.
763 ScrollView scrollView = ScrollView::New();
765 // Do not rely on stage size for UTC tests.
766 Vector2 viewPageSize(720.0f, 1280.0f);
767 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
768 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
769 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
770 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
771 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
774 Property::Map rulerMap;
775 rulerMap.Add(ScrollMode::X_AXIS_SCROLL_ENABLED, false);
776 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_ENABLED, true);
777 rulerMap.Add(ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, viewPageSize.height);
778 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_BOUNDARY, viewPageSize.height * 3);
779 scrollView.SetProperty(ScrollView::Property::SCROLL_MODE, rulerMap);
781 scrollView.SetWrapMode(false);
782 scrollView.SetScrollSensitive(true);
784 application.GetScene().Add(scrollView);
786 // Set up a gesture to perform.
787 Vector2 startPos(0.0f, 50.0f);
788 Vector2 direction(0.0f, -6.0f);
792 // Force starting position.
793 scrollView.ScrollTo(startPos, 0.0f);
794 time += Wait(application);
796 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
797 Vector2 currentPos(PerformGestureSwipe(application, startPos, direction, frames - 1, time, false));
799 // Confirm the final X coord has not moved more than one page from the start X position.
800 DALI_TEST_GREATER((startPos.y + viewPageSize.height), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION);
802 // Finish the gesture and wait for the snap.
803 currentPos += direction;
804 TestEndPan(application, currentPos, time);
805 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
806 Wait(application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL);
808 // Confirm the final Y coord has snapped to exactly one page ahead of the start page.
809 DALI_TEST_EQUALS(viewPageSize.height, scrollView.GetCurrentScrollPosition().y, Math::MACHINE_EPSILON_0, TEST_LOCATION);
814 int UtcDaliToolkitScrollModeP4(void)
816 ToolkitTestApplication application;
817 tet_infoline(" UtcDaliToolkitScrollView ScrollMode property, DefaultRulers");
819 // Set up a scrollView.
820 ScrollView scrollView = ScrollView::New();
822 // Do not rely on stage size for UTC tests.
823 Vector2 viewPageSize(720.0f, 1280.0f);
824 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
825 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
826 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
827 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
828 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
830 // Position rulers - expect Default rulers to be used which don't snap
831 Property::Map rulerMap;
832 rulerMap.Add(ScrollMode::X_AXIS_SCROLL_ENABLED, true);
833 rulerMap.Add(ScrollMode::Y_AXIS_SCROLL_ENABLED, true);
834 scrollView.SetProperty(ScrollView::Property::SCROLL_MODE, rulerMap);
836 scrollView.SetWrapMode(false);
837 scrollView.SetScrollSensitive(true);
839 application.GetScene().Add(scrollView);
841 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
844 scrollView.ScrollTo(START_POSITION, 0.0f);
845 time += Wait(application);
847 // Try a vertical swipe.
848 // PerformGestureSwipe not used as a different initial direction was required
849 Vector2 pos(START_POSITION + Vector2(0.0f, 15.0f));
850 Vector2 dir(0.0f, 1.0f);
852 TestStartPan(application, START_POSITION, pos, time);
856 for(int i = 0; i < 45; i++)
859 TestMovePan(application, pos, time);
860 time += Wait(application);
865 TestEndPan(application, pos, time);
866 Wait(application, RENDER_DELAY_SCROLL);
868 // Take into account resampling done when prediction is off.
869 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
874 int UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP(void)
876 ToolkitTestApplication application;
877 tet_infoline(" UtcDaliToolkitScrollViewScrollToPageWithDirectionBiasP");
879 ScrollView scrollView = ScrollView::New();
880 application.GetScene().Add(scrollView);
881 RulerPtr rulerX = new FixedRuler(100.0f);
882 rulerX->SetDomain(RulerDomain(0.0f, 200.0f, true));
883 RulerPtr rulerY = new FixedRuler(100.0f);
884 rulerY->SetDomain(RulerDomain(0.0f, 200.0f, true));
886 scrollView.SetRulerX(rulerX);
887 scrollView.SetRulerY(rulerY);
889 scrollView.SetWrapMode(true);
891 scrollView.ScrollTo(0, 0.25, Dali::Toolkit::DIRECTION_BIAS_LEFT);
893 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
894 // Check that the scroll position remains the same
895 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION);
897 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
898 // Check that it stays at the same page (i.e. the same scroll position)
899 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION);
900 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION);
902 scrollView.ScrollTo(0, 0.25, Dali::Toolkit::DIRECTION_BIAS_RIGHT);
904 Wait(application, RENDER_FRAME_INTERVAL); // Wait for one frame
905 // Check that it scrolls towards the right
906 DALI_TEST_CHECK(scrollView.GetCurrentScrollPosition().x > 0.0f);
908 Wait(application, RENDER_DELAY_SCROLL); // Wait for one second
909 // Check that it scrolls back to the same page (i.e. the same scroll position)
910 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 0, TEST_LOCATION);
911 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 0.0f), TEST_LOCATION);
916 int UtcDaliToolkitScrollViewScrollToActorP(void)
918 ToolkitTestApplication application;
919 tet_infoline(" UtcDaliToolkitScrollViewScrollToActorP");
921 ScrollView scrollView = ScrollView::New();
922 application.GetScene().Add(scrollView);
924 Actor actorA = Actor::New();
925 const Vector3 positionA = Vector3(100.0f, 400.0f, 0.0f);
926 actorA.SetProperty(Actor::Property::POSITION, positionA);
927 scrollView.Add(actorA);
929 Actor actorB = Actor::New();
930 const Vector3 positionB = Vector3(500.0f, 200.0f, 0.0f);
931 actorB.SetProperty(Actor::Property::POSITION, positionB);
932 scrollView.Add(actorB);
936 scrollView.ScrollTo(actorA, 0.0f);
938 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION);
941 scrollView.ScrollTo(actorB, 0.0f);
943 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION);
945 scrollView.ScrollTo(actorA);
946 Wait(application, RENDER_DELAY_SCROLL);
947 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionA.GetVectorXY(), TEST_LOCATION);
949 scrollView.ScrollTo(actorB);
950 Wait(application, RENDER_DELAY_SCROLL);
951 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), positionB.GetVectorXY(), TEST_LOCATION);
955 int UtcDaliToolkitScrollViewScrollToSnapPointP(void)
957 ToolkitTestApplication application;
958 tet_infoline(" UtcDaliToolkitScrollViewScrollToSnapPointP");
960 ScrollView scrollView = ScrollView::New();
961 application.GetScene().Add(scrollView);
962 RulerPtr rulerX = new FixedRuler(100.0f);
963 rulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
964 RulerPtr rulerY = new FixedRuler(100.0f);
965 rulerY->SetDomain(RulerDomain(0.0f, 400.0f, true));
967 scrollView.SetRulerX(rulerX);
968 scrollView.SetRulerY(rulerY);
970 scrollView.ScrollTo(Vector2(120.0f, 190.0f), 0.0f);
972 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(120.0f, 190.0f), TEST_LOCATION);
974 scrollView.ScrollToSnapPoint();
976 Wait(application, RENDER_DELAY_SCROLL);
977 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 200.0f), TEST_LOCATION);
981 int UtcDaliToolkitScrollViewSetScrollUpdateDistanceP(void)
983 ToolkitTestApplication application;
984 tet_infoline(" UtcDaliToolkitScrollViewSetScrollUpdateDistanceP");
986 ScrollView scrollView = ScrollView::New();
988 scrollView.SetScrollUpdateDistance(0);
989 DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 0, TEST_LOCATION);
990 scrollView.SetScrollUpdateDistance(10);
991 DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 10, TEST_LOCATION);
992 scrollView.SetScrollUpdateDistance(1000);
993 DALI_TEST_EQUALS(scrollView.GetScrollUpdateDistance(), 1000, TEST_LOCATION);
997 int UtcDaliToolkitScrollViewSetWrapModeP(void)
999 ToolkitTestApplication application;
1000 tet_infoline(" UtcDaliToolkitScrollViewSetWrapModeP");
1002 ScrollView scrollView = ScrollView::New();
1003 application.GetScene().Add(scrollView);
1005 Actor actor = Actor::New();
1006 scrollView.Add(actor);
1008 // Position rulers. 4x4 grid.
1009 RulerPtr rulerX = new FixedRuler(50.0f);
1010 RulerPtr rulerY = new FixedRuler(50.0f);
1011 rulerX->SetDomain(RulerDomain(0.0f, 200.0f, false));
1012 rulerY->SetDomain(RulerDomain(0.0f, 200.0f, false));
1013 scrollView.SetRulerX(rulerX);
1014 scrollView.SetRulerY(rulerY);
1016 scrollView.SetWrapMode(false);
1017 scrollView.ScrollTo(Vector2(225.0f, 125.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1019 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 17, TEST_LOCATION);
1021 scrollView.SetWrapMode(true);
1022 scrollView.ScrollTo(Vector2(230.0f, 130.0f), 0.0f); // 5th (1st) page across, and 3rd (3rd) page down. (wrapped)
1024 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 13, TEST_LOCATION);
1028 int UtcDaliToolkitScrollViewActorAutoSnap(void)
1030 ToolkitTestApplication application;
1031 tet_infoline(" UtcDaliToolkitScrollViewActorAutoSnap");
1033 ScrollView scrollView = ScrollView::New();
1034 application.GetScene().Add(scrollView);
1037 RulerPtr rulerX = new DefaultRuler();
1038 RulerPtr rulerY = new DefaultRuler();
1039 rulerX->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1040 rulerY->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1041 scrollView.SetRulerX(rulerX);
1042 scrollView.SetRulerY(rulerY);
1044 const Vector3 aPosition = Vector3(200.0f, 50.0f, 0.0f);
1045 Actor a = Actor::New();
1047 a.SetProperty(Actor::Property::POSITION, aPosition);
1049 const Vector3 bPosition = Vector3(600.0f, 600.0f, 0.0f);
1050 Actor b = Actor::New();
1052 b.SetProperty(Actor::Property::POSITION, bPosition);
1054 // Goto a random position, and execute snap (should not move)
1055 Vector2 targetScroll = Vector2(500.0f, 500.0f);
1056 scrollView.ScrollTo(targetScroll, 0.0f);
1058 scrollView.ScrollToSnapPoint();
1059 Wait(application, RENDER_DELAY_SCROLL);
1060 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), targetScroll, TEST_LOCATION);
1062 // Enable ActorAutoSnap, and now try snapping.
1063 scrollView.SetActorAutoSnap(true);
1064 scrollView.ScrollToSnapPoint();
1065 Wait(application, RENDER_DELAY_SCROLL);
1066 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), bPosition.GetVectorXY(), TEST_LOCATION);
1068 scrollView.ScrollTo(Vector2(0.0f, 0.0f), 0.0f);
1070 scrollView.ScrollToSnapPoint();
1071 Wait(application, RENDER_DELAY_SCROLL);
1072 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), aPosition.GetVectorXY(), TEST_LOCATION);
1076 int UtcDaliToolkitScrollViewSignalsStartComplete(void)
1078 ToolkitTestApplication application;
1079 tet_infoline(" UtcDaliToolkitScrollViewSignalsStartComplete");
1081 gOnScrollStartCalled = false;
1082 gOnScrollCompleteCalled = false;
1084 ScrollView scrollView = ScrollView::New();
1085 application.GetScene().Add(scrollView);
1088 RulerPtr rulerX = new DefaultRuler();
1089 RulerPtr rulerY = new DefaultRuler();
1090 rulerX->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1091 rulerY->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1092 scrollView.SetRulerX(rulerX);
1093 scrollView.SetRulerY(rulerY);
1094 scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
1095 scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1096 scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
1097 scrollView.ScrollTo(Vector2(100.0f, 100.0f));
1098 Wait(application, RENDER_DELAY_SCROLL);
1100 DALI_TEST_CHECK(gOnScrollStartCalled);
1101 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1105 int UtcDaliToolkitScrollViewSignalsUpdate01(void)
1107 ToolkitTestApplication application;
1108 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1110 gOnScrollStartCalled = false;
1111 gOnScrollUpdateCalled = false;
1112 gOnScrollCompleteCalled = false;
1114 ScrollView scrollView = ScrollView::New();
1115 application.GetScene().Add(scrollView);
1116 Vector2 stageSize = application.GetScene().GetSize();
1117 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1118 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1119 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1122 RulerPtr rulerX = new DefaultRuler();
1123 RulerPtr rulerY = new DefaultRuler();
1124 rulerX->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1125 rulerY->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1126 scrollView.SetRulerX(rulerX);
1127 scrollView.SetRulerY(rulerY);
1128 scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
1129 scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1130 scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
1132 Actor image = Actor::New();
1133 image.SetProperty(Actor::Property::SIZE, stageSize);
1134 image.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1135 image.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1136 scrollView.Add(image);
1140 // Do a pan starting from 100,100 and moving down diagonally.
1141 Vector2 pos(100.0f, 100.0f);
1142 uint32_t time = 100;
1143 TestStartPan(application, pos, pos, time);
1146 Wait(application, 100);
1148 for(int i = 0; i < 20; i++)
1150 time += RENDER_FRAME_INTERVAL;
1151 TestMovePan(application, pos, time);
1157 time += RENDER_FRAME_INTERVAL;
1158 TestEndPan(application, pos, time);
1159 Wait(application, RENDER_DELAY_SCROLL);
1161 DALI_TEST_CHECK(gOnScrollStartCalled);
1162 DALI_TEST_CHECK(gOnScrollUpdateCalled);
1163 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1167 int UtcDaliToolkitScrollViewSignalsUpdate02(void)
1169 ToolkitTestApplication application;
1170 tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate");
1172 gOnScrollStartCalled = false;
1173 gOnScrollUpdateCalled = false;
1174 gOnScrollCompleteCalled = false;
1176 ScrollView scrollView = ScrollView::New();
1177 application.GetScene().Add(scrollView);
1178 Vector2 stageSize = application.GetScene().GetSize();
1179 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1180 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1181 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1184 RulerPtr rulerX = new DefaultRuler();
1185 RulerPtr rulerY = new DefaultRuler();
1186 rulerX->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1187 rulerY->SetDomain(RulerDomain(0.0f, 1000.0f, false));
1188 scrollView.SetRulerX(rulerX);
1189 scrollView.SetRulerY(rulerY);
1190 Dali::ConnectionTracker tracker;
1191 bool scrollStarted = false;
1192 bool scrollUpdated = false;
1193 bool scrollCompleted = false;
1194 DALI_TEST_CHECK(scrollView.ConnectSignal(&tracker, "scrollStarted", CallbackFunctor(&scrollStarted)));
1195 DALI_TEST_CHECK(scrollView.ConnectSignal(&tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated)));
1196 DALI_TEST_CHECK(scrollView.ConnectSignal(&tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted)));
1198 Actor image = Actor::New();
1199 image.SetProperty(Actor::Property::SIZE, stageSize);
1200 image.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1201 image.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1202 scrollView.Add(image);
1206 // Do a pan starting from 100,100 and moving down diagonally.
1207 Vector2 pos(100.0f, 100.0f);
1208 uint32_t time = 100;
1209 TestStartPan(application, pos, pos, time);
1212 Wait(application, 100);
1214 for(int i = 0; i < 20; i++)
1216 time += RENDER_FRAME_INTERVAL;
1217 TestMovePan(application, pos, time);
1223 time += RENDER_FRAME_INTERVAL;
1224 TestEndPan(application, pos, time);
1225 Wait(application, RENDER_DELAY_SCROLL);
1227 DALI_TEST_CHECK(scrollStarted);
1228 DALI_TEST_CHECK(scrollUpdated);
1229 DALI_TEST_CHECK(scrollCompleted);
1231 application.GetScene().Remove(scrollView);
1236 int UtcDaliToolkitScrollViewScrollSensitive(void)
1238 ToolkitTestApplication application;
1239 tet_infoline(" UtcDaliToolkitScrollViewScrollSensitive");
1241 // Set up a scrollView...
1242 ScrollView scrollView = ScrollView::New();
1243 scrollView.SetOvershootEnabled(true);
1244 application.GetScene().Add(scrollView);
1245 Vector2 stageSize = application.GetScene().GetSize();
1246 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1247 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1248 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1251 RulerPtr rulerX = new DefaultRuler();
1252 RulerPtr rulerY = new DefaultRuler();
1253 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1254 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1255 scrollView.SetRulerX(rulerX);
1256 scrollView.SetRulerY(rulerY);
1257 scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
1258 scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1259 scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
1260 scrollView.SnapStartedSignal().Connect(&OnSnapStart);
1262 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1264 time += Wait(application);
1266 // First try insensitive swipe.
1267 scrollView.SetScrollSensitive(false);
1268 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1270 DALI_TEST_CHECK(!gOnScrollStartCalled);
1271 DALI_TEST_CHECK(!gOnScrollCompleteCalled);
1272 DALI_TEST_CHECK(!gOnSnapStartCalled);
1274 // Second try sensitive swipe.
1275 scrollView.SetScrollSensitive(true);
1276 PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
1278 DALI_TEST_CHECK(gOnScrollStartCalled);
1279 DALI_TEST_CHECK(gOnScrollCompleteCalled);
1280 DALI_TEST_CHECK(gOnSnapStartCalled);
1284 int UtcDaliToolkitScrollViewAxisAutoLock(void)
1286 ToolkitTestApplication application;
1287 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLock");
1289 // Set up a scrollView...
1290 ScrollView scrollView = ScrollView::New();
1291 application.GetScene().Add(scrollView);
1292 Vector2 stageSize = application.GetScene().GetSize();
1293 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1294 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1295 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1298 RulerPtr rulerX = new DefaultRuler();
1299 RulerPtr rulerY = new DefaultRuler();
1300 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1301 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1302 scrollView.SetRulerX(rulerX);
1303 scrollView.SetRulerY(rulerY);
1304 scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
1305 scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1306 scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
1309 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1311 time += Wait(application);
1313 Vector2 startPosition = scrollView.GetCurrentScrollPosition();
1314 Vector2 dir(5.0f, 1.0f);
1316 // PerformGestureSwipe not used as a different initial direction was required
1318 Vector2 pos(CLAMP_TOUCH_START + Vector2(15.0f, 3.0f));
1320 TestStartPan(application, CLAMP_TOUCH_START, pos, time);
1322 time += Wait(application);
1324 for(int i = 0; i < 47; i++)
1327 TestMovePan(application, pos, time);
1328 time += Wait(application);
1333 TestEndPan(application, pos, time);
1335 const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
1338 scrollView.SetAxisAutoLock(true);
1339 DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
1341 scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
1342 time += Wait(application);
1344 Vector2 pos2(CLAMP_TOUCH_START + Vector2(15.0f, 3.0f));
1346 TestStartPan(application, CLAMP_TOUCH_START, pos2, time);
1348 time += Wait(application);
1350 for(int i = 0; i < 47; i++)
1353 TestMovePan(application, pos2, time);
1354 time += Wait(application);
1359 TestEndPan(application, pos2, time);
1361 const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
1363 // compare how much the Y position has deviated for normal and autolock.
1364 const float devianceNormal = fabsf(startPosition.y - positionAfterNormal.y);
1365 const float devianceAutoLock = fabsf(startPosition.y - positionAfterAutoLock.y);
1367 // in auto-lock it should be a mostly horizontal pan (thus deviance should be much lower)
1368 DALI_TEST_CHECK(devianceAutoLock < devianceNormal);
1370 scrollView.SetAxisAutoLock(false);
1371 DALI_TEST_CHECK(!scrollView.GetAxisAutoLock());
1375 int UtcDaliToolkitScrollViewAxisAutoLockGradient(void)
1377 ToolkitTestApplication application;
1378 tet_infoline(" UtcDaliToolkitScrollViewAxisAutoLockGradient");
1380 // Set up a scrollView...
1381 ScrollView scrollView = ScrollView::New();
1382 scrollView.SetAxisAutoLockGradient(0.5f);
1383 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 0.5f, TEST_LOCATION);
1384 scrollView.SetAxisAutoLockGradient(1.0f);
1385 DALI_TEST_EQUALS(scrollView.GetAxisAutoLockGradient(), 1.0f, TEST_LOCATION);
1389 int UtcDaliToolkitScrollViewConstraints(void)
1391 ToolkitTestApplication application;
1392 tet_infoline(" UtcDaliToolkitScrollViewConstraints");
1394 // Set up a scrollView...
1395 ScrollView scrollView = ScrollView::New();
1396 application.GetScene().Add(scrollView);
1397 Vector2 stageSize = application.GetScene().GetSize();
1398 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1399 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1400 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1403 RulerPtr rulerX = new DefaultRuler();
1404 RulerPtr rulerY = new DefaultRuler();
1405 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1406 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1407 scrollView.SetRulerX(rulerX);
1408 scrollView.SetRulerY(rulerY);
1410 // Add an Actor to ScrollView,
1411 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1412 gConstraintResult = Vector3::ZERO;
1413 Actor a = Actor::New();
1415 a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
1418 Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, TestSumConstraint(TEST_CONSTRAINT_OFFSET));
1419 constraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));
1420 constraint.SetRemoveAction(Constraint::DISCARD);
1421 scrollView.ApplyConstraintToChildren(constraint);
1424 DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
1426 gConstraintResult = Vector3::ZERO;
1427 scrollView.RemoveConstraintsFromChildren();
1430 DALI_TEST_EQUALS(gConstraintResult, Vector3::ZERO, TEST_LOCATION);
1434 int UtcDaliToolkitScrollViewBind(void)
1436 ToolkitTestApplication application;
1437 tet_infoline(" UtcDaliToolkitScrollViewBind");
1439 // Set up a scrollView...
1440 ScrollView scrollView = ScrollView::New();
1441 application.GetScene().Add(scrollView);
1442 Vector2 stageSize = application.GetScene().GetSize();
1443 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1444 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1445 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1448 RulerPtr rulerX = new DefaultRuler();
1449 RulerPtr rulerY = new DefaultRuler();
1450 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1451 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1452 scrollView.SetRulerX(rulerX);
1453 scrollView.SetRulerY(rulerY);
1455 // Add an Actor to ScrollView,
1456 // Apply TestSumConstraint to ScrollView's children (includes this Actor)
1458 gConstraintResult = Vector3::ZERO;
1459 Actor a = Actor::New();
1461 a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
1464 // apply this constraint to scrollview
1465 Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, TestSumConstraint(TEST_CONSTRAINT_OFFSET));
1466 constraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));
1467 constraint.SetRemoveAction(Constraint::DISCARD);
1468 scrollView.ApplyConstraintToChildren(constraint);
1472 DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
1475 gConstraintResult = Vector3::ZERO;
1476 scrollView.UnbindActor(a);
1478 DALI_TEST_EQUALS(gConstraintResult, Vector3::ZERO, TEST_LOCATION);
1481 gConstraintResult = Vector3::ZERO;
1482 scrollView.BindActor(a);
1484 DALI_TEST_EQUALS(gConstraintResult, TEST_ACTOR_POSITION + TEST_CONSTRAINT_OFFSET, TEST_LOCATION);
1488 int UtcDaliToolkitScrollViewOvershoot(void)
1490 ToolkitTestApplication application;
1491 tet_infoline(" UtcDaliToolkitScrollViewOvershoot");
1493 // Set up a scrollView...
1494 ScrollView scrollView = ScrollView::New();
1495 scrollView.SetOvershootEnabled(true);
1498 Vector2 overshootSize = Vector2(100.0f, 100.0f);
1499 scrollView.SetProperty(Scrollable::Property::OVERSHOOT_SIZE, overshootSize);
1500 DALI_TEST_EQUALS(scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION);
1502 application.GetScene().Add(scrollView);
1503 Vector2 stageSize = application.GetScene().GetSize();
1504 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1505 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1506 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1509 RulerPtr rulerX = new DefaultRuler();
1510 RulerPtr rulerY = new DefaultRuler();
1511 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1512 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1513 scrollView.SetRulerX(rulerX);
1514 scrollView.SetRulerY(rulerY);
1515 scrollView.ScrollStartedSignal().Connect(&OnScrollStart);
1516 scrollView.ScrollUpdatedSignal().Connect(&OnScrollUpdate);
1517 scrollView.ScrollCompletedSignal().Connect(&OnScrollComplete);
1519 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1520 time += Wait(application);
1522 // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
1523 Vector2 currentPos = Vector2(100.0f, 100.0f);
1524 currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false);
1525 float overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1526 float overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1527 Vector2 positionValue = scrollView.GetCurrentProperty<Vector2>(ScrollView::Property::SCROLL_POSITION);
1528 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1529 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1530 DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION);
1532 float timeToReachOrigin;
1534 // Now release touch. Overshoot should snap back to zero.
1535 TestEndPan(application, currentPos, time);
1537 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1539 float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1540 float maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1542 DALI_TEST_CHECK((timeToReachOrigin > minTimeToReachOrigin) &&
1543 (timeToReachOrigin < maxTimeToReachOrigin));
1545 // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time
1546 scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION);
1548 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1549 // Now release touch. Overshoot should snap back to zero.
1550 TestEndPan(application, currentPos, time);
1551 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1553 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1554 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1556 DALI_TEST_CHECK((timeToReachOrigin > minTimeToReachOrigin) &&
1557 (timeToReachOrigin < maxTimeToReachOrigin));
1559 // 3. Repeat Scroll, but this time change overshoot snap duration to longer time.
1560 scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION);
1562 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1563 // Now release touch. Overshoot should snap back to zero.
1564 TestEndPan(application, currentPos, time);
1565 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1567 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1568 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1570 DALI_TEST_CHECK((timeToReachOrigin > minTimeToReachOrigin) &&
1571 (timeToReachOrigin < maxTimeToReachOrigin));
1573 // 4. Repeat Scroll, but this time change overshoot function.
1574 scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION);
1575 scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction);
1577 currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false);
1578 // Now release touch. Overshoot should snap back to zero.
1579 TestEndPan(application, currentPos, time);
1580 timeToReachOrigin = TestOvershootSnapDuration(application, scrollView);
1582 minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE;
1583 maxTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) + TIME_TOLERANCE;
1585 DALI_TEST_CHECK((timeToReachOrigin > minTimeToReachOrigin) &&
1586 (timeToReachOrigin < maxTimeToReachOrigin));
1590 int UtcDaliToolkitScrollViewSnapAlphaFunction(void)
1592 ToolkitTestApplication application;
1593 tet_infoline(" UtcDaliToolkitScrollViewSnapAlphaFunction");
1595 // Set up a scrollView...
1596 ScrollView scrollView = ScrollView::New();
1597 scrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_IN);
1598 DALI_TEST_CHECK(scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_IN);
1599 scrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT);
1600 DALI_TEST_CHECK(scrollView.GetScrollSnapAlphaFunction().GetBuiltinFunction() == AlphaFunction::EASE_OUT);
1602 scrollView.SetScrollFlickAlphaFunction(AlphaFunction::BOUNCE);
1603 DALI_TEST_CHECK(scrollView.GetScrollFlickAlphaFunction().GetBuiltinFunction() == AlphaFunction::BOUNCE);
1608 int UtcDaliToolkitScrollViewSnapDuration(void)
1610 ToolkitTestApplication application;
1611 tet_infoline(" UtcDaliToolkitScrollViewSnapDuration");
1613 // Set up a scrollView...
1614 ScrollView scrollView = ScrollView::New();
1615 scrollView.SetScrollSnapDuration(1.0f);
1616 DALI_TEST_EQUALS(scrollView.GetScrollSnapDuration(), 1.0f, TEST_LOCATION);
1617 scrollView.SetScrollSnapDuration(0.5f);
1618 DALI_TEST_EQUALS(scrollView.GetScrollSnapDuration(), 0.5f, TEST_LOCATION);
1620 scrollView.SetScrollFlickDuration(2.0f);
1621 DALI_TEST_EQUALS(scrollView.GetScrollFlickDuration(), 2.0f, TEST_LOCATION);
1622 scrollView.SetScrollFlickDuration(1.5f);
1623 DALI_TEST_EQUALS(scrollView.GetScrollFlickDuration(), 1.5f, TEST_LOCATION);
1627 int UtcDaliToolkitScrollViewSnapStartedSignalP(void)
1629 ToolkitTestApplication application;
1630 tet_infoline(" UtcDaliToolkitScrollViewSnapStartedSignalP");
1632 // Set up a scrollView...
1633 ScrollView scrollView = ScrollView::New();
1634 application.GetScene().Add(scrollView);
1635 Vector2 stageSize = application.GetScene().GetSize();
1636 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1637 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1638 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1641 RulerPtr rulerX = new DefaultRuler();
1642 RulerPtr rulerY = new DefaultRuler();
1643 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1644 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1645 scrollView.SetRulerX(rulerX);
1646 scrollView.SetRulerY(rulerY);
1647 scrollView.SnapStartedSignal().Connect(&OnSnapStart);
1649 scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little.
1651 time += Wait(application);
1653 // First try a snap.
1654 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true);
1656 DALI_TEST_CHECK(gOnSnapStartCalled);
1657 DALI_TEST_CHECK(gLastSnapType == Toolkit::SNAP);
1659 // Second try a swipe.
1660 PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true);
1662 DALI_TEST_CHECK(gOnSnapStartCalled);
1663 DALI_TEST_CHECK(gLastSnapType == Toolkit::FLICK);
1667 int UtcDaliToolkitScrollViewGetCurrentPageP(void)
1669 ToolkitTestApplication application;
1670 tet_infoline(" UtcDaliToolkitScrollViewGetCurrentPageP");
1672 ScrollView scrollView = ScrollView::New();
1673 application.GetScene().Add(scrollView);
1674 RulerPtr rulerX = new FixedRuler(100.0f);
1675 rulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
1676 RulerPtr rulerY = new FixedRuler(100.0f);
1677 rulerY->SetDomain(RulerDomain(0.0f, 400.0f, true));
1679 scrollView.SetRulerX(rulerX);
1680 scrollView.SetRulerY(rulerY);
1682 scrollView.ScrollTo(15);
1683 Wait(application, RENDER_DELAY_SCROLL);
1684 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 15, TEST_LOCATION);
1686 scrollView.ScrollTo(3);
1687 Wait(application, RENDER_DELAY_SCROLL);
1688 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 3, TEST_LOCATION);
1690 scrollView.ScrollTo(9);
1691 Wait(application, RENDER_DELAY_SCROLL);
1692 DALI_TEST_EQUALS(static_cast<int>(scrollView.GetCurrentPage()), 9, TEST_LOCATION);
1697 int UtcDaliToolkitScrollViewSetMaxOvershootP(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" UtcDaliToolkitScrollViewSetMaxOvershootP");
1702 // Set up a scrollView...
1703 ScrollView scrollView = ScrollView::New();
1704 application.GetScene().Add(scrollView);
1705 Vector2 stageSize = application.GetScene().GetSize();
1706 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1707 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1708 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1711 RulerPtr rulerX = new DefaultRuler();
1712 RulerPtr rulerY = new DefaultRuler();
1713 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
1714 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
1715 scrollView.SetRulerX(rulerX);
1716 scrollView.SetRulerY(rulerY);
1718 // Set the max overshoot to be 50 pixels in both X axis and Y axis
1719 scrollView.SetMaxOvershoot(50.0f, 50.0f);
1721 scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little.
1723 time += Wait(application);
1725 // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch)
1726 Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false);
1727 float overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1728 float overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1729 DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION);
1730 DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION);
1732 time += Wait(application);
1733 // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch)
1734 for(int i = 0; i < 106; i++)
1736 TestMovePan(application, currentPos, time);
1737 currentPos += Vector2(1.0f, 1.0f);
1738 time += Wait(application);
1741 overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1742 overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1743 // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot.
1744 // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105.
1745 float correctOvershootValue = 0.508f; // This was measured and then set as the limit
1746 DALI_TEST_EQUALS(overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION);
1747 DALI_TEST_EQUALS(overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION);
1749 // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch)
1750 for(int i = 0; i < 25; i++)
1752 TestMovePan(application, currentPos, time);
1753 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1754 time += Wait(application);
1757 overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1758 overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1759 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1760 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1762 // Change the max overshoot to be 250 pixels in both X axis and Y axis
1763 scrollView.SetMaxOvershoot(250.0f, 250.0f);
1764 time += Wait(application);
1766 // Check that overshoot should be now around 0.8.
1767 overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1768 overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1769 DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f);
1770 DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f);
1772 // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch)
1773 for(int i = 0; i < 50; i++)
1775 TestMovePan(application, currentPos, time);
1776 currentPos += Vector2(1.0f, 1.0f); // Move in this direction
1777 time += Wait(application);
1780 overshootXValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_X);
1781 overshootYValue = scrollView.GetCurrentProperty<float>(ScrollView::Property::OVERSHOOT_Y);
1782 DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
1783 DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
1788 int UtcDaliToolkitScrollViewSetScrollingDirectionP(void)
1790 ToolkitTestApplication application;
1791 tet_infoline(" UtcDaliToolkitScrollViewSetScrollingDirectionP");
1793 // Set up a scrollView...
1794 ScrollView scrollView = ScrollView::New();
1795 application.GetScene().Add(scrollView);
1796 Vector2 stageSize = application.GetScene().GetSize();
1797 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1798 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1799 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1801 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1803 scrollView.ScrollTo(START_POSITION, 0.0f);
1805 time += Wait(application);
1807 // Try a vertical swipe.
1808 // PerformGestureSwipe not used as a different initial direction was required
1810 Vector2 pos(START_POSITION + Vector2(0.0f, 15.0f));
1811 TestStartPan(application, START_POSITION, pos, time);
1812 time += Wait(application);
1813 for(int i = 0; i < 45; i++)
1815 pos += Vector2(0.0f, 1.0f);
1816 TestMovePan(application, pos, time);
1817 time += Wait(application);
1819 pos += Vector2(0.0f, 1.0f);
1820 TestEndPan(application, pos, time);
1821 time += Wait(application);
1823 // Take into account resampling done when prediction is off.
1824 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
1826 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1828 scrollView.ScrollTo(START_POSITION, 0.0f);
1829 time += Wait(application);
1831 // Try a vertical swipe.
1832 // PerformGestureSwipe not used as a different initial direction was required
1833 pos = (START_POSITION + Vector2(0.0f, 15.0f));
1834 TestStartPan(application, START_POSITION, pos, time);
1835 time += Wait(application);
1836 for(int i = 0; i < 45; i++)
1838 pos += Vector2(0.0f, 1.0f);
1839 TestMovePan(application, pos, time);
1840 time += Wait(application);
1842 pos += Vector2(0.0f, 1.0f);
1843 TestEndPan(application, pos, time);
1844 time += Wait(application);
1846 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
1848 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1850 scrollView.ScrollTo(START_POSITION, 0.0f);
1852 time += Wait(application);
1854 // Try a vertical swipe.
1855 // PerformGestureSwipe not used as a different initial direction was required
1856 pos = (START_POSITION + Vector2(0.0f, 15.0f));
1857 TestStartPan(application, START_POSITION, pos, time);
1858 time += Wait(application);
1859 for(int i = 0; i < 45; i++)
1861 pos += Vector2(0.0f, 1.0f);
1862 TestMovePan(application, pos, time);
1863 time += Wait(application);
1865 pos += Vector2(0.0f, 1.0f);
1866 TestEndPan(application, pos, time);
1867 time += Wait(application);
1869 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
1874 int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void)
1876 ToolkitTestApplication application;
1877 tet_infoline(" UtcDaliToolkitScrollViewRemoveScrollingDirectionP");
1879 // Set up a scrollView...
1880 ScrollView scrollView = ScrollView::New();
1881 application.GetScene().Add(scrollView);
1882 Vector2 stageSize = application.GetScene().GetSize();
1883 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
1884 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1885 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1887 Vector2 START_POSITION = Vector2(10.0f, 10.0f);
1890 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1892 scrollView.ScrollTo(START_POSITION, 0.0f);
1894 time += Wait(application);
1896 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION);
1898 // Try a vertical swipe.
1899 // PerformGestureSwipe not used as a different initial direction was required
1900 Vector2 pos(START_POSITION + Vector2(0.0f, 15.0f));
1901 TestStartPan(application, START_POSITION, pos, time);
1902 time += Wait(application);
1903 for(int i = 0; i < 45; i++)
1905 pos += Vector2(0.0f, 1.0f);
1906 TestMovePan(application, pos, time);
1907 time += Wait(application);
1909 pos += Vector2(0.0f, 1.0f);
1910 TestEndPan(application, pos, time);
1911 time += Wait(application);
1913 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
1915 scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL);
1916 // When the horizontal direction is removed, there are no directions set and therefore all will work
1917 scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL);
1919 time += Wait(application);
1920 // Try a vertical swipe.
1921 Vector2 pos2(pos + Vector2(0.0f, 15.0f));
1922 TestStartPan(application, pos, pos2, time);
1923 time += Wait(application);
1924 for(int i = 0; i < 45; i++)
1926 pos2 += Vector2(0.0f, 1.0f);
1927 TestMovePan(application, pos2, time);
1928 time += Wait(application);
1930 pos2 += Vector2(0.0f, 1.0f);
1931 TestEndPan(application, pos2, time);
1933 // The previous scroll should not have had any effect
1934 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION);
1939 int UtcDaliToolkitScrollViewSetRulerXP(void)
1941 ToolkitTestApplication application;
1942 tet_infoline(" UtcDaliToolkitScrollViewSetRulerXP");
1944 ScrollView scrollView = ScrollView::New();
1945 application.GetScene().Add(scrollView);
1946 RulerPtr rulerX = new FixedRuler(100.0f);
1947 rulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
1949 scrollView.SetRulerX(rulerX);
1951 scrollView.ScrollTo(1, 0.0f);
1953 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(100.0f, 0.0f), TEST_LOCATION);
1955 RulerPtr newRulerX = new FixedRuler(200.0f);
1956 newRulerX->SetDomain(RulerDomain(0.0f, 800.0f, true));
1958 scrollView.SetRulerX(newRulerX);
1960 scrollView.ScrollTo(1, 0.0f);
1962 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(200.0f, 0.0f), TEST_LOCATION);
1967 int UtcDaliToolkitScrollViewSetRulerYP(void)
1969 ToolkitTestApplication application;
1970 tet_infoline(" UtcDaliToolkitScrollViewSetRulerYP");
1972 ScrollView scrollView = ScrollView::New();
1973 application.GetScene().Add(scrollView);
1975 RulerPtr rulerY = new FixedRuler(200.0f);
1976 rulerY->SetDomain(RulerDomain(0.0f, 400.0f, true));
1978 scrollView.SetRulerY(rulerY);
1980 scrollView.ScrollTo(Vector2(0.0f, 350.0f), 0.0f);
1982 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 350.0f), TEST_LOCATION);
1984 RulerPtr newRulerY = new FixedRuler(100.0f);
1985 newRulerY->SetDomain(RulerDomain(0.0f, 200.0f, true));
1986 scrollView.SetRulerY(newRulerY);
1988 scrollView.ScrollTo(Vector2(0.0f, 350.0f), 0.0f);
1990 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), Vector2(0.0f, 200.0f), TEST_LOCATION);
1995 int UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP(void)
1997 ToolkitTestApplication application;
1998 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumSpeedForFlickP");
2000 ScrollView scrollView = ScrollView::New();
2001 scrollView.SetMinimumSpeedForFlick(25.0f);
2002 DALI_TEST_EQUALS(scrollView.GetMinimumSpeedForFlick(), 25.0f, TEST_LOCATION);
2003 scrollView.SetMinimumSpeedForFlick(60.0f);
2004 DALI_TEST_EQUALS(scrollView.GetMinimumSpeedForFlick(), 60.0f, TEST_LOCATION);
2008 int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void)
2010 ToolkitTestApplication application;
2011 tet_infoline(" UtcDaliToolkitScrollViewSetMinimumDistanceForFlick");
2013 ScrollView scrollView = ScrollView::New();
2015 scrollView.SetMinimumDistanceForFlick(Vector2(30.0f, 15.0f));
2016 DALI_TEST_EQUALS(scrollView.GetMinimumDistanceForFlick(), Vector2(30.0f, 15.0f), TEST_LOCATION);
2017 scrollView.SetMinimumDistanceForFlick(Vector2(60.0f, 30.0f));
2018 DALI_TEST_EQUALS(scrollView.GetMinimumDistanceForFlick(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2022 int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void)
2024 ToolkitTestApplication application;
2025 tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP");
2027 ScrollView scrollView = ScrollView::New();
2028 // Disable Refresh signal (TET environment cannot use adaptor's Timer)
2029 scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f));
2030 DALI_TEST_EQUALS(scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION);
2031 scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f));
2032 DALI_TEST_EQUALS(scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION);
2036 int UtcDaliToolkitScrollViewApplyEffectP(void)
2038 ToolkitTestApplication application;
2039 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectP");
2041 // Create a ScrollView
2042 ScrollView scrollView = ScrollView::New();
2044 // Create two scroll view effects
2045 Dali::Path path = Dali::Path::New();
2046 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2047 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2049 // Apply both effects
2050 scrollView.ApplyEffect(effect);
2051 scrollView.ApplyEffect(newEffect);
2053 DALI_TEST_CHECK(true);
2058 int UtcDaliToolkitScrollViewApplyEffectN(void)
2060 ToolkitTestApplication application;
2061 tet_infoline(" UtcDaliToolkitScrollViewApplyEffectN");
2063 // Create a ScrollView
2064 ScrollView scrollView = ScrollView::New();
2066 // Create two scroll view effects
2067 Dali::Path path = Dali::Path::New();
2068 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2069 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2071 // Apply both effects
2072 scrollView.ApplyEffect(effect);
2073 scrollView.ApplyEffect(newEffect);
2075 // Attempt to apply the same effect again
2078 scrollView.ApplyEffect(newEffect);
2079 tet_result(TET_FAIL);
2081 catch(DaliException& e)
2083 DALI_TEST_ASSERT(e, "!effectAlreadyExistsInScrollView", TEST_LOCATION);
2089 int UtcDaliToolkitScrollViewRemoveEffectP(void)
2091 ToolkitTestApplication application;
2092 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectP");
2094 // Create a ScrollView
2095 ScrollView scrollView = ScrollView::New();
2097 // Create two scroll view effects
2098 Dali::Path path = Dali::Path::New();
2099 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2100 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2102 // Apply both effects
2103 scrollView.ApplyEffect(effect);
2104 scrollView.ApplyEffect(newEffect);
2106 // Remove both effects
2107 scrollView.RemoveEffect(effect);
2108 scrollView.RemoveEffect(newEffect);
2110 DALI_TEST_CHECK(true);
2115 int UtcDaliToolkitScrollViewRemoveEffectN(void)
2117 ToolkitTestApplication application;
2118 tet_infoline(" UtcDaliToolkitScrollViewRemoveEffectN");
2120 // Create a ScrollView
2121 ScrollView scrollView = ScrollView::New();
2123 // Create two scroll view effects
2124 Dali::Path path = Dali::Path::New();
2125 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2126 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2128 // Apply the first effect
2129 scrollView.ApplyEffect(effect);
2131 // Attempt to remove the second effect which has not been applied to scroll view
2134 scrollView.RemoveEffect(newEffect);
2135 tet_result(TET_FAIL);
2137 catch(DaliException& e)
2139 DALI_TEST_ASSERT(e, "effectExistedInScrollView", TEST_LOCATION);
2145 int UtcDaliToolkitScrollViewRemoveAllEffectsP(void)
2147 ToolkitTestApplication application;
2148 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsP");
2150 // Create a ScrollView
2151 ScrollView scrollView = ScrollView::New();
2153 // Create two scroll view effects
2154 Dali::Path path = Dali::Path::New();
2155 ScrollViewEffect effect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 0.0f, 0.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(100.0f, 100.0f, 0.0f), 2);
2156 ScrollViewEffect newEffect = ScrollViewPagePathEffect::New(path, Vector3(-1.0f, 1.0f, 1.0f), Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(200.0f, 150.0f, 0.0f), 5);
2158 // Apply both effects
2159 scrollView.ApplyEffect(effect);
2160 scrollView.ApplyEffect(newEffect);
2162 // Attempt to apply the same first effect again
2165 scrollView.ApplyEffect(effect);
2166 tet_result(TET_FAIL);
2168 catch(DaliException& e)
2170 DALI_TEST_ASSERT(e, "!effectAlreadyExistsInScrollView", TEST_LOCATION);
2173 // Remove both effects
2174 scrollView.RemoveAllEffects();
2176 // Apply both effects again
2177 scrollView.ApplyEffect(effect);
2178 scrollView.ApplyEffect(newEffect);
2180 DALI_TEST_CHECK(true);
2185 int UtcDaliToolkitScrollViewRemoveAllEffectsN(void)
2187 ToolkitTestApplication application;
2188 tet_infoline(" UtcDaliToolkitScrollViewRemoveAllEffectsN");
2190 // Create a ScrollView
2191 ScrollView scrollView = ScrollView::New();
2193 // Remove effects when there is no effect applied previously
2194 scrollView.RemoveAllEffects();
2196 DALI_TEST_CHECK(true);
2201 int UtcDaliToolkitScrollViewSetOvershootEnabledP(void)
2203 ToolkitTestApplication application;
2204 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEnabledP");
2206 ScrollView scrollView = ScrollView::New();
2208 scrollView.SetOvershootEnabled(true);
2209 DALI_TEST_CHECK(scrollView.IsOvershootEnabled());
2211 scrollView.SetOvershootEnabled(false);
2212 DALI_TEST_CHECK(!scrollView.IsOvershootEnabled());
2217 int UtcDaliToolkitScrollViewSetOvershootEffectColorP(void)
2219 ToolkitTestApplication application;
2220 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootEffectColorP");
2222 ScrollView scrollView = ScrollView::New();
2224 scrollView.SetOvershootEffectColor(Dali::Color::RED);
2225 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::RED, TEST_LOCATION);
2227 scrollView.SetOvershootEffectColor(Dali::Color::YELLOW);
2228 DALI_TEST_EQUALS(scrollView.GetOvershootEffectColor(), Dali::Color::YELLOW, TEST_LOCATION);
2233 int UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP(void)
2235 ToolkitTestApplication application;
2236 tet_infoline(" UtcDaliToolkitScrollViewSetOvershootAnimationSpeedP");
2238 ScrollView scrollView = ScrollView::New();
2240 scrollView.SetOvershootAnimationSpeed(55.0f);
2241 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 55.0f, TEST_LOCATION);
2243 scrollView.SetOvershootAnimationSpeed(120.0f);
2244 DALI_TEST_EQUALS(scrollView.GetOvershootAnimationSpeed(), 120.0f, TEST_LOCATION);
2249 int UtcDaliToolkitScrollViewGetSet(void)
2251 ToolkitTestApplication application;
2252 tet_infoline(" UtcDaliToolkitScrollViewGetSet");
2253 ScrollView scrollView = ScrollView::New();
2254 scrollView.SetMaxFlickSpeed(0.5f);
2255 DALI_TEST_EQUALS(scrollView.GetMaxFlickSpeed(), 0.5f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2256 scrollView.SetFrictionCoefficient(0.6f);
2257 DALI_TEST_EQUALS(scrollView.GetFrictionCoefficient(), 0.6f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2258 scrollView.SetFlickSpeedCoefficient(0.7f);
2259 DALI_TEST_EQUALS(scrollView.GetFlickSpeedCoefficient(), 0.7f, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2263 int UtcDaliToolkitScrollViewRulerDomainConstructorP(void)
2265 ToolkitTestApplication application;
2267 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2268 DALI_TEST_EQUALS(domainX.min, 0.0f, TEST_LOCATION);
2269 DALI_TEST_EQUALS(domainX.max, 200.0f, TEST_LOCATION);
2270 DALI_TEST_EQUALS(domainX.enabled, true, TEST_LOCATION);
2272 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2273 DALI_TEST_EQUALS(domainY.min, 100.0f, TEST_LOCATION);
2274 DALI_TEST_EQUALS(domainY.max, 500.0f, TEST_LOCATION);
2275 DALI_TEST_EQUALS(domainY.enabled, false, TEST_LOCATION);
2280 int UtcDaliToolkitScrollViewRulerDomainGetSizeP(void)
2282 ToolkitTestApplication application;
2284 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2285 DALI_TEST_EQUALS(domainX.GetSize(), 200.0f, TEST_LOCATION);
2287 RulerDomain domainY = RulerDomain(100.0f, 500.0f, false);
2288 DALI_TEST_EQUALS(domainY.GetSize(), 400.0f, TEST_LOCATION);
2293 int UtcDaliToolkitScrollViewRulerDomainClampP(void)
2295 ToolkitTestApplication application;
2297 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2299 float value = domainX.Clamp(50.0f, 100.0f, 1.0f);
2300 DALI_TEST_EQUALS(value, 50.0f, TEST_LOCATION);
2302 value = domainX.Clamp(300.0f, 20.0f, 1.0f);
2303 DALI_TEST_EQUALS(value, 180.0f, TEST_LOCATION);
2305 value = domainX.Clamp(300.0f, 20.0f, 0.5f);
2306 DALI_TEST_EQUALS(value, 80.0f, TEST_LOCATION);
2308 value = domainX.Clamp(250.0f, 200.0f, 2.0f);
2309 DALI_TEST_EQUALS(value, 200.0f, TEST_LOCATION);
2314 int UtcDaliToolkitScrollViewRulerDomainClampWithStateP(void)
2316 ToolkitTestApplication application;
2318 RulerDomain domainX = RulerDomain(0.0f, 200.0f, true);
2321 float value = domainX.Clamp(50.0f, 100.0f, 1.0f, clamped);
2322 DALI_TEST_EQUALS(value, 50.0f, TEST_LOCATION);
2323 DALI_TEST_EQUALS(clamped, Dali::Toolkit::NOT_CLAMPED, TEST_LOCATION);
2325 value = domainX.Clamp(-100.0f, 200.0f, 1.0f, clamped);
2326 DALI_TEST_EQUALS(value, 0.0f, TEST_LOCATION);
2327 DALI_TEST_EQUALS(clamped, Dali::Toolkit::CLAMPED_TO_MIN, TEST_LOCATION);
2329 value = domainX.Clamp(300.0f, 20.0f, 1.0f, clamped);
2330 DALI_TEST_EQUALS(value, 180.0f, TEST_LOCATION);
2331 DALI_TEST_EQUALS(clamped, Dali::Toolkit::CLAMPED_TO_MAX, TEST_LOCATION);
2336 int UtcDaliToolkitScrollViewDefaultRulerConstructorP(void)
2338 ToolkitTestApplication application;
2339 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerConstructorP");
2341 RulerPtr defaultRuler = new DefaultRuler();
2342 DALI_TEST_CHECK(defaultRuler);
2347 int UtcDaliToolkitScrollViewDefaultRulerDestructorP(void)
2349 ToolkitTestApplication application;
2350 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerDestructorP");
2352 RulerPtr defaultRuler = new DefaultRuler();
2354 DALI_TEST_CHECK(true);
2358 int UtcDaliToolkitScrollViewFixedRulerConstructorP(void)
2360 ToolkitTestApplication application;
2361 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerConstructorP");
2363 RulerPtr fixedRuler = new FixedRuler(100.0f);
2364 DALI_TEST_CHECK(fixedRuler);
2366 fixedRuler = new FixedRuler(0.0f);
2367 DALI_TEST_CHECK(fixedRuler);
2372 int UtcDaliToolkitScrollViewFixedRulerDestructorP(void)
2374 ToolkitTestApplication application;
2375 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerDestructorP");
2377 RulerPtr fixedRuler = new FixedRuler(100.0f);
2379 DALI_TEST_CHECK(true);
2383 int UtcDaliToolkitScrollViewRulerGetTypeP(void)
2385 ToolkitTestApplication application;
2386 tet_infoline(" UtcDaliToolkitScrollViewRulerGetTypeP");
2388 RulerPtr defaultRuler = new DefaultRuler();
2389 DALI_TEST_CHECK(defaultRuler);
2390 DALI_TEST_EQUALS(defaultRuler->GetType(), Dali::Toolkit::Ruler::FREE, TEST_LOCATION);
2392 RulerPtr fixedRuler = new FixedRuler(100.0f);
2393 DALI_TEST_CHECK(fixedRuler);
2394 DALI_TEST_EQUALS(fixedRuler->GetType(), Dali::Toolkit::Ruler::FIXED, TEST_LOCATION);
2399 int UtcDaliToolkitScrollViewRulerGetExtensionP(void)
2401 ToolkitTestApplication application;
2402 tet_infoline(" UtcDaliToolkitScrollViewRulerGetExtensionP");
2404 RulerPtr defaultRuler = new DefaultRuler();
2405 DALI_TEST_CHECK(defaultRuler);
2406 DALI_TEST_CHECK(!defaultRuler->GetExtension());
2408 RulerPtr fixedRuler = new FixedRuler(100.0f);
2409 DALI_TEST_CHECK(fixedRuler);
2410 DALI_TEST_CHECK(!fixedRuler->GetExtension());
2415 int UtcDaliToolkitScrollViewRulerEnableDisable(void)
2417 ToolkitTestApplication application;
2418 tet_infoline(" UtcDaliToolkitScrollViewRulerEnableDisable");
2420 RulerPtr ruler = new DefaultRuler();
2422 DALI_TEST_CHECK(ruler->IsEnabled());
2424 DALI_TEST_CHECK(!ruler->IsEnabled());
2426 DALI_TEST_CHECK(ruler->IsEnabled());
2430 int UtcDaliToolkitScrollViewRulerDomainEnableDisable(void)
2432 ToolkitTestApplication application;
2433 tet_infoline(" UtcDaliToolkitScrollViewRulerDomainEnableDisable");
2435 RulerPtr ruler = new DefaultRuler();
2436 DALI_TEST_EQUALS(ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION);
2438 ruler->SetDomain(RulerDomain(0.0f, 100.0f, true));
2439 DALI_TEST_EQUALS(ruler->GetDomain().GetSize(), 100.0f, TEST_LOCATION);
2440 DALI_TEST_EQUALS(ruler->Clamp(-200.0f), 0.0f, TEST_LOCATION);
2441 DALI_TEST_EQUALS(ruler->Clamp(200.0f), 100.0f, TEST_LOCATION);
2443 ruler->DisableDomain();
2444 DALI_TEST_EQUALS(ruler->GetDomain().GetSize(), 1.0f, TEST_LOCATION);
2445 DALI_TEST_EQUALS(ruler->Clamp(-200.0f), -200.0f, TEST_LOCATION);
2446 DALI_TEST_EQUALS(ruler->Clamp(200.0f), 200.0f, TEST_LOCATION);
2450 int UtcDaliToolkitScrollViewRulerSnapAndClamp(void)
2452 ToolkitTestApplication application;
2453 tet_infoline(" UtcDaliToolkitScrollViewRulerSnapAndClamp");
2455 RulerPtr ruler = new FixedRuler(50.0f);
2456 ruler->SetDomain(RulerDomain(0.0f, 400.0f, true));
2458 // default testing. (snap and clamp)
2459 DALI_TEST_EQUALS(ruler->SnapAndClamp(50.0f), 50.0f, TEST_LOCATION);
2460 DALI_TEST_EQUALS(ruler->SnapAndClamp(30.0f), 50.0f, TEST_LOCATION);
2461 DALI_TEST_EQUALS(ruler->SnapAndClamp(10.0f), 0.0f, TEST_LOCATION);
2462 DALI_TEST_EQUALS(ruler->SnapAndClamp(-40.0f), 0.0f, TEST_LOCATION);
2463 DALI_TEST_EQUALS(ruler->SnapAndClamp(390.0f), 400.0f, TEST_LOCATION);
2464 DALI_TEST_EQUALS(ruler->SnapAndClamp(430.0f), 400.0f, TEST_LOCATION);
2467 DALI_TEST_EQUALS(ruler->SnapAndClamp(40.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2468 DALI_TEST_EQUALS(ruler->SnapAndClamp(40.0f, 0.5f), 50.0f, TEST_LOCATION); // No Flick
2469 DALI_TEST_EQUALS(ruler->SnapAndClamp(40.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2471 DALI_TEST_EQUALS(ruler->SnapAndClamp(20.0f, 0.0f), 0.0f, TEST_LOCATION); // Flick Left
2472 DALI_TEST_EQUALS(ruler->SnapAndClamp(20.0f, 0.5f), 0.0f, TEST_LOCATION); // No Flick
2473 DALI_TEST_EQUALS(ruler->SnapAndClamp(20.0f, 1.0f), 50.0f, TEST_LOCATION); // Flick Right
2476 DALI_TEST_EQUALS(ruler->SnapAndClamp(-10.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (over left boundary)
2477 DALI_TEST_EQUALS(ruler->SnapAndClamp(-5.0f, 0.5f, 10.0f), 0.0f, TEST_LOCATION); // 10 units long (slightly ovr left boundary)
2478 DALI_TEST_EQUALS(ruler->SnapAndClamp(300.0f, 0.5f, 10.0f), 300.0f, TEST_LOCATION); // 10 units long (not over a boundary)
2479 DALI_TEST_EQUALS(ruler->SnapAndClamp(395.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (slightly over right boundary)
2480 DALI_TEST_EQUALS(ruler->SnapAndClamp(500.0f, 0.5f, 10.0f), 390.0f, TEST_LOCATION); // 10 units long (over right boundary)
2483 DALI_TEST_EQUALS(ruler->SnapAndClamp(-100.0f, 0.5f, 0.0f, 2.0f), 0.0f, TEST_LOCATION);
2484 DALI_TEST_EQUALS(ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 2.0f), 50.0f, TEST_LOCATION);
2485 DALI_TEST_EQUALS(ruler->SnapAndClamp(700.0f, 0.5f, 0.0f, 2.0f), 700.0f, TEST_LOCATION);
2486 DALI_TEST_EQUALS(ruler->SnapAndClamp(850.0f, 0.5f, 0.0f, 2.0f), 800.0f, TEST_LOCATION);
2488 // clamp state testing.
2490 DALI_TEST_EQUALS(ruler->SnapAndClamp(50.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2491 DALI_TEST_EQUALS(clamped, NOT_CLAMPED, TEST_LOCATION);
2492 DALI_TEST_EQUALS(ruler->SnapAndClamp(30.0f, 0.5f, 0.0f, 1.0f, clamped), 50.0f, TEST_LOCATION);
2493 DALI_TEST_EQUALS(clamped, NOT_CLAMPED, TEST_LOCATION);
2494 DALI_TEST_EQUALS(ruler->SnapAndClamp(10.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2495 DALI_TEST_EQUALS(clamped, NOT_CLAMPED, TEST_LOCATION);
2496 DALI_TEST_EQUALS(ruler->SnapAndClamp(-40.0f, 0.5f, 0.0f, 1.0f, clamped), 0.0f, TEST_LOCATION);
2497 DALI_TEST_EQUALS(clamped, CLAMPED_TO_MIN, TEST_LOCATION);
2498 DALI_TEST_EQUALS(ruler->SnapAndClamp(390.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2499 DALI_TEST_EQUALS(clamped, NOT_CLAMPED, TEST_LOCATION);
2500 DALI_TEST_EQUALS(ruler->SnapAndClamp(430.0f, 0.5f, 0.0f, 1.0f, clamped), 400.0f, TEST_LOCATION);
2501 DALI_TEST_EQUALS(clamped, CLAMPED_TO_MAX, TEST_LOCATION);
2505 int UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP(void)
2507 ToolkitTestApplication application;
2508 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPositionFromPageP");
2510 RulerPtr rulerNormal = new FixedRuler(25.0f);
2511 rulerNormal->SetDomain(RulerDomain(10.0f, 90.0f, true));
2513 unsigned int volume;
2516 position = rulerNormal->GetPositionFromPage(1, volume, true);
2517 DALI_TEST_EQUALS(position, 35.0f, TEST_LOCATION);
2518 DALI_TEST_EQUALS(volume, 0u, TEST_LOCATION);
2520 position = rulerNormal->GetPositionFromPage(2, volume, true);
2521 DALI_TEST_EQUALS(position, 60.0f, TEST_LOCATION);
2522 DALI_TEST_EQUALS(volume, 0u, TEST_LOCATION);
2524 // Disable the ruler
2525 rulerNormal->Disable();
2527 position = rulerNormal->GetPositionFromPage(1, volume, true);
2528 DALI_TEST_EQUALS(position, 10.0f, TEST_LOCATION);
2529 DALI_TEST_EQUALS(volume, 1u, TEST_LOCATION);
2531 position = rulerNormal->GetPositionFromPage(2, volume, true);
2532 DALI_TEST_EQUALS(position, 10.0f, TEST_LOCATION);
2533 DALI_TEST_EQUALS(volume, 2u, TEST_LOCATION);
2538 int UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP(void)
2540 ToolkitTestApplication application;
2541 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetTotalPagesP");
2543 RulerPtr defaultRuler = new DefaultRuler();
2544 DALI_TEST_CHECK(defaultRuler);
2545 DALI_TEST_EQUALS(defaultRuler->GetTotalPages(), 1u, TEST_LOCATION);
2550 int UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP(void)
2552 ToolkitTestApplication application;
2553 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPageFromPositionP");
2555 RulerPtr defaultRuler = new DefaultRuler();
2556 DALI_TEST_CHECK(defaultRuler);
2557 DALI_TEST_EQUALS(defaultRuler->GetPageFromPosition(100.0f, true), 0u, TEST_LOCATION);
2558 DALI_TEST_EQUALS(defaultRuler->GetPageFromPosition(-300.0f, false), 0u, TEST_LOCATION);
2563 int UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP(void)
2565 ToolkitTestApplication application;
2566 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerGetPositionFromPageP");
2568 RulerPtr defaultRuler = new DefaultRuler();
2569 DALI_TEST_CHECK(defaultRuler);
2571 unsigned int volume;
2572 DALI_TEST_EQUALS(defaultRuler->GetPositionFromPage(0, volume, true), 0.0f, TEST_LOCATION);
2573 DALI_TEST_EQUALS(volume, 0u, TEST_LOCATION);
2575 DALI_TEST_EQUALS(defaultRuler->GetPositionFromPage(3, volume, false), 0.0f, TEST_LOCATION);
2576 DALI_TEST_EQUALS(volume, 0u, TEST_LOCATION);
2581 int UtcDaliToolkitScrollViewDefaultRulerSnapP(void)
2583 ToolkitTestApplication application;
2584 tet_infoline(" UtcDaliToolkitScrollViewDefaultRulerSnapP");
2586 RulerPtr defaultRuler = new DefaultRuler();
2587 DALI_TEST_CHECK(defaultRuler);
2589 DALI_TEST_EQUALS(defaultRuler->Snap(50.0f, 0.5f), 50.0f, TEST_LOCATION);
2590 DALI_TEST_EQUALS(defaultRuler->Snap(-120.0f, 1.0f), -120.0f, TEST_LOCATION);
2595 int UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP(void)
2597 ToolkitTestApplication application;
2598 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetTotalPagesP");
2600 RulerPtr fixedRuler = new FixedRuler(100.0f);
2601 fixedRuler->SetDomain(RulerDomain(0.0f, 400.0f, true));
2603 fixedRuler->Enable();
2604 DALI_TEST_EQUALS(fixedRuler->GetTotalPages(), 4u, TEST_LOCATION);
2606 fixedRuler->Disable();
2607 DALI_TEST_EQUALS(fixedRuler->GetTotalPages(), 1u, TEST_LOCATION);
2612 int UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP(void)
2614 ToolkitTestApplication application;
2615 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerGetPageFromPositionP");
2617 RulerPtr fixedRuler = new FixedRuler(100.0f);
2618 fixedRuler->SetDomain(RulerDomain(0.0f, 400.0f, true));
2620 fixedRuler->Enable();
2621 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, true), 3u, TEST_LOCATION);
2622 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2623 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, true), 1u, TEST_LOCATION);
2624 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2626 fixedRuler->Disable();
2627 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2628 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2629 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2630 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2632 // Set domain size to be smaller than the ruler space
2633 fixedRuler->SetDomain(RulerDomain(0.0f, 50.0f, true));
2635 fixedRuler->Enable();
2636 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2637 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, false), 3u, TEST_LOCATION);
2638 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2639 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2641 fixedRuler->Disable();
2642 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, true), 0u, TEST_LOCATION);
2643 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(250.0f, false), 0u, TEST_LOCATION);
2644 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, true), 0u, TEST_LOCATION);
2645 DALI_TEST_EQUALS(fixedRuler->GetPageFromPosition(-350.0f, false), 0u, TEST_LOCATION);
2650 int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
2652 ToolkitTestApplication application;
2653 tet_infoline(" UtcDaliToolkitScrollViewFixedRulerSnapP");
2655 RulerPtr fixedRuler = new FixedRuler(100.0f);
2656 fixedRuler->SetDomain(RulerDomain(0.0f, 400.0f, true));
2658 DALI_TEST_EQUALS(fixedRuler->Snap(-30.0f, 0.0f), -100.0f, TEST_LOCATION);
2659 DALI_TEST_EQUALS(fixedRuler->Snap(-70.0f, 0.0f), -100.0f, TEST_LOCATION);
2660 DALI_TEST_EQUALS(fixedRuler->Snap(-120.0f, 0.0f), -200.0f, TEST_LOCATION);
2661 DALI_TEST_EQUALS(fixedRuler->Snap(-480.0f, 0.0f), -500.0f, TEST_LOCATION);
2662 DALI_TEST_EQUALS(fixedRuler->Snap(20.0f, 0.0f), 0.0f, TEST_LOCATION);
2663 DALI_TEST_EQUALS(fixedRuler->Snap(50.0f, 0.0f), 0.0f, TEST_LOCATION);
2664 DALI_TEST_EQUALS(fixedRuler->Snap(80.0f, 0.0f), 0.0f, TEST_LOCATION);
2665 DALI_TEST_EQUALS(fixedRuler->Snap(100.0f, 0.0f), 100.0f, TEST_LOCATION);
2666 DALI_TEST_EQUALS(fixedRuler->Snap(120.0f, 0.0f), 100.0f, TEST_LOCATION);
2667 DALI_TEST_EQUALS(fixedRuler->Snap(250.0f, 0.0f), 200.0f, TEST_LOCATION);
2668 DALI_TEST_EQUALS(fixedRuler->Snap(620.0f, 0.0f), 600.0f, TEST_LOCATION);
2670 DALI_TEST_EQUALS(fixedRuler->Snap(-30.0f, 0.5f), 0.0f, TEST_LOCATION);
2671 DALI_TEST_EQUALS(fixedRuler->Snap(-70.0f, 0.5f), -100.0f, TEST_LOCATION);
2672 DALI_TEST_EQUALS(fixedRuler->Snap(-120.0f, 0.5f), -100.0f, TEST_LOCATION);
2673 DALI_TEST_EQUALS(fixedRuler->Snap(-480.0f, 0.5f), -500.0f, TEST_LOCATION);
2674 DALI_TEST_EQUALS(fixedRuler->Snap(20.0f, 0.5f), 0.0f, TEST_LOCATION);
2675 DALI_TEST_EQUALS(fixedRuler->Snap(50.0f, 0.5f), 100.0f, TEST_LOCATION);
2676 DALI_TEST_EQUALS(fixedRuler->Snap(80.0f, 0.5f), 100.0f, TEST_LOCATION);
2677 DALI_TEST_EQUALS(fixedRuler->Snap(100.0f, 0.5f), 100.0f, TEST_LOCATION);
2678 DALI_TEST_EQUALS(fixedRuler->Snap(120.0f, 0.5f), 100.0f, TEST_LOCATION);
2679 DALI_TEST_EQUALS(fixedRuler->Snap(250.0f, 0.5f), 300.0f, TEST_LOCATION);
2680 DALI_TEST_EQUALS(fixedRuler->Snap(620.0f, 0.5f), 600.0f, TEST_LOCATION);
2682 DALI_TEST_EQUALS(fixedRuler->Snap(-30.0f, 1.0f), 0.0f, TEST_LOCATION);
2683 DALI_TEST_EQUALS(fixedRuler->Snap(-70.0f, 1.0f), 0.0f, TEST_LOCATION);
2684 DALI_TEST_EQUALS(fixedRuler->Snap(-120.0f, 1.0f), -100.0f, TEST_LOCATION);
2685 DALI_TEST_EQUALS(fixedRuler->Snap(-480.0f, 1.0f), -400.0f, TEST_LOCATION);
2686 DALI_TEST_EQUALS(fixedRuler->Snap(20.0f, 1.0f), 100.0f, TEST_LOCATION);
2687 DALI_TEST_EQUALS(fixedRuler->Snap(50.0f, 1.0f), 100.0f, TEST_LOCATION);
2688 DALI_TEST_EQUALS(fixedRuler->Snap(80.0f, 1.0f), 100.0f, TEST_LOCATION);
2689 DALI_TEST_EQUALS(fixedRuler->Snap(100.0f, 1.0f), 200.0f, TEST_LOCATION);
2690 DALI_TEST_EQUALS(fixedRuler->Snap(120.0f, 1.0f), 200.0f, TEST_LOCATION);
2691 DALI_TEST_EQUALS(fixedRuler->Snap(250.0f, 1.0f), 300.0f, TEST_LOCATION);
2692 DALI_TEST_EQUALS(fixedRuler->Snap(620.0f, 1.0f), 700.0f, TEST_LOCATION);
2697 int UtcDaliToolkitScrollViewConstraintsMove(void)
2699 ToolkitTestApplication application;
2700 tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
2702 // Set up a scrollView...
2703 ScrollView scrollView = ScrollView::New();
2704 application.GetScene().Add(scrollView);
2705 Vector2 stageSize = application.GetScene().GetSize();
2706 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
2707 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2708 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2711 RulerPtr rulerX = new DefaultRuler();
2712 RulerPtr rulerY = new DefaultRuler();
2713 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
2714 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
2715 scrollView.SetRulerX(rulerX);
2716 scrollView.SetRulerY(rulerY);
2718 // Add an Actor to ScrollView,
2719 Actor a = Actor::New();
2721 a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
2724 const Vector2 target = Vector2(100.0f, 100.0f);
2725 const Vector2 target2 = Vector2(200.0f, 200.0f);
2727 Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, MoveActorConstraint);
2728 constraint.AddSource(Source(scrollView, ScrollView::Property::SCROLL_POSITION));
2729 constraint.SetRemoveAction(Constraint::DISCARD);
2730 scrollView.ApplyConstraintToChildren(constraint);
2732 scrollView.ScrollTo(target, 0.0f);
2734 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
2735 scrollView.ScrollTo(target2);
2736 Wait(application, RENDER_DELAY_SCROLL);
2737 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
2742 int UtcDaliToolkitScrollViewConstraintsWrap(void)
2744 ToolkitTestApplication application;
2745 tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
2747 // Set up a scrollView...
2748 ScrollView scrollView = ScrollView::New();
2749 application.GetScene().Add(scrollView);
2750 Vector2 stageSize = application.GetScene().GetSize();
2751 scrollView.SetProperty(Actor::Property::SIZE, stageSize);
2752 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2753 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2756 RulerPtr rulerX = new DefaultRuler();
2757 RulerPtr rulerY = new DefaultRuler();
2758 rulerX->SetDomain(RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true));
2759 rulerY->SetDomain(RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true));
2760 scrollView.SetRulerX(rulerX);
2761 scrollView.SetRulerY(rulerY);
2763 // Add an Actor to ScrollView,
2764 Actor a = Actor::New();
2766 a.SetProperty(Actor::Property::POSITION, TEST_ACTOR_POSITION);
2769 const Vector2 target = Vector2(100.0f, 100.0f);
2770 const Vector2 target2 = Vector2(200.0f, 200.0f);
2772 Constraint constraint = Constraint::New<Vector3>(scrollView, Actor::Property::POSITION, WrapActorConstraint);
2773 constraint.AddSource(LocalSource(Actor::Property::SCALE));
2774 constraint.AddSource(LocalSource(Actor::Property::ANCHOR_POINT));
2775 constraint.AddSource(LocalSource(Actor::Property::SIZE));
2776 constraint.AddSource(Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN));
2777 constraint.AddSource(Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX));
2778 constraint.AddSource(Source(scrollView, Toolkit::ScrollView::Property::WRAP));
2779 constraint.SetRemoveAction(Constraint::DISCARD);
2780 scrollView.ApplyConstraintToChildren(constraint);
2782 scrollView.ScrollTo(target, 0.0f);
2784 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION);
2785 scrollView.ScrollTo(target2);
2786 Wait(application, RENDER_DELAY_SCROLL);
2787 DALI_TEST_EQUALS(scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION);
2789 scrollView.Remove(a);
2795 // Non-API test (so no P or N variant).
2796 int UtcDaliToolkitScrollViewGesturePageLimit(void)
2798 ToolkitTestApplication application;
2799 tet_infoline(" UtcDaliToolkitScrollViewGesturePageLimit");
2801 // Set up a scrollView.
2802 ScrollView scrollView = ScrollView::New();
2804 // Do not rely on stage size for UTC tests.
2805 Vector2 viewPageSize(720.0f, 1280.0f);
2806 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
2807 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
2808 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
2809 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
2810 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
2813 // We set the X ruler to fixed to give us pages to snap to.
2814 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler(viewPageSize.width);
2815 // Note: The 3x page width is arbitary, but we need enough to show that we are
2816 // capping page movement by the page limiter, and not the domain.
2817 rulerX->SetDomain(Dali::Toolkit::RulerDomain(0.0f, viewPageSize.width * 3.0f, false));
2818 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
2820 scrollView.SetRulerX(rulerX);
2821 scrollView.SetRulerY(rulerY);
2823 scrollView.SetWrapMode(false);
2824 scrollView.SetScrollSensitive(true);
2826 application.GetScene().Add(scrollView);
2828 // Set up a gesture to perform.
2829 Vector2 startPos(50.0f, 0.0f);
2830 Vector2 direction(-5.0f, 0.0f);
2833 // Force starting position.
2834 scrollView.ScrollTo(startPos, 0.0f);
2836 time += Wait(application);
2838 // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins.
2839 Vector2 currentPos(PerformGestureSwipe(application, startPos, direction, frames - 1, time, false));
2841 // Confirm the final X coord has not moved more than one page from the start X position.
2842 DALI_TEST_GREATER((startPos.x + viewPageSize.width), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION);
2844 // Finish the gesture and wait for the snap.
2845 currentPos += direction;
2846 TestEndPan(application, currentPos, time);
2847 // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first.
2848 time += Wait(application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL);
2850 // Confirm the final X coord has snapped to exactly one page ahead of the start page.
2851 DALI_TEST_EQUALS(viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION);
2856 int UtcDaliScrollViewSetGetProperty(void)
2858 ToolkitTestApplication application;
2860 // Create the ScrollView actor
2861 ScrollView scrollView = ScrollView::New();
2862 DALI_TEST_CHECK(scrollView);
2864 // Event side properties
2866 // Test "wrapEnabled" property
2867 DALI_TEST_CHECK(scrollView.GetPropertyIndex("wrapEnabled") == ScrollView::Property::WRAP_ENABLED);
2868 scrollView.SetProperty(ScrollView::Property::WRAP_ENABLED, true);
2869 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::WRAP_ENABLED).Get<bool>(), true, TEST_LOCATION);
2871 // Test "panningEnabled" property
2872 DALI_TEST_CHECK(scrollView.GetPropertyIndex("panningEnabled") == ScrollView::Property::PANNING_ENABLED);
2873 scrollView.SetProperty(ScrollView::Property::PANNING_ENABLED, false);
2874 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::PANNING_ENABLED).Get<bool>(), false, TEST_LOCATION);
2876 // Test "axisAutoLockEnabled" property
2877 DALI_TEST_CHECK(scrollView.GetPropertyIndex("axisAutoLockEnabled") == ScrollView::Property::AXIS_AUTO_LOCK_ENABLED);
2878 scrollView.SetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED, false);
2879 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::AXIS_AUTO_LOCK_ENABLED).Get<bool>(), false, TEST_LOCATION);
2881 // Test "wheelScrollDistanceStep" property
2882 DALI_TEST_CHECK(scrollView.GetPropertyIndex("wheelScrollDistanceStep") == ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP);
2883 scrollView.SetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP, Vector2(100.0f, 50.0f));
2884 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::WHEEL_SCROLL_DISTANCE_STEP).Get<Vector2>(), Vector2(100.0f, 50.0f), TEST_LOCATION);
2886 // Test "overshootEnabled" property
2887 DALI_TEST_CHECK(scrollView.GetPropertyIndex("overshootEnabled") == Scrollable::Property::OVERSHOOT_ENABLED);
2888 DALI_TEST_EQUALS(scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), scrollView.IsOvershootEnabled(), TEST_LOCATION);
2889 scrollView.SetProperty(Scrollable::Property::OVERSHOOT_ENABLED, false);
2890 DALI_TEST_EQUALS(scrollView.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get<bool>(), false, TEST_LOCATION);
2892 // Animatable properties
2894 // Test "scrollPosition" property
2895 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPosition") == ScrollView::Property::SCROLL_POSITION);
2896 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION, Vector2(320.0f, 550.0f));
2898 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION).Get<Vector2>(), Vector2(320.0f, 550.0f), TEST_LOCATION);
2900 // Test "scrollPrePosition", "scrollPrePositionX" and "scrollPrePositionY" properties
2901 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePosition") == ScrollView::Property::SCROLL_PRE_POSITION);
2902 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION, Vector2(300.0f, 500.0f));
2904 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(300.0f, 500.0f), TEST_LOCATION);
2906 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePositionX") == ScrollView::Property::SCROLL_PRE_POSITION_X);
2907 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePositionY") == ScrollView::Property::SCROLL_PRE_POSITION_Y);
2908 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 300.0f, TEST_LOCATION);
2909 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 500.0f, TEST_LOCATION);
2910 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X, 400.0f);
2911 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y, 600.0f);
2913 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_X).Get<float>(), 400.0f, TEST_LOCATION);
2914 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_Y).Get<float>(), 600.0f, TEST_LOCATION);
2915 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector2>(), Vector2(400.0f, 600.0f), TEST_LOCATION);
2917 // Test "scrollPrePositionMax", "scrollPrePositionMaxX" and "scrollPrePositionMaxY" properties
2918 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePositionMax") == ScrollView::Property::SCROLL_PRE_POSITION_MAX);
2919 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX, Vector2(100.0f, 200.0f));
2921 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(100.0f, 200.0f), TEST_LOCATION);
2923 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePositionMaxX") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_X);
2924 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPrePositionMaxY") == ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y);
2925 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 100.0f, TEST_LOCATION);
2926 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 200.0f, TEST_LOCATION);
2927 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X, 300.0f);
2928 scrollView.SetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y, 400.0f);
2930 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_X).Get<float>(), 300.0f, TEST_LOCATION);
2931 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX_Y).Get<float>(), 400.0f, TEST_LOCATION);
2932 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_PRE_POSITION_MAX).Get<Vector2>(), Vector2(300.0f, 400.0f), TEST_LOCATION);
2934 // Test "overshootX" property
2935 DALI_TEST_CHECK(scrollView.GetPropertyIndex("overshootX") == ScrollView::Property::OVERSHOOT_X);
2936 scrollView.SetProperty(ScrollView::Property::OVERSHOOT_X, 0.8f);
2938 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X).Get<float>(), 0.8f, TEST_LOCATION);
2940 // Test "overshootY" property
2941 DALI_TEST_CHECK(scrollView.GetPropertyIndex("overshootY") == ScrollView::Property::OVERSHOOT_Y);
2942 scrollView.SetProperty(ScrollView::Property::OVERSHOOT_Y, 0.8f);
2944 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y).Get<float>(), 0.8f, TEST_LOCATION);
2946 // Test "scrollFinal", "scrollFinalX" and "scrollFinalY" properties
2947 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollFinal") == ScrollView::Property::SCROLL_FINAL);
2948 scrollView.SetProperty(ScrollView::Property::SCROLL_FINAL, Vector2(200.0f, 300.0f));
2950 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(200.0f, 300.0f), TEST_LOCATION);
2952 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollFinalX") == ScrollView::Property::SCROLL_FINAL_X);
2953 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollFinalY") == ScrollView::Property::SCROLL_FINAL_Y);
2954 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 200.0f, TEST_LOCATION);
2955 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 300.0f, TEST_LOCATION);
2956 scrollView.SetProperty(ScrollView::Property::SCROLL_FINAL_X, 500.0f);
2957 scrollView.SetProperty(ScrollView::Property::SCROLL_FINAL_Y, 600.0f);
2959 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_X).Get<float>(), 500.0f, TEST_LOCATION);
2960 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL_Y).Get<float>(), 600.0f, TEST_LOCATION);
2961 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_FINAL).Get<Vector2>(), Vector2(500.0f, 600.0f), TEST_LOCATION);
2963 // Test "wrap" property
2964 DALI_TEST_CHECK(scrollView.GetPropertyIndex("wrap") == ScrollView::Property::WRAP);
2965 scrollView.SetProperty(ScrollView::Property::WRAP, false);
2967 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::WRAP).Get<bool>(), false, TEST_LOCATION);
2969 // Test "panning" property
2970 DALI_TEST_CHECK(scrollView.GetPropertyIndex("panning") == ScrollView::Property::PANNING);
2971 scrollView.SetProperty(ScrollView::Property::PANNING, true);
2973 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::PANNING).Get<bool>(), true, TEST_LOCATION);
2975 // Test "scrolling" property
2976 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrolling") == ScrollView::Property::SCROLLING);
2977 scrollView.SetProperty(ScrollView::Property::SCROLLING, false);
2979 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLLING).Get<bool>(), false, TEST_LOCATION);
2981 // Test "scrollDomainSize", "scrollDomainSizeX" and "scrollDomainSizeY" properties
2982 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollDomainSize") == ScrollView::Property::SCROLL_DOMAIN_SIZE);
2983 scrollView.SetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE, Vector2(1200.0f, 1300.0f));
2985 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1200.0f, 1300.0f), TEST_LOCATION);
2987 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollDomainSizeX") == ScrollView::Property::SCROLL_DOMAIN_SIZE_X);
2988 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollDomainSizeY") == ScrollView::Property::SCROLL_DOMAIN_SIZE_Y);
2989 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1200.0f, TEST_LOCATION);
2990 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1300.0f, TEST_LOCATION);
2991 scrollView.SetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X, 1500.0f);
2992 scrollView.SetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y, 1600.0f);
2994 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_X).Get<float>(), 1500.0f, TEST_LOCATION);
2995 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE_Y).Get<float>(), 1600.0f, TEST_LOCATION);
2996 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_SIZE).Get<Vector2>(), Vector2(1500.0f, 1600.0f), TEST_LOCATION);
2998 // Test "scrollDomainOffset" property
2999 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollDomainOffset") == ScrollView::Property::SCROLL_DOMAIN_OFFSET);
3000 scrollView.SetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector2(500.0f, 200.0f));
3002 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_DOMAIN_OFFSET).Get<Vector2>(), Vector2(500.0f, 200.0f), TEST_LOCATION);
3004 // Test "scrollPositionDelta" property
3005 DALI_TEST_CHECK(scrollView.GetPropertyIndex("scrollPositionDelta") == ScrollView::Property::SCROLL_POSITION_DELTA);
3006 scrollView.SetProperty(ScrollView::Property::SCROLL_POSITION_DELTA, Vector2(10.0f, 30.0f));
3008 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION_DELTA).Get<Vector2>(), Vector2(10.0f, 30.0f), TEST_LOCATION);
3010 // Test "startPagePosition" property
3011 DALI_TEST_CHECK(scrollView.GetPropertyIndex("startPagePosition") == ScrollView::Property::START_PAGE_POSITION);
3012 scrollView.SetProperty(ScrollView::Property::START_PAGE_POSITION, Vector3(50.0f, 100.0f, 20.0f));
3014 DALI_TEST_EQUALS(scrollView.GetProperty(ScrollView::Property::START_PAGE_POSITION).Get<Vector3>(), Vector3(50.0f, 100.0f, 20.0f), TEST_LOCATION);
3019 int UtcDaliToolkitScrollViewWheelEvent(void)
3021 ToolkitTestApplication application;
3023 // Set up a scrollView.
3024 ScrollView scrollView = ScrollView::New();
3026 // Do not rely on stage size for UTC tests.
3027 Vector2 viewPageSize(720.0f, 1280.0f);
3028 scrollView.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
3029 scrollView.SetProperty(Actor::Property::SIZE, viewPageSize);
3030 scrollView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3031 scrollView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
3032 scrollView.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 0.0f, 0.0f));
3035 // We set the X ruler to fixed to give us pages to snap to.
3036 Dali::Toolkit::FixedRuler* rulerX = new Dali::Toolkit::FixedRuler(viewPageSize.width);
3037 // Note: The 3x page width is arbitary, but we need enough to show that we are
3038 // capping page movement by the page limiter, and not the domain.
3039 rulerX->SetDomain(Dali::Toolkit::RulerDomain(0.0f, viewPageSize.width * 3.0f, false));
3040 Dali::Toolkit::RulerPtr rulerY = new Dali::Toolkit::DefaultRuler();
3042 scrollView.SetRulerX(rulerX);
3043 scrollView.SetRulerY(rulerY);
3045 scrollView.SetWrapMode(false);
3047 application.GetScene().Add(scrollView);
3049 //Connect to wheel event signal
3050 scrollView.WheelEventSignal().Connect(&OnWheelEvent);
3052 DALI_TEST_CHECK(!gOnWheelEventCalled);
3054 // Render and notify
3055 application.Render();
3056 application.SendNotification();
3057 application.Render();
3058 application.SendNotification();
3060 // Perform a wheel event
3061 Dali::Integration::WheelEvent wheelEvent(Dali::Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, Vector2(10.0f, 10.0f), 1, 1000u);
3062 application.ProcessEvent(wheelEvent);
3063 DALI_TEST_CHECK(gOnWheelEventCalled);
3065 // Set X ruler to free
3066 Dali::Toolkit::DefaultRuler* defaultRuler = new Dali::Toolkit::DefaultRuler();
3067 scrollView.SetRulerX(defaultRuler);
3069 // Perform a wheel event
3070 gOnWheelEventCalled = false;
3071 application.ProcessEvent(wheelEvent);
3072 DALI_TEST_CHECK(gOnWheelEventCalled);
3077 // Perform a wheel event
3078 gOnWheelEventCalled = false;
3079 application.ProcessEvent(wheelEvent);
3080 DALI_TEST_CHECK(gOnWheelEventCalled);
3082 // Wait until it finishes scrolling
3083 Wait(application, RENDER_DELAY_SCROLL);
3085 // Set Y ruler to fixed
3086 Dali::Toolkit::FixedRuler* fixedRulerY = new Dali::Toolkit::FixedRuler(viewPageSize.height);
3087 scrollView.SetRulerY(fixedRulerY);
3089 // Perform a wheel event
3090 gOnWheelEventCalled = false;
3091 application.ProcessEvent(wheelEvent);
3092 DALI_TEST_CHECK(gOnWheelEventCalled);