+
+int UtcDaliImageVisualOrientationCorrection(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliImageVisualOrientationCorrection Enabling OrientationCorrection should rotate an image with exif (90deg) orientation data with requested" );
+
+ VisualFactory factory = VisualFactory::Get();
+ tet_infoline( "Create visual with Orientation correction set OFF" );
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
+ propertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, false );
+ Visual::Base imageVisual = factory.CreateVisual( propertyMap );
+
+ tet_infoline( "Create control for visual, need to loaded it" );
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ Stage::GetCurrent().Add( actor );
+
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
+ // Wait for image to load
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ Vector2 originalImageSize;
+ tet_infoline( "Get size of original visual to compare later with rotated image" );
+ imageVisual.GetNaturalSize( originalImageSize );
+ DALI_TEST_GREATER( originalImageSize.width, originalImageSize.height, TEST_LOCATION ); // Width and Height must be different for this test.
+ imageVisual.Reset(); // remove handle so can unregister it and remove from cache
+ dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline( "Create visual with Orientation correction set ON " );
+ propertyMap.Clear();
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
+ propertyMap.Insert( DevelImageVisual::Property::ORIENTATION_CORRECTION, true );
+ imageVisual = factory.CreateVisual( propertyMap );
+
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
+ // Wait for image to load
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ Vector2 rotatedImageSize;
+ imageVisual.GetNaturalSize( rotatedImageSize );
+ tet_infoline( "Confirm that visual has rotated" );
+ DALI_TEST_EQUALS( originalImageSize.width, rotatedImageSize.height , TEST_LOCATION );
+ DALI_TEST_EQUALS( originalImageSize.height, rotatedImageSize.width , TEST_LOCATION );
+
+ Property::Map resultMap;
+ imageVisual.CreatePropertyMap( resultMap );
+
+ // check the Property::ORIENTATION_CORRECTION value from the returned map
+ Property::Value* typeValue = resultMap.Find( DevelImageVisual::Property::ORIENTATION_CORRECTION, Property::BOOLEAN );
+ DALI_TEST_EQUALS( typeValue->Get<bool>(), true, TEST_LOCATION );
+
+ END_TEST;
+}