X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AnimatedImageVisual.cpp;h=59be4f2201163c8e0bb413da0a7097eefa205202;hp=73f4cf742f6acb54370d8c105b42ffcce8c63fa8;hb=HEAD;hpb=17d3776d3954d676af76bd82d18a059a7ff81650 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp index 73f4cf7..ba02bef 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedImageVisual.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "dummy-control.h" @@ -480,7 +481,7 @@ int UtcDaliAnimatedImageVisualGetPropertyMap04(void) value = resultMap.Find(Toolkit::DevelImageVisual::Property::TOTAL_FRAME_NUMBER, "totalFrameNumber"); DALI_TEST_CHECK(value); - DALI_TEST_EQUALS(value->Get(), 4, TEST_LOCATION); + DALI_TEST_EQUALS(value->Get(), -1, TEST_LOCATION); value = resultMap.Find(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth"); DALI_TEST_CHECK(value); @@ -1992,3 +1993,209 @@ int UtcDaliAnimatedImageVisualDesiredSize(void) END_TEST; } + +int UtcDaliAnimatedImageVisualControlVisibilityChanged(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedImageVisualControlVisibilityChanged"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE) + .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME) + .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME) + .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(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes); + + application.SendNotification(); + application.Render(); + + // Check frame number + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + Test::EmitGlobalTimerSignal(); + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + Property::Map resultMap; + visual.CreatePropertyMap(resultMap); + + // check the property values from the returned map from a visual + Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); + DALI_TEST_CHECK(value); + DALI_TEST_NOT_EQUALS(value->Get(), 0, Math::MACHINE_EPSILON_100, TEST_LOCATION); + + actor.SetProperty(Actor::Property::VISIBLE, false); + + Test::EmitGlobalTimerSignal(); + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + visual.CreatePropertyMap(resultMap); + + // check the property values from the returned map from a visual + value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), 0, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAnimatedImageVisualWindowVisibilityChanged(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedImageVisualWindowVisibilityChanged"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE) + .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME) + .Add(DevelImageVisual::Property::STOP_BEHAVIOR, DevelImageVisual::StopBehavior::FIRST_FRAME) + .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(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedImageVisual::Action::PLAY, attributes); + + application.SendNotification(); + application.Render(); + + // Check frame number + DALI_TEST_CHECK(actor.GetRendererCount() == 1u); + Renderer renderer = actor.GetRendererAt(0u); + DALI_TEST_CHECK(renderer); + + Test::EmitGlobalTimerSignal(); + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + Property::Map resultMap; + visual.CreatePropertyMap(resultMap); + + // check the property values from the returned map from a visual + Property::Value* value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); + DALI_TEST_CHECK(value); + DALI_TEST_NOT_EQUALS(value->Get(), 0, Math::MACHINE_EPSILON_100, TEST_LOCATION); + + Window window = DevelWindow::Get(actor); + window.Hide(); + + Test::EmitGlobalTimerSignal(); + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + visual.CreatePropertyMap(resultMap); + + // check the property values from the returned map from a visual + value = resultMap.Find(DevelImageVisual::Property::CURRENT_FRAME_NUMBER); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), 0, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAnimatedImageVisualFrameCountBeforeLoadingFinished(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedImageVisualFrameCountBeforeLoadingFinished"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_IMAGE) + .Add(ImageVisual::Property::URL, TEST_GIF_FILE_NAME) + .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + Property::Map resultMap1; + visual.CreatePropertyMap(resultMap1); + Property::Value* value1 = resultMap1.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER); + DALI_TEST_CHECK(value1); + DALI_TEST_EQUALS(value1->Get(), -1, Math::MACHINE_EPSILON_100, TEST_LOCATION); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + Property::Map resultMap2; + visual.CreatePropertyMap(resultMap2); + Property::Value* value2 = resultMap2.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER); + DALI_TEST_CHECK(value2); + DALI_TEST_EQUALS(value2->Get(), -1, Math::MACHINE_EPSILON_100, TEST_LOCATION); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - load & render a frame + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + Property::Map resultMap3; + visual.CreatePropertyMap(resultMap3); + Property::Value* value3 = resultMap3.Find(DevelImageVisual::Property::TOTAL_FRAME_NUMBER); + DALI_TEST_CHECK(value3); + DALI_TEST_EQUALS(value3->Get(), 4, Math::MACHINE_EPSILON_100, TEST_LOCATION); + + END_TEST; +}