#include <stdlib.h>
#include <unistd.h>
+#include <toolkit-event-thread-callback.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali/devel-api/object/handle-devel.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
int UtcDaliVisualSetOnOffStage(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliVisualSetDepthIndex" );
+ tet_infoline( "UtcDaliVisualSetOnOffStage" );
VisualFactory factory = VisualFactory::Get();
Property::Map propertyMap;
END_TEST;
}
+int UtcDaliVisualSetOnOffStage2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualSetOnOffStage2" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::SVG );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_SVG_FILE_NAME );
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ actor.SetSize(200.f, 200.f);
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ // First on/off
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ Renderer renderer = actor.GetRendererAt( 0 );
+ auto textures = renderer.GetTextures();
+ DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
+
+ Stage::GetCurrent().Remove( actor );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ // Second on/off
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ renderer = actor.GetRendererAt( 0 );
+ textures = renderer.GetTextures();
+ DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
+
+ Stage::GetCurrent().Remove( actor );
+
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
int UtcDaliVisualGetPropertyMap1(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int UtcDaliSvgVisualCustomShader(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "SvgVisual with custom shader" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map properties;
+ Property::Map shader;
+ const std::string vertexShader = "Foobar";
+ const std::string fragmentShader = "Foobar";
+ shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
+ shader[Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
+
+ properties[Visual::Property::TYPE] = Visual::IMAGE;
+ properties[Visual::Property::SHADER] = shader;
+ properties[ImageVisual::Property::URL] = TEST_SVG_FILE_NAME;
+
+ Visual::Base visual = factory.CreateVisual( properties );
+
+ // trigger creation through setting on stage
+ DummyControl dummy = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+
+ dummy.SetSize( 200.f, 200.f );
+ dummy.SetParentOrigin( ParentOrigin::CENTER );
+ Stage::GetCurrent().Add( dummy );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ Renderer renderer = dummy.GetRendererAt( 0 );
+ Shader shader2 = renderer.GetShader();
+ Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK( map );
+
+ Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
+ DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
+
+ Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
+ DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
+
+ END_TEST;
+}