/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return true;
}
+void PrepareResourceImage( ToolkitTestApplication& application, unsigned int imageWidth, unsigned int imageHeight, Pixel::Format pixelFormat )
+{
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ platform.SetClosestImageSize(Vector2( imageWidth, imageHeight));
+
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
+ Integration::PixelBuffer* pixbuffer = bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, imageWidth, imageHeight, imageWidth, imageHeight );
+ unsigned int bytesPerPixel = GetBytesPerPixel( pixelFormat );
+ unsigned int initialColor = 0xFF;
+ memset( pixbuffer, initialColor, imageHeight*imageWidth*bytesPerPixel);
+
+ Integration::ResourcePointer resourcePtr(bitmap);
+ platform.SetSynchronouslyLoadedResource( resourcePtr );
+}
} //namespace
void dali_visual_startup(void)
DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
// image visual
+ PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
Visual::Base imageVisual = factory.CreateVisual( image );
imageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
DALI_TEST_CHECK( value->Get<bool>() == true );
// Get an image visual with an image handle, and test the default property values
+ PrepareResourceImage( application, 100u, 200u, Pixel::RGBA8888 );
Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
imageVisual = factory.CreateVisual(image);
imageVisual.CreatePropertyMap( resultMap );
//Set a new transform
transform.Clear();
+ transform = DefaultTransform();
transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
Renderer renderer = dummyControl.GetRendererAt(0u);
Property::Index index = renderer.GetPropertyIndex("size");
- tet_infoline( "Test that the TextVisual overrides anything set by developer" );
- DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 1.0, 1.0 ), 0.001f, TEST_LOCATION );
+ tet_infoline( "Test that the TextVisual has NOT overridden what was set by developer" );
+ DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 0.5f, 0.5f ), 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliVisualTextVisualDisableEnable(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualTextVisualDisableEnable Ensure Text visible can be re-enabled" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, DevelVisual::TEXT );
+ propertyMap.Insert( "mixColor", Color::WHITE );
+ propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+ propertyMap.Insert( "enableMarkup", false );
+ propertyMap.Insert( "text", "Hello world" );
+ propertyMap.Insert( "fontFamily", "TizenSans" );
+
+ Property::Map fontStyleMapSet;
+ fontStyleMapSet.Insert( "weight", "bold" );
+ propertyMap.Insert( "fontStyle", fontStyleMapSet );
+
+ propertyMap.Insert( "pointSize", 12.f );
+ propertyMap.Insert( "multiLine", true );
+ propertyMap.Insert( "horizontalAlignment", "CENTER" );
+ propertyMap.Insert( "verticalAlignment", "CENTER" );
+ propertyMap.Insert( "textColor", Color::RED );
+ Visual::Base textVisual = factory.CreateVisual( propertyMap );
+ textVisual.SetDepthIndex( 1.f );
+
+ DummyControl dummyControl = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, textVisual );
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
+
+ dummyControl.SetSize(200.f, 200.f);
+ dummyControl.SetParentOrigin( ParentOrigin::CENTER );
+
+ Stage::GetCurrent().Add( dummyControl );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
+
+ dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
+
+ dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true );
+
+ DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
END_TEST;
}