../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
../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
../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
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
-#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.
#include "test-application.h"
#include "test-actor-utils.h"
+#include "test-gesture-generator.h"
using namespace Dali;
} // namespace Test
-#endif // __DALI_TEST_SUITE_UTILS_H__
+#endif // DALI_TEST_SUITE_UTILS_H
mPlatformAbstraction,
mGlAbstraction,
mGlSyncAbstraction,
- mGestureManager,
mDataRetentionPolicy,
Integration::RenderToFrameBuffer::FALSE,
Integration::DepthBufferAvailable::TRUE,
return mGlSyncAbstraction;
}
-TestGestureManager& TestApplication::GetGestureManager()
-{
- return mGestureManager;
-}
-
void TestApplication::ProcessEvent(const Integration::Event& event)
{
mCore->QueueEvent(event);
// INTERNAL INCLUDES
#include <test-platform-abstraction.h>
-#include "test-gesture-manager.h"
#include "test-gl-sync-abstraction.h"
#include "test-gl-abstraction.h"
#include "test-render-controller.h"
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 );
TestRenderController mRenderController;
TestGlAbstraction mGlAbstraction;
TestGlSyncAbstraction mGlSyncAbstraction;
- TestGestureManager mGestureManager;
TestRenderSurface* mRenderSurface;
Integration::UpdateStatus mStatus;
--- /dev/null
+/*
+ * 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 <dali/integration-api/events/touch-event-integ.h>
+
+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
--- /dev/null
+#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
+++ /dev/null
-/*
- * 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
+++ /dev/null
-#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 <dali/integration-api/gesture-manager.h>
-#include <dali/public-api/common/dali-common.h>
-
-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__
/*
- * 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.
mClosestSize(),
mLoadFileResult(),
mSaveFileResult( false ),
- mSynchronouslyLoadedResource()
+ mSynchronouslyLoadedResource(),
+ mTimerId(0),
+ mCallbackFunction(nullptr)
{
Initialize();
}
return mLoadFileResult.loadResult;
}
-
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
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
-#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.
*/
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
*/
void SetDecodedBitmap( Integration::BitmapPtr bitmap );
+ /**
+ * @brief Triggers the previously stored callback function
+ */
+ void TriggerTimer();
+
private:
TestPlatformAbstraction( const TestPlatformAbstraction& ); ///< Undefined
Integration::ResourcePointer mSynchronouslyLoadedResource;
Integration::BitmapPtr mDecodedBitmap;
+
+ uint32_t mTimerId;
+ CallbackBase* mCallbackFunction;
};
} // Dali
-#endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */
+#endif /* DALI_TEST_PLATFORM_ABSTRACTION_H */
/*
- * 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.
*/
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
#include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
#include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
+#include <dali/devel-api/adaptor-framework/accessibility-gesture-event.h>
namespace Dali
{
mIsEnabled = enabled;
}
- void SendPanGesture( const Dali::Integration::PanGestureEvent& panEvent );
+ void SendPanGesture( const AccessibilityGestureEvent& panEvent );
public:
return mIsEnabled;
}
-void AccessibilityAdaptor::SendPanGesture( const Integration::PanGestureEvent& panEvent )
+void AccessibilityAdaptor::SendPanGesture( const AccessibilityGestureEvent& panEvent )
{
mGestureHandler->HandlePanGesture( panEvent );
}
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 );
}
-#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.
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
+#include <dali/devel-api/adaptor-framework/accessibility-gesture-event.h>
namespace Test
{
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
/*
- * 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.
// CLASS HEADER
#include <dali/integration-api/adaptors/adaptor.h>
+#include <dali/integration-api/adaptors/scene-holder.h>
#include <dali/public-api/object/base-object.h>
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()
{
}
{
}
+void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
+{
+}
+
Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
{
return Internal::Adaptor::Adaptor::AdaptorSignal();
{
}
-void Adaptor::SetMinimumPinchDistance(float distance)
-{
-}
-
void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
{
}
bool OnGoBack();
bool OnGoForward();
bool OnLoadUrl();
+bool OnEvaluteJavaScript();
bool OnClearHistory();
static void ConnectToGlobalSignal( bool (*func)() )
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;
virtual ~WebEngine()
{
gInstanceCount--;
- if ( !gInstanceCount )
+ if( !gInstanceCount )
{
gInstance = NULL;
}
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 )
{
DisconnectFromGlobalSignal( &OnGoBack );
- if ( gInstance && gInstance->CanGoBack() )
+ if( gInstance && gInstance->CanGoBack() )
{
gInstance->mCurrentPlusOnePos--;
}
{
DisconnectFromGlobalSignal( &OnGoForward );
- if ( gInstance && gInstance->CanGoForward() )
+ if( gInstance && gInstance->CanGoForward() )
{
gInstance->mCurrentPlusOnePos++;
}
{
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() );
}
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;
}
{
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 );
{
}
+void WebEngine::Suspend()
+{
+}
+
+void WebEngine::Resume()
+{
+}
+
bool WebEngine::CanGoForward()
{
return Internal::Adaptor::GetImplementation( *this ).CanGoForward();
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 )
{
}
+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 )
{
}
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;
/*
- * 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.
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;
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 );
/*
- * 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.
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/wheel-event-integ.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
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<DummyControlImpl&>(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;
}
/*
- * 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.
#include <dali-toolkit/devel-api/drag-drop-detector/drag-and-drop-detector.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Dali::Toolkit;
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)
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;
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));
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));
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));
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));
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();
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));
/*
- * 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.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
+
using namespace Dali;
using namespace Toolkit;
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;
}
/*
// 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;
}
// 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;
#include <string.h>
#include <sstream>
#include <dali-toolkit-test-suite-utils.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
+#include <dali/integration-api/events/touch-event-integ.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-factory.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h>
#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h>
* @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<frames;i++)
{
- pos += direction; // Move in this direction
- SendPan(application, Gesture::Continuing, pos);
- Wait(application);
+ pos += direction;
+ TestMovePan(application, pos, time );
+ time += Wait(application);
}
if(toFinish)
{
- pos += direction; // Move in this direction
- SendPan(application, Gesture::Finished, pos);
- Wait(application);
+ pos += direction;
+ TestEndPan(application, pos, time );
+ time += Wait(application);
}
return pos;
//-----Test 1: pan 10 frames from position(size * 0.75f) to position(size * 0.25f), page 0 will be turned forward----
pageIndex = 0;
isTurningForwards = true;
- // Do a pan moving up diagonally.
+ // Do a pan moving up diagonally
+ uint32_t time = 0;
Vector2 start = size * 0.75f;
Vector2 direction = -size*0.05f; //-size*0.5f/10.f;
DALI_TEST_EQUALS( portraitView.GetProperty(PageTurnView::Property::CURRENT_PAGE_ID).Get<int>(), 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>(), (int)(pageIndex+1), TEST_LOCATION );
//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 );
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>(), (int)pageIndex, TEST_LOCATION ); // the page is not turned over
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 );
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<int>(), 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>(), (int)(pageIndex+1), TEST_LOCATION );
//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<int>(), 0, TEST_LOCATION ); // the first page is turned back
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 );
/*
- * 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.
#include <string>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Toolkit;
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.
*
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;
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 );
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
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 );
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Toolkit;
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.
*
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<frames;i++)
{
pos += direction; // Move in this direction
- SendPan(application, Gesture::Continuing, pos);
- Wait(application);
+ TestMovePan(application, pos, time );
+ time += Wait(application);
}
if(finish)
{
pos += direction; // Move in this direction.
- SendPan(application, Gesture::Finished, pos);
- Wait(application, RENDER_DELAY_SCROLL);
+ TestEndPan(application, pos, time );
+ time += Wait(application, RENDER_DELAY_SCROLL);
}
return pos;
Vector2 startPos( 50.0f, 0.0f );
Vector2 direction( -5.0f, 0.0f );
int frames = 200;
+ uint32_t time = 0;
// Force starting position.
scrollView.ScrollTo( startPos, 0.0f );
- Wait( application );
+ 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 );
Vector2 startPos( 0.0f, 50.0f );
Vector2 direction( 0.0f, -6.0f );
int frames = 200;
+ uint32_t time = 0;
// Force starting position.
scrollView.ScrollTo( startPos, 0.0f );
- Wait( application );
+ 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.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, TEST_LOCATION );
// Finish the gesture and wait for the snap.
currentPos += direction;
- SendPan( application, Gesture::Finished, currentPos );
+ time += Wait( application );
+ 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 );
Vector2 startPos( 0.0f, 50.0f );
Vector2 direction( 0.0f, -6.0f );
int frames = 200;
+ uint32_t time = 0;
// Force starting position.
scrollView.ScrollTo( startPos, 0.0f );
- Wait( application );
+ 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.y + pageSize.height ), scrollView.GetCurrentScrollPosition().y, 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 );
Vector2 START_POSITION = Vector2(10.0f, 10.0f);
+ uint32_t time = 0;
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);
+ // PerformGestureSwipe not used as a different initial direction was required
+ Vector2 pos( START_POSITION + Vector2(0.0f, 15.0f) );
+ Vector2 dir( 0.0f, 1.0f );
+
+ TestStartPan( application, START_POSITION, pos, time );
+
+ Wait(application);
+
+ for( int i = 0; i<45; i++ )
+ {
+ pos += dir;
+ TestMovePan( application, pos, time );
+ time += Wait( application );
+ }
+
+ pos += dir;
+
+ TestEndPan( application, pos, time );
+ Wait( application, RENDER_DELAY_SCROLL );
+
// 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 );
-
END_TEST;
}
// Do a pan starting from 100,100 and moving down diagonally.
Vector2 pos(100.0f, 100.0f);
- SendPan(application, Gesture::Possible, pos);
- SendPan(application, Gesture::Started, pos);
+ uint32_t time = 100;
+ TestStartPan( application, pos, pos, time );
pos.x += 5.0f;
pos.y += 5.0f;
Wait(application, 100);
for(int i = 0;i<20;i++)
{
- SendPan(application, Gesture::Continuing, pos);
+ time += RENDER_FRAME_INTERVAL;
+ TestMovePan( application, pos, time);
pos.x += 5.0f;
pos.y += 5.0f;
Wait(application);
}
- SendPan(application, Gesture::Finished, pos);
+ time += RENDER_FRAME_INTERVAL;
+ TestEndPan(application, pos, time );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_CHECK(gOnScrollStartCalled);
// Do a pan starting from 100,100 and moving down diagonally.
Vector2 pos(100.0f, 100.0f);
- SendPan(application, Gesture::Possible, pos);
- SendPan(application, Gesture::Started, pos);
+ uint32_t time = 100;
+ TestStartPan( application, pos, pos, time );
pos.x += 5.0f;
pos.y += 5.0f;
Wait(application, 100);
for(int i = 0;i<20;i++)
{
- SendPan(application, Gesture::Continuing, pos);
+ time += RENDER_FRAME_INTERVAL;
+ TestMovePan( application, pos, time);
pos.x += 5.0f;
pos.y += 5.0f;
Wait(application);
}
- SendPan(application, Gesture::Finished, pos);
+ time += RENDER_FRAME_INTERVAL;
+ TestEndPan(application, pos, time );
Wait(application, RENDER_DELAY_SCROLL);
DALI_TEST_CHECK(scrollStarted);
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 insensitive swipe.
scrollView.SetScrollSensitive(false);
- PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
+ PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
DALI_TEST_CHECK( !gOnScrollStartCalled );
DALI_TEST_CHECK( !gOnScrollCompleteCalled );
// Second try sensitive swipe.
scrollView.SetScrollSensitive(true);
- PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, true);
+ PerformGestureSwipe(application, CLAMP_TOUCH_START, CLAMP_TOUCH_MOVEMENT, CLAMP_GESTURE_FRAMES, time, true);
DALI_TEST_CHECK( gOnScrollStartCalled );
DALI_TEST_CHECK( gOnScrollCompleteCalled );
// Normal
scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
- Wait(application);
+ uint32_t time = 0;
+ time += Wait(application);
+
Vector2 startPosition = scrollView.GetCurrentScrollPosition();
- PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
+ Vector2 dir(5.0f, 1.0f);
+
+ // PerformGestureSwipe not used as a different initial direction was required
+
+ Vector2 pos( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
+
+ TestStartPan( application, CLAMP_TOUCH_START, pos, time );
+
+ time += Wait(application);
+
+ for( int i = 0; i<47; i++ )
+ {
+ pos += dir;
+ TestMovePan( application, pos, time );
+ time += Wait( application );
+ }
+
+ pos += dir;
+
+ TestEndPan( application, pos, time );
+
const Vector2 positionAfterNormal = scrollView.GetCurrentScrollPosition();
// Autolock
DALI_TEST_CHECK(scrollView.GetAxisAutoLock());
scrollView.ScrollTo(Vector2(100.0f, 100.0f), 0.0f); // move in a little.
- Wait(application);
- PerformGestureDiagonalSwipe(application, CLAMP_TOUCH_START, Vector2(5.0f, 1.0f), 50, true); // mostly horizontal
+ time += Wait(application);
+
+ Vector2 pos2( CLAMP_TOUCH_START + Vector2(15.0f, 3.0f) );
+
+ TestStartPan( application, CLAMP_TOUCH_START, pos2, time );
+
+ time += Wait(application);
+
+ for( int i = 0; i<47; i++ )
+ {
+ pos2 += dir;
+ TestMovePan( application, pos2, time );
+ time += Wait( application );
+ }
+
+ pos2 += dir;
+
+ TestEndPan( application, pos2, time );
+
const Vector2 positionAfterAutoLock = scrollView.GetCurrentScrollPosition();
// compare how much the Y position has deviated for normal and autolock.
ScrollView scrollView = ScrollView::New();
scrollView.SetOvershootEnabled(true);
+ uint32_t time = 0;
Vector2 overshootSize = Vector2(100.0f,100.0f);
scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize );
DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get<Vector2>(), overshootSize, TEST_LOCATION );
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 );
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;
// 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;
// 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;
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;
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 );
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 );
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);
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;
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;
// 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 );
/*
- * 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.
#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Toolkit;
/*
- * 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.
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
using namespace Dali;
using namespace Dali::Toolkit;
#include <dali/devel-api/adaptor-framework/key-devel.h>
#include <dali/integration-api/events/key-event-integ.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
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,
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;
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
DALI_TEST_EQUALS( editor.GetProperty<std::string>( 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();
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();
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();
// 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();
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();
// 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
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();
}
// 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();
}
// 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();
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();
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();
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();
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();
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();
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();
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 ) );
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();
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 ) );
#include <dali/public-api/rendering/renderer.h>
#include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
+
#include <dali/devel-api/adaptor-framework/key-devel.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
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.
*
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,
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();
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();
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();
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();
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();
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();
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();
TextField field = TextField::New();
DALI_TEST_CHECK( field );
-
field.SetSize( 300.f, 50.f );
field.SetParentOrigin( ParentOrigin::TOP_LEFT );
field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
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();
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();
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 );
DALI_TEST_EQUALS( field.GetProperty<std::string>( 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();
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 );
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();
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 );
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();
// 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();
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();
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();
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;
}
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;
}
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();
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();
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();
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);
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();
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();
DALI_TEST_EQUALS( field.GetProperty<std::string>( 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();
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();
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 );
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 );
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 );
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 );
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();
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();
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();
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();
static int gPageLoadStartedCallbackCalled = 0;
static int gPageLoadFinishedCallbackCalled = 0;
+static int gEvaluateJavaScriptCallbackCalled = 0;
static bool gTouched = false;
struct CallbackFunctor
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;
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;
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 );
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 );
view.StopLoading();
view.ClearHistory();
view.ClearCache();
+ view.ClearCookies();
Test::EmitGlobalTimerSignal();
DALI_TEST_CHECK( !view.CanGoBack() );
DALI_TEST_CHECK( !view.CanGoForward() );
int UtcDaliWebViewProperty1(void)
{
+ // URL
ToolkitTestApplication application;
WebView view = WebView::New();
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( "<body>Hello World!</body>" );
+ 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;
[]( const std::string& arg ) {
}
);
- view.EvaluateJavaScript( "jsObject.postMessage('Hello')" );
DALI_TEST_CHECK( view );
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 );
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();
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 )
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 )
{
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
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:
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
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
* @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 );
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
/*
- * 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.
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;
// 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;
Actor rootActor = Stage::GetCurrent().GetRootLayer();
- Dali::PanGesture pan(panEvent.state);
+ Dali::PanGesture pan( static_cast<Dali::Gesture::State>(panEvent.state) );
+
pan.time = panEvent.time;
pan.numberOfTouches = panEvent.numberOfTouches;
pan.screenPosition = panEvent.currentPosition;
-#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.
#include <dali/devel-api/common/map-wrapper.h>
#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
#include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
+#include <dali/devel-api/adaptor-framework/accessibility-gesture-event.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
* @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.
} // namespace Dali
-#endif // __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__
+#endif // DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H
// EXTERNAL INCLUDES
#include <cstring>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/images/native-image.h>
#include <dali/public-api/adaptor-framework/native-image-source.h>
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(),
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 );
}
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 );
}
}
-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 );
void WebView::Reload()
{
- if ( mWebEngine )
+ if( mWebEngine )
{
mWebEngine.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;
void WebView::GoForward()
{
- if ( mWebEngine )
+ if( mWebEngine )
{
mWebEngine.GoForward();
}
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 );
}
void WebView::ClearHistory()
{
- if ( mWebEngine )
+ if( mWebEngine )
{
mWebEngine.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() )
}
}
+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 );
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;
}
}
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;
+ }
}
}
}
{
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;
}
}
{
bool result = false;
- if ( mWebEngine )
+ if( mWebEngine )
{
result = mWebEngine.SendTouchEvent( touch );
}
{
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
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
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
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
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