[Tizen] Revert "Support multiple window rendering"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali-internal / utc-Dali-Internal-Core.cpp
1 /*
2  * Copyright (c) 2016 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 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22
23 #include <dali-test-suite-utils.h>
24
25 // Internal headers are allowed here
26
27
28 using namespace Dali;
29
30 void utc_dali_internal_core_startup()
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_internal_core_cleanup()
36 {
37   test_return_value = TET_PASS;
38 }
39
40 namespace
41 {
42
43 class RelayoutSignalHandler : public Dali::ConnectionTracker
44 {
45 public:
46
47   RelayoutSignalHandler( TestApplication& application )
48   : mApplication( application ),
49     mSignalCalled( false )
50   {
51   }
52
53   // callback to be connected to RelayoutSignal
54   void RelayoutCallback( Actor actor  )
55   {
56     tet_infoline("RelayoutCallback is called");
57
58     mSignalCalled = true;
59
60     mApplication.SendNotification();
61   }
62
63   TestApplication& mApplication;
64   bool   mSignalCalled;
65 };
66
67 } // anonymous namespace
68
69 int UtcDaliCoreTopMargin(void)
70 {
71   TestApplication application;
72   tet_infoline("Testing Dali::Integration::Core::SetTopMargin");
73
74   Stage stage = Stage::GetCurrent();
75
76   // Test Stage size without top-margin
77
78   const unsigned int initialWidth(  stage.GetSize().width );
79   const unsigned int initialHeight( stage.GetSize().height );
80
81   DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH,  initialWidth,  TEST_LOCATION );
82   DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_HEIGHT, initialHeight, TEST_LOCATION );
83
84   // Retest with top-margin
85
86   unsigned int margin( 10 );
87   application.SetTopMargin( margin );
88
89   const unsigned int newWidth(  stage.GetSize().width );
90   const unsigned int newHeight( stage.GetSize().height );
91
92   DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH,             newWidth,  TEST_LOCATION );
93   DALI_TEST_EQUALS( (TestApplication::DEFAULT_SURFACE_HEIGHT - margin), newHeight, TEST_LOCATION );
94
95   END_TEST;
96 }
97
98 int UtcDaliCoreProcessEvents(void)
99 {
100   TestApplication application;
101   tet_infoline("Testing Dali::Integration::Core::ProcessEvents");
102
103   Vector3 size( 100.0f, 100.0f, 0.0f );
104   Vector3 position( 100.0f, 100.0f, 0.0f );
105
106   Actor actor = Actor::New();
107   actor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
108   actor.SetSize( size );
109   actor.SetPosition( position );
110   Stage::GetCurrent().Add( actor );
111
112   RelayoutSignalHandler relayoutSignal( application );
113   actor.OnRelayoutSignal().Connect( &relayoutSignal, &RelayoutSignalHandler::RelayoutCallback );
114
115   application.SendNotification();
116
117   DALI_TEST_EQUALS( relayoutSignal.mSignalCalled, true, TEST_LOCATION );
118
119   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::SIZE ).Get< Vector3 >(), size, TEST_LOCATION );
120   DALI_TEST_EQUALS( actor.GetProperty( Actor::Property::POSITION ).Get< Vector3 >(), position, TEST_LOCATION );
121
122   END_TEST;
123 }