Merge "Fix bug with mixed language text" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-internal / utc-Dali-TextureManager.cpp
1 /*
2  * Copyright (c) 2017 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 <iostream>
19
20 #include <stdlib.h>
21
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>
25
26 using namespace Dali::Toolkit::Internal;
27
28 class TestObserver : public Dali::Toolkit::TextureUploadObserver
29 {
30 public:
31   TestObserver()
32   : mLoaded(false),
33     mObserverCalled(false)
34   {
35   }
36
37   void UploadComplete( bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect )
38   {
39     mLoaded = loadSuccess;
40     mObserverCalled = true;
41   }
42
43   bool mLoaded;
44   bool mObserverCalled;
45 };
46
47
48 int UtcTextureManagerRequestLoad(void)
49 {
50   ToolkitTestApplication application;
51
52   TextureManager textureManager; // Create new texture manager
53
54   TestObserver observer;
55   std::string filename("image.png");
56
57   TextureManager::TextureId textureId = textureManager.RequestLoad(
58     filename,
59     ImageDimensions(),
60     FittingMode::SCALE_TO_FILL,
61     SamplingMode::BOX_THEN_LINEAR,
62     TextureManager::NO_ATLAS,
63     &observer,
64     true,
65     TextureManager::ReloadPolicy::CACHED );
66
67   const VisualUrl& url = textureManager.GetVisualUrl( textureId );
68
69   DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION );
70
71   END_TEST;
72 }