#include <toolkit-event-thread-callback.h>
#include <dali-scene3d/public-api/controls/model/model.h>
+#include <dali-scene3d/public-api/model-components/model-node.h>
#include <dali/devel-api/actors/camera-actor-devel.h>
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
}
// Positive test case for a method
+int UtcDaliModelNewP2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliModelNew without url");
+
+ Scene3D::Model model = Scene3D::Model::New();
+ DALI_TEST_CHECK(model);
+
+ application.GetScene().Add(model);
+
+ DALI_TEST_CHECK(model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
+
+ application.GetScene().Remove(model);
+
+ DALI_TEST_CHECK(!model.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE));
+
+ END_TEST;
+}
+
+// Positive test case for a method
int UtcDaliModelDownCast(void)
{
ToolkitTestApplication application;
uint32_t modelCount = model.GetModelRoot().GetChildCount();
DALI_TEST_EQUALS(1, modelCount, TEST_LOCATION);
- Actor rootActor = model.GetModelRoot();
- Vector3 rootSize = rootActor.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+ Scene3D::ModelNode rootNode = model.GetModelRoot();
+ Vector3 rootSize = rootNode.GetProperty<Vector3>(Dali::Actor::Property::SIZE);
DALI_TEST_EQUALS(Vector3(2, 2, 1), rootSize, TEST_LOCATION);
END_TEST;
naturalSize = model.GetNaturalSize();
DALI_TEST_EQUALS(Vector3(2, 2, 2), naturalSize, TEST_LOCATION);
- Actor root = model.GetModelRoot();
- DALI_TEST_CHECK(root);
+ Scene3D::ModelNode rootNode = model.GetModelRoot();
+ DALI_TEST_CHECK(rootNode);
END_TEST;
}
DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
- Texture newDiffuseTexture = textureSet.GetTexture(7u);
- Texture newSpecularTexture = textureSet.GetTexture(8u);
+ TextureSet newTextureSet = renderer.GetTextures();
+ Texture newDiffuseTexture = newTextureSet.GetTexture(7u);
+ Texture newSpecularTexture = newTextureSet.GetTexture(8u);
DALI_TEST_NOT_EQUALS(diffuseTexture, newDiffuseTexture, 0.0f, TEST_LOCATION);
DALI_TEST_NOT_EQUALS(specularTexture, newSpecularTexture, 0.0f, TEST_LOCATION);
CameraActor appliedCamera;
DALI_TEST_EQUALS(model.ApplyCamera(0u, appliedCamera), false, TEST_LOCATION); // Cannot apply into empty camera.
- auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location) {
+ auto CompareCameraProperties = [](CameraActor lhs, CameraActor rhs, const char* location)
+ {
DALI_TEST_EQUALS(lhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), rhs.GetProperty<int>(Dali::CameraActor::Property::PROJECTION_MODE), TEST_LOCATION);
DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::NEAR_PLANE_DISTANCE), TEST_LOCATION);
{
DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), rhs.GetProperty<float>(Dali::CameraActor::Property::FIELD_OF_VIEW), TEST_LOCATION);
// TODO : Open this test when infinity far projection implement.
- //DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
+ // DALI_TEST_EQUALS(lhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), rhs.GetProperty<float>(Dali::CameraActor::Property::FAR_PLANE_DISTANCE), TEST_LOCATION);
}
else
{
END_TEST;
}
+
int UtcDaliModelResourceReady(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int UtcDaliModelResourceCacheCheck(void)
+{
+ ToolkitTestApplication application;
+
+ // Load three instances of the same model and add them to the scene
+ Scene3D::Model model1 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model model2 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ Scene3D::Model model3 = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+
+ application.GetScene().Add(model1);
+ application.GetScene().Add(model2);
+ application.GetScene().Add(model3);
+
+ gResourceReadyCalled = false;
+ model1.ResourceReadySignal().Connect(&OnResourceReady);
+ model2.ResourceReadySignal().Connect(&OnResourceReady);
+ model3.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();
+
+ // Check that the loading has finished for all the three instances
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ Actor meshActor1 = model1.FindChildByName("AnimatedCube");
+ Actor meshActor2 = model2.FindChildByName("AnimatedCube");
+ Actor meshActor3 = model3.FindChildByName("AnimatedCube");
+ DALI_TEST_CHECK(meshActor1);
+ DALI_TEST_CHECK(meshActor2);
+ DALI_TEST_CHECK(meshActor3);
+
+ Renderer renderer1 = meshActor1.GetRendererAt(0u);
+ Renderer renderer2 = meshActor2.GetRendererAt(0u);
+ Renderer renderer3 = meshActor3.GetRendererAt(0u);
+ DALI_TEST_CHECK(renderer1);
+ DALI_TEST_CHECK(renderer2);
+ DALI_TEST_CHECK(renderer3);
+
+ // Check that all the three instances use the shared textures and geometries from the cache
+ // but have their own shader objects
+ DALI_TEST_EQUALS(renderer1.GetTextures(), renderer2.GetTextures(), TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer1.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer2.GetGeometry(), TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer1.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer2.GetShader(), 0.0f, TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(renderer1.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
+
+ // Destroy model1
+ model1.Unparent();
+ model1.Reset();
+
+ // Check that all the other two instances still use the shared textures and geometries from the cache
+ // but have their own shader objects
+ DALI_TEST_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
+
+ // Set new IBL textures for model2, and this should apply to model2 instance only
+ gResourceReadyCalled = false;
+ DALI_TEST_EQUALS(gResourceReadyCalled, false, TEST_LOCATION);
+ model2.SetImageBasedLightSource(TEST_DIFFUSE_TEXTURE, TEST_SPECULAR_TEXTURE);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ // Check that the new IBL textures are loaded for model2
+ DALI_TEST_EQUALS(gResourceReadyCalled, true, TEST_LOCATION);
+
+ // Check that the two instances still use the shared geometries from the cache
+ // but now have their own shader objects and different texture set
+ DALI_TEST_NOT_EQUALS(renderer2.GetTextures(), renderer3.GetTextures(), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(renderer2.GetGeometry(), renderer3.GetGeometry(), TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(renderer2.GetShader(), renderer3.GetShader(), 0.0f, TEST_LOCATION);
+
+ // Check that the two instances now have their own diffuse texture and specular texture,
+ // but all the other textures are still the same
+ TextureSet textureSet2 = renderer2.GetTextures();
+ TextureSet textureSet3 = renderer3.GetTextures();
+ DALI_TEST_EQUALS(textureSet2.GetTextureCount(), 9u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureSet3.GetTextureCount(), 9u, TEST_LOCATION);
+
+ for(uint32_t i = 0; i < 7u; i++)
+ {
+ DALI_TEST_EQUALS(textureSet2.GetTexture(i), textureSet3.GetTexture(i), TEST_LOCATION);
+ }
+
+ DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(7u), textureSet3.GetTexture(7u), 0.0f, TEST_LOCATION);
+ DALI_TEST_NOT_EQUALS(textureSet2.GetTexture(8u), textureSet3.GetTexture(8u), 0.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelAddRemoveModelNode(void)
+{
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New();
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+
+ Scene3D::ModelNode node1 = Scene3D::ModelNode::New();
+ Scene3D::ModelNode node2 = Scene3D::ModelNode::New();
+ Scene3D::ModelNode node3 = Scene3D::ModelNode::New();
+ Scene3D::ModelNode node4 = Scene3D::ModelNode::New();
+
+ model.AddModelNode(node1);
+ model.AddModelNode(node2);
+ model.AddModelNode(node3);
+ model.RemoveModelNode(node1); // Remove node before scene on
+
+ application.GetScene().Add(model);
+
+ Dali::Scene3D::ModelNode root = model.GetModelRoot();
+ DALI_TEST_CHECK(root);
+ DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
+
+ model.RemoveModelNode(node2); // Remove node after scene on
+
+ DALI_TEST_EQUALS(1, root.GetChildCount(), TEST_LOCATION);
+
+ model.AddModelNode(node4); // Add during scene on
+
+ DALI_TEST_EQUALS(2, root.GetChildCount(), TEST_LOCATION);
+
+ application.GetScene().Remove(model);
+
+ model.RemoveModelNode(node3); // Remove node after scene off
+
+ END_TEST;
+}
+
+int UtcDaliModelFindChildModelNodeByName(void)
+{
+ tet_infoline(" UtcDaliModelNodeFindChildModelNodeByName.");
+
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New();
+ application.GetScene().Add(model);
+
+ Scene3D::ModelNode modelNode1 = Scene3D::ModelNode::New();
+ Scene3D::ModelNode modelNode2 = Scene3D::ModelNode::New();
+
+ modelNode1.SetProperty(Dali::Actor::Property::NAME, "modelNode1");
+ modelNode2.SetProperty(Dali::Actor::Property::NAME, "modelNode2");
+ model.AddModelNode(modelNode1);
+ model.AddModelNode(modelNode2);
+
+ Scene3D::ModelNode child1 = model.FindChildModelNodeByName("modelNode1");
+ DALI_TEST_CHECK(child1);
+ DALI_TEST_EQUALS(child1, modelNode1, TEST_LOCATION);
+
+ Scene3D::ModelNode child2 = model.FindChildModelNodeByName("modelNode2");
+ DALI_TEST_CHECK(child2);
+ DALI_TEST_EQUALS(child2, modelNode2, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelSizeChange(void)
+{
+ tet_infoline(" UtcDaliModelSizeChange.");
+
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
+ Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector3(600, 600, 600));
+ Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+
+ DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliModelSizeChange2(void)
+{
+ tet_infoline(" UtcDaliModelSizeChange2.");
+
+ ToolkitTestApplication application;
+
+ Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+ model.SetProperty(Dali::Actor::Property::SIZE, Vector3(300, 300, 300));
+ application.GetScene().Add(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model.GetChildCount(), 1u, TEST_LOCATION);
+ Vector3 scale = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+
+ Animation animation = Animation::New(0.5f);
+ animation.AnimateTo(Dali::Property(model, Dali::Actor::Property::SIZE), Vector3(600, 600, 600));
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(250);
+
+ application.SendNotification();
+
+ Vector3 scale2 = model.GetChildAt(0u).GetProperty<Vector3>(Dali::Actor::Property::SCALE);
+ DALI_TEST_NOT_EQUALS(scale, scale2, 0.1f, TEST_LOCATION);
+
+ END_TEST;
+}