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

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.self_test
local WFAsyncTestCase = require 'WFAsyncTestCase'
local WFTestModelClient = require 'WFTestModelClient'

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

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

	-- WF.lrmobile_models
local LrmDocValueTestFactory = require 'LrmDocValueTestFactory'

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

local LrmImportPerformanceTest = {}

local TEST_TIMOUT = 10

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

function LrmImportPerformanceTest.testImport_testPerformance( test )

	local WFWorkerThread = require 'WFWorkerThread'
	
	local factory = WFTestModelClient.makeModelFactory( WFWorkerThread( 'LrmTestAppMessageProcessor.lua' ) )
	
	local libraryModel = factory:openModel( 'LrmTestAppMessageProcessor.makeLibraryModel' )
	
	local deviceId = KSIdGenerator.uuidInLowercaseHex()
	
	local assetArray = {}
	
	for i = 1, 100 do
	
		local thumbnail2xData = KSData.make( 'thumbnail2x ' .. i )
		local previewData = KSData.make( 'preview ' .. i )
		
		local importAsset = {
			renditions = {
				{
					renditionName = 'thumbnail2x',
					renditionData = thumbnail2xData
				},
				{
					renditionName = 'preview',
					renditionData = previewData,
				}
			},
			docValue = LrmDocValueTestFactory.makeCompleteAsset(),
			deviceId = deviceId,
		}
		
		importAsset.docValue.importSource.sha256 =
				string.sub( importAsset.docValue.importSource.sha256, 1, 61) .. string.format( "%.3i", i )

		assetArray[ #assetArray + 1 ] = importAsset
	
	end
	
	local model = libraryModel:openModel( 'addAssetArrayToCatalog', assetArray )
	
	local valueB = model:valueB()
	
	WFAsyncTestCase( test, TEST_TIMOUT )
	
		:waitForPerf( function()
			
			return valueB:mapE( function( assets )
		
				return #assets
				
			end )
		
		end )
		
		:continueWhenValueMatches( 100 )
		
end

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

return {}
-- return LrmImportPerformanceTest
