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