[dali_1.3.47] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-test-application.h
1 #ifndef __DALI_TOOLKIT_TEST_APPLICATION_H__
2 #define __DALI_TOOLKIT_TEST_APPLICATION_H__
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-test-suite-utils.h>
23 #include <dali/devel-api/text-abstraction/font-client.h>
24 #include <dali/integration-api/adaptors/adaptor.h>
25 #include <toolkit-adaptor-impl.h>
26 #include <toolkit-singleton-service.h>
27
28 namespace Dali
29 {
30
31 /**
32  * Adds some functionality on top of TestApplication that is required by the Toolkit.
33  */
34 class ToolkitTestApplication : public TestApplication
35 {
36 public:
37
38   ToolkitTestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
39                           size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
40                           float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
41                           float  verticalDpi   = DEFAULT_VERTICAL_DPI )
42   : TestApplication( surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi )
43   {
44     auto singletonService = SingletonService::Get();
45     Test::SetApplication( singletonService, *this );
46
47     // set the DPI value for font rendering
48     Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
49     if( fontClient )
50     {
51       fontClient.SetDpi( mDpi.x, mDpi.y );
52     }
53   }
54
55   ~ToolkitTestApplication()
56   {
57     // Need to delete core before we delete the adaptor.
58     delete mCore;
59     mCore = NULL;
60   }
61
62   //ToolkitOrientation& GetOrientation()
63   //{
64   //return mOrientation;
65   //}
66
67   /**
68    * @brief Creates an adaptor implementation for those controls like the
69    * text-field and the text-editor which connects a callback to the idle signal.
70    */
71   void CreateAdaptor()
72   {
73     Adaptor::Get();
74   }
75
76   /**
77    * @brief Executes the idle callbacks.
78    *
79    * Some controls like the text-field and the text-editor connect callbacks to the
80    * idle signal.
81    */
82   void RunIdles()
83   {
84     if( Adaptor::IsAvailable() )
85     {
86       for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
87              endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
88            it != endIt;
89            ++it )
90       {
91         CallbackBase* callback = *it;
92
93         CallbackBase::Execute( *callback );
94       }
95
96       Internal::Adaptor::Adaptor::mCallbacks.Clear();
97     }
98   }
99
100 private:
101   //ToolkitOrientation mOrientation;
102 };
103
104 } // namespace Dali
105
106 #endif // __DALI_TOOLKIT_TEST_APPLICATION_H__