Merge "Basic support of keyboard focus for multiple windows" into 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) 2019 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 #include <toolkit-lifecycle-controller.h>
28
29 namespace Dali
30 {
31
32 /**
33  * Adds some functionality on top of TestApplication that is required by the Toolkit.
34  */
35 class ToolkitTestApplication : public TestApplication
36 {
37 public:
38
39   ToolkitTestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
40                           size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
41                           float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
42                           float  verticalDpi   = DEFAULT_VERTICAL_DPI )
43   : TestApplication( surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi )
44   {
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     bool isAdaptorAvailable = Dali::Internal::Adaptor::Adaptor::Get().IsAvailable();
56     if ( isAdaptorAvailable )
57     {
58       Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
59       lifecycleController.InitSignal().Emit();
60
61       Dali::Window window = Dali::Internal::Adaptor::Adaptor::mWindows.front();
62       if ( window )
63       {
64         Dali::Internal::Adaptor::Adaptor::WindowCreatedSignal().Emit( window );
65       }
66     }
67   }
68
69   ~ToolkitTestApplication()
70   {
71     // Need to delete core before we delete the adaptor.
72     delete mCore;
73     mCore = NULL;
74   }
75
76   //ToolkitOrientation& GetOrientation()
77   //{
78   //return mOrientation;
79   //}
80
81   /**
82    * @brief Creates an adaptor implementation for those controls like the
83    * text-field and the text-editor which connects a callback to the idle signal.
84    */
85   void CreateAdaptor()
86   {
87     Adaptor::Get();
88   }
89
90   /**
91    * @brief Executes the idle callbacks.
92    *
93    * Some controls like the text-field and the text-editor connect callbacks to the
94    * idle signal.
95    */
96   void RunIdles()
97   {
98     if( Adaptor::IsAvailable() )
99     {
100       for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
101              endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
102            it != endIt;
103            ++it )
104       {
105         CallbackBase* callback = *it;
106
107         CallbackBase::Execute( *callback );
108       }
109
110       Internal::Adaptor::Adaptor::mCallbacks.Clear();
111     }
112   }
113
114 private:
115   //ToolkitOrientation mOrientation;
116 };
117
118 } // namespace Dali
119
120 #endif // DALI_TOOLKIT_TEST_APPLICATION_H