License conversion from Flora to Apache 2.0
[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 namespace Dali
21 {
22
23 namespace Toolkit
24 {
25
26 DummyControl::DummyControl()
27 : mCustomSlot1Called(false)
28 {
29 }
30
31 DummyControl::DummyControl(const DummyControl& control)
32 : Control( control ),
33   mCustomSlot1Called(false),
34   mCustomSlot1Value(Vector3::ZERO)
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 DummyControl::CustomSlot1( Actor actor, const Vector3& value )
55 {
56   mCustomSlot1Called = true;
57   mCustomSlot1Value = value;
58 }
59
60 DummyControl DummyControlImpl::New()
61 {
62   IntrusivePtr< DummyControlImpl > impl = new DummyControlImpl;
63   DummyControl control( *impl );
64   impl->Initialize();
65   return control;
66 }
67
68 DummyControlImpl::DummyControlImpl()
69 : ControlImpl(true)
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   styleChangeCalled(false),
90   pinchCalled(false),
91   panCalled(false),
92   tapCalled(false),
93   longPressCalled(false),
94   stageConnectionCalled(false),
95   stageDisconnectionCalled(false),
96   childAddCalled(false),
97   childRemoveCalled(false),
98   sizeSetCalled(false),
99   sizeAnimationCalled(false),
100   touchEventCalled(false),
101   mouseWheelEventCalled(false),
102   keyEventCalled(false),
103   keyInputFocusGained(false),
104   keyInputFocusLost(false)
105 {
106 }
107
108 DummyControlImplOverride::~DummyControlImplOverride() { }
109
110
111 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
112 void DummyControlImplOverride::OnStyleChange(StyleChange change) { styleChangeCalled = true;}
113 void DummyControlImplOverride::OnPinch(PinchGesture pinch) { pinchCalled = true; }
114 void DummyControlImplOverride::OnPan(PanGesture pan) { panCalled = true; }
115 void DummyControlImplOverride::OnTap(TapGesture tap) { tapCalled = true; }
116 void DummyControlImplOverride::OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
117 void DummyControlImplOverride::OnStageConnection() { stageConnectionCalled = true; }
118 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
119 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
120 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
121 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
122 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
123 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
124 bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
125 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
126 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
127 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
128
129 DummyControl DummyControl::New( bool override )
130 {
131   DummyControl control;
132
133   if (override)
134   {
135     control = DummyControlImplOverride::New();
136   }
137   else
138   {
139     control = DummyControlImpl::New();
140   }
141
142   return control;
143 }
144
145 DummyControl::DummyControl( DummyControlImpl& implementation )
146 : Control( implementation ),
147   mCustomSlot1Called(false),
148   mCustomSlot1Value(Vector3::ZERO)
149 {
150 }
151
152 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
153 : Control( internal ),
154   mCustomSlot1Called(false),
155   mCustomSlot1Value(Vector3::ZERO)
156 {
157   VerifyCustomActorPointer<DummyControlImpl>(internal);
158 }
159
160 } // namespace Toolkit
161
162 } // namespace Dali