// test harness headers before dali headers.
#include <dali-toolkit-test-suite-utils.h>
-#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali.h>
-#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/atspi-interfaces/accessible.h>
#include <automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/dbus-wrapper.h>
ToolkitTestApplication application;
auto check_box_button = Toolkit::CheckBoxButton::New();
- auto q = Dali::Accessibility::Accessible::Get( check_box_button );
- DALI_TEST_CHECK( q );
+ auto q = Dali::Accessibility::Accessible::Get(check_box_button);
+ DALI_TEST_CHECK(q);
auto states = q->GetStates();
- DALI_TEST_EQUALS( (int) states[ Dali::Accessibility::State::SELECTABLE ], (int) true, TEST_LOCATION );
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SELECTABLE], (int)true, TEST_LOCATION);
END_TEST;
}
auto check_box_button = Toolkit::CheckBoxButton::New();
//check_box_button.SetLabelText( "button" );
check_box_button.SetProperty(Toolkit::Button::Property::LABEL, "button");
- auto q = Dali::Accessibility::Accessible::Get( check_box_button );
- DALI_TEST_CHECK( q );
- DALI_TEST_EQUALS( q->GetName(), "button", TEST_LOCATION );
+ auto q = Dali::Accessibility::Accessible::Get(check_box_button);
+ DALI_TEST_CHECK(q);
+ DALI_TEST_EQUALS(q->GetName(), "button", TEST_LOCATION);
END_TEST;
}
parentButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
parentButton.SetProperty(Actor::Property::POSITION, Dali::Vector2(0.0f, 0.0f));
parentButton.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
- application.GetScene().Add( parentButton );
+ application.GetScene().Add(parentButton);
// Toatally inside of parent
auto buttonA = Toolkit::PushButton::New();
auto buttonC = Toolkit::PushButton::New();
buttonC.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
buttonC.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- buttonC.SetProperty(Actor::Property::POSITION, Dali::Vector2(100.0f,100.0f));
+ buttonC.SetProperty(Actor::Property::POSITION, Dali::Vector2(100.0f, 100.0f));
buttonC.SetProperty(Actor::Property::SIZE, Dali::Vector2(200.0f, 200.0f));
parentButton.Add(buttonC);
auto q = Dali::Accessibility::Accessible::Get(buttonA);
DALI_TEST_CHECK(q);
auto states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SHOWING], (int)true, TEST_LOCATION);
q = Dali::Accessibility::Accessible::Get(buttonB);
DALI_TEST_CHECK(q);
states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SHOWING], (int)true, TEST_LOCATION);
q = Dali::Accessibility::Accessible::Get(buttonC);
DALI_TEST_CHECK(q);
states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) true, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SHOWING], (int)true, TEST_LOCATION);
// Make SHOWING object invisible
buttonC.SetProperty(Actor::Property::VISIBLE, false);
application.Render(16);
states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SHOWING], (int)false, TEST_LOCATION);
// Make SHOWING parent invisible
parentButton.SetProperty(Actor::Property::VISIBLE, false);
q = Dali::Accessibility::Accessible::Get(buttonA);
DALI_TEST_CHECK(q);
states = q->GetStates();
- DALI_TEST_EQUALS((int) states[Dali::Accessibility::State::SHOWING], (int) false, TEST_LOCATION);
+ DALI_TEST_EQUALS((int)states[Dali::Accessibility::State::SHOWING], (int)false, TEST_LOCATION);
END_TEST;
}
END_TEST;
}
+
+int utcDaliImgSrc(void)
+{
+ ToolkitTestApplication application;
+ const std::string imageSrcKey = "imgSrc";
+ // Check that imgSrc is NOT added for non-image view w/ no additional property
+ {
+ const auto checkBoxButton = Toolkit::CheckBoxButton::New();
+ const auto controlAccessible = Dali::Accessibility::Accessible::Get(checkBoxButton);
+ auto attributes = controlAccessible->GetAttributes();
+ DALI_TEST_CHECK(attributes.find(imageSrcKey) == attributes.end());
+ }
+
+ // Check that imgSrc is NOT added for non-image view w/ additional properties
+ {
+ const auto textLabel = Toolkit::TextLabel::New("Hello");
+ const auto controlAccessible = Dali::Accessibility::Accessible::Get(textLabel);
+ auto attributes = controlAccessible->GetAttributes();
+ DALI_TEST_CHECK(attributes.find(imageSrcKey) == attributes.end());
+ }
+
+ // Check that imgSrc is added for image view w/ Url
+ {
+ const std::string imagePath = "gallery-small-1.jpg";
+ const auto imageView = Toolkit::ImageView::New(imagePath);
+ const auto controlAccessible = Dali::Accessibility::Accessible::Get(imageView);
+ auto attributes = controlAccessible->GetAttributes();
+ DALI_TEST_CHECK(attributes.find(imageSrcKey) != attributes.end());
+ DALI_TEST_EQUALS(attributes[imageSrcKey], imagePath, TEST_LOCATION);
+ }
+
+ // Check that imgSrc is added for image view w/ imageMap; single url case
+ {
+ const std::string imagePathForImageMap = "icon-edit.png";
+ Property::Map imageMap;
+ imageMap[Toolkit::ImageVisual::Property::URL] = imagePathForImageMap;
+ imageMap[Toolkit::ImageVisual::Property::RELEASE_POLICY] = Toolkit::ImageVisual::ReleasePolicy::DETACHED;
+
+ auto imageView = Toolkit::ImageView::New();
+ imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
+
+ const auto controlAccessible = Dali::Accessibility::Accessible::Get(imageView);
+ auto attributes = controlAccessible->GetAttributes();
+ DALI_TEST_CHECK(attributes.find(imageSrcKey) != attributes.end());
+ DALI_TEST_EQUALS(attributes[imageSrcKey], imagePathForImageMap, TEST_LOCATION);
+ }
+
+ // Check that imgSrc is added for image view w/ imageMap; url array returns first element
+ {
+ const std::string image1 = "application-icon-20.png";
+ const std::string image2 = "application-icon-21.png";
+ Property::Map imageMap;
+ Property::Array urls{image1, image2};
+ imageMap[Toolkit::ImageVisual::Property::URL] = urls;
+ imageMap[Toolkit::ImageVisual::Property::RELEASE_POLICY] = Toolkit::ImageVisual::ReleasePolicy::DETACHED;
+
+ auto imageView = Toolkit::ImageView::New();
+ imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, imageMap);
+
+ const auto controlAccessible = Dali::Accessibility::Accessible::Get(imageView);
+ auto attributes = controlAccessible->GetAttributes();
+ DALI_TEST_CHECK(attributes.find(imageSrcKey) != attributes.end());
+ DALI_TEST_EQUALS(attributes[imageSrcKey], image1, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
}
}
+/**
+ * @brief Retry function to get playrange until expect values comes.
+ * @note This function might consume EventThreadTrigger.
+ *
+ * @param[in] dummyControl The control for test.
+ * @param[in] expectStartFrame Expect start frame.
+ * @param[in] expectEndFrame Expect end frame.
+ * @param[in] retrialFrames Retry required frame value list.
+ * @param[in] testLocation Location info of UTC. It will be used when UTC failed.
+ */
+void CheckAndRetryPlayRange(DummyControl dummyControl, int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames, const char* testLocation)
+{
+ int tryCount = 0;
+ int tryCountMax = 25;
+ while(++tryCount <= tryCountMax)
+ {
+ Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
+ DALI_TEST_CHECK(value);
+
+ Property::Array* result = value->GetArray();
+ DALI_TEST_CHECK(result);
+ DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
+
+ bool tryAgain = false;
+ for(auto& framePair : retrialFrames)
+ {
+ if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
+ {
+ tryAgain = true;
+ break;
+ }
+ }
+ if(tryAgain)
+ {
+ tet_printf("Retry to get value again! [%d]\n", tryCount);
+ // Dummy sleep 1 second.
+ Test::WaitForEventThreadTrigger(1, 1);
+ continue;
+ }
+
+ DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, testLocation);
+ DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, testLocation);
+ break;
+ }
+ DALI_TEST_CHECK(tryCount <= tryCountMax);
+}
+
+/**
+ * @brief Retry function to get current frame until expect values comes.
+ * @note This function might consume EventThreadTrigger.
+ *
+ * @param[in] dummyControl The control for test.
+ * @param[in] expectCurrentFrame Expect current frame.
+ * @param[in] retrialFrames Retry required frame value list.
+ * @param[in] testLocation Location info of UTC. It will be used when UTC failed.
+ */
+void CheckAndRetryCurrentFrame(DummyControl dummyControl, int expectCurrentFrame, std::vector<int> retrialFrames, const char* testLocation)
+{
+ int tryCount = 0;
+ int tryCountMax = 25;
+ while(++tryCount <= tryCountMax)
+ {
+ Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+
+ Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+
+ int32_t result = value->Get<int32_t>();
+
+ bool tryAgain = false;
+ for(auto& frame : retrialFrames)
+ {
+ if(result == frame)
+ {
+ tryAgain = true;
+ break;
+ }
+ }
+ if(tryAgain)
+ {
+ tet_printf("Retry to get value again! [%d]\n", tryCount);
+ // Dummy sleep 1 second.
+ Test::WaitForEventThreadTrigger(1, 1);
+ continue;
+ }
+
+ DALI_TEST_EQUALS(result, expectCurrentFrame, testLocation);
+ break;
+ }
+ DALI_TEST_CHECK(tryCount <= tryCountMax);
+}
+
} // namespace
int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void)
// Trigger count is 2 - load & render a frame
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+ // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
+ // if ForceRenderOnce triggered before render complete, renderer count could be zero.
+ // Consume it if required.
+ if(actor.GetRendererCount() == 0)
+ {
+ tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
+ Test::WaitForEventThreadTrigger(1, 1);
+ }
+
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
.Add("stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME)
.Add("loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE)
.Add("redrawInScalingDown", false)
+ .Add("enableFrameCache", false)
+ .Add("notifyAfterRasterization", false)
.Add("cornerRadius", cornerRadius)
.Add("borderlineWidth", borderlineWidth)
.Add("borderlineColor", borderlineColor)
.Add("borderlineOffset", borderlineOffset)
.Add("desiredWidth", desiredWidth)
- .Add("desiredHeight", desiredHeight)
- .Add("useFixedCache", false);
+ .Add("desiredHeight", desiredHeight);
Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
DALI_TEST_CHECK(visual);
// Trigger count is 1 - render a frame
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
+ // if ForceRenderOnce triggered before render complete, renderer count could be zero.
+ // Consume it if required.
+ if(actor.GetRendererCount() == 0)
+ {
+ tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
+ Test::WaitForEventThreadTrigger(1, 1);
+ }
+
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
DALI_TEST_CHECK(value);
DALI_TEST_CHECK(value->Get<bool>() == false);
+ value = resultMap.Find(DevelImageVisual::Property::ENABLE_FRAME_CACHE, Property::BOOLEAN);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == false);
+
+ value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == false);
+
value = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4);
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<Vector4>(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION);
DALI_TEST_CHECK(value);
DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
+ value = resultMap.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, Property::BOOLEAN);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == false); // Check default value
+
value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
DALI_TEST_CHECK(value);
DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
// Trigger count is 2 - load & render a frame
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+ // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
+ // if ForceRenderOnce triggered before render complete, renderer count could be zero.
+ // Consume it if required.
+ if(actor.GetRendererCount() == 0)
+ {
+ tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
+ Test::WaitForEventThreadTrigger(1, 1);
+ }
+
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
// Set invalid play range
array.Clear();
array.PushBack(1);
- array.PushBack(100);
+ array.PushBack(totalFrameNumber + 100);
attributes.Clear();
attributes.Add(DevelImageVisual::Property::PLAY_RANGE, array);
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
- value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
-
- result = value->GetArray();
- result->GetElementAt(0).Get(resultStartFrame);
- result->GetElementAt(1).Get(resultEndFrame);
-
- DALI_TEST_EQUALS(resultStartFrame, 1, TEST_LOCATION);
- DALI_TEST_EQUALS(resultEndFrame, totalFrameNumber - 1, TEST_LOCATION); // Should be clamped
+ // Should be clamped.
+ CheckAndRetryPlayRange(actor, 1, totalFrameNumber - 1, {{startFrame, endFrame}}, TEST_LOCATION);
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, Property::Map());
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
- // To make event trigger
- actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
-
application.SendNotification();
application.Render();
+ // Jump to action when paused, will make one or more event trigger
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
- value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
- DALI_TEST_EQUALS(value->Get<int>(), 3, TEST_LOCATION);
+ // Test whether current frame is 3.
+ CheckAndRetryCurrentFrame(actor, 3, {0, 1}, TEST_LOCATION);
array.Clear();
array.PushBack(0);
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, attributes);
// To make event trigger
- actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
+ actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
application.SendNotification();
application.Render();
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
- value = map.Find(DevelImageVisual::Property::PLAY_RANGE);
-
- result = value->GetArray();
- result->GetElementAt(0).Get(resultStartFrame);
- result->GetElementAt(1).Get(resultEndFrame);
-
- DALI_TEST_EQUALS(0, resultStartFrame, TEST_LOCATION);
- DALI_TEST_EQUALS(2, resultEndFrame, TEST_LOCATION);
+ CheckAndRetryPlayRange(actor, 0, 2, {{1, totalFrameNumber - 1}}, TEST_LOCATION);
+ map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
value = map.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER);
DALI_TEST_EQUALS(value->Get<int>(), 2, TEST_LOCATION); // CURRENT_FRAME_NUMBER should be changed also.
// Trigger count is 2 - load & render a frame
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+ // There might be 1 event triggered if start frame is not 0, and render frame spend long time.
+ // if ForceRenderOnce triggered before render complete, renderer count could be zero.
+ // Consume it if required.
+ if(actor.GetRendererCount() == 0)
+ {
+ tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
+ Test::WaitForEventThreadTrigger(1, 1);
+ }
+
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
// renderer is added to actor
- DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
Renderer renderer = actor.GetRendererAt(0u);
DALI_TEST_CHECK(renderer);
END_TEST;
}
-int UtcDaliAnimatedVectorImageVisualUsedFixedCache(void)
+int UtcDaliAnimatedVectorImageVisualEnableFrameCache(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCache");
+ tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCache");
Property::Map propertyMap;
propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
DummyControl actor = DummyControl::New(true);
DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
- //actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
application.GetScene().Add(actor);
application.SendNotification();
application.Render();
- // Trigger count is 1 - render a frame
+ // Trigger count is 1 - load
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
Vector2 controlSize(200.f, 200.f);
application.SendNotification();
application.Render();
- // Trigger count is 1 - load
+ // Trigger count is 1 - render a frame
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
// renderer is added to actor
END_TEST;
}
-int UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed(void)
+int UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliAnimatedVectorImageVisualUsedFixedCacheFailed");
+ tet_infoline("UtcDaliAnimatedVectorImageVisualEnableFrameCacheFailed");
Property::Map propertyMap;
propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
END_TEST;
}
+int UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedVectorImageVisualNotifyAfterRasterization");
+
+ Property::Map propertyMap;
+ propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
+ .Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true)
+ .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 1 - load
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ Vector2 controlSize(200.f, 200.f);
+ actor.SetProperty(Actor::Property::SIZE, controlSize);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 1 - render a frame
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Play animation
+ Property::Map attributes;
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
+
+ application.SendNotification();
+ application.Render();
+
+ // There might be 1 event triggered if render frame spend long time.
+ // if ForceRenderOnce triggered before render complete, renderer count could be zero.
+ // Consume it if required.
+ if(actor.GetRendererCount() == 0)
+ {
+ tet_printf("Warning! render frame trigger not comes yet. Let we wait one more time.\n");
+ Test::WaitForEventThreadTrigger(1, 1);
+ }
+
+ // renderer is added to actor
+ DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+ Renderer renderer = actor.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer);
+
+ // Check renderer behavior
+ DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
+
+ Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+ Property::Value* value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
+ DALI_TEST_CHECK(value->Get<bool>() == true);
+
+ propertyMap.Clear();
+ propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, false);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
+
+ application.SendNotification();
+ application.Render();
+
+ // Check renderer behavior again
+ DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::CONTINUOUSLY);
+
+ map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+ value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
+ DALI_TEST_CHECK(value->Get<bool>() == false);
+
+ propertyMap.Clear();
+ propertyMap.Add(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION, true);
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelVisual::Action::UPDATE_PROPERTY, propertyMap);
+
+ application.SendNotification();
+ application.Render();
+
+ // Check renderer behavior again
+ DALI_TEST_CHECK(renderer.GetProperty<int>(DevelRenderer::Property::RENDERING_BEHAVIOR) == DevelRenderer::Rendering::IF_REQUIRED);
+
+ map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+ value = map.Find(DevelImageVisual::Property::NOTIFY_AFTER_RASTERIZATION);
+ DALI_TEST_CHECK(value->Get<bool>() == true);
+
+ END_TEST;
+}
+
int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
{
ToolkitTestApplication application;
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 2);
- // To make event trigger
- actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
-
application.SendNotification();
application.Render();
+ // Trigger count is 1 - Jump to during stopped
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
Property::Map map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
// To make event trigger
- actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
+ actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
application.SendNotification();
application.Render();
// Wait for animation finish
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- // EventThread will be triggered after animation finished (For render forcibly).
- // TODO : Is this logic will works well on server-side?
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Note : AnimationFinished will occure force-render, and it might required another trigger. Test one more trigger now.
+ Test::WaitForEventThreadTrigger(1, 1);
// Jump to 3
DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3);
- // To make event trigger
- actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
-
application.SendNotification();
application.Render();
+ // Trigger count is 1 - Jump to during stopped.
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
map = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
Property::Array* result = value->GetArray();
DALI_TEST_CHECK(result);
- DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
- DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
+ DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), startFrame, TEST_LOCATION);
+ DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), endFrame, TEST_LOCATION);
playRange.Clear();
playRange.PushBack(0);
result = value->GetArray();
DALI_TEST_CHECK(result);
- DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == 0);
- DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == 2);
+ // Ensure that vector data sended well.
+ CheckAndRetryPlayRange(actor, 0, 2, {{startFrame, endFrame}}, TEST_LOCATION);
attributes.Clear();
result = value->GetArray();
DALI_TEST_CHECK(result);
- DALI_TEST_CHECK(result->GetElementAt(0).Get<int>() == startFrame);
- DALI_TEST_CHECK(result->GetElementAt(1).Get<int>() == endFrame);
+ // Ensure that vector data sended well.
+ CheckAndRetryPlayRange(actor, startFrame, endFrame, {{0, 2}}, TEST_LOCATION);
// Play and update property
attributes.Clear();
application.GetScene().Add(dummyControl);
- // Retry function to get playrange until expect values comes.
- auto CheckAndRetryPlayRange = [&](int expectStartFrame, int expectEndFrame, std::vector<std::pair<int, int>> retrialFrames) {
- int tryCount = 0;
- int tryCountMax = 30;
- while(++tryCount <= tryCountMax)
- {
- Property::Map resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
-
- Property::Value* value = resultMap.Find(DevelImageVisual::Property::PLAY_RANGE, Property::ARRAY);
- DALI_TEST_CHECK(value);
-
- Property::Array* result = value->GetArray();
- DALI_TEST_CHECK(result);
- DALI_TEST_EQUALS(result->Count(), 2, TEST_LOCATION);
-
- bool tryAgain = false;
- for(auto& framePair : retrialFrames)
- {
- if(result->GetElementAt(0).Get<int>() == framePair.first && result->GetElementAt(1).Get<int>() == framePair.second)
- {
- tryAgain = true;
- break;
- }
- }
- if(tryAgain)
- {
- tet_printf("Retry to get value again! [%d]\n", tryCount);
- // Dummy sleep 1 second.
- Test::WaitForEventThreadTrigger(1, 1);
- continue;
- }
-
- DALI_TEST_EQUALS(result->GetElementAt(0).Get<int>(), expectStartFrame, TEST_LOCATION);
- DALI_TEST_EQUALS(result->GetElementAt(1).Get<int>(), expectEndFrame, TEST_LOCATION);
- break;
- }
- DALI_TEST_CHECK(tryCount <= tryCountMax);
- };
-
tet_printf("Pause lottie first.\n");
Property::Map attributes;
} while(totalFrameCount == 0);
// Ensure that vector data sended well.
- CheckAndRetryPlayRange(startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}});
+ CheckAndRetryPlayRange(dummyControl, startFrame, endFrame, {{0, 0}, {0, totalFrameCount - 1}}, TEST_LOCATION);
resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
application.Render(16);
// Ensure that vector data sended well.
- CheckAndRetryPlayRange(changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}});
+ CheckAndRetryPlayRange(dummyControl, changedStartFrame2, changedEndFrame2, {{changedStartFrame1, changedEndFrame1}, {startFrame, endFrame}}, TEST_LOCATION);
resultMap = dummyControl.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);