2 * Copyright (c) 2017 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.
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/internal/visuals/texture-manager-impl.h>
24 #include <dali-toolkit/internal/visuals/texture-upload-observer.h>
26 using namespace Dali::Toolkit::Internal;
28 class TestObserver : public Dali::Toolkit::TextureUploadObserver
33 mObserverCalled(false)
37 virtual void UploadComplete( bool loadSuccess, int32_t textureId, TextureSet textureSet,
38 bool useAtlasing, const Vector4& atlasRect, bool preMultiplied ) override
40 mLoaded = loadSuccess;
41 mObserverCalled = true;
49 int UtcTextureManagerRequestLoad(void)
51 ToolkitTestApplication application;
53 TextureManager textureManager; // Create new texture manager
55 TestObserver observer;
56 std::string filename("image.png");
57 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
58 TextureManager::TextureId textureId = textureManager.RequestLoad(
61 FittingMode::SCALE_TO_FILL,
62 SamplingMode::BOX_THEN_LINEAR,
63 TextureManager::NO_ATLAS,
66 TextureManager::ReloadPolicy::CACHED,
69 VisualUrl url = textureManager.GetVisualUrl( textureId );
71 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
76 int UtcTextureManagerGenerateHash(void)
78 ToolkitTestApplication application;
80 TextureManager textureManager; // Create new texture manager
82 TestObserver observer;
83 std::string filename( "image.png" );
84 auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
85 TextureManager::TextureId textureId = textureManager.RequestLoad(
88 FittingMode::SCALE_TO_FILL,
89 SamplingMode::BOX_THEN_LINEAR,
90 TextureManager::USE_ATLAS,
93 TextureManager::ReloadPolicy::CACHED,
96 VisualUrl url = textureManager.GetVisualUrl( textureId );
98 DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );