+//Test if mesh visual handles the case of lacking an object file.
+int UtcDaliVisualFactoryGetMeshVisualN1(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN1: Request mesh visual without object file" );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+
+
+ END_TEST;
+}
+
+//Test if mesh visual handles the case of being passed invalid material and images urls.
+int UtcDaliVisualFactoryGetMeshVisualN2(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN2: Request mesh visual with invalid material and images urls" );
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, TEST_OBJ_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, "invalid" );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, "also invalid" );
+
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+
+
+ END_TEST;
+}
+
+//Test if mesh visual handles the case of being passed an invalid object url
+int UtcDaliVisualFactoryGetMeshVisualN3(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualFactoryGetMeshVisualN3: Request mesh visual with invalid object url" );
+
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::MESH );
+ propertyMap.Insert( MeshVisual::Property::OBJECT_URL, "invalid" );
+ propertyMap.Insert( MeshVisual::Property::MATERIAL_URL, TEST_MTL_FILE_NAME );
+ propertyMap.Insert( MeshVisual::Property::TEXTURES_PATH, TEST_RESOURCE_DIR "/" );
+
+ //Test to see if mesh doesn't load with these properties, as expected.
+ MeshVisualDoesNotLoadCorrectlyTest( propertyMap, application );
+
+ END_TEST;
+}
+
+//Creates a primitive visual with the given property map and tests to see if it correctly loads in the given application.
+void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestApplication& application )
+{
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ //Create a primitive visual.
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ //Create an actor on stage to house the visual.
+ 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( 200.f, 200.f ) );
+ application.GetScene().Add( actor );
+ visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
+
+ //Ensure set on stage.
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+
+ //Tell test application to load the visual.
+ application.SendNotification();
+ application.Render(0);
+
+ Matrix testScaleMatrix;
+ testScaleMatrix.SetIdentityAndScale( Vector3( 1.0, -1.0, 1.0 ) );
+ Matrix actualScaleMatrix;
+
+ //Test to see if the object has been successfully loaded.
+ DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue<Matrix>( "uObjectMatrix", actualScaleMatrix ) );
+ DALI_TEST_EQUALS( actualScaleMatrix, testScaleMatrix, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+ //Finish by setting off stage, and ensuring this was successful.
+ actor.Unparent();
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+}
+
+//Test if primitive shape loads correctly when supplied with only the bare minimum requirements, the shape to use.
+int UtcDaliVisualFactoryGetPrimitiveVisual1(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual1: Request primitive visual with a shape only" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads correctly when supplied with all possible parameters
+int UtcDaliVisualFactoryGetPrimitiveVisual2(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual2: Request primitive visual with everything" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CUBE );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_RADIUS, 60.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_SMOOTHNESS, 0.8f );
+ propertyMap.Insert( MeshVisual::Property::LIGHT_POSITION, Vector3( 0.9, 1.0, 1.1 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads a sphere correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual3(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual3: Request primitive visual to display a sphere" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::SPHERE );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::STACKS, 20 );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads a conic section correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual4(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual4: Request primitive visual to display a conic section" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::CONICAL_FRUSTUM );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::SLICES, 10 );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_TOP_RADIUS, 30.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS, 40.0f );
+ propertyMap.Insert( PrimitiveVisual::Property::SCALE_HEIGHT, 50.0f );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads a bevelled cube correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual5(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual5: Request primitive visual to display a bevelled cube" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::BEVELLED_CUBE );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+ propertyMap.Insert( PrimitiveVisual::Property::BEVEL_PERCENTAGE, 0.7f );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads an octahedron correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual6(void)
+{
+ //Set up test application first, so everything else can be handled.
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliVisualFactoryGetPrimitiveVisual6: Request primitive visual to display an octahedron" );
+
+ static std::vector<UniformData> customUniforms =
+ {
+ UniformData("uObjectMatrix", Property::Type::MATRIX),
+ };
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
+ //Set up visual properties.
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::PRIMITIVE );
+ propertyMap.Insert( PrimitiveVisual::Property::SHAPE, PrimitiveVisual::Shape::OCTAHEDRON );
+ propertyMap.Insert( PrimitiveVisual::Property::MIX_COLOR, Vector4( 0.5, 0.5, 0.5, 1.0 ) );
+
+ //Test to see if shape loads correctly.
+ TestPrimitiveVisualWithProperties( propertyMap, application );
+
+ END_TEST;
+}
+
+//Test if primitive shape loads a cone correctly.
+int UtcDaliVisualFactoryGetPrimitiveVisual7(void)