X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-scene3d%2Futc-Dali-Model.cpp;h=5d2c344e2179398922ee309f2ae8006c00a72fdb;hb=d3ab7a4cc307562e687de2b2751f2f0a687c2835;hp=c18924ba2ffed291193fad66ba8d1456695561df;hpb=b37f87135b28813d5d43ed891f5e1d72ad2d9694;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp index c18924b..5d2c344 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp @@ -22,6 +22,7 @@ #include #include +#include #include @@ -41,14 +42,17 @@ void model_cleanup(void) namespace { const bool DEFAULT_MODEL_CHILDREN_SENSITIVE = false; +const bool DEFAULT_MODEL_CHILDREN_FOCUSABLE = false; /** * For the AnimatedCube.gltf and its Assets * Donated by Norbert Nopper for glTF testing. * Take from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedCube */ -const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf"; -const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf"; -const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli"; +const char* TEST_GLTF_FILE_NAME = TEST_RESOURCE_DIR "/AnimatedCube.gltf"; +const char* TEST_GLTF_ANIMATION_TEST_FILE_NAME = TEST_RESOURCE_DIR "/animationTest.gltf"; +const char* TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME = TEST_RESOURCE_DIR "/simpleMultiplePrimitiveTest.gltf"; +const char* TEST_DLI_FILE_NAME = TEST_RESOURCE_DIR "/arc.dli"; +const char* TEST_DLI_EXERCISE_FILE_NAME = TEST_RESOURCE_DIR "/exercise.dli"; /** * For the diffuse and specular cube map texture. * These textures are based off version of Wave engine sample @@ -84,6 +88,25 @@ bool TestTouchCallback(Actor, const TouchEvent&) return true; } +bool gFocusChangedCallBackCalled = false; +void TestFocusChangedCallback(Actor, Actor) +{ + gFocusChangedCallBackCalled = true; +} + +// For ResourceReady +static bool gOnRelayoutCallBackCalled = false; +void OnRelayoutCallback(Actor actor) +{ + gOnRelayoutCallBackCalled = true; +} + +static bool gResourceReadyCalled = false; +void OnResourceReady(Control control) +{ + gResourceReadyCalled = true; +} + } // namespace // Negative test case for a method @@ -242,15 +265,23 @@ int UtcDaliModelOnScene01(void) ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + uint32_t modelCount = model.GetModelRoot().GetChildCount(); DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION); - END_TEST; } @@ -259,12 +290,21 @@ int UtcDaliModelOnScene02(void) ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_DLI_FILE_NAME); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + uint32_t modelCount = model.GetModelRoot().GetChildCount(); DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION); @@ -304,7 +344,20 @@ int UtcDaliModelGetNaturalSize(void) Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); Vector3 naturalSize = model.GetNaturalSize(); + DALI_TEST_EQUALS(Vector3::ZERO, naturalSize, TEST_LOCATION); + + application.GetScene().Add(model); + + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + naturalSize = model.GetNaturalSize(); DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION); Actor root = model.GetModelRoot(); @@ -318,12 +371,21 @@ int UtcDaliModelSetImageBasedLightSource01(void) ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + Actor meshActor = model.FindChildByName("AnimatedCube"); DALI_TEST_CHECK(meshActor); @@ -331,19 +393,32 @@ int UtcDaliModelSetImageBasedLightSource01(void) DALI_TEST_CHECK(renderer); TextureSet textureSet = renderer.GetTextures(); - DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION); - Texture diffuseTexture = textureSet.GetTexture(5u); - Texture specularTexture = textureSet.GetTexture(6u); + Texture diffuseTexture = textureSet.GetTexture(7u); + Texture specularTexture = textureSet.GetTexture(8u); + gResourceReadyCalled = false; + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE); - Texture newDiffuseTexture = textureSet.GetTexture(5u); - Texture newSpecularTexture = textureSet.GetTexture(6u); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + Texture newDiffuseTexture = textureSet.GetTexture(7u); + Texture newSpecularTexture = textureSet.GetTexture(8u); DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION); DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION); + model.Unparent(); + model.Reset(); END_TEST; } @@ -352,12 +427,21 @@ int UtcDaliModelSetImageBasedLightSource02(void) ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + Actor meshActor = model.FindChildByName("AnimatedCube"); DALI_TEST_CHECK(meshActor); @@ -365,15 +449,16 @@ int UtcDaliModelSetImageBasedLightSource02(void) DALI_TEST_CHECK(renderer); TextureSet textureSet = renderer.GetTextures(); - DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION); - Texture diffuseTexture = textureSet.GetTexture(5u); - Texture specularTexture = textureSet.GetTexture(6u); + Texture diffuseTexture = textureSet.GetTexture(7u); + Texture specularTexture = textureSet.GetTexture(8u); + // if url is empty, loading is not requested. model.SetImageBasedLightSource("", ""); - Texture newDiffuseTexture = textureSet.GetTexture(5u); - Texture newSpecularTexture = textureSet.GetTexture(6u); + Texture newDiffuseTexture = textureSet.GetTexture(7u); + Texture newSpecularTexture = textureSet.GetTexture(8u); DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION); DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION); @@ -386,12 +471,21 @@ int UtcDaliModelSetImageBasedLightSource03(void) ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + Actor meshActor = model.FindChildByName("AnimatedCube"); DALI_TEST_CHECK(meshActor); @@ -399,15 +493,26 @@ int UtcDaliModelSetImageBasedLightSource03(void) DALI_TEST_CHECK(renderer); TextureSet textureSet = renderer.GetTextures(); - DALI_TEST_EQUALS(textureSet.GetTextureCount(), 7u, TEST_LOCATION); + DALI_TEST_EQUALS(textureSet.GetTextureCount(), 9u, TEST_LOCATION); - Texture diffuseTexture = textureSet.GetTexture(5u); - Texture specularTexture = textureSet.GetTexture(6u); + Texture diffuseTexture = textureSet.GetTexture(7u); + Texture specularTexture = textureSet.GetTexture(8u); + gResourceReadyCalled = false; + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); model.SetImageBasedLightSource("dummy.ktx", "dummy.ktx"); - Texture newDiffuseTexture = textureSet.GetTexture(5u); - Texture newSpecularTexture = textureSet.GetTexture(6u); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + Texture newDiffuseTexture = textureSet.GetTexture(7u); + Texture newSpecularTexture = textureSet.GetTexture(8u); DALI_TEST_EQUALS(diffuseTexture, newDiffuseTexture, TEST_LOCATION); DALI_TEST_EQUALS(specularTexture, newSpecularTexture, TEST_LOCATION); @@ -415,6 +520,29 @@ int UtcDaliModelSetImageBasedLightSource03(void) END_TEST; } +int UtcDaliModelSetImageBasedLightSource04(void) +{ + ToolkitTestApplication application; + + Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); + model.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE); + application.GetScene().Add(model); + + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + END_TEST; +} + int UtcDaliModelImageBasedFactor(void) { ToolkitTestApplication application; @@ -444,12 +572,21 @@ int UtcDaliModelChildrenSensitive01(void) // Allow children actor's event before on scene. view.SetChildrenSensitive(true); DALI_TEST_EQUALS(view.GetChildrenSensitive(), true, TEST_LOCATION); - application.GetScene().Add(view); + gResourceReadyCalled = false; + view.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + Actor meshActor = view.FindChildByName("AnimatedCube"); DALI_TEST_CHECK(meshActor); @@ -532,12 +669,21 @@ int UtcDaliModelChildrenSensitive02(void) // Block children actor's event before on scene. view.SetChildrenSensitive(false); DALI_TEST_EQUALS(view.GetChildrenSensitive(), false, TEST_LOCATION); - application.GetScene().Add(view); + gResourceReadyCalled = false; + view.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + Actor meshActor = view.FindChildByName("AnimatedCube"); DALI_TEST_CHECK(meshActor); @@ -587,18 +733,226 @@ int UtcDaliModelChildrenSensitive02(void) END_TEST; } +int UtcDaliModelChildrenFocusable01(void) +{ + ToolkitTestApplication application; + + Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100)); + view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0)); + view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + // Get vaule. Default is false. + DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION); + + // Allow children actor's focus before on scene. + view.SetChildrenFocusable(true); + DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION); + application.GetScene().Add(view); + + gResourceReadyCalled = false; + view.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + Actor meshActor = view.FindChildByName("AnimatedCube"); + DALI_TEST_CHECK(meshActor); + + // Enable the default algorithm + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK(manager); + Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true); + + // connect focusable signal + gFocusChangedCallBackCalled = false; + meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + manager.FocusChangedSignal().Connect(TestFocusChangedCallback); + + // Initialize with some left-positioned actor + Control focusStartActor = Control::New(); + focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100)); + focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0)); + focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true); + application.GetScene().Add(focusStartActor); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Focusable view find success + DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true); + DALI_TEST_CHECK(gFocusChangedCallBackCalled); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + // Block children actor's focus + view.SetChildrenFocusable(false); + DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Focusable view find failed + DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false); + DALI_TEST_CHECK(!gFocusChangedCallBackCalled); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + // Allow again + view.SetChildrenFocusable(true); + DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Focusable view find success + DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true); + DALI_TEST_CHECK(gFocusChangedCallBackCalled); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + END_TEST; +} + +int UtcDaliModelModelChildrenFocusable02(void) +{ + ToolkitTestApplication application; + + Scene3D::Model view = Scene3D::Model::New(TEST_GLTF_FILE_NAME); + view.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100)); + view.SetProperty(Dali::Actor::Property::POSITION, Vector3(0, 0, 0)); + view.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + view.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + // Get vaule. Default is true. + DALI_TEST_EQUALS(view.GetChildrenFocusable(), DEFAULT_MODEL_CHILDREN_FOCUSABLE, TEST_LOCATION); + + // Block children actor's focus before on scene. + view.SetChildrenFocusable(false); + DALI_TEST_EQUALS(view.GetChildrenFocusable(), false, TEST_LOCATION); + application.GetScene().Add(view); + + gResourceReadyCalled = false; + view.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + Actor meshActor = view.FindChildByName("AnimatedCube"); + DALI_TEST_CHECK(meshActor); + + // Enable the default algorithm + KeyboardFocusManager manager = KeyboardFocusManager::Get(); + DALI_TEST_CHECK(manager); + Dali::Toolkit::DevelKeyboardFocusManager::EnableDefaultAlgorithm(manager, true); + + // connect focusable signal + gFocusChangedCallBackCalled = false; + meshActor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); + manager.FocusChangedSignal().Connect(TestFocusChangedCallback); + + // Initialize with some left-positioned actor + Control focusStartActor = Control::New(); + focusStartActor.SetProperty(Dali::Actor::Property::SIZE, Vector3(100, 100, 100)); + focusStartActor.SetProperty(Dali::Actor::Property::POSITION, Vector3(-200, 0, 0)); + focusStartActor.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); + focusStartActor.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + focusStartActor.SetProperty(Dali::Actor::Property::KEYBOARD_FOCUSABLE, true); + application.GetScene().Add(focusStartActor); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Focusable view find failed + DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == false); + DALI_TEST_CHECK(!gFocusChangedCallBackCalled); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + // Allow again + view.SetChildrenFocusable(true); + DALI_TEST_EQUALS(view.GetChildrenFocusable(), true, TEST_LOCATION); + + // flush the queue and render once + application.SendNotification(); + application.Render(); + + // Focusable view find success + DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true); + DALI_TEST_CHECK(gFocusChangedCallBackCalled); + + // Clear + manager.ClearFocus(); + manager.SetCurrentFocusActor(focusStartActor); + gFocusChangedCallBackCalled = false; + + END_TEST; +} + int UtcDaliModelAnimation01(void) { ToolkitTestApplication application; Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + uint32_t animationCount = model.GetAnimationCount(); DALI_TEST_EQUALS(1, animationCount, TEST_LOCATION); @@ -618,9 +972,16 @@ int UtcDaliModelAnimation02(void) Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_ANIMATION_TEST_FILE_NAME); model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); - application.GetScene().Add(model); + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); application.SendNotification(); application.Render(); @@ -640,22 +1001,96 @@ int UtcDaliModelAnimation02(void) END_TEST; } -// For ResourceReady -namespace +int UtcDaliModelAnimation03(void) { -static bool gOnRelayoutCallBackCalled = false; -void OnRelayoutCallback(Actor actor) -{ - gOnRelayoutCallBackCalled = true; + ToolkitTestApplication application; + + Scene3D::Model model = Scene3D::Model::New(TEST_DLI_EXERCISE_FILE_NAME); + model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + application.GetScene().Add(model); + + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION); + + uint32_t animationCount = model.GetAnimationCount(); + DALI_TEST_EQUALS(18, animationCount, TEST_LOCATION); + + Animation animationByIndex = model.GetAnimation(0u); + DALI_TEST_CHECK(animationByIndex); + + Animation animationByName = model.GetAnimation("idleClip"); + DALI_TEST_CHECK(animationByName); + DALI_TEST_EQUALS(animationByIndex, animationByName, TEST_LOCATION); + + END_TEST; } -static bool gResourceReadyCalled = false; -void OnResourceReady(Control control) +int UtcDaliModelMultiplePrimitives(void) { - gResourceReadyCalled = true; + ToolkitTestApplication application; + + Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_MULTIPLE_PRIMITIVE_FILE_NAME); + model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + application.GetScene().Add(model); + + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + Actor actor = model.FindChildByName("rootNode"); + + DALI_TEST_EQUALS(0, actor.GetChildCount(), TEST_LOCATION); + DALI_TEST_EQUALS(2, actor.GetRendererCount(), TEST_LOCATION); + + END_TEST; } -} // namespace +int UtcDaliModelColorMode(void) +{ + ToolkitTestApplication application; + + Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME); + model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50)); + model.SetProperty(Dali::Actor::Property::COLOR, Color::RED); + application.GetScene().Add(model); + + gResourceReadyCalled = false; + model.ResourceReadySignal().Connect(&OnResourceReady); + DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + Actor actor = model.FindChildByName("AnimatedCube"); + Vector4 childColor = actor[Dali::Actor::Property::COLOR]; + Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR]; + + DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION); + DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION); + + END_TEST; +} int UtcDaliModelResourceReady(void) { ToolkitTestApplication application; @@ -677,6 +1112,10 @@ int UtcDaliModelResourceReady(void) application.SendNotification(); application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(gOnRelayoutCallBackCalled, false, TEST_LOCATION); DALI_TEST_EQUALS(model.IsResourceReady(), true, TEST_LOCATION); DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);