(Automated Tests) Update test suite after changes to PlatformAbstraction
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-orientation.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 "toolkit-orientation.h"
19
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/signals/dali-signal.h>
23
24 namespace Dali
25 {
26
27 namespace
28 {
29 ToolkitOrientation* gToolkitOrientation(NULL);
30 } // unnamed namespace
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 /**
39  * Stub for the Orientation
40  */
41 class Orientation : public BaseObject
42 {
43 public: // Creation & Destruction
44
45   Orientation();
46   Orientation(ToolkitOrientation *orientation);
47   ~Orientation();
48
49 public: // Setters & Getters
50
51   void SetDegrees( int degrees )
52   {
53     mOrientation = degrees;
54   }
55
56   int GetDegrees() const;
57   float GetRadians() const;
58
59 public: // Signals
60
61   Dali::Orientation::OrientationSignalType& ChangedSignal();
62
63   void EmitChangedSignal()
64   {
65     mChangedSignal.Emit(Dali::Orientation(this));
66   }
67
68 private:
69
70   Dali::Orientation::OrientationSignalType mChangedSignal;
71
72   ToolkitOrientation* mToolkitOrientation;
73
74   int mOrientation;
75 };
76
77 Orientation::Orientation()
78 : mToolkitOrientation(NULL),
79   mOrientation(0)
80 {
81 }
82
83 Orientation::Orientation(ToolkitOrientation *orientation)
84 : mToolkitOrientation(orientation),
85   mOrientation(0)
86 {
87 }
88
89 Orientation::~Orientation()
90 {
91 }
92
93 int Orientation::GetDegrees() const
94 {
95   mToolkitOrientation->mFunctionsCalled.GetDegrees = true;
96   return mOrientation;
97 }
98
99 float Orientation::GetRadians() const
100 {
101   mToolkitOrientation->mFunctionsCalled.GetRadians = true;
102   return Math::PI * (float)mOrientation / 180.0f;
103 }
104
105 Dali::Orientation::OrientationSignalType& Orientation::ChangedSignal()
106 {
107   mToolkitOrientation->mFunctionsCalled.ChangedSignal = true;
108   return mChangedSignal;
109 }
110
111 } // namespace Adaptor
112
113 } // namespace Internal
114
115 ////////////////////////////////////////////////////////////////////////////////////////////////////
116
117 ToolkitOrientation::ToolkitOrientation()
118 : mOrientationStub(new Internal::Adaptor::Orientation(this)),
119   mOrientation( mOrientationStub )
120 {
121   gToolkitOrientation = this;
122 }
123
124 ToolkitOrientation::~ToolkitOrientation()
125 {
126   gToolkitOrientation = NULL;
127 }
128
129 Orientation ToolkitOrientation::GetHandle()
130 {
131   return mOrientation;
132 }
133
134 void ToolkitOrientation::SetDegrees( int degrees )
135 {
136   mOrientationStub->SetDegrees( degrees );
137 }
138
139 void ToolkitOrientation::EmitChangedSignal()
140 {
141   mOrientationStub->EmitChangedSignal();
142 }
143
144 } // namespace Dali