#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/align-enums.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <toolkit-event-thread-callback.h>
#include "dummy-control.h"
gKeyInputFocusCallBackCalled = true;
}
+const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
+const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
} // namespace
///////////////////////////////////////////////////////////////////////////////////////////////////
END_TEST;
}
+
+
+int UtcDaliControlResourcesReady(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Register 2 visuals and check ResourceReady when a visual is disabled" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMapLarge;
+ propertyMapLarge.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMapLarge.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
+
+ Property::Map propertyMapSmall;
+ propertyMapSmall.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMapSmall.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
+
+ Visual::Base smallVisual = factory.CreateVisual( propertyMapSmall );
+ smallVisual.SetName("smallVisual");
+ DALI_TEST_CHECK( smallVisual );
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, smallVisual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION );
+
+ Visual::Base largeVisual = factory.CreateVisual( propertyMapLarge );
+ largeVisual.SetName("largeVisual");
+ DALI_TEST_CHECK( largeVisual );
+
+ tet_infoline( "Register Visual but set disabled, IsResourceReady should be true" );
+
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, largeVisual, false );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION );
+
+ END_TEST;
+}
mControlImpl.RelayoutRequest();
}
- // go through and check if all the visuals are ready, if they are emit a signal
- for( auto visualIter = mVisuals.Begin();
- visualIter != mVisuals.End(); ++visualIter )
- {
- const Toolkit::Visual::Base visual = (*visualIter)->visual;
- const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ // Emit signal if all enabled visuals registered by the control are ready.
+ // If any visual is registered and enabled but not ready then the control will not be able to emit ReadySignal.
- // one of the visuals is not ready
- if( !visualImpl.IsResourceReady() )
- {
- return;
- }
+ if ( IsResourceReady() )
+ {
+ Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
+ mResourceReadySignal.Emit( handle );
}
-
- // all the visuals are ready
- Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
- mResourceReadySignal.Emit( handle );
}
bool Control::Impl::IsResourceReady() const
{
- // go through and check all the visuals are ready
- for ( RegisteredVisualContainer::ConstIterator visualIter = mVisuals.Begin();
+ // Iterate through and check all the enabled visuals are ready
+ for ( auto visualIter = mVisuals.Begin();
visualIter != mVisuals.End(); ++visualIter )
- {
- const Toolkit::Visual::Base visual = (*visualIter)->visual;
- const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
-
- // one of the visuals is not ready
- if( !visualImpl.IsResourceReady() )
- {
- return false;
- }
- }
+ {
+ const Toolkit::Visual::Base visual = (*visualIter)->visual;
+ const Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+
+ // one of the enabled visuals is not ready
+ if( !visualImpl.IsResourceReady() && (*visualIter)->enabled )
+ {
+ return false;
+ }
+ }
return true;
}