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

MockPixelProviderProcessor.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2016 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.

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

Mock pixel provider stream object to be used in self tests.

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

	-- RxLua
local Rx = require 'Rx'

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

local function makeForwardToPixelPathProviderScheduler( api )

	return function( self, ... )

		 return self._scheduler[ api ]( self._scheduler, ... )

	end

end

local function createMockPixelProviderProcessor( wfCatalog )

	-- This emulates PixelProviderProcessor without the headaches of mocking
	-- out a transitable wfCatalog
	
	local scheduler = require 'PixelPathProviderScheduler'( wfCatalog )

	return {

		_scheduler = scheduler,
		
		runUntilDone = function( self, name, ... )

			 return self._scheduler[ name ]( self._scheduler, ... )

		end,

		pixStreamIdPixelPathStream = 
			makeForwardToPixelPathProviderScheduler(
				'pixStreamIdPixelPathStream' ),

		pixStreamIdsPixelPathStream = 
			makeForwardToPixelPathProviderScheduler(
				'pixStreamIdsPixelPathStream' ),

		containsPixStreamIdSubstrPixelPathStream = 
			makeForwardToPixelPathProviderScheduler(
				'containsPixStreamIdSubstrPixelPathStream' ),

		bufferedPixelPathStream = 
			makeForwardToPixelPathProviderScheduler(
				'bufferedPixelPathStream' ),

		_DEBUG_requestStatsStream = 
			makeForwardToPixelPathProviderScheduler(
				'_DEBUG_requestStatsStream' ),

		_DEBUG_localAssetIdStatesStream = 
			makeForwardToPixelPathProviderScheduler(
				'_DEBUG_localAssetIdStatesStream' ),


		close = function( self )

			self._scheduler:close()

		end,

	}

end

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

local function createPixelProcessorStream( rxTest, wfCatalog )

	local mockPixelProviderProcessor =
							createMockPixelProviderProcessor( wfCatalog )

	local stream = Rx.Observable.just( mockPixelProviderProcessor )

	rxTest:finally( function()

		mockPixelProviderProcessor:close()

	end )

	return stream

end
--------------------------------------------------------------------------------

return {
	createPixelProcessorStream = createPixelProcessorStream
}
