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

WFIdleTest.lua

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

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

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

	-- wichitafoundation.core.lua.threading
local WFIdle = require 'WFIdle'


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

local WFIdleTest = {}

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

function WFIdleTest.testOnIdleP( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.onIdleP()
		:whenResolvedDo( function( status, blah )
			
			if status == 'data' and blah == true then
				test:notifyTestDidSucceed()
			else
				test:log( "Unexpected resolution on WFIdle.onIdleP: ", status, blah )
				test:notifyTestDidFail()
			end
		
		end )
		:runUntilDone()
	
	test:waitForTestToFinish( 2 )

end

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

function WFIdleTest.testOnIdleDo( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.onIdleDo( function()

		test:notifyTestDidSucceed()

	end )
	
	test:waitForTestToFinish( 2 )

end

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

function WFIdleTest.testDoLater( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.doLater( function()

		test:notifyTestDidSucceed()

	end )
	
	test:waitForTestToFinish( 2 )

end

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

function WFIdleTest.testLaterP( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.laterP()
		:whenResolvedDo( function( status, blah )
			
			if status == 'data' and blah == true then
				test:notifyTestDidSucceed()
			else
				test:log( "Unexpected resolution on WFIdle.laterP: ", status, blah )
				test:notifyTestDidFail()
			end
		
		end )
		:runUntilDone()
	
	test:waitForTestToFinish( 2 )

end

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

function WFIdleTest.testDoASAP( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.doASAP( function()

		test:notifyTestDidSucceed()

	end )
	
	test:waitForTestToFinish( 2 )

end

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

function WFIdleTest.testAsapP( test )

	-- NOTE: Intentionally not using WFAsyncTestCase here because that class
	-- depends on WFIdle.onIdleP. Need an independent test case.
	
	WFIdle.asapP()
		:whenResolvedDo( function( status, blah )
			
			if status == 'data' and blah == true then
				test:notifyTestDidSucceed()
			else
				test:log( "Unexpected resolution on WFIdle.asapP: ", status, blah )
				test:notifyTestDidFail()
			end
		
		end )
		:runUntilDone()
	
	test:waitForTestToFinish( 2 )

end

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

return WFIdleTest
