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