--[[----------------------------------------------------------------------------

WFImageOrientationTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2015 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

----------------------------------------------------------------------------]]--

local WFImageOrientation = require 'WFImageOrientation'

--------------------------------------------------------------------------------

local WFImageOrientationTest = {}
	
--------------------------------------------------------------------------------

function WFImageOrientationTest.testSwapDimensions()
--	TIFF Orientations:
--		1 = Horizontal (normal) 
--		2 = Mirror horizontal 
--		3 = Rotate 180 
--		4 = Mirror vertical 
--		5 = Mirror horizontal and rotate 270 CW 
--		6 = Rotate 90 CW 
--		7 = Mirror horizontal and rotate 90 CW 
--		8 = Rotate 270 CW
	assert( not WFImageOrientation.swapDimensions( 1 ), "Orientation 1 (normal) shouldn't swap dimensions" )
	assert( not WFImageOrientation.swapDimensions( 2 ), "Orientation 2 (Mirror Horizontal) shouldn't swap dimensions" )
	assert( not WFImageOrientation.swapDimensions( 3 ), "Orientation 3 (Rotate 180) shouldn't swap dimensions" )
	assert( not WFImageOrientation.swapDimensions( 4 ), "Orientation 4 (Mirror Vertical) shouldn't swap dimensions" )
	assert( WFImageOrientation.swapDimensions( 5 ), "Orientation 5 (Mirror horizontal and rotate 270 CW) should swap dimensions" )
	assert( WFImageOrientation.swapDimensions( 6 ), "Orientation 6 (Rotate 90 CW) should swap dimensions" )
	assert( WFImageOrientation.swapDimensions( 7 ), "Orientation 7 (Mirror horizontal and rotate 90 CW) should swap dimensions" )
	assert( WFImageOrientation.swapDimensions( 8 ), "Orientation 8 (Rotate 270 CW) should swap dimensions" )
	
end

--------------------------------------------------------------------------------

function WFImageOrientationTest.testOrientationConversions( )
	-- This test all the orientation conversion methods and ensure that
	-- the conversions are stable.
	
	local tiffOrientationsToTest = { 1, 2, 3, 4, 5, 6, 7, 8 }
	
	for _, tiffOrientation in ipairs( tiffOrientationsToTest ) do
	
		local orientation = tiffOrientation
		
		orientation = WFImageOrientation.tiffOrientationToAgOrientation( orientation )
		orientation = WFImageOrientation.AgOrientationToVFOrientation( orientation )
		orientation = WFImageOrientation.vfOrientationToTiffOrientation( orientation )
		orientation = WFImageOrientation.tiffOrientationToVFOrientation( orientation )
		orientation = WFImageOrientation.vfOrientationToAgOrientation( orientation )
		orientation = WFImageOrientation.AgOrientationTOTiffOrientation( orientation )
		
		-- we should end back where we started with tiffOrientation
		assert( tiffOrientation == orientation, 
				string.format( "Original orientation %s and converted orientation %s should be the same.", 
								tiffOrientation, orientation ) )
	end
	
	
end
--------------------------------------------------------------------------------

return WFImageOrientationTest