Removed SetOnStage/SetOffStage from visual-base.h
[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 namespace {
60
61 BaseHandle Create()
62 {
63   return DummyControlImpl::New();
64 }
65
66 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::DummyControl, Toolkit::Control, Create );
67 DALI_TYPE_REGISTRATION_END()
68 }
69
70 DummyControl DummyControlImpl::New()
71 {
72   IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
73   DummyControl control( *impl );
74   impl->Initialize();
75   return control;
76 }
77
78 DummyControlImpl::DummyControlImpl()
79 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
80   mCustomSlot1Called(false)
81 {
82 }
83
84 DummyControlImpl::~DummyControlImpl()
85 {
86 }
87
88 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
89 {
90   Control::RegisterVisual( index, visual );
91 }
92
93 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
94 {
95   Control::RegisterVisual( index, visual, enabled );
96 }
97
98 void DummyControlImpl::UnregisterVisual( Property::Index index )
99 {
100   Control::UnregisterVisual( index );
101 }
102
103 Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
104 {
105   return Control::GetVisual( index );
106 }
107
108 void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
109 {
110   Control::EnableVisual( index, enabled );
111 }
112
113 bool DummyControlImpl::IsVisualEnabled( Property::Index index )
114 {
115   return Control::IsVisualEnabled( index );
116 }
117
118 Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
119 {
120   return Control::CreateTransition( transition );
121 }
122
123 DummyControl DummyControlImplOverride::New()
124 {
125   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
126   DummyControl control( *impl );
127   impl->Initialize();
128   return control;
129 }
130
131
132 DummyControlImplOverride::DummyControlImplOverride()
133 : DummyControlImpl(),
134   initializeCalled(false),
135   activatedCalled(false),
136   onAccTouchedCalled(false),
137   onAccValueChangeCalled(false),
138   themeChangeCalled(false),
139   fontChangeCalled(false),
140   pinchCalled(false),
141   panCalled(false),
142   tapCalled(false),
143   longPressCalled(false),
144   stageConnectionCalled(false),
145   stageDisconnectionCalled(false),
146   childAddCalled(false),
147   childRemoveCalled(false),
148   sizeSetCalled(false),
149   sizeAnimationCalled(false),
150   touchEventCalled(false),
151   hoverEventCalled(false),
152   wheelEventCalled(false),
153   keyEventCalled(false),
154   keyInputFocusGained(false),
155   keyInputFocusLost(false)
156 {
157 }
158
159 DummyControlImplOverride::~DummyControlImplOverride() { }
160
161
162 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
163 bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
164 bool DummyControlImplOverride::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; }
165 bool DummyControlImplOverride::OnAccessibilityValueChange( bool isIncrease )
166 {
167   onAccValueChangeCalled = true; return true;
168 }
169
170 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
171 {
172   themeChangeCalled = change == StyleChange::THEME_CHANGE;
173   fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
174 }
175 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
176 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
177 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
178 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
179 void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
180 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
181 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
182 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
183 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
184 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
185 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
186 bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
187 bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
188 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
189 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
190 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
191
192 DummyControl DummyControl::New( bool override )
193 {
194   DummyControl control;
195
196   if (override)
197   {
198     control = DummyControlImplOverride::New();
199   }
200   else
201   {
202     control = DummyControlImpl::New();
203   }
204
205   return control;
206 }
207
208 DummyControl::DummyControl( DummyControlImpl& implementation )
209 : Control( implementation )
210 {
211 }
212
213 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
214 : Control( internal )
215 {
216   VerifyCustomActorPointer<DummyControlImpl>(internal);
217 }
218
219 } // namespace Toolkit
220
221 } // namespace Dali