2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <toolkit-test-application.h>
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>
32 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
34 ToolkitTestApplication::ToolkitTestApplication( size_t surfaceWidth, size_t surfaceHeight, float horizontalDpi, float verticalDpi )
35 : TestApplication( surfaceWidth, surfaceHeight, horizontalDpi, verticalDpi, ResourcePolicy::DALI_DISCARDS_ALL_DATA, false /* Do not Initialize Core */ ),
36 mMainWindow( new Dali::Window ),
37 mAdaptor( &AdaptorImpl::New() ) // Need to create Adaptor first as many singletons in dali-adaptor need it
42 // Override Scene creation in TestApplication by creating a window.
43 // The window will create a Scene & surface and set up the scene's surface appropriately.
44 *mMainWindow = Window::New( PositionSize( 0, 0, surfaceWidth, surfaceHeight ), "" );
45 mScene = AdaptorImpl::GetScene( *mMainWindow );
46 mRenderSurface = dynamic_cast< TestRenderSurface* >( mScene.GetSurface() );
47 mScene.SetDpi( Vector2( horizontalDpi, verticalDpi ) );
49 // Core needs to be initialized next before we start the adaptor
52 auto singletonService = SingletonService::Get();
53 Test::SetApplication( singletonService, *this );
55 // This will also emit the window created signals
56 AdaptorImpl::GetImpl( *mAdaptor ).Start( *mMainWindow );
58 Dali::LifecycleController lifecycleController = Dali::LifecycleController::Get();
59 lifecycleController.InitSignal().Emit();
61 // set the DPI value for font rendering
62 TextAbstraction::FontClient fontClient = Dali::TextAbstraction::FontClient::Get();
65 fontClient.SetDpi( mDpi.x, mDpi.y );
69 ToolkitTestApplication::~ToolkitTestApplication()
71 // Need to delete core before we delete the adaptor.
75 // Set mRenderSurface to null, it will be deleted by the window that owns it
76 mRenderSurface = nullptr;
79 void ToolkitTestApplication::RunIdles()
81 AdaptorImpl::GetImpl( *mAdaptor.get() ).RunIdles();