7d78fb1ea933749007f0402adf7733ff4b360f76
[platform/core/uifw/dali-adaptor.git] / automated-tests / src / dali-platform-abstraction / resource-collector.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include "resource-collector.h"
19 #include <dali/integration-api/debug.h>
20
21 namespace Dali
22 {
23 namespace Internal
24 {
25 namespace Platform
26 {
27 using namespace Dali::Integration;
28
29 ResourceCollector::ResourceCollector() :
30   mGrandTotalCompletions(0)
31 {
32 }
33
34 ResourceCollector::~ResourceCollector() {}
35
36 void ResourceCollector::LoadResponse( Dali::Integration::ResourceId id, Dali::Integration::ResourceTypeId type, Dali::Integration::ResourcePointer resource, Dali::Integration::LoadStatus status )
37 {
38   if( status == RESOURCE_COMPLETELY_LOADED )
39   {
40     DALI_ASSERT_DEBUG( mCompletionCounts.find(id) == mCompletionCounts.end() && "A resource can only complete once." );
41     mCompletionStatuses[id] = true;
42     ++mCompletionCounts[id];
43     ++mSuccessCounts[id];
44     mCompletionSequence.push_back( id );
45     ++mGrandTotalCompletions;
46   }
47 }
48
49 void ResourceCollector::LoadFailed( Dali::Integration::ResourceId id, Dali::Integration::ResourceFailure failure )
50 {
51   mCompletionStatuses[id] = false;
52   ++mFailureCounts[id];
53   mCompletionSequence.push_back( id );
54   ++mGrandTotalCompletions;
55 }
56
57
58 } /* namespace Platform */
59 } /* namespace Internal */
60 } /* namespace Dali */