+ Dali::Property::Map visualMap;
+ gradientVisual.CreatePropertyMap(visualMap);
+ Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA);
+
+ // test values
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+ }
+ {
+ Visual::Base gradientVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::GRADIENT)
+ .Add(GradientVisual::Property::START_POSITION, Vector2(-0.5f, -0.5f))
+ .Add(GradientVisual::Property::END_POSITION, Vector2(0.5f, 0.5f))
+ .Add(GradientVisual::Property::STOP_COLOR, Property::Array().Add(Color::RED).Add(Vector4(1.0f, 1.0f, 1.0f, 0.5f)))
+ .Add(Visual::Property::PREMULTIPLIED_ALPHA, false));
+
+ Dali::Property::Map visualMap;
+ gradientVisual.CreatePropertyMap(visualMap);
+ Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA);
+
+ // test values
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+ }
+
+ // color visual ( premultiplied alpha by default is false, and cannot change value )
+ {
+ Visual::Base colorVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::COLOR)
+ .Add(ColorVisual::Property::MIX_COLOR, Color::AQUA));
+
+ Dali::Property::Map visualMap;
+ colorVisual.CreatePropertyMap(visualMap);
+ Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA);
+
+ // test values
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), false, TEST_LOCATION);
+ }
+ {
+ Visual::Base colorVisual = factory.CreateVisual(
+ Property::Map()
+ .Add(Toolkit::Visual::Property::TYPE, Visual::COLOR)
+ .Add(ColorVisual::Property::MIX_COLOR, Color::AQUA)
+ .Add(Visual::Property::PREMULTIPLIED_ALPHA, true));
+
+ Dali::Property::Map visualMap;
+ colorVisual.CreatePropertyMap(visualMap);
+ Property::Value* value = visualMap.Find(Visual::Property::PREMULTIPLIED_ALPHA);
+
+ // test values
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<bool>(), false, TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliRegisterVisualOrder(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Register Visual Order");
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+
+ tet_infoline("Register visual, should have depth index of 0.0f");
+ Visual::Base testVisual = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, testVisual);
+ DALI_TEST_EQUALS(testVisual.GetDepthIndex(), 0, TEST_LOCATION);
+
+ tet_infoline("Register more visuals, each added one should have a depth index greater than previous");
+
+ Visual::Base testVisual2 = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2);
+ DALI_TEST_CHECK(testVisual2.GetDepthIndex() > testVisual.GetDepthIndex());
+
+ Visual::Base foregroundVisual = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::FOREGROUND_VISUAL, foregroundVisual);
+ DALI_TEST_CHECK(foregroundVisual.GetDepthIndex() > testVisual2.GetDepthIndex());
+
+ Visual::Base focusVisual = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::FOCUS_VISUAL, focusVisual);
+ DALI_TEST_CHECK(focusVisual.GetDepthIndex() > foregroundVisual.GetDepthIndex());
+
+ tet_infoline("Set depth index on a new visual before registering, the depth index should not have been changed");
+ Visual::Base labelVisual = factory.CreateVisual(propertyMap);
+ labelVisual.SetDepthIndex(-2000);
+ dummyImpl.RegisterVisual(DummyControl::Property::LABEL_VISUAL, labelVisual);
+ DALI_TEST_EQUALS(labelVisual.GetDepthIndex(), -2000, TEST_LOCATION);
+
+ tet_infoline("Replace visual, the depth index should be the same as what was previously set");
+ const int testVisual2DepthIndex = testVisual2.GetDepthIndex();
+ Visual::Base testVisual2Replacement = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(testVisual2Replacement.GetDepthIndex() != testVisual2DepthIndex);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2Replacement);
+ DALI_TEST_EQUALS(testVisual2Replacement.GetDepthIndex(), testVisual2DepthIndex, TEST_LOCATION);
+
+ tet_infoline("Replace visual and set a depth index on the replacement, the depth index of the replacement should be honoured");
+ Visual::Base anotherTestVisual2Replacement = factory.CreateVisual(propertyMap);
+ anotherTestVisual2Replacement.SetDepthIndex(2000);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, anotherTestVisual2Replacement);
+ DALI_TEST_EQUALS(anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION);
+
+ dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(dummyControl);
+
+ END_TEST;
+}
+
+int UtcDaliRegisterVisualOrder02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Register Visual Order with Background Set");
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+
+ const int backgroundDepthIndex = Toolkit::DepthIndex::BACKGROUND;
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::COLOR);
+ propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+
+ tet_printf("Register a control background visual, should have depth index of %d\n", backgroundDepthIndex);
+
+ dummyControl.SetProperty(Control::Property::BACKGROUND, propertyMap);
+
+ const int TEST_VISUAL_1_DEPTH_INDEX = 0;
+ tet_printf("Register visual, should have depth index of %d\n", TEST_VISUAL_1_DEPTH_INDEX);
+ Visual::Base testVisual1 = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, testVisual1);
+ DALI_TEST_EQUALS(testVisual1.GetDepthIndex(), TEST_VISUAL_1_DEPTH_INDEX, TEST_LOCATION);
+
+ tet_printf("Register another visual, should have a depth index greater than previous(%d)\n", TEST_VISUAL_1_DEPTH_INDEX);
+ Visual::Base testVisual2 = factory.CreateVisual(propertyMap);
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, testVisual2);
+ DALI_TEST_CHECK(testVisual2.GetDepthIndex() > testVisual1.GetDepthIndex());
+
+ dummyControl.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ application.GetScene().Add(dummyControl);