From: György Straub Date: Fri, 17 May 2019 10:06:27 +0000 (+0100) Subject: [dali_1.4.20] Merge branch 'devel/master' X-Git-Tag: dali_1.9.8~5^2~46 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=b514a4671789bee2f03b0177393b9a21f62ac2c3;hp=9aa4e505623ff77920c48199756165aca292ca86 [dali_1.4.20] Merge branch 'devel/master' Change-Id: I8657808933950b0c552ec405302267a7f40e88c2 --- diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 1494855..bd7def3 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -57,7 +57,6 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp - ../dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt index bc765c7..f956e18 100644 --- a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt @@ -42,7 +42,6 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp - ../dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp diff --git a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt index 6f50e82..084c2d5 100644 --- a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt @@ -34,7 +34,6 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-application.cpp ../dali-toolkit/dali-toolkit-test-utils/test-button.cpp ../dali-toolkit/dali-toolkit-test-utils/test-harness.cpp - ../dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index f0be18f..36f4850 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -101,7 +101,7 @@ LIST(APPEND TC_SOURCES dali-toolkit-test-utils/test-application.cpp dali-toolkit-test-utils/test-button.cpp dali-toolkit-test-utils/test-harness.cpp - dali-toolkit-test-utils/test-gesture-manager.cpp + dali-toolkit-test-utils/test-gesture-generator.cpp dali-toolkit-test-utils/test-gl-abstraction.cpp dali-toolkit-test-utils/test-gl-sync-abstraction.cpp dali-toolkit-test-utils/test-platform-abstraction.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index 70f4254..577ca36 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TEST_SUITE_UTILS_H__ -#define __DALI_TEST_SUITE_UTILS_H__ +#ifndef DALI_TEST_SUITE_UTILS_H +#define DALI_TEST_SUITE_UTILS_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -34,6 +34,7 @@ void tet_printf(const char *format, ...); #include "test-application.h" #include "test-actor-utils.h" +#include "test-gesture-generator.h" using namespace Dali; @@ -442,4 +443,4 @@ private: } // namespace Test -#endif // __DALI_TEST_SUITE_UTILS_H__ +#endif // DALI_TEST_SUITE_UTILS_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp index 1562d27..0b98b27 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp @@ -47,7 +47,6 @@ void TestApplication::Initialize() mPlatformAbstraction, mGlAbstraction, mGlSyncAbstraction, - mGestureManager, mDataRetentionPolicy, Integration::RenderToFrameBuffer::FALSE, Integration::DepthBufferAvailable::TRUE, @@ -141,11 +140,6 @@ TestGlSyncAbstraction& TestApplication::GetGlSyncAbstraction() return mGlSyncAbstraction; } -TestGestureManager& TestApplication::GetGestureManager() -{ - return mGestureManager; -} - void TestApplication::ProcessEvent(const Integration::Event& event) { mCore->QueueEvent(event); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h index fc2929c..27aafd3 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h @@ -20,7 +20,6 @@ // INTERNAL INCLUDES #include -#include "test-gesture-manager.h" #include "test-gl-sync-abstraction.h" #include "test-gl-abstraction.h" #include "test-render-controller.h" @@ -68,7 +67,6 @@ public: TestRenderController& GetRenderController(); TestGlAbstraction& GetGlAbstraction(); TestGlSyncAbstraction& GetGlSyncAbstraction(); - TestGestureManager& GetGestureManager(); void ProcessEvent(const Integration::Event& event); void SendNotification(); bool Render( uint32_t intervalMilliseconds = DEFAULT_RENDER_INTERVAL, const char* location=NULL ); @@ -96,7 +94,6 @@ protected: TestRenderController mRenderController; TestGlAbstraction mGlAbstraction; TestGlSyncAbstraction mGlSyncAbstraction; - TestGestureManager mGestureManager; TestRenderSurface* mRenderSurface; Integration::UpdateStatus mStatus; 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 new file mode 100644 index 0000000..a0ac206 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.cpp @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test-gesture-generator.h" + +// INTERNAL INCLUDES +#include + +namespace +{ +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 touchEvent; + 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 ); + 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 touchEvent; + 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.SetDeviceId(7); + touchEvent.points.push_back( point ); + touchEvent.time = time; + return touchEvent; +} +} // namespace + +namespace Dali +{ +uint32_t TestGetFrameInterval() +{ + return RENDER_FRAME_INTERVAL; +} + +void TestStartLongPress( TestApplication& application, float x, float y, uint32_t time ) +{ + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( x, y ), time ) ); +} + +void TestTriggerLongPress( TestApplication& application ) +{ + application.GetPlatform().TriggerTimer(); +} + +void TestGenerateLongPress( TestApplication& application, float x, float y, uint32_t time ) +{ + TestStartLongPress( application, x, y, time ); + TestTriggerLongPress( application ); +} + +void TestEndLongPress( TestApplication& application, float x, float y, uint32_t time ) +{ + application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( x, y ), time ) ); +} + +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 ) ); +} + +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 ) ); +} + +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 ) ); +} + +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 ) ); +} + +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 ) ); +} + +void TestStartPan( TestApplication& application, Vector2 start, Vector2 end, uint32_t& time ) +{ + application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, start, time ) ); + + time += RENDER_FRAME_INTERVAL; + + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, end, time ) ); + + time += RENDER_FRAME_INTERVAL; + + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, end, time ) ); + + time += RENDER_FRAME_INTERVAL; +} + +void TestMovePan( TestApplication& application, Vector2 pos, uint32_t time ) +{ + application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, pos, time ) ); +} + +void TestEndPan( TestApplication& application, Vector2 pos, uint32_t time ) +{ + application.ProcessEvent( GenerateSingleTouch( PointState::UP, pos, time ) ); +} + +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 ) ); +} + +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 ) ); +} + +} // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.h new file mode 100644 index 0000000..80611a0 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-generator.h @@ -0,0 +1,108 @@ +#ifndef DALI_TEST_GESTURE_GENERATOR_H +#define DALI_TEST_GESTURE_GENERATOR_H + +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test-application.h" + +namespace Dali +{ +/** + * These functions use touch events to trigger a gesture, assuming the default gesture parameters are used + */ + +/** + * Returns the frame interval used in ms + */ +uint32_t TestGetFrameInterval(); + +/** + * Produces the initial touch of a long press + */ +void TestStartLongPress( TestApplication& application, float x = 20.0f, float y = 20.0f, uint32_t time = 450 ); + +/** + * Triggers the timer to begin a long press gesture + */ +void TestTriggerLongPress( TestApplication& application ); + +/** + * Produces the initial press and triggers the timer to begin a long press gesture + */ +void TestGenerateLongPress( TestApplication& application, float x = 20.0f, float y = 20.0f, uint32_t time = 450 ); + +/** + * End a long press by lifting the touch + */ +void TestEndLongPress( TestApplication& application, float x = 20.0f, float y = 20.0f, uint32_t time = 450 ); + +/** + * Produces a vertical pinch gesture between (20,20) and (20,90) + */ +void TestGeneratePinch( TestApplication& application ); + +/** + * Produces the gesture started event of a pinch, using 4 touches, 50ms apart, starting with 1, ending at 2 + */ +void TestStartPinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ); + +/** + * Produces a gesture continuing event of a pinch, using 4 touches, 50ms apart, starting with 1, ending at 2 + */ +void TestContinuePinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ); + +/** + * Produces a gesture finished event of a pinch, using 2 touches, 50ms apart + */ +void TestEndPinch( TestApplication& application, Vector2 a1, Vector2 b1, Vector2 a2, Vector2 b2, uint32_t time ); + +/** + * Produces a pan gesture from (20,20) to (20,40) + */ +void TestGenerateMiniPan( TestApplication& application ); + +/** + * Produces the start event of a pan gesture, assuming minimum distance moved between start and end is greater than 15 + * in either direction or 11 in both (x&y). Time will be incremented using the standard frame interval per touch movement + */ +void TestStartPan( TestApplication& application, Vector2 start, Vector2 end, uint32_t& time ); + +/** + * Continues a pan event by creating a single touch at pos. + * N.B This does not increment the time + */ +void TestMovePan( TestApplication& application, Vector2 pos, uint32_t time = 400); + +/** + * End a pan gesture at position pos + */ +void TestEndPan( TestApplication& application, Vector2 pos, uint32_t time = 500); + +/** + * Produces a single point tap gesture with a 20ms interval + */ +void TestGenerateTap( TestApplication& application, float x = 20.0f, float y = 20.0f, uint32_t time_down = 100 ); + +/** + * Produce a tap gesture with two touch points and a 20ms interval + */ +void TestGenerateTwoPointTap( TestApplication& application, float x1, float y1, float x2, float y2, uint32_t time_down ); + +} // namespace Dali + +#endif // DALI_TEST_GESTURE_GENERATOR_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp deleted file mode 100644 index 2844ff1..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2014 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "test-gesture-manager.h" - -namespace Dali -{ - -TestGestureManager::TestGestureManager() -{ - Initialize(); -} - -/** - * Destructor - */ -TestGestureManager::~TestGestureManager() -{ -} - -/** - * @copydoc Dali::Integration::GestureManager::Register(Gesture::Type) - */ -void TestGestureManager::Register(const Integration::GestureRequest& request) -{ - mFunctionsCalled.Register = true; -} - -/** - * @copydoc Dali::Integration::GestureManager::Unregister(Gesture::Type) - */ -void TestGestureManager::Unregister(const Integration::GestureRequest& request) -{ - mFunctionsCalled.Unregister = true; -} - -/** - * @copydoc Dali::Integration::GestureManager::Update(Gesture::Type) - */ -void TestGestureManager::Update(const Integration::GestureRequest& request) -{ - mFunctionsCalled.Update = true; -} - - -/** Call this every test */ -void TestGestureManager::Initialize() -{ - mFunctionsCalled.Reset(); -} - -bool TestGestureManager::WasCalled(TestFuncEnum func) -{ - switch(func) - { - case RegisterType: return mFunctionsCalled.Register; - case UnregisterType: return mFunctionsCalled.Unregister; - case UpdateType: return mFunctionsCalled.Update; - } - return false; -} - -void TestGestureManager::ResetCallStatistics(TestFuncEnum func) -{ - switch(func) - { - case RegisterType: mFunctionsCalled.Register = false; break; - case UnregisterType: mFunctionsCalled.Unregister = false; break; - case UpdateType: mFunctionsCalled.Update = false; break; - } -} - -TestGestureManager::TestFunctions::TestFunctions() -: Register(false), - Unregister(false), - Update(false) -{ -} - -void TestGestureManager::TestFunctions::Reset() -{ - Register = false; - Unregister = false; - Update = false; -} - - - -} // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.h deleted file mode 100644 index 6fddd30..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gesture-manager.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef __DALI_TEST_GESTURE_MANAGER_H__ -#define __DALI_TEST_GESTURE_MANAGER_H__ - -/* - * Copyright (c) 2018 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -/** - * Concrete implementation of the gesture manager class. - */ -class DALI_CORE_API TestGestureManager : public Dali::Integration::GestureManager -{ - -public: - - /** - * Constructor - */ - TestGestureManager(); - - /** - * Destructor - */ - virtual ~TestGestureManager(); - - /** - * @copydoc Dali::Integration::GestureManager::Register(Gesture::Type) - */ - virtual void Register(const Integration::GestureRequest& request); - - /** - * @copydoc Dali::Integration::GestureManager::Unregister(Gesture::Type) - */ - virtual void Unregister(const Integration::GestureRequest& request); - - /** - * @copydoc Dali::Integration::GestureManager::Update(Gesture::Type) - */ - virtual void Update(const Integration::GestureRequest& request); - -public: // TEST FUNCTIONS - - // Enumeration of Gesture Manager methods - enum TestFuncEnum - { - RegisterType, - UnregisterType, - UpdateType, - }; - - /** Call this every test */ - void Initialize(); - bool WasCalled(TestFuncEnum func); - void ResetCallStatistics(TestFuncEnum func); - -private: - - struct TestFunctions - { - TestFunctions(); - void Reset(); - - bool Register; - bool Unregister; - bool Update; - }; - - TestFunctions mFunctionsCalled; -}; - -} // Dali - -#endif // __DALI_TEST_GESTURE_MANAGER_H__ diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp index 190aa63..39628701 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -28,7 +28,9 @@ TestPlatformAbstraction::TestPlatformAbstraction() mClosestSize(), mLoadFileResult(), mSaveFileResult( false ), - mSynchronouslyLoadedResource() + mSynchronouslyLoadedResource(), + mTimerId(0), + mCallbackFunction(nullptr) { Initialize(); } @@ -82,7 +84,6 @@ bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, return mLoadFileResult.loadResult; } - /** Call this every test */ void TestPlatformAbstraction::Initialize() { @@ -144,4 +145,24 @@ void TestPlatformAbstraction::SetDecodedBitmap( Integration::BitmapPtr bitmap ) mDecodedBitmap = bitmap; } +uint32_t TestPlatformAbstraction::StartTimer( uint32_t milliseconds, CallbackBase* callback ) +{ + mCallbackFunction = callback; + mTimerId++; + return mTimerId; +} + +void TestPlatformAbstraction::TriggerTimer() +{ + if (mCallbackFunction != nullptr) + { + CallbackBase::Execute( *mCallbackFunction ); + } +} + +void TestPlatformAbstraction::CancelTimer ( uint32_t timerId ) +{ + mCallbackFunction = nullptr; +} + } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h index dfa4d6c..7c1b010 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TEST_PLATFORM_ABSTRACTION_H__ -#define __DALI_TEST_PLATFORM_ABSTRACTION_H__ +#ifndef DALI_TEST_PLATFORM_ABSTRACTION_H +#define DALI_TEST_PLATFORM_ABSTRACTION_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -89,6 +89,15 @@ public: */ virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; } + /** + * @copydoc PlatformAbstraction::StartTimer() + */ + virtual uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback ); + + /* + * @copydoc PlatformAbstraction::CancelTimer() + */ + virtual void CancelTimer ( uint32_t timerId ); public: // TEST FUNCTIONS @@ -156,6 +165,11 @@ public: // TEST FUNCTIONS */ void SetDecodedBitmap( Integration::BitmapPtr bitmap ); + /** + * @brief Triggers the previously stored callback function + */ + void TriggerTimer(); + private: TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined @@ -184,8 +198,11 @@ private: Integration::ResourcePointer mSynchronouslyLoadedResource; Integration::BitmapPtr mDecodedBitmap; + + uint32_t mTimerId; + CallbackBase* mCallbackFunction; }; } // Dali -#endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */ +#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */ diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp index a4b0d87..df3e5d5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -16,10 +16,10 @@ */ #include -#include #include #include #include +#include namespace Dali { @@ -53,7 +53,7 @@ public: mIsEnabled = enabled; } - void SendPanGesture( const Dali::Integration::PanGestureEvent& panEvent ); + void SendPanGesture( const AccessibilityGestureEvent& panEvent ); public: @@ -140,7 +140,7 @@ bool AccessibilityAdaptor::IsEnabled() const return mIsEnabled; } -void AccessibilityAdaptor::SendPanGesture( const Integration::PanGestureEvent& panEvent ) +void AccessibilityAdaptor::SendPanGesture( const AccessibilityGestureEvent& panEvent ) { mGestureHandler->HandlePanGesture( panEvent ); } @@ -615,7 +615,7 @@ void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled ) Dali::Internal::Adaptor::GetImplementation(adaptor).SetEnabled(enabled); } -void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::Integration::PanGestureEvent& panEvent ) +void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent ) { Dali::Internal::Adaptor::GetImplementation(adaptor).SendPanGesture( panEvent ); } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h index 744f971..a463baf 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-accessibility-adaptor.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H__ -#define __DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H__ +#ifndef DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H +#define DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,7 +20,7 @@ // EXTERNAL INCLUDES #include -#include +#include namespace Test { @@ -29,9 +29,9 @@ namespace AccessibilityAdaptor void MockSetReadPosition( Dali::AccessibilityAdaptor adaptor, Dali::Vector2& position ); void SetEnabled( Dali::AccessibilityAdaptor adaptor, bool enabled); -void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::Integration::PanGestureEvent& panEvent ); +void SendPanGesture( Dali::AccessibilityAdaptor adaptor, const Dali::AccessibilityGestureEvent& panEvent ); } // namespace AccessibilityAdaptor } // namespace Test -#endif // +#endif // DALI_TEST_TOOLKIT_ACCESSIBILITY_ADAPTOR_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp index 10a2659..c980501 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -17,6 +17,7 @@ // CLASS HEADER #include +#include #include @@ -78,6 +79,26 @@ Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surfac return Internal::Adaptor::Adaptor::Get(); } +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window ) +{ + return Internal::Adaptor::Adaptor::Get(); +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration ) +{ + return Internal::Adaptor::Adaptor::Get(); +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface ) +{ + return Internal::Adaptor::Adaptor::Get(); +} + +Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration ) +{ + return Internal::Adaptor::Adaptor::Get(); +} + Adaptor::~Adaptor() { } @@ -134,6 +155,10 @@ void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surfa { } +void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface ) +{ +} + Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() { return Internal::Adaptor::Adaptor::AdaptorSignal(); @@ -185,10 +210,6 @@ void Adaptor::NotifyLanguageChanged() { } -void Adaptor::SetMinimumPinchDistance(float distance) -{ -} - void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) { } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp index 29f26b9..5316331 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-web-engine.cpp @@ -43,6 +43,7 @@ static int gInstanceCount = 0; bool OnGoBack(); bool OnGoForward(); bool OnLoadUrl(); +bool OnEvaluteJavaScript(); bool OnClearHistory(); static void ConnectToGlobalSignal( bool (*func)() ) @@ -65,6 +66,14 @@ public: WebEngine() : mUrl() , mCurrentPlusOnePos( 0 ) + , mCacheModel( Dali::WebEnginePlugin::CacheModel::DOCUMENT_VIEWER ) + , mCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy::NO_THIRD_PARTY ) + , mUserAgent() + , mEnableJavaScript( true ) + , mLoadImagesAutomatically( true ) + , mDefaultTextEncodingName() + , mDefaultFontSize( 16 ) + , mEvaluating( false ) { gInstanceCount++; gInstance = this; @@ -73,7 +82,7 @@ public: virtual ~WebEngine() { gInstanceCount--; - if ( !gInstanceCount ) + if( !gInstanceCount ) { gInstance = NULL; } @@ -110,26 +119,123 @@ public: ConnectToGlobalSignal( &OnGoBack ); } + void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) + { + if( resultHandler ) + { + if( !mEvaluating ) + { + ConnectToGlobalSignal( &OnEvaluteJavaScript ); + } + mResultCallbacks.push_back( resultHandler ); + } + } + void ClearHistory() { ConnectToGlobalSignal( &OnClearHistory ); } - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal() + Dali::WebEnginePlugin::CacheModel GetCacheModel() const + { + return mCacheModel; + } + + void SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) + { + mCacheModel = cacheModel; + } + + Dali::WebEnginePlugin::CookieAcceptPolicy GetCookieAcceptPolicy() const + { + return mCookieAcceptPolicy; + } + + void SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) + { + mCookieAcceptPolicy = policy; + } + + const std::string& GetUserAgent() const + { + return mUserAgent; + } + + void SetUserAgent( const std::string& userAgent ) + { + mUserAgent = userAgent; + } + + bool IsJavaScriptEnabled() const + { + return mEnableJavaScript; + } + + void EnableJavaScript( bool enabled ) + { + mEnableJavaScript = enabled; + } + + bool AreImagesAutomaticallyLoaded() const + { + return mLoadImagesAutomatically; + } + + void LoadImagesAutomatically( bool automatic ) + { + mLoadImagesAutomatically = automatic; + } + + const std::string& GetDefaultTextEncodingName() const + { + return mDefaultTextEncodingName; + } + + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) + { + mDefaultTextEncodingName = defaultTextEncodingName; + } + + int GetDefaultFontSize() const + { + return mDefaultFontSize; + } + + void SetDefaultFontSize( int defaultFontSize ) + { + mDefaultFontSize = defaultFontSize; + } + + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal() { return mPageLoadStartedSignal; } - Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal() + Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal() { return mPageLoadFinishedSignal; } - std::string mUrl; - std::vector< std::string > mHistory; - size_t mCurrentPlusOnePos; - Dali::WebEnginePlugin::WebEngineSignalType mPageLoadStartedSignal; - Dali::WebEnginePlugin::WebEngineSignalType mPageLoadFinishedSignal; + Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() + { + return mPageLoadErrorSignal; + } + + std::string mUrl; + std::vector< std::string > mHistory; + size_t mCurrentPlusOnePos; + Dali::WebEnginePlugin::CacheModel mCacheModel; + Dali::WebEnginePlugin::CookieAcceptPolicy mCookieAcceptPolicy; + std::string mUserAgent; + bool mEnableJavaScript; + bool mLoadImagesAutomatically; + std::string mDefaultTextEncodingName; + int mDefaultFontSize; + Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal; + Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal; + Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal; + std::vector< std::function< void( const std::string& ) > > mResultCallbacks; + bool mEvaluating; }; inline WebEngine& GetImplementation( Dali::WebEngine& webEngine ) @@ -153,7 +259,7 @@ bool OnGoBack() { DisconnectFromGlobalSignal( &OnGoBack ); - if ( gInstance && gInstance->CanGoBack() ) + if( gInstance && gInstance->CanGoBack() ) { gInstance->mCurrentPlusOnePos--; } @@ -164,7 +270,7 @@ bool OnGoForward() { DisconnectFromGlobalSignal( &OnGoForward ); - if ( gInstance && gInstance->CanGoForward() ) + if( gInstance && gInstance->CanGoForward() ) { gInstance->mCurrentPlusOnePos++; } @@ -175,9 +281,9 @@ bool OnLoadUrl() { DisconnectFromGlobalSignal( &OnLoadUrl ); - if ( gInstance ) + if( gInstance ) { - if ( gInstance->mHistory.size() > gInstance->mCurrentPlusOnePos ) + if( gInstance->mHistory.size() > gInstance->mCurrentPlusOnePos ) { gInstance->mHistory.erase( gInstance->mHistory.begin() + gInstance->mCurrentPlusOnePos, gInstance->mHistory.end() ); } @@ -186,7 +292,21 @@ bool OnLoadUrl() gInstance->mPageLoadStartedSignal.Emit( gInstance->mUrl ); gInstance->mPageLoadFinishedSignal.Emit( gInstance->mUrl ); } + return false; +} +bool OnEvaluteJavaScript() +{ + DisconnectFromGlobalSignal( &OnEvaluteJavaScript ); + + if( gInstance ) + { + for( auto& func : gInstance->mResultCallbacks ) + { + func("undefined"); + } + gInstance->mResultCallbacks.clear(); + } return false; } @@ -194,7 +314,7 @@ bool OnClearHistory() { DisconnectFromGlobalSignal( &OnClearHistory ); - if ( gInstance && gInstance->mCurrentPlusOnePos ) { + if( gInstance && gInstance->mCurrentPlusOnePos ) { std::string url = gInstance->mHistory[ gInstance->mCurrentPlusOnePos - 1 ]; std::vector< std::string >().swap( gInstance->mHistory ); gInstance->mHistory.push_back( url ); @@ -283,6 +403,14 @@ void WebEngine::StopLoading() { } +void WebEngine::Suspend() +{ +} + +void WebEngine::Resume() +{ +} + bool WebEngine::CanGoForward() { return Internal::Adaptor::GetImplementation( *this ).CanGoForward(); @@ -303,8 +431,9 @@ void WebEngine::GoBack() Internal::Adaptor::GetImplementation( *this ).GoBack(); } -void WebEngine::EvaluateJavaScript( const std::string& script ) +void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) { + Internal::Adaptor::GetImplementation( *this ).EvaluateJavaScript( script, resultHandler ); } void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler ) @@ -320,6 +449,80 @@ void WebEngine::ClearCache() { } +void WebEngine::ClearCookies() +{ +} + +Dali::WebEnginePlugin::CacheModel WebEngine::GetCacheModel() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetCacheModel(); +} + +void WebEngine::SetCacheModel( Dali::WebEnginePlugin::CacheModel cacheModel ) +{ + Internal::Adaptor::GetImplementation( *this ).SetCacheModel( cacheModel ); +} + +Dali::WebEnginePlugin::CookieAcceptPolicy WebEngine::GetCookieAcceptPolicy() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetCookieAcceptPolicy(); +} + +void WebEngine::SetCookieAcceptPolicy( Dali::WebEnginePlugin::CookieAcceptPolicy policy ) +{ + Internal::Adaptor::GetImplementation( *this ).SetCookieAcceptPolicy( policy ); +} + +const std::string& WebEngine::GetUserAgent() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetUserAgent(); +} + +void WebEngine::SetUserAgent( const std::string& userAgent ) +{ + Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent ); +} + +bool WebEngine::IsJavaScriptEnabled() const +{ + return Internal::Adaptor::GetImplementation( *this ).IsJavaScriptEnabled(); +} + +void WebEngine::EnableJavaScript( bool enabled ) +{ + Internal::Adaptor::GetImplementation( *this ).EnableJavaScript( enabled ); +} + +bool WebEngine::AreImagesAutomaticallyLoaded() const +{ + return Internal::Adaptor::GetImplementation( *this ).AreImagesAutomaticallyLoaded(); +} + +void WebEngine::LoadImagesAutomatically( bool automatic ) +{ + Internal::Adaptor::GetImplementation( *this ).LoadImagesAutomatically( automatic ); +} + +const std::string& WebEngine::GetDefaultTextEncodingName() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetDefaultTextEncodingName(); +} + +void WebEngine::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +{ + Internal::Adaptor::GetImplementation( *this ).SetDefaultTextEncodingName( defaultTextEncodingName ); +} + +int WebEngine::GetDefaultFontSize() const +{ + return Internal::Adaptor::GetImplementation( *this ).GetDefaultFontSize(); +} + +void WebEngine::SetDefaultFontSize( int defaultFontSize ) +{ + Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize ); +} + void WebEngine::SetSize( int width, int height ) { } @@ -334,15 +537,20 @@ bool WebEngine::SendKeyEvent( const KeyEvent& event ) return true; } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal() { return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal(); } -Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal() +Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal() { return Internal::Adaptor::GetImplementation( *this ).PageLoadFinishedSignal(); } +Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal() +{ + return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal(); +} + } // namespace Dali; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp index 2044f1e..ee6f133 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AccessibilityManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -2344,7 +2344,7 @@ int UtcDaliAccessibilityManagerHandlePanGesture(void) dummyControl.SetSize(480, 800); Stage::GetCurrent().Add( dummyControl ); - Dali::Integration::PanGestureEvent panGestureEvent(Gesture::Started); + AccessibilityGestureEvent panGestureEvent(AccessibilityGestureEvent::Started); panGestureEvent.previousPosition = Vector2(0.f, 0.f); panGestureEvent.currentPosition = Vector2(100.f, 0.f); panGestureEvent.timeDelta = 16; @@ -2352,12 +2352,12 @@ int UtcDaliAccessibilityManagerHandlePanGesture(void) Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - panGestureEvent.state = Gesture::Continuing; + panGestureEvent.state = AccessibilityGestureEvent::Continuing; panGestureEvent.previousPosition = Vector2(100.f, 0.f); panGestureEvent.currentPosition = Vector2(200.f, 0.f); Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); - panGestureEvent.state = Gesture::Finished; + panGestureEvent.state = AccessibilityGestureEvent::Finished; panGestureEvent.previousPosition = Vector2(200.f, 0.f); panGestureEvent.currentPosition = Vector2(300.f, 0.f); Test::AccessibilityAdaptor::SendPanGesture( accessibilityAdaptor, panGestureEvent ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 6150385..31f3094 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -28,10 +28,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -236,107 +232,32 @@ int UtcDaliControlImplOnGestureMethods(void) dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); DALI_TEST_CHECK( dummyImpl.pinchCalled == false ); - Integration::PinchGestureEvent pinch(Gesture::Started); - pinch.scale = 10.0f; - pinch.speed = 50.0f; - pinch.centerPoint = Vector2(20.0f, 20.0f); - application.ProcessEvent(pinch); + + TestGeneratePinch(application); + DALI_TEST_CHECK( dummyImpl.pinchCalled == true ); DALI_TEST_CHECK( dummyImpl.panCalled == false ); - Integration::PanGestureEvent pan(Gesture::Possible); - pan.previousPosition = Vector2(10.0f, 20.0f); - pan.currentPosition = Vector2(20.0f, 20.0f); - pan.timeDelta = 10; - pan.numberOfTouches = 1u; - application.ProcessEvent(pan); - pan.state = Gesture::Started; - application.ProcessEvent(pan); - DALI_TEST_CHECK( dummyImpl.panCalled == true ); - DALI_TEST_CHECK( dummyImpl.tapCalled == false ); - Integration::TapGestureEvent tap(Gesture::Possible); - tap.numberOfTaps = 1u; - tap.numberOfTouches = 1u; - tap.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(tap); - tap.state = Gesture::Started; - application.ProcessEvent(tap); - DALI_TEST_CHECK( dummyImpl.tapCalled == true ); + TestGenerateMiniPan(application); - DALI_TEST_CHECK( dummyImpl.longPressCalled == false ); - Integration::LongPressGestureEvent longPress(Gesture::Possible); - longPress.numberOfTouches = 1u; - longPress.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(longPress); - longPress.state = Gesture::Started; - application.ProcessEvent(longPress); - DALI_TEST_CHECK( dummyImpl.longPressCalled == true ); - longPress.state = Gesture::Finished; - application.ProcessEvent(longPress); - - Stage::GetCurrent().Remove(dummy); - } + DALI_TEST_CHECK( dummyImpl.panCalled == true ); - // Ensure full code coverage - { - DummyControl dummy = DummyControl::New(); - dummy.SetSize( Vector2( 100.0f, 100.0f ) ); + DALI_TEST_CHECK( dummyImpl.tapCalled == false ); - dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); - Stage::GetCurrent().Add(dummy); + TestGenerateTap(application); - // Render and notify a couple of times - application.SendNotification(); - application.Render(); - application.SendNotification(); - application.Render(); + DALI_TEST_CHECK( dummyImpl.tapCalled == true ); - DummyControlImpl& dummyImpl = static_cast(dummy.GetImplementation()); - dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); + DALI_TEST_CHECK( dummyImpl.longPressCalled == false ); - DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f ); - Integration::PinchGestureEvent pinch(Gesture::Started); - pinch.scale = 10.0f; - pinch.speed = 50.0f; - pinch.centerPoint = Vector2(20.0f, 20.0f); - application.ProcessEvent(pinch); + TestGenerateLongPress(application); - // Render and notify a couple of times - application.SendNotification(); - application.Render(); - application.SendNotification(); - application.Render(); - DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f ); - - Integration::PanGestureEvent pan(Gesture::Possible); - pan.previousPosition = Vector2(10.0f, 20.0f); - pan.currentPosition = Vector2(20.0f, 20.0f); - pan.timeDelta = 10; - pan.numberOfTouches = 1u; - application.ProcessEvent(pan); - pan.state = Gesture::Started; - application.ProcessEvent(pan); - - Integration::TapGestureEvent tap(Gesture::Possible); - tap.numberOfTaps = 1u; - tap.numberOfTouches = 1u; - tap.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(tap); - tap.state = Gesture::Started; - application.ProcessEvent(tap); - - Integration::LongPressGestureEvent longPress(Gesture::Possible); - longPress.numberOfTouches = 1u; - longPress.point = Vector2(50.0f, 50.0f); - application.ProcessEvent(longPress); - longPress.state = Gesture::Started; - application.ProcessEvent(longPress); - longPress.state = Gesture::Finished; - application.ProcessEvent(longPress); + DALI_TEST_CHECK( dummyImpl.longPressCalled == true ); Stage::GetCurrent().Remove(dummy); } + END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-DragAndDropDetector.cpp b/automated-tests/src/dali-toolkit/utc-Dali-DragAndDropDetector.cpp index 3fbbfcd..e1282ad 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-DragAndDropDetector.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-DragAndDropDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -24,7 +24,6 @@ #include #include -#include using namespace Dali; using namespace Dali::Toolkit; @@ -91,25 +90,6 @@ namespace touchEvent.points.push_back(point); return touchEvent; } - - Integration::PanGestureEvent GeneratePan( - Gesture::State state, - Vector2 previousPosition, - Vector2 currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1, - unsigned int time = 1u) - { - Integration::PanGestureEvent pan(state); - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - pan.time = time; - - return pan; - } - } int UtcDaliDragAndDropDetectorConstructorN(void) @@ -305,12 +285,11 @@ int UtcDaliDragAndDropDetectorStartSignal(void) DragSignalFunctor functor(data); detector.StartedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(control, data.control, TEST_LOCATION); - DALI_TEST_EQUALS(Vector2(12.0f, 12.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION); + DALI_TEST_EQUALS(Vector2(20.0f, 40.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION); data.Reset(); END_TEST; @@ -345,8 +324,7 @@ int UtcDaliDragAndDropDetectorEnteredSignal(void) DragSignalFunctor functor(data); detector.EnteredSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); Vector2 screenCoordinates(10.0f, 110.0f); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates)); @@ -389,8 +367,7 @@ int UtcDaliDragAndDropDetectorMovedSignal(void) DragSignalFunctor functor(data); detector.MovedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); Vector2 screenCoordinates(10.0f, 110.0f); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates)); @@ -440,8 +417,7 @@ int UtcDaliDragAndDropDetectorExitedSignal(void) DragSignalFunctor functor(data); detector.ExitedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); Vector2 screenCoordinates(10.0f, 110.0f); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates)); @@ -486,8 +462,7 @@ int UtcDaliDragAndDropDetectorDroppedSignal(void) DragSignalFunctor functor(data); detector.DroppedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); Vector2 screenCoordinates(10.0f, 110.0f); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates)); @@ -535,14 +510,10 @@ int UtcDaliDragAndDropDetectorEndedSignal(void) DragSignalFunctor functor(data); detector.EndedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, Vector2(10.0f, 10.0f))); - application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 10.0f), Vector2(120.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(120.0f, 12.0f), Vector2(120.0f, 20.0f), 10)); - DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(control1, data.control, TEST_LOCATION); data.Reset(); @@ -581,8 +552,7 @@ int UtcDaliDragAndDropDetectorGetContent(void) DragSignalFunctor functor(data); detector.DroppedSignal().Connect(&application, functor); - application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); - application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10)); + TestGenerateMiniPan(application); Vector2 screenCoordinates(10.0f, 110.0f); application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates)); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index deca627..4891370 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -24,7 +24,7 @@ #include #include #include -#include + using namespace Dali; using namespace Toolkit; @@ -66,46 +66,18 @@ static void OnScrollUpdate( const Vector2& position ) gOnScrollUpdateCalled = true; } -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) +Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition, uint32_t time ) { - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); - - last.x = pos.x; - last.y = pos.y; + Integration::TouchEvent touchEvent; + 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 ); + touchEvent.time = time; + return touchEvent; } /* @@ -1144,36 +1116,41 @@ int UtcDaliItemViewOvershootVertical(void) // Do a pan starting from 100,100 and moving down Vector2 pos(100.0f, 100.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.y += 5.0f; Wait(application, 100); for(int i = 0;i<200;i++) { - SendPan(application, Gesture::Continuing, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); pos.y += 5.0f; Wait(application); } - SendPan(application, Gesture::Finished, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); + Wait(application, 100); // Do a pan starting from 100,100 and moving up pos = Vector2(100.0f, 300.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); + pos.y -= 5.0f; Wait(application, 100); for(int i = 0;i<200;i++) { - SendPan(application, Gesture::Continuing, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); pos.y -= 5.0f; Wait(application); } - SendPan(application, Gesture::Finished, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); Wait(application, 100); END_TEST; } @@ -1205,36 +1182,36 @@ int UtcDaliItemViewOvershootHorizontal(void) // Do a pan starting from 100,100 and moving left Vector2 pos(100.0f, 100.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 )); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 )); pos.x -= 5.0f; Wait(application, 100); for(int i = 0;i<200;i++) { - SendPan(application, Gesture::Continuing, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); pos.x -= 5.0f; Wait(application); } - SendPan(application, Gesture::Finished, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); Wait(application, 100); // Do a pan starting from 100,100 and moving right pos = Vector2(100.0f, 100.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::DOWN, pos, 100 ) ); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); pos.x += 5.0f; Wait(application, 100); for(int i = 0;i<200;i++) { - SendPan(application, Gesture::Continuing, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::MOTION, pos, 100 ) ); pos.x += 5.0f; Wait(application); } - SendPan(application, Gesture::Finished, pos); + application.ProcessEvent( GenerateSingleTouch(PointState::UP, pos, 100 ) ); Wait(application, 100); END_TEST; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp index f7d5908..1607611 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,82 +50,47 @@ static void TestCallback(BaseHandle handle) * @param application Test application instance * @param duration Time to pass in milliseconds. */ -void Wait(ToolkitTestApplication& application, int duration = 0) +int Wait(ToolkitTestApplication& application, int duration = 0) { + int time = 0; + for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++) { application.SendNotification(); application.Render(RENDER_FRAME_INTERVAL); + time += RENDER_FRAME_INTERVAL; } -} - -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; + return time; } -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); - - last.x = pos.x; - last.y = pos.y; -} - -static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool toStart = true, bool toFinish = true) +static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool toStart = true, bool toFinish = true) { - // Now do a pan starting from (start) and heading (direction) - Vector2 pos(start); + Vector2 pos( start ); if( toStart ) { - SendPan(application, Gesture::Possible, pos); - Wait(application); - SendPan(application, Gesture::Started, pos); - Wait(application); + // Now do a pan starting from (start + 20) and heading (direction) + Vector2 pos_start_jump( start + Vector2(15.0f, 0.0f) ); + TestStartPan( application, start, pos_start_jump, time ); + pos += direction; } + time += Wait(application); + for(int i = 0;i(), 0, TEST_LOCATION ); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 5, time, true, false); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified ); - PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, time, false, true); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); - Wait(application, 1000); + time += Wait(application, 1000); DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified ); // the page is turned over DALI_TEST_EQUALS( portraitView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get(), (int)(pageIndex+1), TEST_LOCATION ); @@ -507,7 +473,7 @@ int UtcDaliPageTurnPortraitViewSignals(void) //pan 10 frames from position( size.width, size.height*0.5f ) to position( size * 0.75f ) start = Vector2( size.width, size.height*0.5f ); direction = Vector2(-size.width*0.025f, size.height*0.025f); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 5, time, true, false); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); @@ -515,12 +481,12 @@ int UtcDaliPageTurnPortraitViewSignals(void) signalVerified[0] = false; isTurningForwards = false; - PerformGestureDiagonalSwipe( application, start + direction*2 , direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start + direction*2 , direction, 5, time, false, true); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); // start the sliding back - Wait(application, 1000); + time += Wait(application, 1000); DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified ); DALI_TEST_EQUALS( portraitView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get(), (int)pageIndex, TEST_LOCATION ); // the page is not turned over @@ -534,13 +500,13 @@ int UtcDaliPageTurnPortraitViewSignals(void) isTurningForwards = false; start = size*0.25f; direction = Vector2(size.x*0.05f, 0.f); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 4, time, true, false); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified ); - PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, time, false, true); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); @@ -613,21 +579,22 @@ int UtcDaliPageTurnLanscapeViewSignals(void) pageIndex = 0; isTurningForwards = true; // Do a pan to the left. + uint32_t time = 0; Vector2 start = Vector2(stageSize.x * 0.85f, stageSize.y*0.5); Vector2 direction = Vector2(-stageSize.x*0.04f, -stageSize.x*0.03f); DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get(), 0, TEST_LOCATION ); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 5, time, true, false); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified ); - PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, time, false, true); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); - Wait(application, 1000); + time += Wait(application, 1000); DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified ); // the page is turned over DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get(), (int)(pageIndex+1), TEST_LOCATION ); @@ -642,17 +609,17 @@ int UtcDaliPageTurnLanscapeViewSignals(void) //pan 10 frames from position( size.width, size.height*0.5f ) to position( size * 0.75f ) start = Vector2( stageSize.x * 0.15f, stageSize.y*0.5f ); direction = Vector2(stageSize.x * 0.03f, 0.f); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 5, time, true, false); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified ); - PerformGestureDiagonalSwipe( application, start + direction*5.f , direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start + direction*5.f , direction, 5, time, false, true); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); - Wait(application, 1000); + time += Wait(application, 1000); DALI_TEST_CHECK( callbackTurnFinished.mSignalVerified ); DALI_TEST_EQUALS( landscapeView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get(), 0, TEST_LOCATION ); // the first page is turned back @@ -664,13 +631,13 @@ int UtcDaliPageTurnLanscapeViewSignals(void) isTurningForwards = false; start = stageSize*0.55f; direction = Vector2(stageSize.x*0.025f, 0.f); - PerformGestureDiagonalSwipe( application, start, direction, 5, true, false); + PerformGestureDiagonalSwipe( application, start, direction, 5, time, true, false); DALI_TEST_CHECK( callbackPanStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); DALI_TEST_CHECK( !callbackPanFinished.mSignalVerified ); - PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, false, true); + PerformGestureDiagonalSwipe( application, start+direction*5.f, direction, 5, time, false, true); DALI_TEST_CHECK( !callbackTurnStarted.mSignalVerified ); DALI_TEST_CHECK( callbackPanFinished.mSignalVerified ); DALI_TEST_CHECK( !callbackTurnFinished.mSignalVerified ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp index d4401ea..ff46053 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,7 +20,6 @@ #include #include #include -#include using namespace Dali; using namespace Toolkit; @@ -40,48 +39,6 @@ namespace const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); - - last.x = pos.x; - last.y = pos.y; -} - /* * Simulate time passed by. * @@ -143,25 +100,29 @@ static void OnScrollPositionIntervalReached( float position ) gOnScrollPositionIntervalReachedSignalCalled = true; } -static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames) +static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time) { gOnPanFinishedCalled = false; // Now do a pan starting from (start) and heading (direction) - Vector2 pos(start); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + Vector2 pos( start + ( direction * 15 ) ); + uint32_t time = start_time; + + TestStartPan( application, start, pos, time ); + Wait(application); for(int i = 0; i < frames; i++) { pos += direction; // Move in this direction - SendPan(application, Gesture::Continuing, pos); + time += RENDER_FRAME_INTERVAL; + TestMovePan( application, pos, time); Wait(application); } pos += direction; // Move in this direction. - SendPan(application, Gesture::Finished, pos); + time += RENDER_FRAME_INTERVAL; + TestEndPan(application, pos, time ); Wait(application); return pos; @@ -1754,7 +1715,7 @@ int UtcDaliToolkitScrollBarPanFinishedSignalP(void) application.Render(); // Perform a swipe gesture on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500); DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION ); @@ -1790,7 +1751,7 @@ int UtcDaliToolkitScrollBarPanFinishedSignalN(void) application.Render(); // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500); DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION ); // Create a source actor that owns the scroll properties required by the scroll bar @@ -1816,12 +1777,12 @@ int UtcDaliToolkitScrollBarPanFinishedSignalN(void) application.Render(); // Perform a swipe gesture on the scroll bar but not on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000); DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION ); // Perform a swipe gesture on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000); DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index a59a708..3e66bf1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -20,7 +20,6 @@ #include #include #include -#include using namespace Dali; using namespace Toolkit; @@ -85,48 +84,6 @@ const float TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION = TEST_CUSTOM2_SNAP_OVERSHOOT_D const float TIME_TOLERANCE = 0.05f; ///< Allow testing tolerance between a 10th of second (+/- 3 frames) -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); - - last.x = pos.x; - last.y = pos.y; -} - /* * Simulate time passed by. * @@ -269,31 +226,38 @@ float TestAlphaFunction(float progress) return std::min( progress * 2.0f, 1.0f ); } -static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true) +/** + * Generate a complete pan gesture + * Note: To initiate the gesture it will go from start, diagonally SE on the screen, then continue in the direction for frames touches + */ +static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t& time, bool finish = true) { gOnScrollStartCalled = false; gOnScrollUpdateCalled = false; gOnScrollCompleteCalled = false; gOnSnapStartCalled = false; - // Now do a pan starting from (start) and heading (direction) - Vector2 pos(start); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + Vector2 pos( start ); + + // This is created to ensure a pan is started + Vector2 pos_start_jump( start + Vector2(11.0f, 11.0f) ); + TestStartPan( application, start, pos_start_jump, time ); + pos = pos_start_jump; + Wait(application); for(int i = 0;i(), overshootSize, TEST_LOCATION ); @@ -1424,11 +1457,11 @@ int UtcDaliToolkitScrollViewOvershoot(void) scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + time += Wait(application); // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch) Vector2 currentPos = Vector2(100.0f, 100.0f); - currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, time, false); float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); Vector2 positionValue = scrollView.GetCurrentProperty< Vector2 >( ScrollView::Property::SCROLL_POSITION ); @@ -1439,7 +1472,8 @@ int UtcDaliToolkitScrollViewOvershoot(void) float timeToReachOrigin; // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); + timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); float minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + DEFAULT_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1451,9 +1485,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) // 2. Repeat Scroll, but this time change overshoot snap duration to shorter time scrollView.SetSnapOvershootDuration(TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM1_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1465,9 +1499,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) // 3. Repeat Scroll, but this time change overshoot snap duration to longer time. scrollView.SetSnapOvershootDuration(TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM2_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1480,9 +1514,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) scrollView.SetSnapOvershootDuration(TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION); scrollView.SetSnapOvershootAlphaFunction(TestAlphaFunction); - currentPos = PerformGestureDiagonalSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, false); + currentPos = PerformGestureSwipe(application, Vector2(100.0f, 100.0f), Vector2(5.0f, 5.0f), 100, time, false); // Now release touch. Overshoot should snap back to zero. - SendPan(application, Gesture::Finished, currentPos); + TestEndPan(application, currentPos, time); timeToReachOrigin = TestOvershootSnapDuration(application, scrollView); minTimeToReachOrigin = SCROLL_ANIMATION_DURATION + TEST_CUSTOM3_SNAP_OVERSHOOT_DURATION * (SNAP_POSITION_WITH_DECELERATED_VELOCITY.x / DEFAULT_MAX_OVERSHOOT) - TIME_TOLERANCE; @@ -1553,16 +1587,17 @@ int UtcDaliToolkitScrollViewSnapStartedSignalP(void) scrollView.SnapStartedSignal().Connect( &OnSnapStart ); scrollView.ScrollTo(CLAMP_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + uint32_t time = 0; + time += Wait(application); // First try a snap. - PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, true); + PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(0.5f, 0.0f), 60, time, true); DALI_TEST_CHECK( gOnSnapStartCalled ); DALI_TEST_CHECK( gLastSnapType == Toolkit::Snap ); // Second try a swipe. - PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, true); + PerformGestureSwipe(application, CLAMP_TOUCH_START, Vector2(20.0f, 0.0f), 60, time, true); DALI_TEST_CHECK( gOnSnapStartCalled ); DALI_TEST_CHECK( gLastSnapType == Toolkit::Flick ); @@ -1624,35 +1659,49 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) scrollView.SetMaxOvershoot(50.0f, 50.0f); scrollView.ScrollTo(OVERSHOOT_START_SCROLL_POSITION, 0.0f); // move in a little. - Wait(application); + uint32_t time = 0; + time += Wait(application); // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch) - Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false); + Vector2 currentPos = PerformGestureSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 10, time, false); float overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); float overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION); + time += Wait(application); // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false); + for(int i = 0; i<106; i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); + time += Wait(application); + } + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot. // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105. - float correctOvershootValue = 50.0f / 105.f; + float correctOvershootValue = 0.508f; // This was measured and then set as the limit DALI_TEST_EQUALS( overshootXValue, correctOvershootValue, 0.001f, TEST_LOCATION ); DALI_TEST_EQUALS( overshootYValue, correctOvershootValue, 0.001f, TEST_LOCATION ); - // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); + // Scroll page further in NW (-25,-25 pixels), then check that overshoot should be now 1.0. (don't release touch) + for(int i = 0;i<25;i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); // Move in this direction + time += Wait(application); + } + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); - // Change the max overshoot to be 100 pixels in both X axis and Y axis - scrollView.SetMaxOvershoot(100.0f, 100.0f); - Wait(application); + // Change the max overshoot to be 250 pixels in both X axis and Y axis + scrollView.SetMaxOvershoot(250.0f, 250.0f); + time += Wait(application); // Check that overshoot should be now around 0.8. overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); @@ -1660,8 +1709,14 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f); DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f); - // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) - currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); + // Scroll page further in NW (-50,-50 pixels), then check that overshoot should be now 1.0. (don't release touch) + for(int i = 0;i<50;i++) + { + TestMovePan(application, currentPos, time ); + currentPos += Vector2(1.0f, 1.0f); // Move in this direction + time += Wait(application); + } + overshootXValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_X ); overshootYValue = scrollView.GetCurrentProperty< float >( ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); @@ -1686,26 +1741,71 @@ int UtcDaliToolkitScrollViewSetScrollingDirectionP(void) Vector2 START_POSITION = Vector2(10.0f, 10.0f); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); + uint32_t time = 0; + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + // PerformGestureSwipe not used as a different initial direction was required + + Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + // Take into account resampling done when prediction is off. DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + // PerformGestureSwipe not used as a different initial direction was required + pos = ( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); - scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); - Wait(application); + scrollView.ScrollTo(START_POSITION, 0.0f); + + time += Wait(application); + // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + // PerformGestureSwipe not used as a different initial direction was required + pos = ( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); END_TEST; @@ -1725,22 +1825,52 @@ int UtcDaliToolkitScrollViewRemoveScrollingDirectionP(void) scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); Vector2 START_POSITION = Vector2(10.0f, 10.0f); + uint32_t time = 0; scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); scrollView.ScrollTo(START_POSITION, 0.0f); - Wait(application); - // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); + + time += Wait(application); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), START_POSITION, TEST_LOCATION ); + // Try a vertical swipe. + // PerformGestureSwipe not used as a different initial direction was required + Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) ); + TestStartPan( application, START_POSITION, pos, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos += Vector2(0.0f, 1.0f); + TestMovePan( application, pos, time ); + time += Wait( application ); + } + pos += Vector2(0.0f, 1.0f); + TestEndPan( application, pos, time ); + time += Wait( application ); + + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); + scrollView.RemoveScrollingDirection(Dali::PanGestureDetector::DIRECTION_VERTICAL); + // When the horizontal direction is removed, there are no directions set and therefore all will work + scrollView.SetScrollingDirection(Dali::PanGestureDetector::DIRECTION_HORIZONTAL); - scrollView.ScrollTo(Vector2(10.0f, 10.0f), 0.0f); - Wait(application); + time += Wait(application); // Try a vertical swipe. - PerformGestureDiagonalSwipe(application, START_POSITION, Vector2(0.0f, 1.0f), 60, true); - // Take into account resampling done when prediction is off. + Vector2 pos2( pos + Vector2(0.0f, 15.0f) ); + TestStartPan( application, pos, pos2, time ); + time += Wait(application); + for( int i = 0; i<45; i++ ) + { + pos2 += Vector2(0.0f, 1.0f); + TestMovePan( application, pos2, time ); + time += Wait( application ); + } + pos2 += Vector2(0.0f, 1.0f); + TestEndPan( application, pos2, time ); + + // The previous scroll should not have had any effect DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition() - Vector2(0.0f, 0.5f), Vector2(10.0f, -50.0f), 0.25f, TEST_LOCATION ); END_TEST; @@ -2642,19 +2772,20 @@ int UtcDaliToolkitScrollViewGesturePageLimit(void) // Force starting position. scrollView.ScrollTo( startPos, 0.0f ); - Wait( application ); + uint32_t time = 0; + time += Wait( application ); // Deliberately skip the "Finished" part of the gesture, so we can read the coordinates before the snap begins. - Vector2 currentPos( PerformGestureDiagonalSwipe( application, startPos, direction, frames - 1, false ) ); + Vector2 currentPos( PerformGestureSwipe( application, startPos, direction, frames - 1, time, false ) ); // Confirm the final X coord has not moved more than one page from the start X position. DALI_TEST_GREATER( ( startPos.x + pageSize.width ), scrollView.GetCurrentScrollPosition().x, TEST_LOCATION ); // Finish the gesture and wait for the snap. currentPos += direction; - SendPan( application, Gesture::Finished, currentPos ); + TestEndPan(application, currentPos, time); // We add RENDER_FRAME_INTERVAL on to wait for an extra frame (for the last "finished" gesture to complete first. - Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); + time += Wait( application, RENDER_DELAY_SCROLL + RENDER_FRAME_INTERVAL ); // Confirm the final X coord has snapped to exactly one page ahead of the start page. DALI_TEST_EQUALS( pageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp index 438a496..f15a256 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollViewEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -25,7 +25,6 @@ #include #include #include -#include using namespace Dali; using namespace Toolkit; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp index 9cd92ca..d7adf0e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,7 +20,6 @@ #include #include #include -#include using namespace Dali; using namespace Dali::Toolkit; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 251b339..f56c3c1 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -23,9 +23,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -159,51 +156,6 @@ static void TestInputStyleChangedCallback( TextEditor control, TextEditor::Input gInputStyleMask = mask; } -// Generate a TapGestureEvent to send to Core. -Integration::TapGestureEvent GenerateTap( - Gesture::State state, - unsigned int numberOfTaps, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::TapGestureEvent tap( state ); - - tap.numberOfTaps = numberOfTaps; - tap.numberOfTouches = numberOfTouches; - tap.point = point; - - return tap; -} - -Integration::LongPressGestureEvent GenerateLongPress( - Gesture::State state, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::LongPressGestureEvent longPress( state ); - - longPress.numberOfTouches = numberOfTouches; - longPress.point = point; - return longPress; -} - -// Generate a PanGestureEvent to send to Core -Integration::PanGestureEvent GeneratePan( Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1u ) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - // Generate a KeyEvent to send to Core. Integration::KeyEvent GenerateKey( const std::string& keyName, const std::string& logicalKey, @@ -230,53 +182,6 @@ Integration::KeyEvent GenerateKey( const std::string& keyName, deviceSubclass ); } -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent( GeneratePan( state, last, pos, 16 ) ); - - last.x = pos.x; - last.y = pos.y; -} - -/* - * Simulate time passed by. - * - * @note this will always process at least 1 frame (1/60 sec) - * - * @param application Test application instance - * @param duration Time to pass in milliseconds. - * @return The actual time passed in milliseconds - */ -static int Wait(ToolkitTestApplication& application, int duration = 0) -{ - int time = 0; - - for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++) - { - application.SendNotification(); - application.Render(RENDER_FRAME_INTERVAL); - time += RENDER_FRAME_INTERVAL; - } - - return time; -} - Dali::Integration::Point GetPointDownInside( Vector2& pos ) { Dali::Integration::Point point; @@ -1072,8 +977,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) ); + TestGenerateTap( application, 18.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1100,8 +1004,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) ); + TestGenerateTap( application, 30.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1118,8 +1021,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) ); + TestGenerateTap( application, 43.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1143,8 +1045,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) ); + TestGenerateTap( application, 88.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1177,8 +1078,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) ); + TestGenerateTap( application, 115.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1195,8 +1095,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) ); + TestGenerateTap( application, 164.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1224,8 +1123,7 @@ int utcDaliTextEditorInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) ); + TestGenerateTap( application, 191.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1295,10 +1193,8 @@ int utcDaliTextEditorInputStyleChanged02(void) inputStyleChangedSignal = false; // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) ); + TestGenerateTap( application, 53.0f, 25.0f, 100 ); + TestGenerateTap( application, 53.0f, 25.0f, 200 ); // Render and notify application.SendNotification(); @@ -1426,8 +1322,7 @@ int utcDaliTextEditorInputStyleChanged02(void) DALI_TEST_CHECK( !inputStyleChangedSignal ); // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) ); + TestGenerateTap( application, 63.0f, 25.0f, 900 ); // Render and notify application.SendNotification(); @@ -1469,8 +1364,7 @@ int utcDaliTextEditorInputStyleChanged02(void) editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet ); // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) ); + TestGenerateTap( application, 30.0f, 25.0f, 1500 ); // Render and notify application.SendNotification(); @@ -1530,8 +1424,7 @@ int utcDaliTextEditorEvent01(void) DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1562,8 +1455,7 @@ int utcDaliTextEditorEvent01(void) application.Render(); // Create a tap event on the second text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); + TestGenerateTap( application, 150.0f, 125.0f ); // Render and notify application.SendNotification(); @@ -1613,8 +1505,7 @@ int utcDaliTextEditorEvent02(void) Actor stencil = editor.GetChildAt( 0u ); // Create a tap event to touch the text editor. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f, 100 ); // Render and notify application.SendNotification(); @@ -1677,8 +1568,7 @@ int utcDaliTextEditorEvent02(void) // Send some taps and check the cursor positions. // Try to tap at the beginning. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f, 700 ); // Render and notify application.SendNotification(); @@ -1690,8 +1580,7 @@ int utcDaliTextEditorEvent02(void) DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2. // Tap away from the start position. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) ); + TestGenerateTap( application, 16.0f, 25.0f, 1400 ); // Render and notify application.SendNotification(); @@ -1749,8 +1638,7 @@ int utcDaliTextEditorEvent03(void) // Send some taps and check text controller with clipboard window Dali::Clipboard clipboard = Clipboard::Get(); clipboard.ShowClipboard(); - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 100 ); clipboard.HideClipboard(); // Render and notify @@ -1758,16 +1646,14 @@ int utcDaliTextEditorEvent03(void) application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 1000 ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 1100 ); // Render and notify application.SendNotification(); @@ -1789,8 +1675,8 @@ int utcDaliTextEditorEvent03(void) } // Double tap out of bounds - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) ); + TestGenerateTap( application, 29.0f, 25.0f, 1700 ); + TestGenerateTap( application, 29.0f, 25.0f, 1800 ); // Render and notify application.SendNotification(); @@ -1808,8 +1694,7 @@ int utcDaliTextEditorEvent03(void) } // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress(application, 1.0f, 25.0f); // Render and notify application.SendNotification(); @@ -1844,8 +1729,7 @@ int utcDaliTextEditorEvent04(void) application.Render(); // Tap on the text editor - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1939,8 +1823,7 @@ int utcDaliTextEditorEvent05(void) application.Render(); // Tap on the text editor - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2017,8 +1900,7 @@ int utcDaliTextEditorEvent06(void) application.Render(); // Tap on the text editor - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2108,8 +1990,7 @@ int utcDaliTextEditorEvent07(void) application.Render(); // Tap on the text editor - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2253,8 +2134,7 @@ int utcDaliTextEditorEvent08(void) application.Render(); // Tap on the text editor - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2461,16 +2341,14 @@ int utcDaliTextEditorHandles(void) application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 100 ); // Render and notify application.SendNotification(); application.Render(); // Tap to create the grab handle. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 700 ); // Render and notify application.SendNotification(); @@ -2498,22 +2376,6 @@ int utcDaliTextEditorHandles(void) application.SendNotification(); application.Render(); - // drag grab handle right - SendPan(application, Gesture::Possible, touchPos); - SendPan(application, Gesture::Started, touchPos); - touchPos.x += 5.0f; - Wait(application, 100); - - for(int i = 0;i<20;i++) - { - SendPan(application, Gesture::Continuing, touchPos); - touchPos.x += 5.0f; - Wait(application); - } - - SendPan(application, Gesture::Finished, touchPos); - Wait(application); - // Release the grab handle. event = Dali::Integration::TouchEvent(); event.AddPoint( GetPointUpInside( touchPos ) ); @@ -2524,16 +2386,14 @@ int utcDaliTextEditorHandles(void) application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 1400 ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word and create the selection handles. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f, 1500 ); // Render and notify application.SendNotification(); @@ -2550,22 +2410,6 @@ int utcDaliTextEditorHandles(void) application.SendNotification(); application.Render(); - // drag the left selection handle right - SendPan(application, Gesture::Possible, touchPos); - SendPan(application, Gesture::Started, touchPos); - touchPos.x += 5.0f; - Wait(application, 100); - - for(int i = 0;i<20;i++) - { - SendPan(application, Gesture::Continuing, touchPos); - touchPos.x += 5.0f; - Wait(application); - } - - SendPan(application, Gesture::Finished, touchPos); - Wait(application); - // Release the left selection handle. event = Dali::Integration::TouchEvent(); event.AddPoint( GetPointUpInside( touchPos ) ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 4c126be..9ff0f65 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -21,10 +21,8 @@ #include #include -#include #include -#include -#include + #include #include #include @@ -150,48 +148,6 @@ static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField) textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap ); } -// Generate a PanGestureEvent to send to Core -static Integration::PanGestureEvent GeneratePan( - Gesture::State state, - const Vector2& previousPosition, - const Vector2& currentPosition, - unsigned long timeDelta, - unsigned int numberOfTouches = 1) -{ - Integration::PanGestureEvent pan(state); - - pan.previousPosition = previousPosition; - pan.currentPosition = currentPosition; - pan.timeDelta = timeDelta; - pan.numberOfTouches = numberOfTouches; - - return pan; -} - -/** - * Helper to generate PanGestureEvent - * - * @param[in] application Application instance - * @param[in] state The Gesture State - * @param[in] pos The current position of touch. - */ -static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) -{ - static Vector2 last; - - if( (state == Gesture::Started) || - (state == Gesture::Possible) ) - { - last.x = pos.x; - last.y = pos.y; - } - - application.ProcessEvent(GeneratePan(state, last, pos, 16)); - - last.x = pos.x; - last.y = pos.y; -} - /* * Simulate time passed by. * @@ -267,34 +223,6 @@ static void TestInputStyleChangedCallback( TextField control, TextField::InputSt gInputStyleMask = mask; } -// Generate a TapGestureEvent to send to Core. -Integration::TapGestureEvent GenerateTap( - Gesture::State state, - unsigned int numberOfTaps, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::TapGestureEvent tap( state ); - - tap.numberOfTaps = numberOfTaps; - tap.numberOfTouches = numberOfTouches; - tap.point = point; - - return tap; -} - -Integration::LongPressGestureEvent GenerateLongPress( - Gesture::State state, - unsigned int numberOfTouches, - Vector2 point) -{ - Integration::LongPressGestureEvent longPress( state ); - - longPress.numberOfTouches = numberOfTouches; - longPress.point = point; - return longPress; -} - // Generate a KeyEvent to send to Core. Integration::KeyEvent GenerateKey( const std::string& keyName, const std::string& logicalKey, @@ -1216,8 +1144,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) ); + TestGenerateTap( application, 18.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1244,8 +1171,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) ); + TestGenerateTap( application, 30.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1262,8 +1188,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) ); + TestGenerateTap( application, 43.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1287,8 +1212,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) ); + TestGenerateTap( application, 88.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1320,8 +1244,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) ); + TestGenerateTap( application, 115.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1338,8 +1261,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) ); + TestGenerateTap( application, 164.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1363,8 +1285,7 @@ int utcDaliTextFieldInputStyleChanged01(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) ); + TestGenerateTap( application, 191.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1406,7 +1327,6 @@ int utcDaliTextFieldInputStyleChanged02(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -1434,10 +1354,8 @@ int utcDaliTextFieldInputStyleChanged02(void) inputStyleChangedSignal = false; // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) ); + TestGenerateTap( application, 53.0f, 25.0f, 100 ); + TestGenerateTap( application, 53.0f, 25.0f, 200 ); // Render and notify application.SendNotification(); @@ -1562,8 +1480,7 @@ int utcDaliTextFieldInputStyleChanged02(void) DALI_TEST_CHECK( !inputStyleChangedSignal ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) ); + TestGenerateTap( application, 63.0f, 25.0f, 300 ); // Render and notify application.SendNotification(); @@ -1610,6 +1527,10 @@ int utcDaliTextFieldEvent01(void) field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + // Render and notify + application.SendNotification(); + application.Render(); + // Avoid a crash when core load gl resources. application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); @@ -1627,8 +1548,7 @@ int utcDaliTextFieldEvent01(void) DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1655,8 +1575,8 @@ int utcDaliTextFieldEvent01(void) field2.SetParentOrigin( ParentOrigin::TOP_LEFT ); field2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - field2.SetSize( 100.f, 100.f ); - field2.SetPosition( 100.f, 100.f ); + field2.SetSize( 100.f, 100.0f ); + field2.SetPosition( 100.0f, 100.0f ); Stage::GetCurrent().Add( field2 ); @@ -1665,8 +1585,7 @@ int utcDaliTextFieldEvent01(void) application.Render(); // Create a tap event on the second text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); + TestGenerateTap( application, 150.0f, 125.0f ); // Render and notify application.SendNotification(); @@ -1700,7 +1619,7 @@ int utcDaliTextFieldEvent02(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -1718,8 +1637,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f, 300 ); // Render and notify application.SendNotification(); @@ -1788,8 +1706,7 @@ int utcDaliTextFieldEvent02(void) // Send some taps and check the cursor positions. // Try to tap at the beginning. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f, 900 ); // Render and notify application.SendNotification(); @@ -1801,8 +1718,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2. // Tap away from the start position. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) ); + TestGenerateTap( application, 16.0f, 25.0f, 1500 ); // Render and notify application.SendNotification(); @@ -1869,16 +1785,14 @@ int utcDaliTextFieldEvent03(void) application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) ); + TestGenerateTap( application, 3.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -1930,32 +1844,28 @@ int utcDaliTextFieldEvent04(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap grab handle - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 0.f, 40.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 0.f, 40.0f ) ) ); + TestGenerateTap( application, 0.0f, 40.0f ); END_TEST; } @@ -1987,45 +1897,25 @@ int utcDaliTextFieldEvent05(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); - // drag grab handle right - Vector2 pos(0.0f, 40.0f); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); - pos.x += 5.0f; - Wait(application, 100); - - for(int i = 0;i<20;i++) - { - SendPan(application, Gesture::Continuing, pos); - pos.x += 5.0f; - Wait(application); - } - - SendPan(application, Gesture::Finished, pos); - Wait(application, RENDER_FRAME_INTERVAL); - Actor stencil = field.GetChildAt( 1u ); END_TEST; } @@ -2058,24 +1948,21 @@ int utcDaliTextFieldEvent06(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress(application, 1.0f, 25.0f); // Render and notify application.SendNotification(); @@ -2115,8 +2002,7 @@ int utcDaliTextFieldEvent07(void) application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress(application, 1.0f, 25.0f); // Render and notify application.SendNotification(); @@ -2156,8 +2042,7 @@ int utcDaliTextFieldEvent08(void) application.Render(); // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress( application, 1.0f, 25.0f, 20 ); // Render and notify application.SendNotification(); @@ -2165,12 +2050,12 @@ int utcDaliTextFieldEvent08(void) Wait(application, 500); + TestEndLongPress( application, 1.0f, 25.0f, 520 ); + // Long Press - application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateLongPress( application, 1.0f, 25.0f, 600 ); // Render and notify - application.SendNotification(); application.Render(); Wait(application, 500); @@ -2222,8 +2107,7 @@ int utcDaliTextFieldEvent09(void) application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); application.SendNotification(); application.Render(); @@ -2313,24 +2197,21 @@ int utcDaliTextFieldStyleWhilstSelected(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2429,8 +2310,7 @@ int utcDaliTextFieldEscKeyLoseFocus(void) DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2501,24 +2381,21 @@ int utcDaliTextFieldSomeSpecialKeys(void) application.Render(); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Tap first to get the focus. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); application.Render(); // Double tap to select a word. - application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 1.f, 25.0f ) ) ); + TestGenerateTap( application, 1.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2772,7 +2649,7 @@ int UtcDaliTextFieldEnableShiftSelectionProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2800,7 +2677,7 @@ int UtcDaliTextFieldEnableGrabHandleProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2828,7 +2705,7 @@ int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( field ); @@ -2861,7 +2738,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) Stage::GetCurrent().Add( field ); - field.SetSize( 300.f, 50.f ); + field.SetSize( 300.0f, 50.0f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -2877,8 +2754,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2892,8 +2768,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2903,8 +2778,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); @@ -2914,8 +2788,7 @@ int utcDaliTextFieldLayoutDirectionCoverage(void) field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END"); // Create a tap event to touch the text field. - application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); - application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); + TestGenerateTap( application, 150.0f, 25.0f ); // Render and notify application.SendNotification(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp index cd49363..bb9e279 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-WebView.cpp @@ -39,6 +39,7 @@ const char* const TEST_URL2( "http://www.somewhere.valid2.com" ); static int gPageLoadStartedCallbackCalled = 0; static int gPageLoadFinishedCallbackCalled = 0; +static int gEvaluateJavaScriptCallbackCalled = 0; static bool gTouched = false; struct CallbackFunctor @@ -65,6 +66,15 @@ static void OnPageLoadFinished( WebView view, const std::string& url ) gPageLoadFinishedCallbackCalled++; } +static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode ) +{ +} + +static void OnEvaluateJavaScript( const std::string& result ) +{ + gEvaluateJavaScriptCallbackCalled++; +} + static bool OnTouched( Actor actor, const Dali::TouchData& touch ) { gTouched = true; @@ -146,6 +156,7 @@ int UtcDaliWebViewPageNavigation(void) ConnectionTracker* testTracker = new ConnectionTracker(); view.PageLoadStartedSignal().Connect( &OnPageLoadStarted ); view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished ); + view.PageLoadErrorSignal().Connect( &OnPageLoadError ); bool signal1 = false; bool signal2 = false; bool signal3 = false; @@ -159,7 +170,6 @@ int UtcDaliWebViewPageNavigation(void) view.LoadUrl( TEST_URL1 ); view.GetNaturalSize(); Test::EmitGlobalTimerSignal(); - DALI_TEST_CHECK( view.GetUrl().find( TEST_URL1 ) != std::string::npos ); DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION ); DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION ); DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION ); @@ -167,11 +177,12 @@ int UtcDaliWebViewPageNavigation(void) DALI_TEST_CHECK( !signal3 ); view.LoadUrl( TEST_URL2 ); + view.Suspend(); view.SetSize( 400, 300 ); application.SendNotification(); application.Render(); Test::EmitGlobalTimerSignal(); - DALI_TEST_CHECK( view.GetUrl().find( TEST_URL2 ) != std::string::npos ); + view.Resume(); DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION ); DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION ); DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION ); @@ -191,6 +202,7 @@ int UtcDaliWebViewPageNavigation(void) view.StopLoading(); view.ClearHistory(); view.ClearCache(); + view.ClearCookies(); Test::EmitGlobalTimerSignal(); DALI_TEST_CHECK( !view.CanGoBack() ); DALI_TEST_CHECK( !view.CanGoForward() ); @@ -244,6 +256,7 @@ int UtcDaliWebViewTouchAndKeys(void) int UtcDaliWebViewProperty1(void) { + // URL ToolkitTestApplication application; WebView view = WebView::New(); @@ -258,6 +271,217 @@ int UtcDaliWebViewProperty1(void) END_TEST; } +int UtcDaliWebViewProperty2(void) +{ + // CACHE_MODEL + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const std::string kDefaultValue = "DOCUMENT_VIEWER"; + const WebView::CacheModel::Type kTestEnum = WebView::CacheModel::PRIMARY_WEB_BROWSER; + const std::string kTestValue = "PRIMARY_WEB_BROWSER"; + + // Check default value + std::string output; + Property::Value value = view.GetProperty( WebView::Property::CACHE_MODEL ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::CACHE_MODEL, kTestEnum ); + value = view.GetProperty( WebView::Property::CACHE_MODEL ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + view.SetProperty( WebView::Property::CACHE_MODEL, kTestValue ); + value = view.GetProperty( WebView::Property::CACHE_MODEL ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty3(void) +{ + // COOKIE_ACCEPT_POLICY + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const std::string kDefaultValue = "NO_THIRD_PARTY"; + const WebView::CookieAcceptPolicy::Type kTestEnum = WebView::CookieAcceptPolicy::NEVER; + const std::string kTestValue = "NEVER"; + + // Check default value + std::string output; + Property::Value value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestEnum ); + value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + view.SetProperty( WebView::Property::COOKIE_ACCEPT_POLICY, kTestValue ); + value = view.GetProperty( WebView::Property::COOKIE_ACCEPT_POLICY ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty4(void) +{ + // USER_AGENT + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const std::string kDefaultValue; + const std::string kTestValue = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"; + + // Check default value + std::string output; + Property::Value value = view.GetProperty( WebView::Property::USER_AGENT ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::USER_AGENT, kTestValue ); + value = view.GetProperty( WebView::Property::USER_AGENT ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty5(void) +{ + // ENABLE_JAVASCRIPT + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const bool kDefaultValue = true; + const bool kTestValue = false; + + // Check default value + bool output; + Property::Value value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::ENABLE_JAVASCRIPT, kTestValue ); + value = view.GetProperty( WebView::Property::ENABLE_JAVASCRIPT ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty6(void) +{ + // LOAD_IMAGES_AUTOMATICALLY + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const bool kDefaultValue = true; + const bool kTestValue = false; + + // Check default value + bool output; + Property::Value value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY, kTestValue ); + value = view.GetProperty( WebView::Property::LOAD_IMAGES_AUTOMATICALLY ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty7(void) +{ + // DEFAULT_TEXT_ENCODING_NAME + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const std::string kDefaultValue; + const std::string kTestValue = "UTF-8"; + + // Check default value + std::string output; + Property::Value value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME, kTestValue ); + value = view.GetProperty( WebView::Property::DEFAULT_TEXT_ENCODING_NAME ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewProperty8(void) +{ + // DEFAULT_FONT_SIZE + ToolkitTestApplication application; + + WebView view = WebView::New(); + DALI_TEST_CHECK( view ); + + const int kDefaultValue = 16; + const int kTestValue = 26; + + // Check default value + int output; + Property::Value value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kDefaultValue, TEST_LOCATION ); + + // Check Set/GetProperty + view.SetProperty( WebView::Property::DEFAULT_FONT_SIZE, kTestValue ); + value = view.GetProperty( WebView::Property::DEFAULT_FONT_SIZE ); + DALI_TEST_CHECK( value.Get( output ) ); + DALI_TEST_EQUALS( output, kTestValue, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliWebViewEvaluteJavaScript(void) +{ + ToolkitTestApplication application; + + WebView view = WebView::New( "ko-KR", "Asia/Seoul" ); + + view.LoadHTMLString( "Hello World!" ); + view.EvaluateJavaScript( "jsObject.postMessage('Hello')" ); + view.EvaluateJavaScript( "jsObject.postMessage('World')", OnEvaluateJavaScript ); + Test::EmitGlobalTimerSignal(); + + DALI_TEST_EQUALS( gEvaluateJavaScriptCallbackCalled, 1, TEST_LOCATION ); + + END_TEST; +} + + int UtcDaliWebViewMethodsForCoverage(void) { ToolkitTestApplication application; @@ -269,7 +493,6 @@ int UtcDaliWebViewMethodsForCoverage(void) []( const std::string& arg ) { } ); - view.EvaluateJavaScript( "jsObject.postMessage('Hello')" ); DALI_TEST_CHECK( view ); diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.cpp b/dali-toolkit/devel-api/controls/web-view/web-view.cpp index 0d1c680..20ae948 100644 --- a/dali-toolkit/devel-api/controls/web-view/web-view.cpp +++ b/dali-toolkit/devel-api/controls/web-view/web-view.cpp @@ -70,11 +70,6 @@ void WebView::LoadUrl( const std::string& url ) Dali::Toolkit::GetImpl( *this ).LoadUrl( url ); } -const std::string& WebView::GetUrl() -{ - return Dali::Toolkit::GetImpl( *this ).GetUrl(); -} - void WebView::LoadHTMLString( const std::string& htmlString ) { Dali::Toolkit::GetImpl( *this ).LoadHTMLString( htmlString ); @@ -90,6 +85,16 @@ void WebView::StopLoading() Dali::Toolkit::GetImpl( *this ).StopLoading(); } +void WebView::Suspend() +{ + Dali::Toolkit::GetImpl( *this ).Suspend(); +} + +void WebView::Resume() +{ + Dali::Toolkit::GetImpl( *this ).Resume(); +} + bool WebView::CanGoForward() { return Dali::Toolkit::GetImpl( *this ).CanGoForward(); @@ -110,9 +115,14 @@ void WebView::GoBack() Dali::Toolkit::GetImpl( *this ).GoBack(); } +void WebView::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) +{ + Dali::Toolkit::GetImpl( *this ).EvaluateJavaScript( script, resultHandler ); +} + void WebView::EvaluateJavaScript( const std::string& script ) { - Dali::Toolkit::GetImpl( *this ).EvaluateJavaScript( script ); + Dali::Toolkit::GetImpl( *this ).EvaluateJavaScript( script, nullptr ); } void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) @@ -130,16 +140,26 @@ void WebView::ClearCache() Dali::Toolkit::GetImpl( *this ).ClearCache(); } -WebView::WebViewSignalType& WebView::PageLoadStartedSignal() +void WebView::ClearCookies() +{ + Dali::Toolkit::GetImpl( *this ).ClearCookies(); +} + +WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal() { return Dali::Toolkit::GetImpl( *this ).PageLoadStartedSignal(); } -WebView::WebViewSignalType& WebView::PageLoadFinishedSignal() +WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal() { return Dali::Toolkit::GetImpl( *this ).PageLoadFinishedSignal(); } +WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal() +{ + return Dali::Toolkit::GetImpl( *this ).PageLoadErrorSignal(); +} + WebView::WebView( Internal::WebView& implementation ) : Control( implementation ) { diff --git a/dali-toolkit/devel-api/controls/web-view/web-view.h b/dali-toolkit/devel-api/controls/web-view/web-view.h index 8d33f3a..ad39718 100644 --- a/dali-toolkit/devel-api/controls/web-view/web-view.h +++ b/dali-toolkit/devel-api/controls/web-view/web-view.h @@ -53,6 +53,60 @@ class DALI_TOOLKIT_API WebView : public Control public: /** + * @brief A structure used to contain the cache model enumeration. + */ + struct CacheModel + { + /** + * @brief Enumeration for cache model options. + */ + enum Type + { + /** + * @brief Use the smallest cache capacity. + */ + DOCUMENT_VIEWER, + + /** + * @brief Use the bigger cache capacity than DocumentBrowser. + */ + DOCUMENT_BROWSER, + + /** + * @brief Use the biggest cache capacity. + */ + PRIMARY_WEB_BROWSER + }; + }; + + /** + * @brief A structure used to contain the cookie acceptance policy enumeration. + */ + struct CookieAcceptPolicy + { + /** + * @brief Enumeration for the cookies accept policies. + */ + enum Type + { + /** + * @brief Accepts every cookie sent from any page. + */ + ALWAYS, + + /** + * @brief Rejects all the cookies. + */ + NEVER, + + /** + * @brief Accepts only cookies set by the main document that is loaded. + */ + NO_THIRD_PARTY + }; + }; + + /** * @brief Enumeration for the start and end property ranges for this control. */ enum PropertyRange @@ -69,15 +123,153 @@ public: enum { /** - * @brief name "url", type string - * - * @details Sets the url to load + * @brief The url to load. + * @details name "url", type Property::STRING. + */ + URL = PROPERTY_START_INDEX, + + /** + * @brief The cache model. + * @details Name "cacheModel", type WebView::CacheModel::Type (Property::INTEGER) or Property::STRING. + * @note Default is WebView::CacheModel::DOCUMENT_VIEWER. + * @see WebView::CacheModel::Type + */ + CACHE_MODEL, + + /** + * @brief The cookie acceptance policy. + * @details Name "cookieAcceptPolicy", type WebView::CookieAcceptPolicy::Type (Property::INTEGER) or Property::STRING. + * @note Default is WebView::CookieAcceptPolicy::NO_THIRD_PARTY. + * @see WebView::CookieAcceptPolicy::Type + */ + COOKIE_ACCEPT_POLICY, + + /** + * @brief The user agent string. + * @details Name "userAgent", type Property::STRING. + */ + USER_AGENT, + + /** + * @brief Whether JavaScript is enabled. + * @details Name "enableJavaScript", type Property::BOOLEAN. + * @note Default is true. */ - URL = PROPERTY_START_INDEX + ENABLE_JAVASCRIPT, + + /** + * @brief Whether images can be loaded automatically. + * @details Name "loadImagesAutomatically", type Property::BOOLEAN. + * @note Default is true. + */ + LOAD_IMAGES_AUTOMATICALLY, + + /** + * @brief The default text encoding name. + * @details Name "defaultTextEncodingName", type Property::STRING. + * @note If the value is not set, the web engine detects web page's text encoding. + */ + DEFAULT_TEXT_ENCODING_NAME, + + /** + * @brief The default font size in pixel. + * @details Name "defaultFontSize", type Property::INT. + * @note Default is 16. + */ + DEFAULT_FONT_SIZE }; }; - typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType; + /** + * @brief Enumeration for indicating error code of page loading. + */ + enum class LoadErrorCode + { + /** + * @brief Unknown. + */ + UNKNOWN = 0, + + /** + * @brief User canceled. + */ + CANCELED, + + /** + * @brief Can't show the page for this MIME type. + */ + CANT_SUPPORT_MIMETYPE, + + /** + * @brief File IO error. + */ + FAILED_FILE_IO, + + /** + * @brief Cannot connect to the network. + */ + CANT_CONNECT, + + /** + * @brief Fail to look up host from the DNS. + */ + CANT_LOOKUP_HOST, + + /** + * @brief Fail to SSL/TLS handshake. + */ + FAILED_TLS_HANDSHAKE, + + /** + * @brief Received certificate is invalid. + */ + INVALID_CERTIFICATE, + + /** + * @brief Connection timeout. + */ + REQUEST_TIMEOUT, + + /** + * @brief Too many redirects. + */ + TOO_MANY_REDIRECTS, + + /** + * @brief Too many requests during this load. + */ + TOO_MANY_REQUESTS, + + /** + * @brief Malformed URL. + */ + BAD_URL, + + /** + * @brief Unsupported scheme. + */ + UNSUPPORTED_SCHEME, + + /** + * @brief User authentication failed on the server. + */ + AUTHENTICATION, + + /** + * @brief Web server has an internal server error. + */ + INTERNAL_SERVER + }; + + /** + * @brief WebView signal type related with page loading. + */ + typedef Signal< void ( WebView, const std::string& ) > WebViewPageLoadSignalType; + + /** + * @brief WebView signal type related with page loading error. + */ + typedef Signal< void ( WebView, const std::string&, LoadErrorCode ) > WebViewPageLoadErrorSignalType; public: @@ -143,13 +335,6 @@ public: void LoadUrl( const std::string& url ); /** - * @brief Returns the URL of the Web. - * - * @return Url of string type - */ - const std::string& GetUrl(); - - /** * @brief Loads a given string as web contents. * * @param [in] htmlString The string to use as the contents of the web page @@ -167,6 +352,16 @@ public: void StopLoading(); /** + * @brief Suspends the operation associated with the view. + */ + void Suspend(); + + /** + * @brief Resumes the operation associated with the view object after calling Suspend(). + */ + void Resume(); + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -194,6 +389,14 @@ public: * @brief Evaluates JavaScript code represented as a string. * * @param[in] script The JavaScript code + * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result. + */ + void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ); + + /** + * @brief Evaluates JavaScript code represented as a string. + * + * @param[in] script The JavaScript code */ void EvaluateJavaScript( const std::string& script ); @@ -234,18 +437,30 @@ public: void ClearCache(); /** + * @brief Clears all the cookies of Web. + */ + void ClearCookies(); + + /** * @brief Connects to this signal to be notified when page loading is started. * * @return A signal object to connect with */ - WebViewSignalType& PageLoadStartedSignal(); + WebViewPageLoadSignalType& PageLoadStartedSignal(); /** * @brief Connects to this signal to be notified when page loading is finished. * * @return A signal object to connect with */ - WebViewSignalType& PageLoadFinishedSignal(); + WebViewPageLoadSignalType& PageLoadFinishedSignal(); + + /** + * @brief Connects to this signal to be notified when an error occurs in page loading. + * + * @return A signal object to connect with. + */ + WebViewPageLoadErrorSignalType& PageLoadErrorSignal(); public: // Not intended for application developers diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp index aee1bc0..9eeab0e 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -1298,11 +1298,11 @@ bool AccessibilityManager::AccessibilityActionTouch(const TouchEvent& touchEvent return handled; } -bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent) +bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& panEvent) { bool handled = false; - if( panEvent.state == Gesture::Started ) + if( panEvent.state == AccessibilityGestureEvent::Started ) { // Find the focusable actor at the event position Dali::HitTestAlgorithm::Results results; @@ -1319,7 +1319,7 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& // Gesture::Finished (Up) events are delivered with previous (Motion) event position // Use the real previous position; otherwise we may incorrectly get a ZERO velocity - if ( Gesture::Finished != panEvent.state ) + if ( AccessibilityGestureEvent::Finished != panEvent.state ) { // Store the previous position for next Gesture::Finished iteration. mPreviousPosition = panEvent.previousPosition; @@ -1327,7 +1327,8 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& Actor rootActor = Stage::GetCurrent().GetRootLayer(); - Dali::PanGesture pan(panEvent.state); + Dali::PanGesture pan( static_cast(panEvent.state) ); + pan.time = panEvent.time; pan.numberOfTouches = panEvent.numberOfTouches; pan.screenPosition = panEvent.currentPosition; diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h index f794170..d51d753 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__ -#define __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__ +#ifndef DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H +#define DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include // INTERNAL INCLUDES #include @@ -498,7 +498,7 @@ private: * @param[in] panEvent The pan event to be handled. * @return whether the gesture is handled successfully or not. */ - virtual bool HandlePanGesture(const Integration::PanGestureEvent& panEvent); + virtual bool HandlePanGesture(const AccessibilityGestureEvent& panEvent); /** * Change the accessibility status when Accessibility feature(screen-reader) turned on or off. @@ -765,4 +765,4 @@ inline const Internal::AccessibilityManager& GetImpl(const Dali::Toolkit::Access } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__ +#endif // DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index 5836f42..b0d81de 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -20,6 +20,8 @@ // EXTERNAL INCLUDES #include +#include +#include #include #include #include @@ -47,17 +49,45 @@ BaseHandle Create() return Toolkit::WebView::New(); } -DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create ); - -DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL ); - -DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL ); -DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL ); +DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER ) +DALI_ENUM_TO_STRING_TABLE_END( CacheModel ) + +DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER ) +DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY ) +DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy ) + +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create ) + +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel", STRING, CACHE_MODEL ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy", STRING, COOKIE_ACCEPT_POLICY ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent", STRING, USER_AGENT ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript", BOOLEAN, ENABLE_JAVASCRIPT ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING, DEFAULT_TEXT_ENCODING_NAME ) +DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize", INTEGER, DEFAULT_FONT_SIZE ) + +DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL ) +DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL ) +DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadError", PAGE_LOAD_ERROR_SIGNAL ) DALI_TYPE_REGISTRATION_END() +const std::string kEmptyString; + } // anonymous namepsace +#define GET_ENUM_STRING( structName, inputExp ) \ + Scripting::GetLinearEnumerationName< Toolkit::WebView::structName::Type >( static_cast< Toolkit::WebView::structName::Type >( inputExp ), structName##_TABLE, structName##_TABLE_COUNT ) + +#define GET_ENUM_VALUE( structName, inputExp, outputExp ) \ + Scripting::GetEnumerationProperty< Toolkit::WebView::structName::Type >( inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp ) + WebView::WebView( const std::string& locale, const std::string& timezoneId ) : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ), mUrl(), @@ -65,10 +95,13 @@ WebView::WebView( const std::string& locale, const std::string& timezoneId ) mWebViewSize( Stage::GetCurrent().GetSize() ), mWebEngine(), mPageLoadStartedSignal(), - mPageLoadFinishedSignal() + mPageLoadFinishedSignal(), + mPageLoadErrorSignal() { mWebEngine = Dali::WebEngine::New(); - if ( mWebEngine ) + + // WebEngine is empty when it is not properly initialized. + if( mWebEngine ) { mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, locale, timezoneId ); } @@ -106,22 +139,23 @@ void WebView::OnInitialize() Self().SetKeyboardFocusable( true ); Self().TouchSignal().Connect( this, &WebView::OnTouchEvent ); - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted ); mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished ); + mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError ); } } void WebView::LoadUrl( const std::string& url ) { mUrl = url; - if ( mWebEngine ) + if( mWebEngine ) { Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() ); mVisual = Toolkit::VisualFactory::Get().CreateVisual( image ); - if ( mVisual ) + if( mVisual ) { // Clean up previously registered visual and add new one. DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual ); @@ -130,19 +164,14 @@ void WebView::LoadUrl( const std::string& url ) } } -const std::string& WebView::GetUrl() -{ - return mWebEngine ? mWebEngine.GetUrl() : mUrl; -} - void WebView::LoadHTMLString( const std::string& htmlString ) { - if ( mWebEngine ) + if( mWebEngine ) { Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() ); mVisual = Toolkit::VisualFactory::Get().CreateVisual( image ); - if ( mVisual ) + if( mVisual ) { DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual ); mWebEngine.LoadHTMLString( htmlString ); @@ -152,7 +181,7 @@ void WebView::LoadHTMLString( const std::string& htmlString ) void WebView::Reload() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.Reload(); } @@ -160,12 +189,28 @@ void WebView::Reload() void WebView::StopLoading() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.StopLoading(); } } +void WebView::Suspend() +{ + if( mWebEngine ) + { + mWebEngine.Suspend(); + } +} + +void WebView::Resume() +{ + if( mWebEngine ) + { + mWebEngine.Resume(); + } +} + bool WebView::CanGoForward() { return mWebEngine ? mWebEngine.CanGoForward() : false; @@ -173,7 +218,7 @@ bool WebView::CanGoForward() void WebView::GoForward() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.GoForward(); } @@ -186,23 +231,23 @@ bool WebView::CanGoBack() void WebView::GoBack() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.GoBack(); } } -void WebView::EvaluateJavaScript( const std::string& script ) +void WebView::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) { - if ( mWebEngine ) + if( mWebEngine ) { - mWebEngine.EvaluateJavaScript( script ); + mWebEngine.EvaluateJavaScript( script, resultHandler ); } } void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.AddJavaScriptMessageHandler( exposedObjectName, handler ); } @@ -210,7 +255,7 @@ void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, void WebView::ClearHistory() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.ClearHistory(); } @@ -218,22 +263,35 @@ void WebView::ClearHistory() void WebView::ClearCache() { - if ( mWebEngine ) + if( mWebEngine ) { mWebEngine.ClearCache(); } } -Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadStartedSignal() +void WebView::ClearCookies() +{ + if( mWebEngine ) + { + mWebEngine.ClearCookies(); + } +} + +Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal() { return mPageLoadStartedSignal; } -Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadFinishedSignal() +Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal() { return mPageLoadFinishedSignal; } +Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal() +{ + return mPageLoadErrorSignal; +} + void WebView::OnPageLoadStarted( const std::string& url ) { if( !mPageLoadStartedSignal.Empty() ) @@ -252,6 +310,15 @@ void WebView::OnPageLoadFinished( const std::string& url ) } } +void WebView::OnPageLoadError( const std::string& url, int errorCode ) +{ + if( !mPageLoadErrorSignal.Empty() ) + { + Dali::Toolkit::WebView handle( GetOwner() ); + mPageLoadErrorSignal.Emit( handle, url, static_cast< Toolkit::WebView::LoadErrorCode >( errorCode ) ); + } +} + bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { Dali::BaseHandle handle( object ); @@ -269,6 +336,11 @@ bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* t webView.PageLoadFinishedSignal().Connect( tracker, functor ); connected = true; } + else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_ERROR_SIGNAL ) ) + { + webView.PageLoadErrorSignal().Connect( tracker, functor ); + connected = true; + } return connected; } @@ -318,6 +390,65 @@ void WebView::SetProperty( BaseObject* object, Property::Index index, const Prop } break; } + case Toolkit::WebView::Property::CACHE_MODEL: + { + Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel(); + GET_ENUM_VALUE( CacheModel, value, output ); + impl.SetCacheModel( output ); + break; + } + case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY: + { + Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy(); + GET_ENUM_VALUE( CookieAcceptPolicy, value, output ); + impl.SetCookieAcceptPolicy( output ); + break; + } + case Toolkit::WebView::Property::USER_AGENT: + { + std::string input; + if( value.Get( input ) ) + { + impl.SetUserAgent( input ); + } + break; + } + case Toolkit::WebView::Property::ENABLE_JAVASCRIPT: + { + bool input; + if( value.Get( input ) ) + { + impl.EnableJavaScript( input ); + } + break; + } + case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY: + { + bool input; + if( value.Get( input ) ) + { + impl.LoadImagesAutomatically( input ); + } + break; + } + case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME: + { + std::string input; + if( value.Get( input ) ) + { + impl.SetDefaultTextEncodingName( input ); + } + break; + } + case Toolkit::WebView::Property::DEFAULT_FONT_SIZE: + { + int input; + if( value.Get( input ) ) + { + impl.SetDefaultFontSize( input ); + } + break; + } } } } @@ -335,9 +466,46 @@ Property::Value WebView::GetProperty( BaseObject* object, Property::Index proper { case Toolkit::WebView::Property::URL: { - value = impl.GetUrl(); + value = impl.mUrl; + break; + } + case Toolkit::WebView::Property::CACHE_MODEL: + { + value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() ); + break; + } + case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY: + { + value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() ); break; } + case Toolkit::WebView::Property::USER_AGENT: + { + value = impl.GetUserAgent(); + break; + } + case Toolkit::WebView::Property::ENABLE_JAVASCRIPT: + { + value = impl.IsJavaScriptEnabled(); + break; + } + case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY: + { + value = impl.AreImagesAutomaticallyLoaded(); + break; + } + case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME: + { + value = impl.GetDefaultTextEncodingName(); + break; + } + case Toolkit::WebView::Property::DEFAULT_FONT_SIZE: + { + value = impl.GetDefaultFontSize(); + break; + } + default: + break; } } @@ -348,7 +516,7 @@ bool WebView::OnTouchEvent( Actor actor, const Dali::TouchData& touch ) { bool result = false; - if ( mWebEngine ) + if( mWebEngine ) { result = mWebEngine.SendTouchEvent( touch ); } @@ -359,13 +527,107 @@ bool WebView::OnKeyEvent( const Dali::KeyEvent& event ) { bool result = false; - if ( mWebEngine ) + if( mWebEngine ) { result = mWebEngine.SendKeyEvent( event ); } return result; } +Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const +{ + return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER; +} + +void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel ) +{ + if( mWebEngine ) + { + mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) ); + } +} + +Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const +{ + return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY; +} + +void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy ) +{ + if( mWebEngine ) + { + mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) ); + } +} + +const std::string& WebView::GetUserAgent() const +{ + return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString; +} + +void WebView::SetUserAgent( const std::string& userAgent ) +{ + if( mWebEngine ) + { + mWebEngine.SetUserAgent( userAgent ); + } +} + +bool WebView::IsJavaScriptEnabled() const +{ + return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true; +} + +void WebView::EnableJavaScript( bool enabled ) +{ + if( mWebEngine ) + { + mWebEngine.EnableJavaScript( enabled ); + } +} + +bool WebView::AreImagesAutomaticallyLoaded() const +{ + return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true; +} + +void WebView::LoadImagesAutomatically( bool automatic ) +{ + if( mWebEngine ) + { + mWebEngine.LoadImagesAutomatically( automatic ); + } +} + +const std::string& WebView::GetDefaultTextEncodingName() const +{ + return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString; +} + +void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) +{ + if( mWebEngine ) + { + mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName ); + } +} + +int WebView::GetDefaultFontSize() const +{ + return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0; +} + +void WebView::SetDefaultFontSize( int defaultFontSize ) +{ + if( mWebEngine ) + { + mWebEngine.SetDefaultFontSize( defaultFontSize ); + } +} + +#undef GET_ENUM_STRING +#undef GET_ENUM_VALUE + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.h b/dali-toolkit/internal/controls/web-view/web-view-impl.h index 2bc7ddf..bce288d 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.h +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.h @@ -68,74 +68,89 @@ public: void LoadUrl( const std::string& url ); /** - * @copydoc Dali::Toolkit::WebView::GetUrl() - */ - const std::string& GetUrl(); - - /** * @copydoc Dali::WebEngine::LoadHTMLString() */ void LoadHTMLString( const std::string& htmlString ); /** - * @copydoc Dali::WebEngine::Reload() + * @copydoc Dali::Toolkit::WebView::Reload() */ void Reload(); /** - * @copydoc Dali::WebEngine::StopLoading() + * @copydoc Dali::Toolkit::WebView::StopLoading() */ void StopLoading(); /** - * @copydoc Dali::WebEngine::CanGoForward() + * @copydoc Dali::Toolkit::WebView::StopLoading() + */ + void Suspend(); + + /** + * @copydoc Dali::Toolkit::WebView::Resume() + */ + void Resume(); + + /** + * @copydoc Dali::Toolkit::WebView::CanGoForward() */ bool CanGoForward(); /** - * @copydoc Dali::WebEngine::GoForward() + * @copydoc Dali::Toolkit::WebView::GoForward() */ void GoForward(); /** - * @copydoc Dali::WebEngine::CanGoBack() + * @copydoc Dali::Toolkit::WebView::CanGoBack() */ bool CanGoBack(); /** - * @copydoc Dali::WebEngine::GoBack() + * @copydoc Dali::Toolkit::WebView::GoBack() */ void GoBack(); /** - * @copydoc Dali::WebEngine::EvaluateJavaScript() + * @copydoc Dali::Toolkit::WebView::EvaluateJavaScript() */ - void EvaluateJavaScript( const std::string& script ); + void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ); /** - * @copydoc Dali::WebEngine::AddJavaScriptMessageHandler() + * @copydoc Dali::Toolkit::WebView::AddJavaScriptMessageHandler() */ void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ); /** - * @copydoc Dali::WebEngine::ClearHistory() + * @copydoc Dali::Toolkit::WebView::ClearHistory() */ void ClearHistory(); /** - * @copydoc Dali::WebEngine::ClearCache() + * @copydoc Dali::Toolkit::WebView::ClearCache() */ void ClearCache(); /** + * @copydoc Dali::Toolkit::WebView::ClearCookies() + */ + void ClearCookies(); + + /** * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal() */ - Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal(); + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadStartedSignal(); /** * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal() */ - Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal(); + Dali::Toolkit::WebView::WebViewPageLoadSignalType& PageLoadFinishedSignal(); + + /** + * @copydoc Dali::Toolkit::WebView::PageLoadErrorSignal() + */ + Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal(); public: // Properties @@ -205,18 +220,129 @@ private: WebView& operator=( const WebView& webView ); + /** + * @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER. + * @see Toolkit::WebView::CacheModel::Type + */ + Toolkit::WebView::CacheModel::Type GetCacheModel() const; + + /** + * @brief Set cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER. + * @param[in] cacheModel The cache model option + * @see Toolkit::WebView::CacheModel::Type + */ + void SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel ); + + /** + * @brief Gets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY. + * @see Toolkit::WebView::CookieAcceptPolicy::Type + */ + Toolkit::WebView::CookieAcceptPolicy::Type GetCookieAcceptPolicy() const; + + /** + * @brief Sets the cookie acceptance policy. The default is Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY. + * @param[in] policy The cookie acceptance policy + * @see Toolkit::WebView::CookieAcceptPolicy::Type + */ + void SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy ); + + /** + * @brief Get user agent string. + * @return The string value of user agent + */ + const std::string& GetUserAgent() const; + + /** + * @brief Set user agent string. + * @param[in] userAgent The string value of user agent + */ + void SetUserAgent( const std::string& userAgent ); + + /** + * @brief Returns whether JavaScript can be executable. The default is true. + * + * @return true if JavaScript executing is enabled, false otherwise + */ + bool IsJavaScriptEnabled() const; + + /** + * @brief Enables/disables JavaScript executing. The default is enabled. + * + * @param[in] enabled True if JavaScript executing is enabled, false otherwise + */ + void EnableJavaScript( bool enabled ); + + /** + * @brief Returns whether images can be loaded automatically. The default is true. + * + * @return true if images are loaded automatically, false otherwise + */ + bool AreImagesAutomaticallyLoaded() const; + + /** + * @brief Enables/disables auto loading of images. The default is enabled. + * + * @param[in] automatic True if images are loaded automatically, false otherwise + */ + void LoadImagesAutomatically( bool automatic ); + + /** + * @brief Gets the default text encoding name (e.g. UTF-8). + * + * @return The default text encoding name + */ + const std::string& GetDefaultTextEncodingName() const; + + /** + * @brief Sets the default text encoding name (e.g. UTF-8). + * + * @param[in] defaultTextEncodingName The default text encoding name + */ + void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ); + + /** + * @brief Returns the default font size in pixel. The default value is 16. + * + * @return The default font size + */ + int GetDefaultFontSize() const; + + /** + * @brief Sets the default font size in pixel. The default value is 16. + * + * @param[in] defaultFontSize A new default font size to set + */ + void SetDefaultFontSize( int defaultFontSize ); + + /** + * @brief Callback function to be called when page load started. + * @param[in] url The url currently being loaded + */ void OnPageLoadStarted( const std::string& url ); + /** + * @brief Callback function to be called when page load finished. + * @param[in] url The url currently being loaded + */ void OnPageLoadFinished( const std::string& url ); + /** + * @brief Callback function to be called when there is an error in page loading. + * @param[in] url The url currently being loaded + * @param[in] errorCode The error code + */ + void OnPageLoadError( const std::string& url, int errorCode ); + private: - std::string mUrl; - Dali::Toolkit::Visual::Base mVisual; - Dali::Size mWebViewSize; - Dali::WebEngine mWebEngine; - Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal; - Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal; + std::string mUrl; + Dali::Toolkit::Visual::Base mVisual; + Dali::Size mWebViewSize; + Dali::WebEngine mWebEngine; + + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal; + Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal; + Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal; }; } // namespace Internal diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index f41153b..55e6f17 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 4; -const unsigned int TOOLKIT_MICRO_VERSION = 19; +const unsigned int TOOLKIT_MICRO_VERSION = 20; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 2cc7dd7..7001896 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: Dali 3D engine Toolkit -Version: 1.4.19 +Version: 1.4.20 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT