RegisterVisuals has option not to auto stage visual
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / dummy-control.cpp
1 /*
2  * Copyright (c) 2014 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 "dummy-control.h"
19
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 DummyControl::DummyControl()
30 {
31 }
32
33 DummyControl::DummyControl(const DummyControl& control)
34 : Control( control )
35 {
36 }
37
38 DummyControl::~DummyControl()
39 {
40 }
41
42 DummyControl DummyControl::DownCast( BaseHandle handle )
43 {
44   return Control::DownCast<DummyControl, DummyControlImpl>(handle);
45 }
46
47 DummyControl& DummyControl::operator=(const DummyControl& control)
48 {
49   Control::operator=( control );
50   return *this;
51 }
52
53 // Used to test signal connections
54 void DummyControlImpl::CustomSlot1( Actor actor )
55 {
56   mCustomSlot1Called = true;
57 }
58
59 DummyControl DummyControlImpl::New()
60 {
61   IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
62   DummyControl control( *impl );
63   impl->Initialize();
64   return control;
65 }
66
67 DummyControlImpl::DummyControlImpl()
68 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
69   mCustomSlot1Called(false)
70 {
71 }
72
73
74 DummyControlImpl::~DummyControlImpl()
75 {
76 }
77
78 void DummyControlImpl::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual )
79 {
80   Control::RegisterVisual( index, placementActor, visual );
81 }
82
83 void DummyControlImpl::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual, bool enabled )
84 {
85   Control::RegisterVisual( index, placementActor, visual, enabled );
86 }
87
88 void DummyControlImpl::UnregisterVisual( Property::Index index )
89 {
90   Control::UnregisterVisual( index );
91 }
92
93 Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
94 {
95   return Control::GetVisual( index );
96 }
97
98 void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
99 {
100   Control::EnableVisual( index, enabled );
101 }
102
103 bool DummyControlImpl::IsVisualEnabled( Property::Index index )
104 {
105   return Control::IsVisualEnabled( index );
106 }
107
108 Actor DummyControlImpl::GetPlacementActor( Property::Index index )
109 {
110   return Control::GetPlacementActor( index );
111 }
112
113 DummyControl DummyControlImplOverride::New()
114 {
115   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
116   DummyControl control( *impl );
117   impl->Initialize();
118   return control;
119 }
120
121
122 DummyControlImplOverride::DummyControlImplOverride()
123 : DummyControlImpl(),
124   initializeCalled(false),
125   activatedCalled(false),
126   onAccTouchedCalled(false),
127   onAccValueChangeCalled(false),
128   themeChangeCalled(false),
129   fontChangeCalled(false),
130   pinchCalled(false),
131   panCalled(false),
132   tapCalled(false),
133   longPressCalled(false),
134   stageConnectionCalled(false),
135   stageDisconnectionCalled(false),
136   childAddCalled(false),
137   childRemoveCalled(false),
138   sizeSetCalled(false),
139   sizeAnimationCalled(false),
140   touchEventCalled(false),
141   hoverEventCalled(false),
142   wheelEventCalled(false),
143   keyEventCalled(false),
144   keyInputFocusGained(false),
145   keyInputFocusLost(false)
146 {
147 }
148
149 DummyControlImplOverride::~DummyControlImplOverride() { }
150
151
152 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
153 bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
154 bool DummyControlImplOverride::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; }
155 bool DummyControlImplOverride::OnAccessibilityValueChange( bool isIncrease )
156 {
157   onAccValueChangeCalled = true; return true;
158 }
159
160 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
161 {
162   themeChangeCalled = change == StyleChange::THEME_CHANGE;
163   fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
164 }
165 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
166 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
167 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
168 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
169 void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
170 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
171 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
172 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
173 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
174 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
175 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
176 bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
177 bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
178 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
179 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
180 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
181
182 DummyControl DummyControl::New( bool override )
183 {
184   DummyControl control;
185
186   if (override)
187   {
188     control = DummyControlImplOverride::New();
189   }
190   else
191   {
192     control = DummyControlImpl::New();
193   }
194
195   return control;
196 }
197
198 DummyControl::DummyControl( DummyControlImpl& implementation )
199 : Control( implementation )
200 {
201 }
202
203 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
204 : Control( internal )
205 {
206   VerifyCustomActorPointer<DummyControlImpl>(internal);
207 }
208
209 } // namespace Toolkit
210
211 } // namespace Dali