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

XmpDevelopStateMachineTest.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2022 Adobe
All Rights Reserved.

NOTICE: All information contained herein is, and remains
the property of Adobe and its suppliers, if any. The intellectual
and technical concepts contained herein are proprietary to Adobe
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.

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


	-- wf.core
local WFFiniteStateMachineUtils = require 'WFFiniteStateMachineUtils'
local WFRxTestCase = require 'WFRxTestCase'

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

local XmpDevelopStateMachine = require "XmpDevelopStateMachine"

--------------------------------------------------------------------------------
-- README
-- 
-- How to HTML file for state machine
-- 
-- The state machine can generate an HTML file which is useful for navigating.
-- 
-- This test below will create an HTML in the FSM_HTML_DIR
--
-- To run this test locally
-- 
-- 1) update this for your source directory 
local SRC_PARENT_DIR = "/Users/bkruse/adobe_github_code/lightroom/nimbus/"
local FSM_HTML_DIR= SRC_PARENT_DIR .. "imported/adobe/wichitafoundation/lightroomcc/pixel_provider/scheduler/state_machine/" 

--------------------------------------------------------------------------------
-- 2) set generateHTMLFile to true 
local generateHTMLFile = false

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

local function makeHTMLStateMachine( fname, fsm, description, 
										startStates, finishStates )

	local html = WFFiniteStateMachineUtils.getAsHTMLFileWithJustStartFinishTOCSection( 
					fsm, "XmpDevelopStateMachine", description, startStates,
					finishStates )

	local htmlFilePath = string.format( "%s%s.html", FSM_HTML_DIR, fname )

	local fh = assert( io.open( htmlFilePath, 'w' ), 
						string.format( "failed to open %s for writing",
										htmlFilePath ) )

	fh:write( html )

	fh:close()

end

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

local function rxTestGenerateHTMLFile()

	if not generateHTMLFile then

		return

	end

	local fsm = require "PixelPathProviderStateMachine".make()

	local startStates, finishStates = 
			XmpDevelopStateMachine._privateTestExport.getEnsureLocalDevelopSettingsStartFinishStates()

	makeHTMLStateMachine( 
		"XmpDevelopStateMachineEnsureLocalDevelopSettings", 
		fsm, "The develop panel uses these states to ensure all develop settings files are on the local machine.", startStates, finishStates )

	startStates, finishStates = 
		XmpDevelopStateMachine._privateTestExport.getEnsureLocalDevelopSettingsForRenderStartFinishStates()

	makeHTMLStateMachine( 
		"XmpDevelopStateMachineEnsureLocalDevelopSettingsForRender", 
		fsm, "States that attempt to ensure local develop settings are available in order to do local render", startStates, finishStates )

end

--==============================================================================

return WFRxTestCase.wrapSuite( 'XmpDevelopStateMachineTest', {

	rxTestGenerateHTMLFile = rxTestGenerateHTMLFile,

} )
