[dali_1.9.6] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-test-application.cpp
1 /*
2  * Copyright (c) 2020 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 // CLASS HEADER
19 #include <toolkit-test-application.h>
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/adaptor-framework/adaptor.h>
25 #include <toolkit-adaptor-impl.h>
26 #include <toolkit-lifecycle-controller.h>
27
28 namespace Dali
29 {
30
31 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
32
33 ToolkitTestApplication::ToolkitTestApplication( size_t surfaceWidth, size_t surfaceHeight, float  horizontalDpi, float verticalDpi )
34 : TestApplication( surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi, false /* Do not Initialize Core */ ),
35   mMainWindow( new Dali::Window ),
36   mAdaptor( &AdaptorImpl::New() ) // Need to create Adaptor first as many singletons in dali-adaptor need it
37 {
38   // Create Core next
39   CreateCore();
40
41   // Override Scene creation in TestApplication by creating a window.
42   // The window will create a Scene & surface and set up the scene's surface appropriately.
43   *mMainWindow = Window::New( PositionSize( 0, 0, surfaceWidth, surfaceHeight ), "" );
44   mScene = AdaptorImpl::GetScene( *mMainWindow );
45   mScene.SetDpi( Vector2( horizontalDpi, verticalDpi ) );
46
47   // Core needs to be initialized next before we start the adaptor
48   InitializeCore();
49
50   // This will also emit the window created signals
51   AdaptorImpl::GetImpl( *mAdaptor ).Start( *mMainWindow );
52
53   Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
54   lifecycleController.InitSignal().Emit();
55
56   // set the DPI value for font rendering
57   TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
58   if( fontClient )
59   {
60     fontClient.SetDpi( mDpi.x, mDpi.y );
61   }
62 }
63
64 ToolkitTestApplication::~ToolkitTestApplication()
65 {
66   // Need to delete core before we delete the adaptor.
67   delete mCore;
68   mCore = NULL;
69 }
70
71 void ToolkitTestApplication::RunIdles()
72 {
73   AdaptorImpl::GetImpl( *mAdaptor.get() ).RunIdles();
74 }
75
76 } // namespace Dali