int UtcDaliVideoViewProperty4(void)
{
  ToolkitTestApplication application;
  tet_infoline(" UtcDaliVideoViewProperty4");

  Toolkit::VideoView view = Toolkit::VideoView::New();
  DALI_TEST_CHECK( view );

  float left, right;
  left = right = 0.f;

  Property::Map map;
  map.Insert( VOLUME_LEFT, 1.0f );
  map.Insert( VOLUME_RIGHT, 0.5f );

  Property::Map map2;
  view.SetProperty( VideoView::Property::VOLUME, map );
  Property::Value val4 = view.GetProperty( VideoView::Property::VOLUME );
  DALI_TEST_CHECK( val4.Get( map2 ) );

  Property::Value* volumeLeft = map.Find( VOLUME_LEFT );
  Property::Value* volumeRight = map.Find( VOLUME_RIGHT );

  DALI_TEST_CHECK( volumeLeft && volumeLeft->Get( left ) );
  DALI_TEST_CHECK( volumeRight && volumeRight->Get( right ) );
  DALI_TEST_CHECK( left == 1.0f );
  DALI_TEST_CHECK( right == 0.5f );

  END_TEST;
}
Exemplo n.º 2
0
int UtcDaliControlRendererSetGetDepthIndex(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererSetDepthIndex" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "color-renderer");
  propertyMap.Insert("blend-color", Color::BLUE);
  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );

  controlRenderer.SetDepthIndex( 1.f );

  Actor actor = Actor::New();
  actor.SetSize(200.f, 200.f);
  Stage::GetCurrent().Add( actor );
  controlRenderer.SetOnStage( actor );

  DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1.f, TEST_LOCATION );
  DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), 1.f, TEST_LOCATION );

  controlRenderer.SetDepthIndex( -1.f );
  DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1.f, TEST_LOCATION );
  DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), -1.f, TEST_LOCATION );

  END_TEST;
}
Exemplo n.º 3
0
int UtcDaliControlRendererSetOnOffStage(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererSetDepthIndex" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "color-renderer");
  propertyMap.Insert("blend-color", Color::BLUE);
  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );

  Actor actor = Actor::New();
  actor.SetSize(200.f, 200.f);
  Stage::GetCurrent().Add( actor );

  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );

  controlRenderer.SetOnStage( actor );
  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 1u );

  controlRenderer.SetOffStage( actor );
  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );

  END_TEST;
}
Actor NewActor( const Property::Map& map )
{
  BaseHandle handle;

  // First find type and create Actor
  Property::Value* typeValue = map.Find( "type" );
  if ( typeValue )
  {
    TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() );
    if ( type )
    {
      handle = type.CreateInstance();
    }
  }

  if ( !handle )
  {
    DALI_LOG_ERROR( "Actor type not provided\n" );
    return Actor();
  }

  Actor actor( Actor::DownCast( handle ) );

  if ( actor )
  {
    // Now set the properties, or create children
    for ( unsigned int i = 0, mapCount = map.Count(); i < mapCount; ++i )
    {
      const StringValuePair& pair( map.GetPair( i ) );
      const std::string& key( pair.first );
      if ( key == "type" )
      {
        continue;
      }

      const Property::Value& value( pair.second );

      if ( key == "actors" )
      {
        // Create children
        Property::Array actorArray = value.Get< Property::Array >();
        for ( Property::Array::SizeType i = 0; i < actorArray.Size(); ++i)
        {
          actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
        }
      }
      else
      {
        Property::Index index( actor.GetPropertyIndex( key ) );

        if ( index != Property::INVALID_INDEX )
        {
          actor.SetProperty( index, value );
        }
      }
    }
  }

  return actor;
}
Exemplo n.º 5
0
int UtcDaliControlRendererCopyAndAssignment(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererCopyAndAssignment" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "color-renderer");
  propertyMap.Insert("blend-color", Color::BLUE);
  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );

  ControlRenderer controlRendererCopy( controlRenderer );
  DALI_TEST_CHECK(controlRenderer == controlRendererCopy);

  ControlRenderer emptyControlRenderer;
  ControlRenderer emptyControlRendererCopy( emptyControlRenderer );
  DALI_TEST_CHECK(emptyControlRenderer == emptyControlRendererCopy);

  ControlRenderer controlRendererEquals;
  controlRendererEquals = controlRenderer;
  DALI_TEST_CHECK(controlRenderer == controlRendererEquals);

  ControlRenderer emptyControlRendererEquals;
  emptyControlRendererEquals = emptyControlRenderer;
  DALI_TEST_CHECK( emptyControlRenderer == emptyControlRendererEquals );

  //self assignment
  controlRenderer = controlRenderer;
  DALI_TEST_CHECK( controlRenderer = controlRendererCopy );

  END_TEST;
}
Exemplo n.º 6
0
Property::Value& Property::Value::GetValue(const std::string& key) const
{
  DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid");

  Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));

  DALI_ASSERT_DEBUG(container);

  if(container)
  {
    for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
    {
      if(iter->first == key)
      {
        return iter->second;
      }
    }
  }

  DALI_LOG_WARNING("Cannot find property map key %s", key.c_str());
  DALI_ASSERT_ALWAYS(!"Cannot find property map key");

  // should never return this
  static Property::Value null;
  return null;
}
Exemplo n.º 7
0
void Property::Value::SetItem(const int index, const Property::Value &value)
{
  switch( GetType() )
  {
    case Property::MAP:
    {
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));
      if( container && index < static_cast<int>(container->size()) )
      {
        int i = 0;
        for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
        {
          if(i++ == index)
          {
            iter->second = value;
            break;
          }
        }
      }
    }
    break;

    case Property::ARRAY:
    {
      Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
      if( container && index < static_cast<int>(container->size()) )
      {
        (*container)[index] = value;
      }
    }
    break;

    case Property::NONE:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::INTEGER:
    case Property::UNSIGNED_INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX3:
    case Property::MATRIX:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      DALI_ASSERT_ALWAYS(!"Cannot SetItem on property Type; not a container");
      break;
    }
  }
}
Exemplo n.º 8
0
int UtcDaliControlRendererGetPropertyMap6(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererGetPropertyMap6: NPatchRenderer" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert( "renderer-type", "n-patch-renderer" );
  propertyMap.Insert( "image-url", TEST_NPATCH_FILE_NAME );
  propertyMap.Insert( "border-only", true );
  ControlRenderer nPatchRenderer = factory.GetControlRenderer( propertyMap );

  Property::Map resultMap;
  nPatchRenderer.CreatePropertyMap( resultMap );

  // check the property values from the returned map from control renderer
  Property::Value* value = resultMap.Find( "renderer-type", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == "n-patch-renderer" );

  value = resultMap.Find( "image-url", Property::STRING );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<std::string>() == TEST_NPATCH_FILE_NAME );

  value = resultMap.Find( "border-only", Property::BOOLEAN );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<bool>() );

  END_TEST;
}
int UtcDaliCheckBoxSetLabelP(void)
{
  TestApplication application;

  CheckBoxButton checkBox = CheckBoxButton::New();

  Property::Map propertyMap;
  propertyMap.Insert("text",  "activate");
  checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );

  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented

  END_TEST;
}
Exemplo n.º 10
0
const std::string& Property::Value::GetKey(const int index) const
{
  switch( GetType() )
  {
    case Property::MAP:
    {
      int i = 0;
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));
      DALI_ASSERT_DEBUG(container && "Property::Map has no container?");
      if(container)
      {
        if(0 <= index && index < static_cast<int>(container->size()))
        {
          for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
          {
            if(i++ == index)
            {
              return iter->first;
            }
          }
        }
      }
    }
    break;
    case Property::NONE:
    case Property::ARRAY:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::UNSIGNED_INTEGER:
    case Property::INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX:
    case Property::MATRIX3:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      break;
    }
  }


  // should never return this
  static std::string null;
  return null;
}
Exemplo n.º 11
0
int Property::Value::GetSize() const
{
  int ret = 0;

  switch(GetType())
  {
    case Property::MAP:
    {
      Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));
      if(container)
      {
        ret = container->size();
      }
    }
    break;

    case Property::ARRAY:
    {
      Property::Array *container = AnyCast<Property::Array>(&(mImpl->mValue));
      if(container)
      {
        ret = container->size();
      }
    }
    break;

    case Property::NONE:
    case Property::BOOLEAN:
    case Property::FLOAT:
    case Property::INTEGER:
    case Property::UNSIGNED_INTEGER:
    case Property::VECTOR2:
    case Property::VECTOR3:
    case Property::VECTOR4:
    case Property::MATRIX3:
    case Property::MATRIX:
    case Property::RECTANGLE:
    case Property::ROTATION:
    case Property::STRING:
    case Property::TYPE_COUNT:
    {
      break;
    }

  }

  return ret;
}
void CreatePropertyMap( Actor actor, Property::Map& map )
{
  map.Clear();

  if ( actor )
  {
    map[ "type" ] = actor.GetTypeName();

    // Default properties
    Property::IndexContainer indices;
    actor.GetPropertyIndices( indices );
    const Property::IndexContainer::ConstIterator endIter = indices.End();

    for ( Property::IndexContainer::Iterator iter = indices.Begin(); iter != endIter; ++iter )
    {
      map[ actor.GetPropertyName( *iter ) ] = actor.GetProperty( *iter );
    }

    // Children
    unsigned int childCount( actor.GetChildCount() );
    if ( childCount )
    {
      Property::Array childArray;
      for ( unsigned int child = 0; child < childCount; ++child )
      {
        Property::Map childMap;
        CreatePropertyMap( actor.GetChildAt( child ), childMap );
        childArray.PushBack( childMap );
      }
      map[ "actors" ] = childArray;
    }
  }
}
Exemplo n.º 13
0
bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
{
  bool result = false;
  Property::Map imageMap;
  imageMap[mapKey] =mapValue;

  field.SetProperty( property , imageMap );
  Property::Value propValue = field.GetProperty( property );
  Property::Map* resultMap = propValue.GetMap();

  if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
  {
    result = true;
  }

  return result;
}
Exemplo n.º 14
0
int UtcDaliControlRendererGetPropertyMap1(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererGetPropertyMap1: ColorRenderer" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "color-renderer");
  propertyMap.Insert("blend-color", Color::BLUE);
  ControlRenderer colorRenderer = factory.GetControlRenderer( propertyMap );

  Property::Map resultMap;
  colorRenderer.CreatePropertyMap( resultMap );

  Property::Value* typeValue = resultMap.Find( "renderer-type", Property::STRING );
  DALI_TEST_CHECK( typeValue );
  DALI_TEST_CHECK( typeValue->Get<std::string>() == "color-renderer" );

  Property::Value* colorValue = resultMap.Find( "blend-color", Property::VECTOR4 );
  DALI_TEST_CHECK( colorValue );
  DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::BLUE );

  // change the blend color
  Actor actor;
  factory.ResetRenderer( colorRenderer, actor, Color::CYAN );
  colorRenderer.CreatePropertyMap( resultMap );

  colorValue = resultMap.Find( "blend-color", Property::VECTOR4 );
  DALI_TEST_CHECK( colorValue );
  DALI_TEST_CHECK( colorValue->Get<Vector4>() == Color::CYAN );

  END_TEST;
}
Exemplo n.º 15
0
int UtcDaliPropertyMapFind(void)
{
  Property::Map map;
  map[ "hello" ] = 1;
  map[ "world" ] = 2;

  Property::Value* value = NULL;

  value = map.Find( "hello" );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<int>() == 1 );

  value = map.Find( "world" );
  DALI_TEST_CHECK( value );
  DALI_TEST_CHECK( value->Get<int>() == 2 );

  value = map.Find( "invalid-key" );
  DALI_TEST_CHECK( !value );

  END_TEST;
}
Exemplo n.º 16
0
int UtcDaliScriptingNewActorNegative(void)
{
  TestApplication application;

  // Empty map
  {
    Actor handle = NewActor( Property::Map() );
    DALI_TEST_CHECK( !handle );
  }

  // Map with only properties
  {
    Property::Map map;
    map.push_back( Property::StringValuePair( "parent-origin", ParentOrigin::TOP_CENTER ) );
    map.push_back( Property::StringValuePair( "anchor-point", AnchorPoint::TOP_CENTER ) );
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( !handle );
  }

  // Add some signals to the map, we should have no signal connections as its not yet supported
  {
    Property::Map map;
    map.push_back( Property::StringValuePair( "type", "Actor" ) );
    map.push_back( Property::StringValuePair( "signals", Property::MAP ) );
    Actor handle = NewActor( map );
    DALI_TEST_CHECK( handle );
    DALI_TEST_CHECK( !handle.MouseWheelEventSignal().GetConnectionCount() );
    DALI_TEST_CHECK( !handle.OffStageSignal().GetConnectionCount() );
    DALI_TEST_CHECK( !handle.OnStageSignal().GetConnectionCount() );
    DALI_TEST_CHECK( !handle.SetSizeSignal().GetConnectionCount() );
    DALI_TEST_CHECK( !handle.TouchedSignal().GetConnectionCount() );
  }
  END_TEST;
}
void DissolveEffectApp::OnInit( Application& application )
{
  Stage::GetCurrent().KeyEventSignal().Connect(this, &DissolveEffectApp::OnKeyEvent);

  // Creates a default view with a default tool bar, the view is added to the stage.
  mContent = DemoHelper::CreateView( application, mView,mToolBar, "", TOOLBAR_IMAGE, "" );

  // Add an effect-changing button on the right of the tool bar.
  mEffectChangeButton = Toolkit::PushButton::New();
  mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE );
  mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED );
  mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked );
  mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );

  // Add title to the tool bar.
  mTitleActor = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_HIGHP );
  mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );

  // Add an slide-show button on the right of the title
  mPlayStopButton = Toolkit::PushButton::New();
  mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON );
  mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED );
  mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked );
  mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );

  // use pan gesture to detect the cursor or finger movement
  mPanGestureDetector = PanGestureDetector::New();
  mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture );

  mViewTimer = Timer::New( VIEWINGTIME );
  mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick );
  mTimerReady = true;

  // Set size to stage size to avoid seeing a black border on transition
  mParent = Actor::New();
  mParent.SetSize( Stage::GetCurrent().GetSize() );
  mParent.SetParentOrigin( ParentOrigin::CENTER );
  mContent.Add( mParent );

  // show the first image
  mCurrentImage = CreateStageFillingImageView( IMAGES[mIndex] );
  mCurrentImage.SetParentOrigin( ParentOrigin::CENTER );
  mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
  mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
  mParent.Add( mCurrentImage );

  mPanGestureDetector.Attach( mCurrentImage );

  mDissolveEffect = Dali::Toolkit::CreateDissolveEffect( mUseHighPrecision );
  Property::Map emptyShaderMap;
  mEmptyEffect.Insert( "shader", emptyShaderMap );
}
Exemplo n.º 18
0
int UtcDaliScriptingNewShaderEffect(void)
{
  TestApplication application;

  Property::Map programMap;
  programMap.push_back( Property::StringValuePair( "vertex-filename", "bump.vert" ) );
  programMap.push_back( Property::StringValuePair( "fragment-filename", "bump.frag" ) );

  Property::Map imageMap;
  imageMap.push_back( Property::StringValuePair( "filename", "image.png" ) );

  Property::Map map;
  map.push_back( Property::StringValuePair( "image", imageMap ) );
  map.push_back( Property::StringValuePair( "program", programMap ) );
  map.push_back( Property::StringValuePair( "uLightPosition", Vector3( 0.0, 0.0, -1.5) ) );
  map.push_back( Property::StringValuePair( "uAmbientLight", (int)10 ) );

  ShaderEffect shader = NewShaderEffect( map );

  DALI_TEST_CHECK( shader );
  END_TEST;
}
Exemplo n.º 19
0
void Property::Value::SetValue(const std::string& key, const Property::Value &value)
{
  DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid");

  Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));

  if(container)
  {
    for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
    {
      if(iter->first == key)
      {
        iter->second = value;
        return;
      }
    }

    // if we get here its a new key
    container->push_back(Property::StringValuePair(key, value));

  }
}
Exemplo n.º 20
0
int UtcDaliPropertyMapGetKey(void)
{
  Property::Map map;
  map[ "hello" ] = 1;
  map[ "world" ] = 2;

  DALI_TEST_CHECK( map.GetKey( 0 ) == "hello" );
  DALI_TEST_CHECK( map.GetKey( 1 ) == "world" );

  // Out of bounds
  try
  {
    map.GetKey( 2 );
    tet_result( TET_FAIL );
  }
  catch ( DaliException& e )
  {
    DALI_TEST_ASSERT( e, "position", TEST_LOCATION );
  }

  END_TEST;
}
Exemplo n.º 21
0
int UtcDaliPropertyMapGetValue(void)
{
  Property::Map map;
  map[ "hello" ] = 1;
  map[ "world" ] = 2;

  Property::Value& value = map.GetValue( 0 );
  DALI_TEST_CHECK( value.Get<int>() == 1 );
  value = 10; // Allows the actual changing of the value as we have a ref
  DALI_TEST_CHECK( map[ "hello" ].Get<int>() == 10 );

  // Out of bounds
  try
  {
    map.GetValue( 2 );
    tet_result( TET_FAIL );
  }
  catch ( DaliException& e )
  {
    DALI_TEST_ASSERT( e, "position", TEST_LOCATION );
  }

  END_TEST;
}
Exemplo n.º 22
0
int UtcDaliPropertyMapConstOperator(void)
{
  Property::Map map;
  map[ "hello" ] = 1;
  map[ "world" ] = 2;
  DALI_TEST_CHECK( map.Count() == 2 );

  const Property::Map& constMap( map );
  DALI_TEST_CHECK( constMap[ "world" ].Get<int>() == 2 );
  DALI_TEST_CHECK( constMap.Count() == 2 ); // Ensure count hasn't gone up

  // Invalid Key
  try
  {
    constMap[ "invalid-key" ];
    tet_result( TET_FAIL );
  }
  catch ( DaliException& e )
  {
    DALI_TEST_ASSERT( e, "! \"Invalid Key\"", TEST_LOCATION );
  }

  END_TEST;
}
Exemplo n.º 23
0
bool Property::Value::HasKey(const std::string& key) const
{
  bool has = false;

  if( Property::MAP == GetType() )
  {
    Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));

    DALI_ASSERT_DEBUG(container && "Property::Map has no container?");

    if(container)
    {
      for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
      {
        if(iter->first == key)
        {
          has = true;
        }
      }
    }
  }

  return has;
}
int UtcDaliCheckBoxSetLabelDisabledP(void)
{
  TestApplication application;

  CheckBoxButton checkBox = CheckBoxButton::New();
  Stage::GetCurrent().Add( checkBox );

  checkBox.SetSize( Vector2( 20.0f, 20.0f ) );
  checkBox.SetDisabledBackgroundImage( "Image.jpg" );

  application.SendNotification();
  application.Render();

  Property::Map propertyMap;
  propertyMap.Insert("text",  "activate");
  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);

  checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );

  DALI_TEST_CHECK(  checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented

  END_TEST;
}
Exemplo n.º 25
0
int UtcDaliPropertyMapInsertP(void)
{
  Property::Map map;
  DALI_TEST_EQUALS( 0, map.Count(), TEST_LOCATION );
  map.Insert( "foo", "bar");
  DALI_TEST_EQUALS( 1, map.Count(), TEST_LOCATION );
  Property::Value* value = map.Find( "foo" );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( "bar", value->Get<std::string>(), TEST_LOCATION );
  map.Insert( std::string("foo2"), "testing" );
  DALI_TEST_EQUALS( 2, map.Count(), TEST_LOCATION );
  value = map.Find( "foo2" );
  DALI_TEST_CHECK( value );
  DALI_TEST_EQUALS( "testing", value->Get<std::string>(), TEST_LOCATION );

  END_TEST;
}
Exemplo n.º 26
0
void RendererFactory::ResetRenderer( Toolkit::ControlRenderer& renderer, Actor& actor, const Property::Map& propertyMap )
{
  if( renderer )
  {
    Property::Value* type = propertyMap.Find( RENDERER_TYPE_NAME );
    std::string typeValue ;
    if( type && type->Get( typeValue ))
    {
      //If there's been a renderer type change then we have to return a new shader
      if( typeValue ==  COLOR_RENDERER && typeid( renderer ) != typeid( ColorRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  GRADIENT_RENDERER && typeid( renderer ) != typeid( GradientRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  IMAGE_RENDERER && typeid( renderer ) != typeid( ImageRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  N_PATCH_RENDERER && typeid( renderer ) != typeid( NPatchRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
      else if( typeValue ==  BORDER_RENDERER && typeid( renderer ) != typeid( BorderRenderer ) )
      {
        renderer = GetControlRenderer( propertyMap );
        return;
      }
    }

    GetImplementation( renderer ).Initialize( actor, propertyMap );
  }
  else
  {
    renderer = GetControlRenderer( propertyMap );
  }

}
Exemplo n.º 27
0
void ControlRenderer::Initialize( Actor& actor, const Property::Map& propertyMap )
{
  if( mImpl->mCustomShader )
  {
    mImpl->mCustomShader->SetPropertyMap( propertyMap );
  }
  else
  {
    Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
    if( customShaderValue )
    {
      Property::Map customShader;
      if( customShaderValue->Get( customShader ) )
      {
        mImpl->mCustomShader = new Impl::CustomShader( propertyMap );
      }
    }
  }
  DoInitialize( actor, propertyMap );
}
void CreatePropertyMap( Image image, Property::Map& map )
{
  map.Clear();

  if ( image )
  {
    std::string imageType( "ResourceImage" );

    // Get Type - cannot use TypeRegistry as Image is not an Object and thus, not registered
    BufferImage bufferImage = BufferImage::DownCast( image );
    if ( bufferImage )
    {
      imageType = "BufferImage";
      map[ "pixelFormat" ] = GetEnumerationName< Pixel::Format >( bufferImage.GetPixelFormat(), PIXEL_FORMAT_TABLE, PIXEL_FORMAT_TABLE_COUNT );
    }
    else if ( FrameBufferImage::DownCast( image ) )
    {
      imageType = "FrameBufferImage";
    }

    map[ "type" ] = imageType;
    map[ "releasePolicy" ] = GetEnumerationName< Image::ReleasePolicy >( image.GetReleasePolicy(), IMAGE_RELEASE_POLICY_TABLE, IMAGE_RELEASE_POLICY_TABLE_COUNT );

    ResourceImage resourceImage = ResourceImage::DownCast( image );
    if( resourceImage )
    {
      map[ "filename" ] = resourceImage.GetUrl();
      map[ "loadPolicy" ] = GetEnumerationName< ResourceImage::LoadPolicy >( resourceImage.GetLoadPolicy(), IMAGE_LOAD_POLICY_TABLE, IMAGE_LOAD_POLICY_TABLE_COUNT );
    }

    int width( image.GetWidth() );
    int height( image.GetHeight() );

    if ( width && height )
    {
      map[ "width" ] = width;
      map[ "height" ] = height;
    }
  }
}
Exemplo n.º 29
0
int UtcDaliPropertyMapPopulate(void)
{
  Property::Map map;
  DALI_TEST_CHECK( map.Empty() );

  map[ "hello" ] = 1;
  map[ "world" ] = "world";
  map[ "world" ] = 3; // same item as line above
  DALI_TEST_CHECK( !map.Empty() ); // Should no longer be empty
  DALI_TEST_CHECK( map.Count() == 2 ); // Should only have two items, not three!!
  DALI_TEST_CHECK( map["hello"].Get<int>() == 1 );
  DALI_TEST_CHECK( map["world"].Get<int>() == 3 );

  map.Clear();
  DALI_TEST_CHECK( map.Empty() );
  END_TEST;
}
Exemplo n.º 30
0
int UtcDaliPropertyMapCopyAndAssignment(void)
{
  Property::Map map;
  map[ "hello" ] = 1;
  map[ "world" ] = 2;

  Property::Map assignedMap;
  assignedMap[ "foo" ] = 3;
  DALI_TEST_CHECK( assignedMap.Count() == 1 );
  assignedMap = map;
  DALI_TEST_CHECK( assignedMap.Count() == 2 );

  Property::Map copiedMap( map );
  DALI_TEST_CHECK( copiedMap.Count() == 2 );

  // Self assignment
  DALI_TEST_CHECK( map.Count() == 2 );
  map = map;
  DALI_TEST_CHECK( map.Count() == 2 );

  END_TEST;
}