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

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

NOTICE: All information contained herein is, and remain 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 may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

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

	-- WF.core.rxlua
local WFRxTestCase = require 'WFRxTestCase'

	-- WF.oz_client.utils
local OzFilePaths = require 'OzFilePaths'

	-- WF.oz_client.sync_engine
local WFOzSyncConstants = require 'WFOzSyncConstants'

	-- WF.core.utils
local KSIdGenerator = require 'KSIdGenerator'
local KSPathUtils = require 'KSPathUtils'

	-- WF.core.os
local WFPlatformInfo = require 'WFPlatformInfo'

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

local OzFilePathsTest = {}

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

function OzFilePathsTest.rxTestStandardDocumentsPath( rxTest )

	local catalogId = KSIdGenerator.uuidInLowercaseHex()
	
	local documentsDir = OzFilePaths.getStandardOriginalFolderDocumentsPath( catalogId )
	
	local pattern = '(.*)%/([0-9a-f]+)%/Originals$'
	
	if WFPlatformInfo.isWindows then
		pattern = '(.*)\\([0-9a-f]+)\\Originals$'
	end
	
	local docDir, catId = documentsDir:match( pattern )
	
	rxTest:expectEqual( docDir, KSPathUtils.getStandardFilePath 'carouselDocuments' )
	rxTest:expectEqual( catId, catalogId )
	
end

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

function OzFilePathsTest.rxTestStandardDocumentsPathWithGlobalId( rxTest )

	local catalogId = WFOzSyncConstants.kGlobalDocumentId
	
	local documentsDir = OzFilePaths.getStandardOriginalFolderDocumentsPath( catalogId )
	
	local pattern = '(.*)%/Originals$'
	
	if WFPlatformInfo.isWindows then
		pattern = '(.*)\\Originals$'
	end
	
	local docDir = documentsDir:match( pattern )

	if WFPlatformInfo.isAndroid then
		rxTest:expectEqual( docDir, KSPathUtils.getStandardFilePath 'carouselDocuments' )
	else
		rxTest:expectEqual( docDir, KSPathUtils.child( KSPathUtils.getStandardFilePath 'carouselDocuments', catalogId ) )
	end
	rxTest:expectEqual( WFOzSyncConstants.isGlobalDocumentId( catalogId ), true )
	
end

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

if WFPlatformInfo.isAndroid then
	function OzFilePathsTest.rxTestAndroidXmpCameraRawAbsoluteFilePath( rxTest )

		local documentsDir = KSPathUtils.getStandardFilePath( 'carouselDocuments' )

		local docValue = {
			_localOnly = {
				files = {
					xmp_develop = {
						path = "somePath",
						sha256 = "deadbeef"
					}
				}
			}
		}

		local expectedValue = KSPathUtils.child( documentsDir, "somePath" )

		rxTest:expectEqual( expectedValue, OzFilePaths.getAbsoluteXmpDevelopPath( docValue ) )

	end
end

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

return WFRxTestCase.wrapSuite( 'OzFilePathsTest', OzFilePathsTest )

