df988c00e85cb95484843b6d9f757b803bd2f555
[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 Flora License, Version 1.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://floralicense.org/license/
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 #include "dummy-control.h"
18
19 namespace Dali
20 {
21
22 namespace Toolkit
23 {
24
25 DummyControl::DummyControl()
26 : mCustomSlot1Called(false)
27 {
28 }
29
30 DummyControl::DummyControl(const DummyControl& control)
31 : Control( control ),
32   mCustomSlot1Called(false),
33   mCustomSlot1Value(Vector3::ZERO)
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 DummyControl::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 : ControlImpl(true)
69 {
70 }
71
72 DummyControlImpl::~DummyControlImpl()
73 {
74 }
75
76 DummyControl DummyControlImplOverride::New()
77 {
78   IntrusivePtr< DummyControlImplOverride > impl = new DummyControlImplOverride;
79   DummyControl control( *impl );
80   impl->Initialize();
81   return control;
82 }
83
84
85 DummyControlImplOverride::DummyControlImplOverride()
86 : DummyControlImpl(),
87   initializeCalled(false),
88   styleChangeCalled(false),
89   pinchCalled(false),
90   panCalled(false),
91   tapCalled(false),
92   longPressCalled(false),
93   stageConnectionCalled(false),
94   stageDisconnectionCalled(false),
95   childAddCalled(false),
96   childRemoveCalled(false),
97   sizeSetCalled(false),
98   sizeAnimationCalled(false),
99   touchEventCalled(false),
100   mouseWheelEventCalled(false),
101   keyEventCalled(false),
102   keyInputFocusGained(false),
103   keyInputFocusLost(false)
104 {
105 }
106
107 DummyControlImplOverride::~DummyControlImplOverride() { }
108
109
110 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
111 void DummyControlImplOverride::OnStyleChange(StyleChange change) { styleChangeCalled = true;}
112 void DummyControlImplOverride::OnPinch(PinchGesture pinch) { pinchCalled = true; }
113 void DummyControlImplOverride::OnPan(PanGesture pan) { panCalled = true; }
114 void DummyControlImplOverride::OnTap(TapGesture tap) { tapCalled = true; }
115 void DummyControlImplOverride::OnLongPress(LongPressGesture longPress) { longPressCalled = true; }
116 void DummyControlImplOverride::OnStageConnection() { stageConnectionCalled = true; }
117 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
118 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
119 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
120 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
121 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
122 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
123 bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
124 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
125 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
126 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
127
128 DummyControl DummyControl::New( bool override )
129 {
130   DummyControl control;
131
132   if (override)
133   {
134     control = DummyControlImplOverride::New();
135   }
136   else
137   {
138     control = DummyControlImpl::New();
139   }
140
141   return control;
142 }
143
144 DummyControl::DummyControl( DummyControlImpl& implementation )
145 : Control( implementation ),
146   mCustomSlot1Called(false),
147   mCustomSlot1Value(Vector3::ZERO)
148 {
149 }
150
151 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
152 : Control( internal ),
153   mCustomSlot1Called(false),
154   mCustomSlot1Value(Vector3::ZERO)
155 {
156   VerifyCustomActorPointer<DummyControlImpl>(internal);
157 }
158
159 } // namespace Toolkit
160
161 } // namespace Dali