1301b8f2ccb05fe8c659ca2ffe68785155a807ca
[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( false, surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi )
43   {
44     Initialize();
45     auto singletonService = SingletonService::Get();
46     Test::SetApplication( singletonService, *this );
47
48     // set the DPI value for font rendering
49     Dali::TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
50     if( fontClient )
51     {
52       fontClient.SetDpi( mDpi.x, mDpi.y );
53     }
54   }
55
56   ~ToolkitTestApplication()
57   {
58     // Need to delete core before we delete the adaptor.
59     delete mCore;
60     mCore = NULL;
61   }
62
63   //ToolkitOrientation& GetOrientation()
64   //{
65   //return mOrientation;
66   //}
67
68   /**
69    * @brief Creates an adaptor implementation for those controls like the
70    * text-field and the text-editor which connects a callback to the idle signal.
71    */
72   void CreateAdaptor()
73   {
74     Adaptor::Get();
75   }
76
77   /**
78    * @brief Executes the idle callbacks.
79    *
80    * Some controls like the text-field and the text-editor connect callbacks to the
81    * idle signal.
82    */
83   void RunIdles()
84   {
85     if( Adaptor::IsAvailable() )
86     {
87       for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
88              endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
89            it != endIt;
90            ++it )
91       {
92         CallbackBase* callback = *it;
93
94         CallbackBase::Execute( *callback );
95       }
96
97       Internal::Adaptor::Adaptor::mCallbacks.Clear();
98     }
99   }
100
101 private:
102   //ToolkitOrientation mOrientation;
103 };
104
105 } // namespace Dali
106
107 #endif // __DALI_TOOLKIT_TEST_APPLICATION_H__