Merge remote-tracking branch 'origin/tizen' into new_text
[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 )
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_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   themeChangeCalled( false ),
90   fontChangeCalled( false ),
91   pinchCalled(false),
92   panCalled(false),
93   tapCalled(false),
94   longPressCalled(false),
95   stageConnectionCalled(false),
96   stageDisconnectionCalled(false),
97   childAddCalled(false),
98   childRemoveCalled(false),
99   sizeSetCalled(false),
100   sizeAnimationCalled(false),
101   touchEventCalled(false),
102   mouseWheelEventCalled(false),
103   keyEventCalled(false),
104   keyInputFocusGained(false),
105   keyInputFocusLost(false)
106 {
107 }
108
109 DummyControlImplOverride::~DummyControlImplOverride() { }
110
111
112 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
113 void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) { themeChangeCalled = change.themeChange; fontChangeCalled = change.defaultFontSizeChange; }
114 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
115 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
116 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
117 void DummyControlImplOverride::OnLongPress(const LongPressGesture& longPress) { longPressCalled = true; }
118 void DummyControlImplOverride::OnStageConnection() { stageConnectionCalled = true; }
119 void DummyControlImplOverride::OnStageDisconnection() { stageDisconnectionCalled = true; }
120 void DummyControlImplOverride::OnChildAdd(Actor& child) { childAddCalled = true; }
121 void DummyControlImplOverride::OnChildRemove(Actor& child) { childRemoveCalled = true; }
122 void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCalled = true; }
123 void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; }
124 bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; }
125 bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; }
126 bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
127 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
128 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
129
130 DummyControl DummyControl::New( bool override )
131 {
132   DummyControl control;
133
134   if (override)
135   {
136     control = DummyControlImplOverride::New();
137   }
138   else
139   {
140     control = DummyControlImpl::New();
141   }
142
143   return control;
144 }
145
146 DummyControl::DummyControl( DummyControlImpl& implementation )
147 : Control( implementation )
148 {
149 }
150
151 DummyControl::DummyControl( Dali::Internal::CustomActor* internal )
152 : Control( internal )
153 {
154   VerifyCustomActorPointer<DummyControlImpl>(internal);
155 }
156
157 } // namespace Toolkit
158
159 } // namespace Dali