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