Fixing build break in test cases
[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/public-api/styling/style-manager.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, const Vector3& value )
54 {
55   mCustomSlot1Called = true;
56   mCustomSlot1Value = value;
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_STYLE_CHANGE_SIGNALS ) ),
69   mCustomSlot1Called(false),
70   mCustomSlot1Value(Vector3::ZERO)
71 {
72 }
73
74
75 DummyControlImpl::~DummyControlImpl()
76 {
77 }
78
79 DummyControl DummyControlImplOverride::New()
80 {
81   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
82   DummyControl control( *impl );
83   impl->Initialize();
84   return control;
85 }
86
87
88 DummyControlImplOverride::DummyControlImplOverride()
89 : DummyControlImpl(),
90   initializeCalled(false),
91   themeChangeCalled( false ),
92   fontChangeCalled( false ),
93   pinchCalled(false),
94   panCalled(false),
95   tapCalled(false),
96   longPressCalled(false),
97   stageConnectionCalled(false),
98   stageDisconnectionCalled(false),
99   childAddCalled(false),
100   childRemoveCalled(false),
101   sizeSetCalled(false),
102   sizeAnimationCalled(false),
103   touchEventCalled(false),
104   mouseWheelEventCalled(false),
105   keyEventCalled(false),
106   keyInputFocusGained(false),
107   keyInputFocusLost(false)
108 {
109 }
110
111 DummyControlImplOverride::~DummyControlImplOverride() { }
112
113
114 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
115 void DummyControlImplOverride::OnThemeChange(StyleManager change) { themeChangeCalled = true;}
116 void DummyControlImplOverride::OnFontChange(bool defaultFontChange, bool defaultFontSizeChange) { fontChangeCalled = true; }
117 void DummyControlImplOverride::OnPinch(PinchGesture pinch) { pinchCalled = true; }
118 void DummyControlImplOverride::OnPan(PanGesture pan) { panCalled = true; }
119 void DummyControlImplOverride::OnTap(TapGesture tap) { tapCalled = true; }
120 void DummyControlImplOverride::OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
121 void DummyControlImplOverride::OnStageConnection() { stageConnectionCalled = true; }
122 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
123 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
124 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
125 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
126 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
127 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
128 bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
129 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
130 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
131 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
132
133 DummyControl DummyControl::New( bool override )
134 {
135   DummyControl control;
136
137   if (override)
138   {
139     control = DummyControlImplOverride::New();
140   }
141   else
142   {
143     control = DummyControlImpl::New();
144   }
145
146   return control;
147 }
148
149 DummyControl::DummyControl( DummyControlImpl& implementation )
150 : Control( implementation )
151 {
152 }
153
154 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
155 : Control( internal )
156 {
157   VerifyCustomActorPointer<DummyControlImpl>(internal);
158 }
159
160 } // namespace Toolkit
161
162 } // namespace Dali