2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "utc-image-loading-common.h"
20 void utc_image_loading_load_completion_startup(void)
22 utc_dali_loading_startup();
25 void utc_image_loading_load_completion_cleanup(void)
27 utc_dali_loading_cleanup();
30 // Positive test case for loading. Load lots and be sure it has succeeded.
31 int UtcDaliLoadCompletion(void)
33 tet_printf("Running load completion test \n");
35 DALI_ASSERT_ALWAYS( gAbstraction != 0 );
37 // Start a bunch of loads that should work:
39 Dali::Integration::BitmapResourceType bitmapResourceType;
40 Dali::Integration::LoadResourcePriority priority = Dali::Integration::LoadPriorityNormal;
41 unsigned loadsLaunched = 0;
43 for( unsigned loadGroup = 0; loadGroup < NUM_LOAD_GROUPS_TO_ISSUE; ++loadGroup )
45 for( unsigned validImage = 0; validImage < NUM_VALID_IMAGES; ++validImage )
47 Dali::Integration::ResourceRequest request( loadGroup * NUM_VALID_IMAGES + validImage + 1, bitmapResourceType, VALID_IMAGES[validImage], priority );
48 gAbstraction->LoadResource( request );
50 loadsLaunched += NUM_VALID_IMAGES;
53 // Drain the completed loads:
54 Dali::Internal::Platform::ResourceCollector resourceSink;
55 gAbstraction->GetResources( resourceSink );
57 gAbstraction->GetResources( resourceSink );
59 const double startDrainTime = GetTimeMilliseconds( *gAbstraction );
60 while( resourceSink.mGrandTotalCompletions < loadsLaunched && GetTimeMilliseconds( *gAbstraction ) - startDrainTime < MAX_MILLIS_TO_WAIT_FOR_KNOWN_LOADS )
63 gAbstraction->GetResources( resourceSink );
66 // Check the loads completed as expected:
68 tet_printf( "Issued Loads: %u, Completed Loads: %u, Successful Loads: %u, Failed Loads: %u \n", loadsLaunched, resourceSink.mGrandTotalCompletions, unsigned(resourceSink.mSuccessCounts.size()), unsigned(resourceSink.mFailureCounts.size()) );
69 DALI_TEST_CHECK( loadsLaunched == resourceSink.mGrandTotalCompletions );
70 DALI_TEST_CHECK( loadsLaunched == resourceSink.mSuccessCounts.size() );
71 DALI_TEST_CHECK( 0 == resourceSink.mFailureCounts.size() );
73 // Check that each success was reported exactly once:
74 for( ResourceCounterMap::const_iterator it = resourceSink.mSuccessCounts.begin(), end = resourceSink.mSuccessCounts.end(); it != end; ++it )
76 DALI_TEST_CHECK( it->second == 1u );