Geometry Batching
[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
22 namespace Dali
23 {
24
25 namespace Toolkit
26 {
27
28 DummyControl::DummyControl()
29 {
30 }
31
32 DummyControl::DummyControl(const DummyControl& control)
33 : Control( control )
34 {
35 }
36
37 DummyControl::~DummyControl()
38 {
39 }
40
41 DummyControl DummyControl::DownCast( BaseHandle handle )
42 {
43   return Control::DownCast<DummyControl, DummyControlImpl>(handle);
44 }
45
46 DummyControl& DummyControl::operator=(const DummyControl& control)
47 {
48   Control::operator=( control );
49   return *this;
50 }
51
52 // Used to test signal connections
53 void DummyControlImpl::CustomSlot1( Actor actor )
54 {
55   mCustomSlot1Called = true;
56 }
57
58 DummyControl DummyControlImpl::New()
59 {
60   IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
61   DummyControl control( *impl );
62   impl->Initialize();
63   return control;
64 }
65
66 DummyControlImpl::DummyControlImpl()
67 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
68   mCustomSlot1Called(false)
69 {
70 }
71
72
73 DummyControlImpl::~DummyControlImpl()
74 {
75 }
76
77 DummyControl DummyControlImplOverride::New()
78 {
79   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
80   DummyControl control( *impl );
81   impl->Initialize();
82   return control;
83 }
84
85
86 DummyControlImplOverride::DummyControlImplOverride()
87 : DummyControlImpl(),
88   initializeCalled(false),
89   activatedCalled(false),
90   onAccTouchedCalled(false),
91   onAccValueChangeCalled(false),
92   themeChangeCalled(false),
93   fontChangeCalled(false),
94   pinchCalled(false),
95   panCalled(false),
96   tapCalled(false),
97   longPressCalled(false),
98   stageConnectionCalled(false),
99   stageDisconnectionCalled(false),
100   childAddCalled(false),
101   childRemoveCalled(false),
102   sizeSetCalled(false),
103   sizeAnimationCalled(false),
104   touchEventCalled(false),
105   hoverEventCalled(false),
106   wheelEventCalled(false),
107   keyEventCalled(false),
108   keyInputFocusGained(false),
109   keyInputFocusLost(false)
110 {
111 }
112
113 DummyControlImplOverride::~DummyControlImplOverride() { }
114
115
116 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
117 bool DummyControlImplOverride::OnAccessibilityActivated() { activatedCalled = true; return true; }
118 bool DummyControlImplOverride::OnAccessibilityTouch(const TouchEvent& touchEvent) { onAccTouchedCalled = true; return true; }
119 bool DummyControlImplOverride::OnAccessibilityValueChange( bool isIncrease )
120 {
121   onAccValueChangeCalled = true; return true;
122 }
123
124 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
125 {
126   themeChangeCalled = change == StyleChange::THEME_CHANGE;
127   fontChangeCalled = change == StyleChange::DEFAULT_FONT_SIZE_CHANGE;
128 }
129 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
130 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
131 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
132 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
133 void DummyControlImplOverride::OnStageConnection( int depth ) { Control::OnStageConnection( depth ); stageConnectionCalled = true; }
134 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; Control::OnStageDisconnection(); }
135 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
136 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
137 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
138 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
139 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
140 bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; }
141 bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; }
142 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
143 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
144 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
145
146 DummyControl DummyControl::New( bool override )
147 {
148   DummyControl control;
149
150   if (override)
151   {
152     control = DummyControlImplOverride::New();
153   }
154   else
155   {
156     control = DummyControlImpl::New();
157   }
158
159   return control;
160 }
161
162 DummyControl::DummyControl( DummyControlImpl& implementation )
163 : Control( implementation )
164 {
165 }
166
167 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
168 : Control( internal )
169 {
170   VerifyCustomActorPointer<DummyControlImpl>(internal);
171 }
172
173 } // namespace Toolkit
174
175 } // namespace Dali