X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-gesture-generator.cpp;h=4532c6e6ad0b030b21422d12310f11e80561d2d3;hp=a0ac206c9e5c7bd667e291b99a4b0cdffbd1de84;hb=4082d081eb74560feaa2d9aa17dc16bc2e3740f8;hpb=4aaa3009e1e192b20eae5f0831996f1034cbb6f4 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.cpp index a0ac206..4532c6e 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,36 +22,36 @@ namespace { -const uint32_t RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) +const uint32_t RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) -Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time ) +Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition, uint32_t time) { Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( state ); + Integration::Point point; + point.SetState(state); point.SetDeviceId(4); - point.SetScreenPosition( screenPosition ); - point.SetDeviceClass( Device::Class::TOUCH ); - point.SetDeviceSubclass( Device::Subclass::NONE ); - touchEvent.points.push_back( point ); + point.SetScreenPosition(screenPosition); + point.SetDeviceClass(Device::Class::TOUCH); + point.SetDeviceSubclass(Device::Subclass::NONE); + touchEvent.points.push_back(point); touchEvent.time = time; return touchEvent; } -Integration::TouchEvent GenerateDoubleTouch( PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time ) +Integration::TouchEvent GenerateDoubleTouch(PointState::Type stateA, const Vector2& screenPositionA, PointState::Type stateB, const Vector2& screenPositionB, uint32_t time) { Integration::TouchEvent touchEvent; - Integration::Point point; - point.SetState( stateA ); + Integration::Point point; + point.SetState(stateA); point.SetDeviceId(4); - point.SetScreenPosition( screenPositionA ); - point.SetDeviceClass( Device::Class::TOUCH ); - point.SetDeviceSubclass( Device::Subclass::NONE ); - touchEvent.points.push_back( point ); - point.SetScreenPosition( screenPositionB ); - point.SetState( stateB); + point.SetScreenPosition(screenPositionA); + point.SetDeviceClass(Device::Class::TOUCH); + point.SetDeviceSubclass(Device::Subclass::NONE); + touchEvent.points.push_back(point); + point.SetScreenPosition(screenPositionB); + point.SetState(stateB); point.SetDeviceId(7); - touchEvent.points.push_back( point ); + touchEvent.points.push_back(point); touchEvent.time = time; return touchEvent; } @@ -64,101 +64,140 @@ uint32_t TestGetFrameInterval() return RENDER_FRAME_INTERVAL; } -void TestStartLongPress( TestApplication& application, float x, float y, uint32_t time ) +void TestStartLongPress(TestApplication& application, float x, float y, uint32_t time) { - application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( x, y ), time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(x, y), time)); } -void TestTriggerLongPress( TestApplication& application ) +void TestTriggerLongPress(TestApplication& application) { application.GetPlatform().TriggerTimer(); } -void TestGenerateLongPress( TestApplication& application, float x, float y, uint32_t time ) +void TestGenerateLongPress(TestApplication& application, float x, float y, uint32_t time) { - TestStartLongPress( application, x, y, time ); - TestTriggerLongPress( application ); + TestStartLongPress(application, x, y, time); + TestTriggerLongPress(application); } -void TestEndLongPress( TestApplication& application, float x, float y, uint32_t time ) +void TestEndLongPress(TestApplication& application, float x, float y, uint32_t time) { - application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( x, y ), time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(x, y), time)); } -void TestGeneratePinch( TestApplication& application) +void TestGeneratePinch(TestApplication& application) { - application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), PointState::DOWN, Vector2( 20.0f, 90.0f ), 150 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 28.0f ), PointState::MOTION, Vector2( 20.0f, 82.0f ), 160 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 37.0f ), PointState::MOTION, Vector2( 20.0f, 74.0f ), 170 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 46.0f ), PointState::MOTION, Vector2( 20.0f, 66.0f ), 180 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, Vector2( 20.0f, 55.0f ), PointState::MOTION, Vector2( 20.0f, 58.0f ), 190 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::UP, Vector2( 20.0f, 55.0f ), PointState::UP, Vector2( 20.0f, 58.0f ), 200 ) ); + application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 28.0f), PointState::MOTION, Vector2(20.0f, 82.0f), 160)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 37.0f), PointState::MOTION, Vector2(20.0f, 74.0f), 170)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 46.0f), PointState::MOTION, Vector2(20.0f, 66.0f), 180)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 55.0f), PointState::MOTION, Vector2(20.0f, 58.0f), 190)); + application.ProcessEvent(GenerateDoubleTouch(PointState::UP, Vector2(20.0f, 55.0f), PointState::UP, Vector2(20.0f, 58.0f), 200)); } -void TestStartPinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ) +void TestStartPinch(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) { - application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, a1, PointState::DOWN, b1, time ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a2, PointState::MOTION, b2, time + 50 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a2, PointState::MOTION, b2, time + 100 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a2, PointState::MOTION, b2, time + 150 ) ); + application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, a1, PointState::DOWN, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 50)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 100)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 150)); } -void TestContinuePinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ) +void TestContinuePinch(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) { - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a1, PointState::MOTION, b1, time ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a1, PointState::MOTION, b1, time + 50 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a2, PointState::MOTION, b2, time + 100 ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a2, PointState::MOTION, b2, time +150 ) ); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time + 50)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 100)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 150)); } -void TestEndPinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ) +void TestEndPinch(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) { - application.ProcessEvent( GenerateDoubleTouch( PointState::MOTION, a1, PointState::MOTION, b1, time ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::UP, a2, PointState::UP, b2, time +50 ) ); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::UP, a2, PointState::UP, b2, time + 50)); } -void TestGenerateMiniPan( TestApplication& application) +void TestGenerateMiniPan(TestApplication& application) { - application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 20.0f, 20.0f ), 250 ) ); - application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 20.0f, 40.0f ), 251 ) ); - application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 20.0f, 40.0f ), 255 ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 250)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 40.0f), 255)); } -void TestStartPan( TestApplication& application, Vector2 start, Vector2 end, uint32_t& time ) +void TestStartPan(TestApplication& application, Vector2 start, Vector2 end, uint32_t& time) { - application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, start, time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, start, time)); time += RENDER_FRAME_INTERVAL; - application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, end, time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, end, time)); time += RENDER_FRAME_INTERVAL; - application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, end, time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, end, time)); time += RENDER_FRAME_INTERVAL; } -void TestMovePan( TestApplication& application, Vector2 pos, uint32_t time ) +void TestMovePan(TestApplication& application, Vector2 pos, uint32_t time) { - application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, pos, time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, pos, time)); } -void TestEndPan( TestApplication& application, Vector2 pos, uint32_t time ) +void TestEndPan(TestApplication& application, Vector2 pos, uint32_t time) { - application.ProcessEvent( GenerateSingleTouch( PointState::UP, pos, time ) ); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, pos, time)); } -void TestGenerateTap( TestApplication& application, float x, float y, uint32_t time_down ) +void TestTriggerTap(TestApplication& application) { - application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( x, y ), time_down ) ); - application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( x, y ), time_down + 20 ) ); + application.GetPlatform().TriggerTimer(); +} + +void TestGenerateTap(TestApplication& application, float x, float y, uint32_t time_down) +{ + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(x, y), time_down)); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(x, y), time_down + 20)); + TestTriggerTap(application); +} + +void TestGenerateTwoPointTap(TestApplication& application, float x1, float y1, float x2, float y2, uint32_t time_down) +{ + application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(x1, y1), PointState::DOWN, Vector2(x2, y2), time_down)); + application.ProcessEvent(GenerateDoubleTouch(PointState::UP, Vector2(x1, y1), PointState::UP, Vector2(x2, y2), time_down + 20)); + TestTriggerTap(application); +} + +void TestGenerateRotation(TestApplication& application) +{ + application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), PointState::DOWN, Vector2(20.0f, 90.0f), 150)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(25.0f, 95.0f), 160)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(30.0f, 100.0f), 170)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(35.0f, 105.0f), 180)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, Vector2(20.0f, 20.0f), PointState::MOTION, Vector2(40.0f, 110.0f), 190)); + application.ProcessEvent(GenerateDoubleTouch(PointState::UP, Vector2(20.0f, 20.0f), PointState::UP, Vector2(45.0f, 115.0f), 200)); +} + +void TestStartRotation(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) +{ + application.ProcessEvent(GenerateDoubleTouch(PointState::DOWN, a1, PointState::DOWN, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 50)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 100)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 150)); +} + +void TestContinueRotation(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) +{ + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time + 50)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 100)); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a2, PointState::MOTION, b2, time + 150)); } -void TestGenerateTwoPointTap( TestApplication& application, float x1, float y1, float x2, float y2, uint32_t time_down ) +void TestEndRotation(TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time) { - application.ProcessEvent( GenerateDoubleTouch( PointState::DOWN, Vector2( x1, y1 ), PointState::DOWN, Vector2( x2, y2 ), time_down ) ); - application.ProcessEvent( GenerateDoubleTouch( PointState::UP, Vector2( x1, y1 ), PointState::UP, Vector2( x2, y2 ), time_down + 20 ) ); + application.ProcessEvent(GenerateDoubleTouch(PointState::MOTION, a1, PointState::MOTION, b1, time)); + application.ProcessEvent(GenerateDoubleTouch(PointState::UP, a2, PointState::UP, b2, time + 50)); } } // namespace Dali