X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-VisualFactory.cpp;h=db708c1ff199bf5884adbad1e4f85fbac806bc1e;hp=c78d09002bf0d7fe4b6d744c07f5f9216bd88654;hb=f27c332dcf251d50ddfe3b2ab15ec2eaff5296b1;hpb=0d07bc303ad28647afa1342319721384cc37d19f diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index c78d090..db708c1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -76,7 +76,7 @@ void TestVisualRender( ToolkitTestApplication& application, actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -97,7 +97,7 @@ void TestVisualAsynchronousRender( ToolkitTestApplication& application, actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -232,7 +232,7 @@ int UtcDaliVisualFactoryGetColorVisual2(void) DALI_TEST_EQUALS( actualValue, Vector3(testColor), TEST_LOCATION ); DALI_TEST_EQUALS( actualColor.a, testColor.a, TEST_LOCATION ); - Stage::GetCurrent().Remove(actor); + application.GetScene().Remove(actor); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); END_TEST; @@ -260,7 +260,7 @@ int UtcDaliVisualFactoryGetBorderVisual1(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f)); DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -308,7 +308,7 @@ int UtcDaliVisualFactoryGetBorderVisual2(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f)); DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); @@ -340,7 +340,7 @@ int UtcDaliVisualFactoryGetBorderVisual2(void) visual = factory.CreateVisual( map ); dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); blendMode = actor.GetRendererAt(0u).GetProperty( Renderer::Property::BLEND_MODE ); DALI_TEST_EQUALS( static_cast(blendMode), BlendMode::ON, TEST_LOCATION ); @@ -459,7 +459,7 @@ int UtcDaliVisualFactoryDefaultOffsetsGradientVisual(void) DummyControl actor = DummyControl::New(true); TestVisualRender( application, actor, visual ); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove( actor ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); END_TEST; @@ -771,7 +771,7 @@ int UtcDaliVisualFactoryGetNPatchVisual3(void) DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove( actor ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); Vector2 naturalSize( 0.0f, 0.0f ); @@ -797,7 +797,7 @@ int UtcDaliVisualFactoryGetNPatchVisual3(void) visual.GetNaturalSize( naturalSize ); DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION ); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove( actor ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); } @@ -897,7 +897,7 @@ int UtcDaliVisualFactoryGetNPatchVisual6(void) visual.GetNaturalSize( naturalSize ); DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION ); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove( actor ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); } @@ -925,7 +925,7 @@ int UtcDaliVisualFactoryGetNPatchVisual6(void) visual.GetNaturalSize( naturalSize ); DALI_TEST_EQUALS( naturalSize, Vector2( imageSize.GetWidth() - 2.0f, imageSize.GetHeight() - 2.0f ), TEST_LOCATION ); - Stage::GetCurrent().Remove( actor ); + application.GetScene().Remove( actor ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); } @@ -967,7 +967,7 @@ int UtcDaliVisualFactoryGetNPatchVisual7(void) actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); actor.Unparent(); application.SendNotification(); @@ -984,7 +984,7 @@ int UtcDaliVisualFactoryGetNPatchVisual7(void) END_TEST; } -int UtcDaliNPatchVisualAuxiliaryImage(void) +int UtcDaliNPatchVisualAuxiliaryImage01(void) { ToolkitTestApplication application; tet_infoline( "NPatchVisual with aux image" ); @@ -1017,7 +1017,7 @@ int UtcDaliNPatchVisualAuxiliaryImage(void) dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap ); dummy.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); dummy.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); - Stage::GetCurrent().Add(dummy); + application.GetScene().Add(dummy); application.SendNotification(); application.Render(); @@ -1034,6 +1034,38 @@ int UtcDaliNPatchVisualAuxiliaryImage(void) END_TEST; } +int UtcDaliNPatchVisualAuxiliaryImage02(void) +{ + ToolkitTestApplication application; + tet_infoline( "Multiple NPatchVisual with aux image coincidentally" ); + + const Property::Value NPATCH_TEST{ + {ImageVisual::Property::URL, TEST_9_PATCH_FILE_NAME}, + {DevelImageVisual::Property::AUXILIARY_IMAGE, TEST_AUX_IMAGE}}; + + ImageView imageView1 = ImageView::New(); + imageView1[ImageView::Property::IMAGE] = NPATCH_TEST; + application.GetScene().Add( imageView1 ); + + ImageView imageView2 = ImageView::New(); + imageView2[ImageView::Property::IMAGE] = NPATCH_TEST; + application.GetScene().Add( imageView2 ); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + Renderer renderer1 = imageView1.GetRendererAt( 0 ); + auto textureSet1 = renderer1.GetTextures(); + + Renderer renderer2 = imageView2.GetRendererAt( 0 ); + auto textureSet2 = renderer2.GetTextures(); + DALI_TEST_EQUALS( textureSet1 == textureSet2, true, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliVisualFactoryGetNPatchVisualN1(void) { @@ -1128,15 +1160,12 @@ int UtcDaliVisualFactoryGetSvgVisual(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) ); + // Either application.SendNotification() or the trigger can now complete the task. application.SendNotification(); application.Render(); - - // renderer is not added to actor until the rasterization is completed. - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); // renderer is added to actor @@ -1168,14 +1197,11 @@ int UtcDaliVisualFactoryGetSvgVisualLarge(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size. dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); + // Either application.SendNotification() or the trigger can now complete the task. application.SendNotification(); application.Render(); - - // renderer is not added to actor until the rasterization is completed. - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); // renderer is added to actor @@ -1213,15 +1239,13 @@ int UtcDaliVisualFactoryGetSvgVisualAtlas(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) ); + // Either application.SendNotification() or the trigger can now complete the task. + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); application.SendNotification(); application.Render(); - - // renderer is not added to actor until the rasterization is completed. - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); // renderer is added to actor @@ -1252,7 +1276,7 @@ void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplic DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. @@ -1295,7 +1319,7 @@ void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTest DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. @@ -1602,7 +1626,7 @@ void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestA dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) ); //Ensure set on stage. @@ -2043,7 +2067,12 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual1(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION ); application.SendNotification(); application.Render(); @@ -2061,14 +2090,23 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual1(void) timer.MockEmitSignal(); application.SendNotification(); application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); textureTrace.Reset(); - // Force the timer used by the animatedImageVisual to tick, timer.MockEmitSignal(); application.SendNotification(); application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); textureTrace.Reset(); @@ -2076,10 +2114,15 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual1(void) timer.MockEmitSignal(); application.SendNotification(); application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); textureTrace.Reset(); - // Test SetOffStage(). + // Test SetOffScene(). actor.Unparent(); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); @@ -2112,7 +2155,12 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual2(void) DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual ); actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION ); application.SendNotification(); application.Render();